Fix OpenGL extension detection on Linux/Mesa.

Created function in glwrap to test whether a GL extension is available.
This required using OpenGL3's glGetStringi. Backwards compat code can
be added to function if necessary.
This commit is contained in:
Stephen Just 2014-08-19 16:08:27 -06:00
parent 160d4ae432
commit 6b3786457f
3 changed files with 22 additions and 3 deletions

View File

@ -1213,3 +1213,19 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
glGetError();
}
bool hasGLExtension(const char* extension) {
GLint numExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
Log::debug("GLWrap", "Found %d OpenGL Extensions", numExtensions);
for (GLint i = 0; i < numExtensions; i++) {
const char* foundExtension =
(const char*) glGetStringi(GL_EXTENSIONS, i);
if (foundExtension && strcmp(foundExtension, extension) == 0) {
Log::debug("GLWrap", "Extension %s found", extension);
return true;
}
}
Log::debug("GLWrap", "Extension %s not found", extension);
return false;
}

View File

@ -162,4 +162,7 @@ void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>
void GL32_draw2DRectangle(irr::video::SColor color, const irr::core::rect<s32>& position,
const irr::core::rect<s32>* clip = 0);
bool hasGLExtension(const char* extension);
#endif

View File

@ -486,9 +486,9 @@ void IrrDriver::initDevice()
// Default false value for hasVSLayer if --no-graphics argument is used
if (!ProfileWorld::isNoGraphics())
{
const GLubyte *extensions = glGetString(GL_EXTENSIONS);
if (extensions && strstr((const char*)extensions, "GL_AMD_vertex_shader_layer") != NULL)
hasVSLayer = true;
if (hasGLExtension("GL_AMD_vertex_shader_layer")) {
hasVSLayer = true;
}
}