GL: Cleanup.

This commit is contained in:
Бранимир Караџић 2019-01-26 15:27:04 -08:00
parent 7a45afd5a5
commit 3aeb8ce065

View File

@ -1656,8 +1656,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
_minFilter = s_textureFilterMin[min][_hasMips ? mip+1 : 0]; _minFilter = s_textureFilterMin[min][_hasMips ? mip+1 : 0];
} }
void updateExtension(const char* _name) void updateExtension(const bx::StringView& _name)
{ {
bx::StringView ext(_name);
if (0 == bx::strCmp(ext, "GL_", 3) ) // skip GL_
{
ext.set(ext.getPtr()+3, ext.getTerm() );
}
bool supported = false; bool supported = false;
for (uint32_t ii = 0; ii < Extension::Count; ++ii) for (uint32_t ii = 0; ii < Extension::Count; ++ii)
{ {
@ -1665,12 +1671,6 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (!extension.m_supported if (!extension.m_supported
&& extension.m_initialize) && extension.m_initialize)
{ {
const char* ext = _name;
if (0 == bx::strCmp(ext, "GL_", 3) ) // skip GL_
{
ext += 3;
}
if (0 == bx::strCmp(ext, extension.m_name) ) if (0 == bx::strCmp(ext, extension.m_name) )
{ {
extension.m_supported = true; extension.m_supported = true;
@ -1680,7 +1680,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
} }
} }
BX_TRACE("GL_EXTENSION %s: %s", supported ? " (supported)" : "", _name); BX_TRACE("GL_EXTENSION %s: %.*s", supported ? " (supported)" : "", _name.getLength(), _name.getPtr() );
BX_UNUSED(supported); BX_UNUSED(supported);
} }
@ -1877,29 +1877,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
glGetError(); // ignore error if glGetString returns NULL. glGetError(); // ignore error if glGetString returns NULL.
if (NULL != extensions) if (NULL != extensions)
{ {
char name[1024]; bx::StringView ext(extensions);
const char* pos = extensions;
const char* end = extensions + bx::strLen(extensions);
uint32_t index = 0; uint32_t index = 0;
while (pos < end) while (!ext.isEmpty() )
{ {
uint32_t len; const bx::StringView space = bx::strFind(ext, ' ');
const bx::StringView space = bx::strFind(pos, ' '); const bx::StringView token = bx::StringView(ext.getPtr(), space.getPtr() );
if (!space.isEmpty() ) updateExtension(token);
{
len = bx::uint32_min(sizeof(name), (uint32_t)(space.getPtr() - pos) );
}
else
{
len = bx::uint32_min(sizeof(name), (uint32_t)bx::strLen(pos) );
}
bx::strCopy(name, BX_COUNTOF(name), pos, len); ext.set(token.getTerm() + 1, ext.getTerm() );
name[len] = '\0';
updateExtension(name);
pos += len+1;
++index; ++index;
} }
} }