From c1bba2afe662d71ca274fd4453042f98ba6a5397 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sun, 5 Feb 2017 18:41:49 +0700 Subject: [PATCH] Request core GL profile. --- .../mupen64plus/mupen64plus_DisplayWindow.cpp | 7 ++-- .../windows/windows_DisplayWindow.cpp | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp b/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp index 5bbf4d5e..ce0be5aa 100644 --- a/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp +++ b/src/Graphics/OpenGLContext/mupen64plus/mupen64plus_DisplayWindow.cpp @@ -55,11 +55,10 @@ void DisplayWindowMupen64plus::_setAttributes() #elif defined(GLES3_1) CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3); CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 1); -#elif defined(OS_MAC_OS_X) - CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3); - CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 2); #else - // Do nothing + CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_PROFILE_MASK, M64P_GL_CONTEXT_PROFILE_CORE); + CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MAJOR_VERSION, 3); + CoreVideo_GL_SetAttribute(M64P_GL_CONTEXT_MINOR_VERSION, 3); #endif #ifndef GLES2 diff --git a/src/Graphics/OpenGLContext/windows/windows_DisplayWindow.cpp b/src/Graphics/OpenGLContext/windows/windows_DisplayWindow.cpp index 3c5633bf..5a5e1acc 100644 --- a/src/Graphics/OpenGLContext/windows/windows_DisplayWindow.cpp +++ b/src/Graphics/OpenGLContext/windows/windows_DisplayWindow.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -91,6 +92,39 @@ bool DisplayWindowWindows::_start() return false; } + PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = + (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); + + if (wglGetExtensionsStringARB != NULL) { + const char * wglextensions = wglGetExtensionsStringARB(hDC); + + if (strstr(wglextensions, "WGL_ARB_create_context") != nullptr && + strstr(wglextensions, "WGL_ARB_create_context_profile") != nullptr) { + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = + (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); + + GLint majorVersion = 0; + glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); + GLint minorVersion = 0; + glGetIntegerv(GL_MINOR_VERSION, &minorVersion); + + const int attribList[] = + { + WGL_CONTEXT_MAJOR_VERSION_ARB, majorVersion, + WGL_CONTEXT_MINOR_VERSION_ARB, minorVersion, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + 0 //End + }; + + HGLRC coreHrc = wglCreateContextAttribsARB(hDC, 0, attribList); + if (coreHrc != NULL) { + wglDeleteContext(hRC); + wglMakeCurrent(hDC, coreHrc); + hRC = coreHrc; + } + } + } + return _resizeWindow(); }