diff --git a/Windows/OpenGLBase.cpp b/Windows/OpenGLBase.cpp index a1e5fdf62b..ee271bfc00 100644 --- a/Windows/OpenGLBase.cpp +++ b/Windows/OpenGLBase.cpp @@ -12,7 +12,7 @@ static HDC hDC=NULL; // Private GDI Device Context static HGLRC hRC=NULL; // Permanent Rendering Context static HWND hWnd=NULL; // Holds Our Window Handle static HINSTANCE hInstance; // Holds The Instance Of The Application - + static int xres, yres; // TODO: Make config? @@ -174,15 +174,28 @@ bool GL_Init(HWND window, std::string *error_message) { HGLRC m_hrc; if(wglewIsSupported("WGL_ARB_create_context") == 1) { - m_hrc = wglCreateContextAttribsARB(hDC,0, attribs); - wglMakeCurrent(NULL,NULL); - wglDeleteContext(hRC); - wglMakeCurrent(hDC, m_hrc); + m_hrc = wglCreateContextAttribsARB(hDC, 0, attribs); + if (!m_hrc) { + // Fall back + m_hrc = hRC; + } else { + // Switch to the new ARB context. + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hRC); + wglMakeCurrent(hDC, m_hrc); + } } else { // We can't make a GL 3.x context. Use an old style context (GL 2.1 and before) m_hrc = hRC; } + if (!m_hrc) { + *error_message = "No m_hrc"; + return false; + } + + hRC = m_hrc; + //Checking GL version const char *GLVersionString = (const char *)glGetString(GL_VERSION); @@ -191,13 +204,6 @@ bool GL_Init(HWND window, std::string *error_message) { glGetIntegerv(GL_MAJOR_VERSION, &OpenGLVersion[0]); glGetIntegerv(GL_MINOR_VERSION, &OpenGLVersion[1]); - if (!m_hrc) { - *error_message = "No m_hrc"; - return false; - } - - hRC = m_hrc; - glstate.Initialize(); setVSync(0); if (enableGLDebug && glewIsSupported("GL_ARB_debug_output")) { diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 26d110d813..fd4153acea 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -55,7 +55,7 @@ namespace MainWindow TCHAR *szWindowClass = TEXT("PPSSPPWnd"); TCHAR *szDisplayClass = TEXT("PPSSPPDisplay"); - // Foward declarations of functions included in this code module: + // Forward declarations of functions included in this code module: LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);