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.
This commit is contained in:
parent
65121cf9a9
commit
fd8757a64b
|
@ -9,6 +9,7 @@
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
// gl_1_1
|
// gl_1_1
|
||||||
PFNGLCLEARINDEXPROC glClearIndex;
|
PFNGLCLEARINDEXPROC glClearIndex;
|
||||||
|
@ -805,6 +806,17 @@ namespace GLExtensions
|
||||||
bool init_khr_debug();
|
bool init_khr_debug();
|
||||||
bool init_arb_buffer_storage();
|
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()
|
void InitExtensionList()
|
||||||
{
|
{
|
||||||
_extensionlist.clear();
|
_extensionlist.clear();
|
||||||
|
@ -925,6 +937,11 @@ namespace GLExtensions
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_GLVersion < 300)
|
||||||
|
{
|
||||||
|
InitExtensionList21();
|
||||||
|
return;
|
||||||
|
}
|
||||||
GLint NumExtension = 0;
|
GLint NumExtension = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &NumExtension);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &NumExtension);
|
||||||
for (GLint i = 0; i < NumExtension; ++i)
|
for (GLint i = 0; i < NumExtension; ++i)
|
||||||
|
@ -935,7 +952,10 @@ namespace GLExtensions
|
||||||
GLint major, minor;
|
GLint major, minor;
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
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)
|
if (_isES3)
|
||||||
_GLVersion = 330; // Get all the fun things
|
_GLVersion = 330; // Get all the fun things
|
||||||
}
|
}
|
||||||
|
@ -970,13 +990,18 @@ namespace GLExtensions
|
||||||
_isES3 = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3;
|
_isES3 = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3;
|
||||||
_isES = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3 || GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES2;
|
_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
|
// 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 it fails then the user's drivers don't support GL 3.0
|
||||||
if (GetFuncAddress ("glGetIntegerv", (void**)&glGetIntegerv) == NULL)
|
if (GetFuncAddress ("glGetIntegerv", (void**)&glGetIntegerv) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
if (GetFuncAddress("glGetString", (void**)&glGetString) == NULL)
|
||||||
|
return false;
|
||||||
if (GetFuncAddress("glGetStringi", (void**)&glGetStringi) == NULL)
|
if (GetFuncAddress("glGetStringi", (void**)&glGetStringi) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
if (GetFuncAddress("glGetError", (void**)&glGetError) == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
InitVersion();
|
InitVersion();
|
||||||
InitExtensionList();
|
InitExtensionList();
|
||||||
|
@ -1063,8 +1088,6 @@ namespace GLExtensions
|
||||||
&& GrabFunction(glPushClientAttrib)
|
&& GrabFunction(glPushClientAttrib)
|
||||||
&& GrabFunction(glPopClientAttrib)
|
&& GrabFunction(glPopClientAttrib)
|
||||||
&& GrabFunction(glRenderMode)
|
&& GrabFunction(glRenderMode)
|
||||||
&& GrabFunction(glGetError)
|
|
||||||
&& GrabFunction(glGetString)
|
|
||||||
&& GrabFunction(glFinish)
|
&& GrabFunction(glFinish)
|
||||||
&& GrabFunction(glFlush)
|
&& GrabFunction(glFlush)
|
||||||
&& GrabFunction(glHint)
|
&& GrabFunction(glHint)
|
||||||
|
|
Loading…
Reference in New Issue