diff --git a/dynamic.c b/dynamic.c index 81a03dd2a1..e011d802fa 100644 --- a/dynamic.c +++ b/dynamic.c @@ -39,6 +39,10 @@ #include "cheevos/cheevos.h" #endif +#ifdef HAVE_OPENGL +#include "gfx/common/gl_common.h" +#endif + #ifdef HAVE_NETWORKING #include "network/netplay/netplay.h" #endif @@ -1368,14 +1372,10 @@ bool rarch_environment_cb(unsigned cmd, void *data) if (!dynamic_verify_hw_context(cb->context_type, cb->version_minor, cb->version_major)) return false; - if (cb->context_type == RETRO_HW_CONTEXT_OPENGL_CORE) - { - gfx_ctx_flags_t flags; - flags.flags = 0; - BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); - - video_context_driver_set_flags(&flags); - } +#if defined(HAVE_OPENGL) + if (!gl_set_core_context(cb->context_type)) + return false; +#endif cb->get_current_framebuffer = video_driver_get_current_framebuffer; cb->get_proc_address = video_driver_get_proc_address; diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 41a52f2bd5..0f77410cd5 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -19,6 +19,7 @@ #include #include +#include #include #ifdef HAVE_CONFIG_H @@ -386,6 +387,23 @@ static INLINE GLenum gl_min_filter_to_mag(GLenum type) return type; } +static INLINE bool gl_set_core_context(enum retro_hw_context_type ctx_type) +{ + gfx_ctx_flags_t flags; + if (ctx_type != RETRO_HW_CONTEXT_OPENGL_CORE) + return false; + + /** + * Ensure that the rest of the frontend knows we have a core context + */ + flags.flags = 0; + BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + + video_context_driver_set_flags(&flags); + + return true; +} + RETRO_END_DECLS #endif diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 7db576af99..8589a69c6e 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1797,25 +1797,18 @@ static void *gl_init(const video_info_t *video, if (gl_flags & GL_CONTEXT_CORE_PROFILE_BIT) { - gfx_ctx_flags_t flags; - - gl_query_core_context_set(true); - gl->core_context_in_use = true; - - /** - * Ensure that the rest of the frontend knows we have a core context - */ - flags.flags = 0; - BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); - - video_context_driver_set_flags(&flags); - RARCH_LOG("[GL]: Using Core GL context, setting up VAO...\n"); if (!gl_check_capability(GL_CAPS_VAO)) { RARCH_ERR("[GL]: Failed to initialize VAOs.\n"); goto error; } + + if (gl_set_core_context(hwr->context_type)) + { + gl_query_core_context_set(true); + gl->core_context_in_use = true; + } } } #endif