Usage of OGL-extensions simplified

Since the question of the usage of OGL-extensions pops up from time to time, I tried to provide a simple solution to this problem.

I have made a header-file similar to the glext.h from SGI. It allows you to
use the functions-pointers provided by the extensions as ordinary function
calls without any overhead (except for the first call of the function):

     [http://wwwmath.uni-muenster.de/cs/u/kostab/glext.h](http://wwwmath.uni-muenster.de/cs/u/kostab/glext.h)  

So you can write:

...
glActiveTextureARB(GL_TEXTURE1_ARB);
...

instead of:

...
// declare function pointer
GLACTIVETEXTUREARBPROC glActiveTextureARB = 0;
...
// init function pointer
glActiveTextureARB = (GLACTIVETEXTUREARBPROC)wglGetProcAddress(...);
...
// use function pointer
(*glActiveTextureARB)(GL_TEXTURE1_ARB);
...

Most of the NVidia extensions (cube map, texture compression, register
combiners, …) are contained. If there are some other usefull extensions
missing, email me and I add them.

What do you think? Is it usefull? Could/should it be improved?

Looks pretty good!
(and is more complete than mine)

Thanks a lot!
Excellent work!

Regards,

LG

Nice work

Just a question though. Haven’t looked into it that much yet. Do you have any macro to determine if an extension is available or not?

Originally posted by Bob:
[b]Nice work

Just a question though. Haven’t looked into it that much yet. Do you have any macro to determine if an extension is available or not?[/b]

Not yet. But I think this is something I can add for the future…

Kosta

Hi !

There is something I did for my graphics engine that you might find interesting.

Basically, I have created a C+±wrapper class called HGL_RC which is the equivalent of the Windows RC.

When you create the HGL_RC, it will automatically check for the available extensions and load them.

Then, each call to HGL_RC::wglMakeCurrent makes the extensions of the specific RC the current ones (this is useful coz you can have different pointers for the extensions according to your RC).

I mean, for example, I have got one global glLockArraysEXT function and I have got one in each HGL_RC : when the RC becomes current, the value of the HGL_RC is copied to the global function pointer.

I have also defined global booleans that tells you if the extension is available in the current RC.

This has been very useful to me as I develop several apps using MFC and OpenGL : when you render to a DIB, you use the generic Microsoft implementation of OpenGL and there are almost no extension. On the other hand, when I really use my GeForce, I want to use its extension…

With this system, I use the same routine for rendering to both (when GL_EXT_separate_specular_color is not available, I use the 2-passes technique) Rendering Contexts.

Well, there are a lot of other advantages in this system (dynamic link to OpenGL.dll e.g.) but this is the one that made me code this class…

Unfortunately, I can not post the code because it is part of a commercial app. But I will be happy if any one wants some more precisions on how I coded it.

Best regards.

Eric