diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index ac630886c0..1e6b960558 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -23,9 +23,13 @@ #endif #include "../gl_common.h" +#include "../image.h" +#include "../../ps3/shared.h" #include "ps3_ctx.h" +static struct texture_image menu_texture; + void gfx_ctx_set_swap_interval(unsigned interval, bool inited) { if (inited) @@ -64,3 +68,37 @@ void gfx_ctx_swap_buffers(void) { psglSwap(); } + +bool gfx_ctx_menu_init(void) +{ + gl_t *gl = driver.video_data; + + if (!gl) + return false; + +#ifdef HAVE_CG_MENU + glGenTextures(1, &gl->menu_texture_id); + + RARCH_LOG("Loading texture image for menu...\n"); + if(!texture_image_load(DEFAULT_MENU_BORDER_FILE, &menu_texture)) + { + RARCH_ERR("Failed to load texture image for menu.\n"); + return false; + } + + glBindTexture(GL_TEXTURE_2D, gl->menu_texture_id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_ARGB_SCE, menu_texture.width, menu_texture.height, 0, + GL_ARGB_SCE, GL_UNSIGNED_INT_8_8_8_8, menu_texture.pixels); + + glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); + + free(menu_texture.pixels); +#endif + + return true; +} diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index 3593b6ae11..f3ff2f54c6 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -58,5 +58,9 @@ bool gfx_ctx_window_has_focus(void); void gfx_ctx_input_driver(const input_driver_t **input, void **input_data); +#ifdef HAVE_CG_MENU +bool gfx_ctx_menu_init(void) +#endif + #endif diff --git a/ps3/ps3_video_psgl.c b/ps3/ps3_video_psgl.c index 4da9146e93..72990c3942 100644 --- a/ps3/ps3_video_psgl.c +++ b/ps3/ps3_video_psgl.c @@ -100,9 +100,6 @@ static const GLfloat white_color[] = { }; struct { -#ifdef HAVE_CG_MENU - struct texture_image menu_texture; -#endif PSGLdevice* gl_device; PSGLcontext* gl_context; } ps3_gl; @@ -991,7 +988,7 @@ static void gl_set_nonblock_state(void *data, bool state) } } -static bool psgl_init_device(gl_t *gl, const video_info_t *video, uint32_t resolution_id) +static bool psgl_init_device(gl_t *gl) { PSGLinitOptions options = { @@ -1022,10 +1019,10 @@ static bool psgl_init_device(gl_t *gl, const video_info_t *video, uint32_t resol params.bufferingMode = PSGL_BUFFERING_MODE_TRIPLE; } - if(resolution_id) + if(g_console.current_resolution_id) { CellVideoOutResolution resolution; - cellVideoOutGetResolution(resolution_id, &resolution); + cellVideoOutGetResolution(g_console.current_resolution_id, &resolution); params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT; params.width = resolution.width; @@ -1057,7 +1054,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (!gl) return NULL; - if (!psgl_init_device(gl, video, g_console.current_resolution_id)) + if (!psgl_init_device(gl)) return NULL; @@ -1320,40 +1317,6 @@ const char * ps3_get_resolution_label(uint32_t resolution) } } -static bool gfx_ctx_menu_init(void) -{ - gl_t *gl = driver.video_data; - - if (!gl) - return false; - -#ifdef HAVE_CG_MENU - glGenTextures(1, &gl->menu_texture_id); - - RARCH_LOG("Loading texture image for menu...\n"); - if(!texture_image_load(DEFAULT_MENU_BORDER_FILE, &ps3_gl.menu_texture)) - { - RARCH_ERR("Failed to load texture image for menu.\n"); - return false; - } - - glBindTexture(GL_TEXTURE_2D, gl->menu_texture_id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_ARGB_SCE, ps3_gl.menu_texture.width, ps3_gl.menu_texture.height, 0, - GL_ARGB_SCE, GL_UNSIGNED_INT_8_8_8_8, ps3_gl.menu_texture.pixels); - - glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); - - free(ps3_gl.menu_texture.pixels); -#endif - - return true; -} - void ps3_set_filtering(unsigned index, bool set_smooth) { gl_t *gl = driver.video_data;