Create gl_set_core_context

This commit is contained in:
twinaphex 2018-10-10 18:24:41 +02:00
parent c3c169aeab
commit 5b4473b948
3 changed files with 32 additions and 21 deletions

View File

@ -39,6 +39,10 @@
#include "cheevos/cheevos.h" #include "cheevos/cheevos.h"
#endif #endif
#ifdef HAVE_OPENGL
#include "gfx/common/gl_common.h"
#endif
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
#include "network/netplay/netplay.h" #include "network/netplay/netplay.h"
#endif #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)) if (!dynamic_verify_hw_context(cb->context_type, cb->version_minor, cb->version_major))
return false; return false;
if (cb->context_type == RETRO_HW_CONTEXT_OPENGL_CORE) #if defined(HAVE_OPENGL)
{ if (!gl_set_core_context(cb->context_type))
gfx_ctx_flags_t flags; return false;
flags.flags = 0; #endif
BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
video_context_driver_set_flags(&flags);
}
cb->get_current_framebuffer = video_driver_get_current_framebuffer; cb->get_current_framebuffer = video_driver_get_current_framebuffer;
cb->get_proc_address = video_driver_get_proc_address; cb->get_proc_address = video_driver_get_proc_address;

View File

@ -19,6 +19,7 @@
#include <boolean.h> #include <boolean.h>
#include <string.h> #include <string.h>
#include <libretro.h>
#include <retro_common_api.h> #include <retro_common_api.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -386,6 +387,23 @@ static INLINE GLenum gl_min_filter_to_mag(GLenum type)
return 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 RETRO_END_DECLS
#endif #endif

View File

@ -1797,25 +1797,18 @@ static void *gl_init(const video_info_t *video,
if (gl_flags & GL_CONTEXT_CORE_PROFILE_BIT) 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"); RARCH_LOG("[GL]: Using Core GL context, setting up VAO...\n");
if (!gl_check_capability(GL_CAPS_VAO)) if (!gl_check_capability(GL_CAPS_VAO))
{ {
RARCH_ERR("[GL]: Failed to initialize VAOs.\n"); RARCH_ERR("[GL]: Failed to initialize VAOs.\n");
goto error; goto error;
} }
if (gl_set_core_context(hwr->context_type))
{
gl_query_core_context_set(true);
gl->core_context_in_use = true;
}
} }
} }
#endif #endif