Move more SDL specifics to sdlwrap.

This commit is contained in:
Themaister 2012-05-25 22:28:20 +02:00
parent 1e73ba4661
commit a2e7805524
3 changed files with 37 additions and 26 deletions

View File

@ -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())

View File

@ -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

View File

@ -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);