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"
#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;

View File

@ -19,6 +19,7 @@
#include <boolean.h>
#include <string.h>
#include <libretro.h>
#include <retro_common_api.h>
#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

View File

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