MultiTexture error

I’m programming in VisualC++ using
#include <GL\gl.h>
#include <GL\glut.h>

For my OpenGL includes. When I use
glGetString(GL_EXTENSIONS)
GL_ARB_multitexture is the first thing included in the string, but if I attempt to use
glActiveTexture(GL_TEXTURE1);

or any of it’s related functions it gives me an ‘undeclared identifier’ error. code C2065. when I compile.

Does anyone know what I’m missing to be able to use the multitexturing functions?

You need to include glext.h and bind the extension procs.
http://oss.sgi.com/projects/ogl-sample/registry/
http://www.opengl.org/resources/features/OGLextensions/

Okay, I’ve always avoided messing with make files and stuff like that, so I need a little more help with how to bind the extension.

You can use an extension wrapper like GLEW to handle all the messy stuff for you.

Thank you both for your help. And actually I think more detailed instructions on how to bind things, and what exactly needs binding in visualC++, would be most helpfull.

For one, it might come in handy later with more than just openGL extensions.

Also, I looked at the documentation for GLEW, it seems a little complicated to set up itself, no garantee that my program would be portable to another computer, and it does not work with GLUT unless I also use GLX.

I’ll try it though if I can’t figure out how to bind things myself.

On many systems, you can get away with

#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>

On some systems (windows in particular) however, you can’t access extension function directly. You have to ask your system for function pointers and use those. This, however, is system (WGL/GLX/AGL) specific, and for all i know, glut doesn’t provide a way to do it portably (as does SDL with SDL_GL_GetProcAddress for example).

Setting up the extension function pointers isn’t that hard, but if you want to stay portable, you have to provide the code for all the different environments. Which is exactly what GLEW does (and a bit more).

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

#ifdef GL_ARB_multitexture
PFNGLACTIVETEXTUREARB glActiveTextureARB = NULL;
#endif
/* other extension functions */

void init_wgl(void) {
#ifdef GL_ARB_multitexture
  PFNGLACTIVETEXTUREARB glActiveTextureARB = wglGetProcAddress("glActiveTextureARB");
#endif
}

For other systems, substitute wglGetProcAddress with glXGetProcAddress or aglGetProcAddress.

And do yourself a favor and use a wrapper library.