PDA

View Full Version : MultiTexture error



Centauri
09-11-2005, 07:39 PM
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?

Hlz
09-11-2005, 08:19 PM
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/

Centauri
09-11-2005, 09:12 PM
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.

memfr0b
09-12-2005, 12:58 AM
You can use an extension wrapper like GLEW (http://glew.sourceforge.net/) to handle all the messy stuff for you.

Centauri
09-12-2005, 03:36 PM
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.

memfr0b
09-12-2005, 11:45 PM
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.