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:
mem 2003-10-02 09:49:29 +00:00
parent 48708fe729
commit ede84ed0fb
1 changed files with 7 additions and 5 deletions

View File

@ -9,13 +9,14 @@ const GLubyte* glewGetErrorString (GLenum error)
{
static const GLubyte* _glewErrorString[] =
{
"no error",
"missing GL version",
"No error",
"Missing GL version",
"GL 1.1 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)
@ -25,7 +26,8 @@ const GLubyte* glewGetString (GLenum name)
NULL,
"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];
}
/* ------------------------------------------------------------------------ */