GL init: Don't die if wglCreateContextAttribsARB is supported but returns 0.

This commit is contained in:
Henrik Rydgard committed 2013-03-17 14:47:57 +01:00
1 parent 8f0cd93ca9
commit 53bcb29ef6
2 files changed
+19 -13

No files matched your search

+18 -12
View File
@@ -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")) {
+1 -1
View File
@@ -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);