Extensions problem...

Can someone tell me why this code might crash everything when I call it? Dosnt even give me a reason, just comes up with the XP Encountered a problem executing the app window.

The problem seems? to be in this line:
if(strstr((const char *)glGetString(GL_EXTENSIONS), “ARB_multitexture”) != NULL)

but here is the rest of the code just in case I am missing something.

//OpenGL Extensions
void CheckExtensions(void)
{
glGetString(GL_EXTENSIONS);

#ifdef _WIN32
if(strstr((const char *)glGetString(GL_EXTENSIONS), “ARB_multitexture”) != NULL)
{
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &MaxTextures);
glActiveTextureARB = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress(“glActiveTextureARB”);
glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREPROC) wglGetProcAddress(“glClientActiveTextureARB”);
glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FPROC) wglGetProcAddress(“glMultiTexCoord1fARB”);
glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress(“glMultiTexCoord2fARB”);
glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FPROC) wglGetProcAddress(“glMultiTexCoord3fARB”);
glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FPROC) wglGetProcAddress(“glMultiTexCoord4fARB”);
MultiTextureSupport = true;
}

else
{
	MultiTextureSupport = false;
}

if(strstr((const char *)glGetString(GL_EXTENSIONS), "EXT_compiled_vertex_array") != NULL)
{
	glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC) wglGetProcAddress("glLockArraysEXT");
	glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC) wglGetProcAddress("glUnlockArraysEXT");
	CompiledVertexArraySupport = true;
}

else
{
	CompiledVertexArraySupport = false;
}

#endif
}

I don’t know what is wrong but could I STRONGLY suggest you use the code from http://www.opengl.org/resources/features/OGLextensions/

To detect if an extension is supported. (your code may fail under certain circumstances)

Check if you have a valid opengl context activated in the same thread that open these extensions.

The previous two posts are both valid points. I would recommend the Nehe code. A suggestion would be that you store the pointer returned by glGetString and then do your strstr on that pointer. There are two benefits to this 1. You only call glGetString once (not so important) and 2. you can validate the pointer (if (!ptrString) return; ).

If your pointer is NULL then I would guess that Ffelagunds suggestion is correct and you are trying to call GL functions before you have created your context. Which would make this a beginner question…

[This message has been edited by rgpc (edited 01-19-2004).]