Add forced debug context support to WGL.

This commit is contained in:
Themaister 2013-08-14 14:04:26 +02:00
parent 3b1e65ba08
commit 4d8e9df03d
2 changed files with 30 additions and 9 deletions

View File

@ -104,7 +104,15 @@ static void create_gl_context(HWND hwnd)
return;
}
if (g_major * 1000 + g_minor >= 3001) // Create core context
#ifdef GL_DEBUG
bool debug = true;
#else
bool debug = g_extern.system.hw_render_callback.debug_context;
#endif
bool core_context = (g_major * 1000 + g_minor) >= 3001;
if (core_context || debug)
{
#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
@ -124,13 +132,26 @@ static void create_gl_context(HWND hwnd)
#ifndef WGL_CONTEXT_DEBUG_BIT_ARB
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
#endif
const int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, (int)g_major,
WGL_CONTEXT_MINOR_VERSION_ARB, (int)g_minor,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB, g_extern.system.hw_render_callback.debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
0,
};
int attribs[16];
int *aptr = attribs;
if (core_context)
{
*aptr++ = WGL_CONTEXT_MAJOR_VERSION_ARB;
*aptr++ = g_major;
*aptr++ = WGL_CONTEXT_MINOR_VERSION_ARB;
*aptr++ = g_minor;
*aptr++ = WGL_CONTEXT_PROFILE_MASK_ARB;
*aptr++ = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
}
if (debug)
{
*aptr++ = WGL_CONTEXT_FLAGS_ARB;
*aptr++ = WGL_CONTEXT_DEBUG_BIT_ARB;
}
*aptr = 0;
if (!pcreate_context)
pcreate_context = (wglCreateContextAttribsProc)wglGetProcAddress("wglCreateContextAttribsARB");

View File

@ -575,7 +575,7 @@ struct retro_hw_render_callback
// The reset callback might still be called in extreme situations such as if the context is lost beyond recovery.
// For optimal stability, set this to false, and allow context to be reset at any time.
retro_hw_context_reset_t context_destroy; // A callback to be called before the context is destroyed. Resources can be deinitialized at this step. This can be set to NULL, in which resources will just be destroyed without any notification.
bool debug_context; // Creates a debug context. Only takes effect when using GL core.
bool debug_context; // Creates a debug context.
};
// Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. Called by the frontend in response to keyboard events.