mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-22 13:55:07 +00:00
Guard against people updating the string lists but forgetting to update the
magic constants sprinkled in the code. Any reasonable compiler should be able to optimize this away. git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@147 783a27ee-832a-0410-bc00-9f386506c6dd
This commit is contained in:
parent
48708fe729
commit
ede84ed0fb
@ -9,13 +9,14 @@ const GLubyte* glewGetErrorString (GLenum error)
|
|||||||
{
|
{
|
||||||
static const GLubyte* _glewErrorString[] =
|
static const GLubyte* _glewErrorString[] =
|
||||||
{
|
{
|
||||||
"no error",
|
"No error",
|
||||||
"missing GL version",
|
"Missing GL version",
|
||||||
"GL 1.1 and up are not supported",
|
"GL 1.1 and up are not supported",
|
||||||
"GLX 1.2 and up are not supported",
|
"GLX 1.2 and up are not supported",
|
||||||
"unknown error"
|
"Unknown error"
|
||||||
};
|
};
|
||||||
return _glewErrorString[error > 4 ? 4 : error];
|
const int max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1;
|
||||||
|
return _glewErrorString[error > max_error ? max_error : error];
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLubyte* glewGetString (GLenum name)
|
const GLubyte* glewGetString (GLenum name)
|
||||||
@ -25,7 +26,8 @@ const GLubyte* glewGetString (GLenum name)
|
|||||||
NULL,
|
NULL,
|
||||||
"GLEW_VERSION_STRING"
|
"GLEW_VERSION_STRING"
|
||||||
};
|
};
|
||||||
return _glewString[name > 1 ? 0 : name];
|
const int max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;
|
||||||
|
return _glewString[name > max_string ? max_string : name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
Loading…
Reference in New Issue
Block a user