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

@ -149,6 +149,7 @@ typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, G
typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
typedef const GLubyte* (GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); typedef const GLubyte* (GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
typedef const GLubyte* (GL_APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
@ -332,6 +333,7 @@ GL_IMPORT______(true, PFNGLGETQUERYOBJECTUI64VPROC, glGetQueryObj
GL_IMPORT______(false, PFNGLGETSHADERIVPROC, glGetShaderiv); GL_IMPORT______(false, PFNGLGETSHADERIVPROC, glGetShaderiv);
GL_IMPORT______(false, PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog); GL_IMPORT______(false, PFNGLGETSHADERINFOLOGPROC, glGetShaderInfoLog);
GL_IMPORT______(false, PFNGLGETSTRINGPROC, glGetString); GL_IMPORT______(false, PFNGLGETSTRINGPROC, glGetString);
GL_IMPORT______(true, PFNGLGETSTRINGIPROC, glGetStringi);
GL_IMPORT______(false, PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation); GL_IMPORT______(false, PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation);
#if BGFX_CONFIG_RENDERER_OPENGL || !(BGFX_CONFIG_RENDERER_OPENGLES < 30) #if BGFX_CONFIG_RENDERER_OPENGL || !(BGFX_CONFIG_RENDERER_OPENGLES < 30)
GL_IMPORT______(true, PFNGLINVALIDATEFRAMEBUFFERPROC, glInvalidateFramebuffer); GL_IMPORT______(true, PFNGLINVALIDATEFRAMEBUFFERPROC, glInvalidateFramebuffer);

View file

@ -1209,6 +1209,34 @@ namespace bgfx { namespace gl
_minFilter = s_textureFilterMin[min][_hasMips ? mip+1 : 0]; _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 struct RendererContextGL : public RendererContextI
{ {
RendererContextGL() RendererContextGL()
@ -1365,34 +1393,24 @@ namespace bgfx { namespace gl
strncpy(name, pos, len); strncpy(name, pos, len);
name[len] = '\0'; name[len] = '\0';
bool supported = false; updateExtension(name);
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);
pos += len+1; pos += len+1;
++index; ++index;
} }
}
else if (NULL != glGetStringi)
{
GLint numExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
glGetError(); // ignore error if glGetString returns NULL.
for (GLint index = 0; index < numExtensions; ++index)
{
const char* name = (const char*)glGetStringi(GL_EXTENSIONS, index);
updateExtension(name);
}
}
BX_TRACE("Supported extensions:"); BX_TRACE("Supported extensions:");
for (uint32_t ii = 0; ii < Extension::Count; ++ii) for (uint32_t ii = 0; ii < Extension::Count; ++ii)
@ -1403,7 +1421,6 @@ namespace bgfx { namespace gl
} }
} }
} }
}
// Allow all texture filters. // Allow all texture filters.
memset(s_textureFilter, true, BX_COUNTOF(s_textureFilter) ); memset(s_textureFilter, true, BX_COUNTOF(s_textureFilter) );