GL: Added different code path when glGetString(GL_EXTENSIONS) returns NULL.

This commit is contained in:
Branimir Karadžić
2016-01-05 21:06:42 -08:00
parent 8f5202ca99
commit 011bbfd451
2 changed files with 49 additions and 30 deletions

View File

@@ -1209,6 +1209,34 @@ namespace bgfx { namespace gl
_minFilter = s_textureFilterMin[min][_hasMips ? mip+1 : 0];
}
void updateExtension(const char* _name)
{
bool supported = false;
for (uint32_t ii = 0; ii < Extension::Count; ++ii)
{
Extension& extension = s_extension[ii];
if (!extension.m_supported
&& extension.m_initialize)
{
const char* ext = _name;
if (0 == strncmp(ext, "GL_", 3) ) // skip GL_
{
ext += 3;
}
if (0 == strcmp(ext, extension.m_name) )
{
extension.m_supported = true;
supported = true;
break;
}
}
}
BX_TRACE("GL_EXTENSION %3d%s: %s", index, supported ? " (supported)" : "", _name);
BX_UNUSED(supported);
}
struct RendererContextGL : public RendererContextI
{
RendererContextGL()
@@ -1365,42 +1393,31 @@ namespace bgfx { namespace gl
strncpy(name, pos, len);
name[len] = '\0';
bool supported = false;
for (uint32_t ii = 0; ii < Extension::Count; ++ii)
{
Extension& extension = s_extension[ii];
if (!extension.m_supported
&& extension.m_initialize)
{
const char* ext = name;
if (0 == strncmp(ext, "GL_", 3) ) // skip GL_
{
ext += 3;
}
if (0 == strcmp(ext, extension.m_name) )
{
extension.m_supported = true;
supported = true;
break;
}
}
}
BX_TRACE("GL_EXTENSION %3d%s: %s", index, supported ? " (supported)" : "", name);
BX_UNUSED(supported);
updateExtension(name);
pos += len+1;
++index;
}
}
else if (NULL != glGetStringi)
{
GLint numExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
glGetError(); // ignore error if glGetString returns NULL.
BX_TRACE("Supported extensions:");
for (uint32_t ii = 0; ii < Extension::Count; ++ii)
for (GLint index = 0; index < numExtensions; ++index)
{
if (s_extension[ii].m_supported)
{
BX_TRACE("\t%2d: %s", ii, s_extension[ii].m_name);
}
const char* name = (const char*)glGetStringi(GL_EXTENSIONS, index);
updateExtension(name);
}
}
BX_TRACE("Supported extensions:");
for (uint32_t ii = 0; ii < Extension::Count; ++ii)
{
if (s_extension[ii].m_supported)
{
BX_TRACE("\t%2d: %s", ii, s_extension[ii].m_name);
}
}
}