mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-28 16:51:57 +00:00
974679c6d8
Core-profile extension query patch by Carsten Neumann https://sourceforge.net/p/glew/bugs/174/
93 lines
3.6 KiB
C
93 lines
3.6 KiB
C
/* ------------------------------------------------------------------------- */
|
|
|
|
GLboolean GLEWAPIENTRY glewGetExtension (const char* name)
|
|
{
|
|
const GLubyte* start;
|
|
const GLubyte* end;
|
|
GLuint dot;
|
|
GLint numExt, i, major;
|
|
/* query opengl version to decide how to enumerate extensions */
|
|
start = glGetString(GL_VERSION);
|
|
dot = _glewStrCLen(start, '.');
|
|
if (dot == 0)
|
|
return GL_FALSE;
|
|
major = start[dot-1]-'0';
|
|
|
|
if (major >= 3)
|
|
{
|
|
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
|
|
for(i = 0; i < numExt; ++i)
|
|
{
|
|
start = glGetStringi(GL_EXTENSIONS, i);
|
|
end = start + _glewStrLen(start);
|
|
if(_glewSearchExtension(name, start, end) == GL_TRUE)
|
|
return GL_TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
start = (const GLubyte*)glGetString(GL_EXTENSIONS);
|
|
if (start == 0)
|
|
return GL_FALSE;
|
|
end = start + _glewStrLen(start);
|
|
return _glewSearchExtension(name, start, end);
|
|
}
|
|
return GL_FALSE;
|
|
}
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
#ifndef GLEW_MX
|
|
static
|
|
#endif
|
|
GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
|
|
{
|
|
const GLubyte* s;
|
|
GLuint dot;
|
|
GLint major, minor;
|
|
const GLubyte* extArray[1000];
|
|
const GLubyte** extArrayStart;
|
|
const GLubyte** extArrayEnd;
|
|
const GLubyte* extStart;
|
|
const GLubyte* extEnd;
|
|
/* query opengl version */
|
|
s = glGetString(GL_VERSION);
|
|
dot = _glewStrCLen(s, '.');
|
|
if (dot == 0)
|
|
return GLEW_ERROR_NO_GL_VERSION;
|
|
|
|
major = s[dot-1]-'0';
|
|
minor = s[dot+1]-'0';
|
|
|
|
if (minor < 0 || minor > 9)
|
|
minor = 0;
|
|
if (major<0 || major>9)
|
|
return GLEW_ERROR_NO_GL_VERSION;
|
|
|
|
|
|
if (major == 1 && minor == 0)
|
|
{
|
|
return GLEW_ERROR_GL_VERSION_10_ONLY;
|
|
}
|
|
else
|
|
{
|
|
CONST_CAST(GLEW_VERSION_4_3) = ( major > 4 ) || ( major == 4 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_4_2) = GLEW_VERSION_4_3 == GL_TRUE || ( major == 4 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_4_1) = GLEW_VERSION_4_2 == GL_TRUE || ( major == 4 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_4_0) = GLEW_VERSION_4_1 == GL_TRUE || ( major == 4 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_3_3) = GLEW_VERSION_4_0 == GL_TRUE || ( major == 3 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_3_2) = GLEW_VERSION_3_3 == GL_TRUE || ( major == 3 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_3_1) = GLEW_VERSION_3_2 == GL_TRUE || ( major == 3 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_3_0) = GLEW_VERSION_3_1 == GL_TRUE || ( major == 3 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_2_1) = GLEW_VERSION_3_0 == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_2_0) = GLEW_VERSION_2_1 == GL_TRUE || ( major == 2 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_1_5) = GLEW_VERSION_2_0 == GL_TRUE || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_1_4) = GLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_1_3) = GLEW_VERSION_1_4 == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
|
|
CONST_CAST(GLEW_VERSION_1_2_1) = GLEW_VERSION_1_3 == GL_TRUE ? GL_TRUE : GL_FALSE;
|
|
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;
|
|
}
|
|
|
|
/* initialize core */
|