PDA

View Full Version : using extensions in multiple files



Boris008
03-04-2002, 08:16 AM
I am having trouble using extensions in multiple files in windows. This is probably more a programming issue than and openGL but it involves extensions. Here's my problem (I have lots of problems but that's a different forum;~):

Suppose I have the extensions defined in a header file where I do:

#include "glext.h"
PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;
etc...

followed by:

void initMultiTexture()
{
glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
glClientActiveTextureARB= (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTextureARB");
}

Then, I initialize the extensions I want by initMultiTexture(); in main.cpp, for example

Now, I have a world class and a character class that also use extensions. How do I define the extension functions in these files without having the compiler seeing function redefinitions?

Thanks for the help,

Boris

[This message has been edited by Boris008 (edited 03-04-2002).]

V-man
03-04-2002, 03:52 PM
In the header file, you declare them as extern, and you define them in a cpp file:

lets call one glmyext.h and glmyext.cpp

and then you make the functions available in your other .h and .cpp by including glmyext.h

V-man

Boris008
03-05-2002, 07:28 AM
Thanks man! Works like a charm.

Boris