diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index a39cb5a377..912a50ff71 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -39,6 +39,8 @@ static HDC g_hdc; static HMONITOR g_last_hm; static HMONITOR g_all_hms[MAX_MONITORS]; static unsigned g_num_mons; +static unsigned g_major; +static unsigned g_minor; static bool g_quit; static bool g_inited; @@ -58,6 +60,9 @@ static void gfx_ctx_destroy(void); static BOOL (APIENTRY *p_swap_interval)(int); +typedef HGLRC (APIENTRY *wglCreateContextAttribsProc)(HDC, HGLRC, const int*); +static wglCreateContextAttribsProc pcreate_context; + static void setup_pixel_format(HDC hdc) { PIXELFORMATDESCRIPTOR pfd = {0}; @@ -87,7 +92,53 @@ static void create_gl_context(HWND hwnd) g_quit = true; } else + { g_quit = true; + return; + } + + if (g_major * 1000 + g_minor >= 3001) // Create core context + { +#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#endif +#ifndef WGL_CONTEXT_MINOR_VERSION_ARB +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#endif +#ifndef WGL_CONTEXT_PROFILE_MASK_ARB +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#endif +#ifndef WGL_CONTEXT_CORE_PROFILE_BIT_ARB +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001 +#endif + const int attribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, g_major, + WGL_CONTEXT_MINOR_VERSION_ARB, g_minor, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0, + }; + + if (!pcreate_context) + pcreate_context = (wglCreateContextAttribsProc)wglGetProcAddress("wglCreateContextAttribsARB"); + + if (pcreate_context) + { + HGLRC context = pcreate_context(g_hdc, NULL, attribs); + + if (context) + { + wglMakeCurrent(NULL, NULL); + wglDeleteContext(g_hrc); + g_hrc = context; + if (!wglMakeCurrent(g_hdc, g_hrc)) + g_quit = true; + } + else + RARCH_ERR("[WGL]: Failed to create core context. Falling back to legacy context.\n"); + } + else + RARCH_ERR("[WGL]: wglCreateContextAttribsARB not supported.\n"); + } } static bool BrowseForFile(char *filename) @@ -462,6 +513,7 @@ static void gfx_ctx_destroy(void) } g_inited = false; + g_major = g_minor = 0; } static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data) @@ -486,8 +538,8 @@ static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) static bool gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned minor) { - (void)major; - (void)minor; + g_major = major; + g_minor = minor; return api == GFX_CTX_OPENGL_API; } diff --git a/gfx/gl.c b/gfx/gl.c index ee4904bde7..388abe254d 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -182,9 +182,6 @@ static PFNGLDELETEVERTEXARRAYSPROC pglDeleteVertexArrays; static bool load_vao_proc(gl_t *gl) { - if (!gl_query_extension(gl, "ARB_vertex_array_object")) - return false; - LOAD_GL_SYM(GenVertexArrays); LOAD_GL_SYM(BindVertexArray); LOAD_GL_SYM(DeleteVertexArrays); diff --git a/libretro-test-gl/libretro-test.c b/libretro-test-gl/libretro-test.c index 92bb507505..45ce564b77 100644 --- a/libretro-test-gl/libretro-test.c +++ b/libretro-test-gl/libretro-test.c @@ -325,7 +325,7 @@ void retro_run(void) pglBindFramebuffer(GL_FRAMEBUFFER, hw_render.get_current_framebuffer()); glClearColor(0.3, 0.4, 0.5, 1.0); glViewport(0, 0, width, height); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); pglUseProgram(prog);