[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: Parsing OpenGL extensions string
Stephen J Baker wrote:
Miguel A. Osorio wrote:
Hey people,
I recently downloaded a GDC presentation by Mark Kilgard on OpenGL
extensions, and there's a section on using extensions. Run-time
checking of extensions is done by searching inside the string returned
by glGetString(GL_EXTENSIONS), but Kilgard advises *not* to use the
standard function "strstr", using instead glutExtensionSupported or
other routine.
What would be the problem using strstr?
I believe the problem was when the first characters of one extension
matched
the whole of another extension.
(just using strstr could get you in trouble also if your extension
matches the end or even middle of an other extension)
And you cannot just add a space at the end of your search word,
because then you would miss the last extension in the extensions
string.... So you end up with something like the glut code which
uses strstr AND checks that the extension token is properly space
separated, or at the end or at the begining of the extension string..
BTW, also remember not to copy the extension string to a fixed size
buffer. There is on ongoing competition on which vendor first
breaks the 1Mbyte limit on the string length. It is best to
use the pointer returned from glGetString directly.
Eero