mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-22 13:55:07 +00:00
Patch ID: 3260500 - Query extension string only once
This commit is contained in:
parent
4a9b2a7b42
commit
1b38b41837
@ -46,7 +46,7 @@ if (@ARGV)
|
||||
|
||||
if (length($extstring))
|
||||
{
|
||||
print " CONST_CAST(" . $extvar . ") = " . $extpre . "GetExtension(\"$extstring\");\n";
|
||||
print " CONST_CAST(" . $extvar . ") = _glewSearchExtension(\"$extstring\", start, end);\n";
|
||||
}
|
||||
|
||||
if (keys %$functions)
|
||||
|
@ -217,3 +217,23 @@ static GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuin
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for name in the extensions string. Use of strstr()
|
||||
* is not sufficient because extension names can be prefixes of
|
||||
* other extension names. Could use strtok() but the constant
|
||||
* string returned by glGetString might be in read-only memory.
|
||||
*/
|
||||
static GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)
|
||||
{
|
||||
const GLubyte* p;
|
||||
GLuint len = _glewStrLen((const GLubyte*)name);
|
||||
p = start;
|
||||
while (p < end)
|
||||
{
|
||||
GLuint n = _glewStrCLen(p, ' ');
|
||||
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
|
||||
p += n+1;
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
@ -1,26 +1,14 @@
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Search for name in the extensions string. Use of strstr()
|
||||
* is not sufficient because extension names can be prefixes of
|
||||
* other extension names. Could use strtok() but the constant
|
||||
* string returned by glGetString might be in read-only memory.
|
||||
*/
|
||||
GLboolean glewGetExtension (const char* name)
|
||||
{
|
||||
GLubyte* p;
|
||||
GLubyte* end;
|
||||
GLuint len = _glewStrLen((const GLubyte*)name);
|
||||
p = (GLubyte*)glGetString(GL_EXTENSIONS);
|
||||
if (0 == p) return GL_FALSE;
|
||||
end = p + _glewStrLen(p);
|
||||
while (p < end)
|
||||
{
|
||||
GLuint n = _glewStrCLen(p, ' ');
|
||||
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
|
||||
p += n+1;
|
||||
}
|
||||
return GL_FALSE;
|
||||
const GLubyte* start;
|
||||
const GLubyte* end;
|
||||
start = (const GLubyte*)glGetString(GL_EXTENSIONS);
|
||||
if (start == 0)
|
||||
return GL_FALSE;
|
||||
end = start + _glewStrLen(start);
|
||||
return _glewSearchExtension(name, start, end);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -33,6 +21,8 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
||||
const GLubyte* s;
|
||||
GLuint dot;
|
||||
GLint major, minor;
|
||||
const GLubyte* start;
|
||||
const GLubyte* end;
|
||||
/* query opengl version */
|
||||
s = glGetString(GL_VERSION);
|
||||
dot = _glewStrCLen(s, '.');
|
||||
@ -69,4 +59,11 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
||||
CONST_CAST(GLEW_VERSION_1_2) = GLEW_VERSION_1_2_1 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
|
||||
CONST_CAST(GLEW_VERSION_1_1) = GLEW_VERSION_1_2 == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
/* query opengl extensions string */
|
||||
start = glGetString(GL_EXTENSIONS);
|
||||
if (start == 0)
|
||||
start = (const GLubyte*)"";
|
||||
end = start + _glewStrLen(start);
|
||||
|
||||
/* initialize extensions */
|
||||
|
@ -2,27 +2,21 @@
|
||||
|
||||
GLboolean glxewGetExtension (const char* name)
|
||||
{
|
||||
GLubyte* p;
|
||||
GLubyte* end;
|
||||
GLuint len;
|
||||
const GLubyte* start;
|
||||
const GLubyte* end;
|
||||
|
||||
if (glXGetCurrentDisplay == NULL) return GL_FALSE;
|
||||
len = _glewStrLen((const GLubyte*)name);
|
||||
p = (GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);
|
||||
if (0 == p) return GL_FALSE;
|
||||
end = p + _glewStrLen(p);
|
||||
while (p < end)
|
||||
{
|
||||
GLuint n = _glewStrCLen(p, ' ');
|
||||
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
|
||||
p += n+1;
|
||||
}
|
||||
return GL_FALSE;
|
||||
start = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);
|
||||
if (0 == start) return GL_FALSE;
|
||||
end = start + _glewStrLen(start);
|
||||
return _glewSearchExtension(name, start, end);
|
||||
}
|
||||
|
||||
GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
|
||||
{
|
||||
int major, minor;
|
||||
const GLubyte* start;
|
||||
const GLubyte* end;
|
||||
/* initialize core GLX 1.2 */
|
||||
if (_glewInit_GLX_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY;
|
||||
/* initialize flags */
|
||||
@ -49,4 +43,11 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* query GLX extension string */
|
||||
start = 0;
|
||||
if (glXGetCurrentDisplay != NULL)
|
||||
start = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);
|
||||
if (start == 0)
|
||||
start = (const GLubyte *)"";
|
||||
end = start + _glewStrLen(start);
|
||||
/* initialize extensions */
|
||||
|
@ -5,32 +5,37 @@ static PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglewGetExtensionsStringEXT = NULL;
|
||||
|
||||
GLboolean wglewGetExtension (const char* name)
|
||||
{
|
||||
GLubyte* p;
|
||||
GLubyte* end;
|
||||
GLuint len = _glewStrLen((const GLubyte*)name);
|
||||
const GLubyte* start;
|
||||
const GLubyte* end;
|
||||
if (_wglewGetExtensionsStringARB == NULL)
|
||||
if (_wglewGetExtensionsStringEXT == NULL)
|
||||
return GL_FALSE;
|
||||
else
|
||||
p = (GLubyte*)_wglewGetExtensionsStringEXT();
|
||||
start = (const GLubyte*)_wglewGetExtensionsStringEXT();
|
||||
else
|
||||
p = (GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC());
|
||||
if (0 == p) return GL_FALSE;
|
||||
end = p + _glewStrLen(p);
|
||||
while (p < end)
|
||||
{
|
||||
GLuint n = _glewStrCLen(p, ' ');
|
||||
if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
|
||||
p += n+1;
|
||||
}
|
||||
return GL_FALSE;
|
||||
start = (const GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC());
|
||||
if (start == 0)
|
||||
return GL_FALSE;
|
||||
end = start + _glewStrLen(start);
|
||||
return _glewSearchExtension(name, start, end);
|
||||
}
|
||||
|
||||
GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST)
|
||||
{
|
||||
GLboolean crippled;
|
||||
const GLubyte* start;
|
||||
const GLubyte* end;
|
||||
/* find wgl extension string query functions */
|
||||
_wglewGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB");
|
||||
_wglewGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT");
|
||||
/* query wgl extension string */
|
||||
if (_wglewGetExtensionsStringARB == NULL)
|
||||
if (_wglewGetExtensionsStringEXT == NULL)
|
||||
start = (const GLubyte*)"";
|
||||
else
|
||||
start = (const GLubyte*)_wglewGetExtensionsStringEXT();
|
||||
else
|
||||
start = (const GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC());
|
||||
end = start + _glewStrLen(start);
|
||||
/* initialize extensions */
|
||||
crippled = _wglewGetExtensionsStringARB == NULL && _wglewGetExtensionsStringEXT == NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user