Originally posted by Bode:
[b]Hi…
In my attempt to deal with extensions I’m confused as to how to declare my function pointer variables. The examples that I see do something like this to declare the function prototypes:
#ifdef _WIN32
typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC)(GLenum pname, GLfloat param);
typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC)(GLenum pname, const GLfloat *params);
#endif
Then, define the variables like:
#ifdef _WIN32
PFNGLPOINTPARAMETERFEXTPROC glPointParameterfEXT;
PFNGLPOINTPARAMETERFVEXTPROC glPointParameterfvEXT;
#endif
The problem that I can’t get is determining the function name of glPointParameterfvEXT. I see that I could extract it from PFNGLPOINTPARAMETERFVEXTPROC, but that would be terribly tedious if I have a lot of extensions.
So I’m wondering if there is an .h file that will have the gl* extension function defined somewhere? Or does everybody know to call the PFNGLPOINTPARAMETERFVEXTPROC function pointer to glPointParameterfvEXT? Or is this in some other file besides gl.h/glext.h?
Thanks a bunch…
Bode [/b]
Bode,
The glext.h file will define the PFNGLBLABLABLAEXTPROC pointers. It’s up to you to declare a pointer of that type and call the platform specific function to fill the pointer with the correct address. For windows this is:
(PFNGLBLABLABLAEXTPROC)wglGetProcAddress( “glBlaBlaBlaEXT”)
For other platforms there are corresponding calls.
AFAIK there is no .h file around that declares the required character strings to pass to wglGetProcAddress, but they are quite easy to derive from the PFNGLBLABLABLA definition: small caps gl, capitalise each word and an all caps finish like ‘EXT’, ‘NV’ etc.
You could search around the net for classes/files that implement a bunch of extensions for you, but as I said it’s relatively simple to code for yourself (just a lot of repetetive work if you want to use a lot of extensions).
I’m assuming you are familiar with the following:
- verify extension support during compile-time with #ifdef ExtensionName
- verify extension support during runtime by querying glGetString(GL_EXTENSIONS) for the ExtensionName
- only use the extension functions if support is available and wglGetProcAddress returned a valid pointer
HTH
Jean-Marc.