From fd8757a64b8bfe05069215f322b8a8bc43ea8fe4 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 23 Jan 2014 16:02:53 -0600 Subject: [PATCH] Fix OpenGL 2.1 devices that support everything we need. The only two devices that do this are Mesa software rasterizer and Intel Ironlake(With a few hacks). Basically since it doesn't support OpenGL 3.0, it can't grab the version the new way. So failing that, it sets to GL 2.1, and continues. Further along, on Ironlake at least, it tries grabbing the extensions the new GL 3.0 way and fails. So have a fallback that grabs the extensions string the old way, in probably the most elegant way possible. --- .../OGL/GLExtensions/GLExtensions.cpp | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp b/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp index 996177e277..08caf9d44c 100644 --- a/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp +++ b/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.cpp @@ -9,6 +9,7 @@ #include #endif #include +#include // gl_1_1 PFNGLCLEARINDEXPROC glClearIndex; @@ -805,6 +806,17 @@ namespace GLExtensions bool init_khr_debug(); bool init_arb_buffer_storage(); + // Initializes the extension list the old way + void InitExtensionList21() + { + const char* extensions = (const char*)glGetString(GL_EXTENSIONS); + std::string tmp(extensions); + std::istringstream buffer(tmp); + + while (buffer >> tmp) + _extensionlist[tmp] = true; + } + void InitExtensionList() { _extensionlist.clear(); @@ -925,6 +937,11 @@ namespace GLExtensions break; } } + if (_GLVersion < 300) + { + InitExtensionList21(); + return; + } GLint NumExtension = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &NumExtension); for (GLint i = 0; i < NumExtension; ++i) @@ -935,7 +952,10 @@ namespace GLExtensions GLint major, minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); - _GLVersion = major * 100 + minor * 10; + if (glGetError() == GL_NO_ERROR) + _GLVersion = major * 100 + minor * 10; + else + _GLVersion = 210; if (_isES3) _GLVersion = 330; // Get all the fun things } @@ -970,13 +990,18 @@ namespace GLExtensions _isES3 = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3; _isES = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3 || GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES2; - // Grab glGetStringi and glGetIntegerv immediately + // Grab a few functions for initial checking // We need them to grab the extension list + // Also to check if there is an error grabbing the version // If it fails then the user's drivers don't support GL 3.0 if (GetFuncAddress ("glGetIntegerv", (void**)&glGetIntegerv) == NULL) return false; + if (GetFuncAddress("glGetString", (void**)&glGetString) == NULL) + return false; if (GetFuncAddress("glGetStringi", (void**)&glGetStringi) == NULL) return false; + if (GetFuncAddress("glGetError", (void**)&glGetError) == NULL) + return false; InitVersion(); InitExtensionList(); @@ -1063,8 +1088,6 @@ namespace GLExtensions && GrabFunction(glPushClientAttrib) && GrabFunction(glPopClientAttrib) && GrabFunction(glRenderMode) - && GrabFunction(glGetError) - && GrabFunction(glGetString) && GrabFunction(glFinish) && GrabFunction(glFlush) && GrabFunction(glHint)