diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index cdd6ea466e..22a45d7a39 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -874,11 +874,7 @@ static void gl_set_rotation(void *data, unsigned rotation) static void gl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { - gl_t *gl = (gl_t*)data; - const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); - - if (gl && ctx && ctx->set_video_mode) - ctx->set_video_mode(gl, width, height, fullscreen); + gfx_ctx_set_video_mode(data, width, height, fullscreen); } #ifdef HAVE_FBO @@ -1669,11 +1665,11 @@ static bool gl_frame(void *data, const void *frame, !driver->nonblock_state && !runloop->is_slowmotion && !runloop->is_paused) { - ctx->swap_buffers(gl); + gfx_ctx_swap_buffers(gl); glClear(GL_COLOR_BUFFER_BIT); } - ctx->swap_buffers(gl); + gfx_ctx_swap_buffers(gl); #ifdef HAVE_GL_SYNC if (settings->video.hard_sync && gl->have_sync) @@ -2493,12 +2489,7 @@ static bool gl_alive(void *data) static bool gl_focus(void *data) { - gl_t *gl = (gl_t*)data; - const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); - - if (!gl) - return false; - return ctx->has_focus(gl); + return gfx_ctx_focus(data); } static bool gl_suppress_screensaver(void *data, bool enable) diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index e84f45e9d7..1edb176986 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -73,6 +73,7 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = { NULL }; + const gfx_ctx_driver_t *gfx_ctx_get_ptr(void) { driver_t *driver = driver_get_ptr(); @@ -81,6 +82,33 @@ const gfx_ctx_driver_t *gfx_ctx_get_ptr(void) return (const gfx_ctx_driver_t*)driver->video_context; } +void gfx_ctx_swap_buffers(void *data) +{ + const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); + + if (ctx->swap_buffers) + ctx->swap_buffers(data); +} + +bool gfx_ctx_focus(void *data) +{ + const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); + + if (data && ctx && ctx->has_focus) + return ctx->has_focus(data); + return false; +} + +void gfx_ctx_set_video_mode(void *data, + unsigned width, unsigned height, + bool fullscreen) +{ + const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); + + if (ctx && ctx->set_video_mode) + ctx->set_video_mode(data, width, height, fullscreen); +} + void gfx_ctx_translate_aspect(void *data, float *aspect, unsigned width, unsigned height) { diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index f1a977896e..122e967a96 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -207,6 +207,14 @@ bool gfx_ctx_get_metrics(enum display_metric_types type, float *value); void gfx_ctx_translate_aspect(void *data, float *aspect, unsigned width, unsigned height); +void gfx_ctx_set_video_mode(void *data, + unsigned width, unsigned height, + bool fullscreen); + +void gfx_ctx_swap_buffers(void *data); + +bool gfx_ctx_focus(void *data); + #ifdef __cplusplus } #endif