avaibility of opengl extension

How can I test if an opengl extension is available on the video card ?


Originally posted by roffe:

I’ve already read this, but I didn’t find what I want : I know how to use extensions, but I want a fonction to test if a particular extension is available, to prevent for use it if it isn’t supported by the hardware…

Originally posted by Acheum:
I know how to use extensions, but I want a fonction to test if a particular extension is available

Is this a joke? You say you know how to use extensions, but you don’t know how to check if an extension is supported. The link I gave you points to source code for extension checking.

nehe.gamedev.net has a tutorial on how to do that (Lesson 24).


to kwow if a particular extension is supported (for example GL_ARB_fragment_program), do:

char *ext_string = glGetString(EXTENSIONS);
if (strstr(ext_string, “GL_ARB_fragment_program”) != NULL)
// the extension is supported
// the extension is not supported

Oups sorry, I didn’t read very well…

#include <GL/gl.h>
#include <string.h>

isExtensionSupported(const char *extension)
const GLubyte *extensions = NULL;
const GLubyte *start;
GLubyte *where, *terminator;

/* Extension names should not have spaces. */
where = (GLubyte *) strchr(extension, ’ ');
if (where | | extension == ‘\0’)
return 0;
extensions = glGetString(GL_EXTENSIONS);
It takes a bit of care to be fool-proof about parsing the
OpenGL extensions string. Don’t be fooled by sub-strings,
etc. */
start = extensions;
for (; {
where = (GLubyte *) strstr((const char *) start, extension);
if (!where)
terminator = where + strlen(extension);
if (where == start | | *(where - 1) == ’ ')
if (*terminator == ’ ’ | | *terminator == ‘\0’)
return 1;
start = terminator;
return 0;


ext_string, “GL_ARB_fragment_program”)

AARRGHH, there is a paper of nvidia, somewhere out there, where is told that a developer should "avoid the use of strstr(…) because it results in som inexplicably bugs.

There is also a tool.
Check this site!! http://www.realtech-vr.com/glview/

But some drivers don’t “refresh” extensions string always. For example there is no VBO extension in ext. string with nVidia detonator < 44.03. Best way is to call wglGetProcAddress and check whether it is NULL or not…

They didnt expose them becourse you shouldnt depend on that extension to work in those drivers, it was intended for developers to test it, not use it in a real app, so i dont think they forgot to update the extensionstring.