From a2e78055246d9e9111c5a69ef96324c3e883d671 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 25 May 2012 22:28:20 +0200 Subject: [PATCH] Move more SDL specifics to sdlwrap. --- gfx/gl.c | 19 ++++--------------- gfx/sdlwrap.c | 42 ++++++++++++++++++++++++++++++++---------- gfx/sdlwrap.h | 2 +- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index f78c50d633..2874eef569 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1175,10 +1175,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei if (msg) gl_render_msg(gl, msg); - char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) - sdlwrap_wm_set_caption(buf); - + sdlwrap_update_window_title(false); sdlwrap_swap_buffers(); return true; @@ -1226,10 +1223,8 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (!sdlwrap_init()) return NULL; - const SDL_VideoInfo *video_info = SDL_GetVideoInfo(); - rarch_assert(video_info); - unsigned full_x = video_info->current_w; - unsigned full_y = video_info->current_h; + unsigned full_x = 0, full_y = 0; + sdlwrap_get_video_size(&full_x, &full_y); RARCH_LOG("Detecting desktop resolution %ux%u.\n", full_x, full_y); sdlwrap_set_swap_interval(video->vsync ? 1 : 0, false); @@ -1246,13 +1241,8 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo g_settings.video.force_16bit ? 15 : 0, video->fullscreen)) return NULL; - gfx_window_title_reset(); - char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) - sdlwrap_wm_set_caption(buf); + sdlwrap_update_window_title(true); - // Remove that ugly mouse :D - SDL_ShowCursor(SDL_DISABLE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #if (defined(HAVE_XML) || defined(HAVE_CG)) && defined(_WIN32) @@ -1382,7 +1372,6 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo } sdlwrap_input_driver(input, input_data); - gl_init_font(gl, g_settings.video.font_path, g_settings.video.font_size); if (!gl_check_error()) diff --git a/gfx/sdlwrap.c b/gfx/sdlwrap.c index 81aed5afe3..2fd95f6f91 100644 --- a/gfx/sdlwrap.c +++ b/gfx/sdlwrap.c @@ -15,6 +15,7 @@ #include "sdlwrap.h" #include "SDL_syswm.h" +#include "gfx_common.h" #include "../general.h" #ifdef __APPLE__ @@ -67,13 +68,40 @@ void sdlwrap_set_swap_interval(unsigned interval, bool inited) else RARCH_WARN("Could not find GLX VSync call.\n"); #endif - } #endif + if (!success) RARCH_WARN("Failed to set swap interval.\n"); } +static void sdlwrap_wm_set_caption(const char *str) +{ +#if SDL_MODERN + SDL_SetWindowTitle(g_window, str); +#else + SDL_WM_SetCaption(str, NULL); +#endif +} + +void sdlwrap_update_window_title(bool reset) +{ + if (reset) + gfx_window_title_reset(); + + char buf[128]; + if (gfx_window_title(buf, sizeof(buf))) + sdlwrap_wm_set_caption(buf); +} + +void sdlwrap_get_video_size(unsigned *width, unsigned *height) +{ + const SDL_VideoInfo *video_info = SDL_GetVideoInfo(); + rarch_assert(video_info); + *width = video_info->current_w; + *height = video_info->current_h; +} + bool sdlwrap_init(void) { #if SDL_MODERN @@ -178,6 +206,9 @@ bool sdlwrap_set_video_mode( if (attr <= 0) RARCH_WARN("GL double buffer has not been enabled.\n"); + // Remove that ugly mouse :D + SDL_ShowCursor(SDL_DISABLE); + return true; } @@ -198,15 +229,6 @@ void sdlwrap_set_resize(unsigned width, unsigned height) #endif } -void sdlwrap_wm_set_caption(const char *str) -{ -#if SDL_MODERN - SDL_SetWindowTitle(g_window, str); -#else - SDL_WM_SetCaption(str, NULL); -#endif -} - void sdlwrap_swap_buffers(void) { #if SDL_MODERN diff --git a/gfx/sdlwrap.h b/gfx/sdlwrap.h index a0c9fec116..61196c2eb2 100644 --- a/gfx/sdlwrap.h +++ b/gfx/sdlwrap.h @@ -50,7 +50,7 @@ bool sdlwrap_set_video_mode( bool sdlwrap_init(void); void sdlwrap_destroy(void); -void sdlwrap_wm_set_caption(const char *str); +void sdlwrap_update_window_title(bool reset); void sdlwrap_swap_buffers(void);