diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index b0d70cdc58..ec12ed8411 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -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"); diff --git a/libretro.h b/libretro.h index 0af84e6548..72050e93d5 100755 --- a/libretro.h +++ b/libretro.h @@ -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.