diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 7a08a07405..dda6547f5c 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -112,6 +112,8 @@ VIDEO IMAGE #if defined(__CELLOS_LV2__) #include "../../ps3/image.c" +#elif defined(_XBOX1) +#include "../../xbox1/image.c" #endif /*============================================================ @@ -294,5 +296,4 @@ MENU #include "../../360/frontend-xdk/menu.cpp" #elif defined(_XBOX1) #include "../../xbox1/frontend/RetroLaunch/IoSupport.cpp" -#include "../../xbox1/frontend/RetroLaunch/Surface.cpp" #endif diff --git a/console/rmenu/rmenu.c b/console/rmenu/rmenu.c index f12ab4d5a5..f75f961423 100644 --- a/console/rmenu/rmenu.c +++ b/console/rmenu/rmenu.c @@ -33,6 +33,8 @@ #include "../../console/rarch_console_config.h" #include "../../console/rarch_console_settings.h" +#include "../../gfx/image.h" + #ifdef HAVE_RSOUND #include "../../console/rarch_console_rsound.h" #endif @@ -70,17 +72,14 @@ #ifdef _XBOX1 #include "../../xbox1/frontend/RetroLaunch/IoSupport.h" -#include "../../xbox1/frontend/RetroLaunch/Surface.h" #include "../../gfx/fonts/xdk1_xfonts.h" #define ROM_PANEL_WIDTH 510 #define ROM_PANEL_HEIGHT 20 int xpos, ypos; -// Rom selector panel with coords -d3d_surface_t m_menuMainRomSelectPanel; -// Background image with coords -d3d_surface_t m_menuMainBG; +texture_image m_menuMainRomSelectPanel; +texture_image m_menuMainBG; // Rom list coords int m_menuMainRomListPos_x; @@ -669,8 +668,9 @@ static void display_menubar(menu *current_menu) #ifdef _XBOX1 //Render background image - d3d_surface_render(&m_menuMainBG, 0, 0, - m_menuMainBG.m_imageInfo.Width, m_menuMainBG.m_imageInfo.Height); + m_menuMainBG.x = 0; + m_menuMainBG.y = 0; + texture_image_render(&m_menuMainBG); #else render_msg_place_func(x_position, 0.05f, 1.4f, WHITE, current_menu->title); render_msg_place_func(0.3f, 0.06f, 0.82f, WHITE, m_title); @@ -737,7 +737,13 @@ static void browser_render(filebrowser_t * b, float current_x, float current_y, //check if this is the currently selected file const char *current_pathname = filebrowser_get_current_path(b); if(strcmp(current_pathname, b->current_dir.list->elems[i].data) == 0) - d3d_surface_render(&m_menuMainRomSelectPanel, currentX, currentY, ROM_PANEL_WIDTH, ROM_PANEL_HEIGHT); + { + m_menuMainRomSelectPanel.x = currentX; + m_menuMainRomSelectPanel.y = currentY; + m_menuMainRomSelectPanel.width = ROM_PANEL_WIDTH; + m_menuMainRomSelectPanel.height = ROM_PANEL_HEIGHT; + texture_image_render(&m_menuMainRomSelectPanel); + } render_msg_place_func(currentX, currentY, 0, 0, fname_tmp); #else @@ -1743,7 +1749,13 @@ static void select_setting(item *items, menu *current_menu, uint64_t input) render_msg_place_func(x_position_center, items[i].text_ypos, FONT_SIZE, items[i].text_color, items[i].setting_text); #ifdef _XBOX1 if(current_menu->selected == items[i].enum_id) - d3d_surface_render(&m_menuMainRomSelectPanel, x_position, items[i].text_ypos, ROM_PANEL_WIDTH, ROM_PANEL_HEIGHT); + { + m_menuMainRomSelectPanel.x = x_position; + m_menuMainRomSelectPanel.y = items[i].text_ypos; + m_menuMainRomSelectPanel.width = ROM_PANEL_WIDTH; + m_menuMainRomSelectPanel.height = ROM_PANEL_HEIGHT; + texture_image_render(&m_menuMainRomSelectPanel); + } #endif } } @@ -2198,7 +2210,11 @@ static void ingame_menu(item *items, menu *current_menu, uint64_t input) render_msg_place_func(x_position, comment_y_position, font_size, WHITE, comment); #ifdef _XBOX1 - d3d_surface_render(&m_menuMainRomSelectPanel, x_position, (y_position+(y_position_increment*g_console.ingame_menu_item)), ROM_PANEL_WIDTH, ROM_PANEL_HEIGHT); + m_menuMainRomSelectPanel.x = x_position; + m_menuMainRomSelectPanel.y = (y_position+(y_position_increment*g_console.ingame_menu_item)); + m_menuMainRomSelectPanel.width = ROM_PANEL_WIDTH; + m_menuMainRomSelectPanel.height = ROM_PANEL_HEIGHT; + texture_image_render(&m_menuMainRomSelectPanel); #endif } @@ -2237,19 +2253,19 @@ void menu_init (void) // Load background image if(width == 640) { - d3d_surface_new(&m_menuMainBG, "D:\\Media\\main-menu_480p.png"); + texture_image_load("D:\\Media\\main-menu_480p.png", &m_menuMainBG); m_menuMainRomListPos_x = 60; m_menuMainRomListPos_y = 80; } else if(width == 1280) { - d3d_surface_new(&m_menuMainBG, "D:\\Media\\main-menu_720p.png"); + texture_image_load("D:\\Media\\main-menu_720p.png", &m_menuMainBG); m_menuMainRomListPos_x = 360; m_menuMainRomListPos_y = 130; } // Load rom selector panel - d3d_surface_new(&m_menuMainRomSelectPanel, "D:\\Media\\menuMainRomSelectPanel.png"); + texture_image_load("D:\\Media\\menuMainRomSelectPanel.png", &m_menuMainRomSelectPanel); //Display some text //Center the text (hardcoded) @@ -2264,8 +2280,8 @@ void menu_free (void) filebrowser_free(&tmpBrowser); #ifdef _XBOX1 - d3d_surface_free(&m_menuMainBG); - d3d_surface_free(&m_menuMainRomSelectPanel); + texture_image_free(&m_menuMainBG); + texture_image_free(&m_menuMainRomSelectPanel); #endif } diff --git a/gfx/image.h b/gfx/image.h index 1b4660833d..6c9775cf35 100644 --- a/gfx/image.h +++ b/gfx/image.h @@ -19,13 +19,29 @@ #include #include "../boolean.h" +#ifdef _XBOX1 +#include "../xdk/xdk_defines.h" +#endif + struct texture_image { unsigned width; unsigned height; +#ifdef _XBOX1 + unsigned x; + unsigned y; + LPDIRECT3DTEXTURE pixels; + LPDIRECT3DVERTEXBUFFER vertex_buf; +#else uint32_t *pixels; +#endif }; +#ifdef _XBOX1 +void texture_image_free(struct texture_image *out_img); +bool texture_image_render(struct texture_image *out_img); +#endif + bool texture_image_load(const char *path, struct texture_image* img); #endif diff --git a/xbox1/frontend/RetroLaunch/Surface.h b/xbox1/frontend/RetroLaunch/Surface.h deleted file mode 100644 index 51466e7f78..0000000000 --- a/xbox1/frontend/RetroLaunch/Surface.h +++ /dev/null @@ -1,33 +0,0 @@ -/* RetroArch - A frontend for libretro. -* Copyright (C) 2010-2012 - Hans-Kristian Arntzen -* Copyright (C) 2011-2012 - Daniel De Matteis -* -* RetroArch is free software: you can redistribute it and/or modify it under the terms -* of the GNU General Public License as published by the Free Software Found- -* ation, either version 3 of the License, or (at your option) any later version. -* -* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; -* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -* PURPOSE. See the GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License along with RetroArch. -* If not, see . -*/ - -#ifndef _D3D_SURFACE_H_ -#define _D3D_SURFACE_H_ - -#include "../../../xdk/xdk_defines.h" - -typedef struct -{ - LPDIRECT3DTEXTURE m_pTexture; - LPDIRECT3DVERTEXBUFFER m_pVertexBuffer; - D3DXIMAGE_INFO m_imageInfo; -} d3d_surface_t; - -bool d3d_surface_new(d3d_surface_t *surface, const char *filename); -void d3d_surface_free(d3d_surface_t *surface); -bool d3d_surface_render(d3d_surface_t *surface, int x, int y, int32_t w, int32_t h); - -#endif \ No newline at end of file diff --git a/xbox1/frontend/RetroLaunch/Surface.cpp b/xbox1/image.c similarity index 75% rename from xbox1/frontend/RetroLaunch/Surface.cpp rename to xbox1/image.c index e80b561f08..26b2978037 100644 --- a/xbox1/frontend/RetroLaunch/Surface.cpp +++ b/xbox1/image.c @@ -14,19 +14,20 @@ * If not, see . */ -#include "Surface.h" +#include "../gfx/image.h" +#include "xdk_d3d8.h" -#include "../../xdk_d3d8.h" - -bool d3d_surface_new(d3d_surface_t *surface, const char *filename) +bool texture_image_load(const char *path, struct texture_image *out_img) { xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + + D3DXIMAGE_INFO m_imageInfo; - surface->m_pTexture = NULL; - surface->m_pVertexBuffer = NULL; + out_img->pixels = NULL; + out_img->vertex_buf = NULL; HRESULT ret = D3DXCreateTextureFromFileExA(d3d->d3d_render_device, // d3d device - filename, // filename + path, // filename D3DX_DEFAULT, // width D3DX_DEFAULT, // height D3DX_DEFAULT, // mipmaps @@ -36,9 +37,9 @@ bool d3d_surface_new(d3d_surface_t *surface, const char *filename) D3DX_DEFAULT, // texture filter D3DX_DEFAULT, // mipmapping 0, // colorkey - &surface->m_imageInfo, // image info - NULL, // pallete - &surface->m_pTexture); // texture + &m_imageInfo, // image info + NULL, // palette + &out_img->pixels); // texture if(FAILED(ret)) { @@ -48,42 +49,50 @@ bool d3d_surface_new(d3d_surface_t *surface, const char *filename) // create a vertex buffer for the quad that will display the texture ret = d3d->d3d_render_device->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats), - D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &surface->m_pVertexBuffer); + D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &out_img->vertex_buf); if (FAILED(ret)) { RARCH_ERR("Error occurred during CreateVertexBuffer().\n"); - surface->m_pTexture->Release(); + out_img->pixels->Release(); return false; } + + out_img->width = m_imageInfo.Width; + out_img->height = m_imageInfo.Height; return true; } -void d3d_surface_free(d3d_surface_t *surface) +void texture_image_free(struct texture_image *out_img) { // free the vertex buffer - if (surface->m_pVertexBuffer) + if (out_img->vertex_buf) { - surface->m_pVertexBuffer->Release(); - surface->m_pVertexBuffer = NULL; + out_img->vertex_buf->Release(); + out_img->vertex_buf = NULL; } // free the texture - if (surface->m_pTexture) + if (out_img->pixels) { - surface->m_pTexture->Release(); - surface->m_pTexture = NULL; + out_img->pixels->Release(); + out_img->pixels = NULL; } } -bool d3d_surface_render(d3d_surface_t *surface, int x, int y, int32_t w, int32_t h) +bool texture_image_render(struct texture_image *out_img) { xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; - if (surface->m_pTexture == NULL || surface->m_pVertexBuffer == NULL) + if (out_img->pixels == NULL || out_img->vertex_buf == NULL) return false; + int x = out_img->x; + int y = out_img->y; + int w = out_img->width; + int h = out_img->height; + float fX = static_cast(x); float fY = static_cast(y); @@ -100,7 +109,7 @@ bool d3d_surface_render(d3d_surface_t *surface, int x, int y, int32_t w, int32_t // load the existing vertices DrawVerticeFormats *pCurVerts; - HRESULT ret = surface->m_pVertexBuffer->Lock(0, 0, (unsigned char**)&pCurVerts, 0); + HRESULT ret = out_img->vertex_buf->Lock(0, 0, (unsigned char**)&pCurVerts, 0); if (FAILED(ret)) { @@ -111,7 +120,7 @@ bool d3d_surface_render(d3d_surface_t *surface, int x, int y, int32_t w, int32_t // copy the new verts over the old verts memcpy(pCurVerts, newVerts, 4 * sizeof(DrawVerticeFormats)); - surface->m_pVertexBuffer->Unlock(); + out_img->vertex_buf->Unlock(); d3d->d3d_render_device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); d3d->d3d_render_device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); @@ -123,8 +132,8 @@ bool d3d_surface_render(d3d_surface_t *surface, int x, int y, int32_t w, int32_t d3d->d3d_render_device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE); // draw the quad - d3d->d3d_render_device->SetTexture(0, surface->m_pTexture); - d3d->d3d_render_device->SetStreamSource(0, surface->m_pVertexBuffer, sizeof(DrawVerticeFormats)); + d3d->d3d_render_device->SetTexture(0, out_img->pixels); + d3d->d3d_render_device->SetStreamSource(0, out_img->vertex_buf, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->SetVertexShader(D3DFVF_CUSTOMVERTEX); d3d->d3d_render_device->DrawPrimitive(D3DPT_QUADLIST, 0, 1);