Automatic OpenGL function pointer fetching ala GLEW

I finally got enough of GLEW not working the way it should and got a
small Perl script to start my own SDL specific.

This first state script produces a C source file from the SDL_opengl.h
header file so that all defined OpenGL functions are just ready to be used.
I’m at least going to change this so that the GL function pointers can
be prefetched instead of this versions on demand fetching.
This will make error detection much easier as there is no need to check
SDL_GetError() after every new GL function like now.

I would like to hear ideas how to improve this as an official part of SDL.


Save the attached Perl script to SDL include folder
run the script directing the output to SDL_GLE.c (any none existing file
name will do)
If the script doesn’t spit any errors then all went OK.

Now include the produced SDL_GLE.c to your product and define
GL_GLEXT_PROTOTYPES before you include SDL_opengl.h in your project.
Check SDL_GetError() after every time you have used a new GL function.

Here is an example of the code the script will produce for every OpenGL

// OpenGL Function 'glAlphaFragmentOp2ATI’
GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op,GLuint dst,GLuint
dstMod,GLuint arg1,GLuint arg1Rep,GLuint arg1Mod,GLuint arg2,GLuint
arg2Rep,GLuint arg2Mod) {
if(SDL_GLE_glAlphaFragmentOp2ATI == NULL) {
SDL_GLE_glAlphaFragmentOp2ATI =
if(SDL_GLE_glAlphaFragmentOp2ATI == NULL) {
SDL_SetError(“Error while retrieving OpenGL function ‘%s’”,
“glAlphaFragmentOp2ATI” );



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…

I would like to hear ideas how to improve this as an official part of SDL.

I’d rather not make it an official part of SDL, but you should
definitely put this on github/bitbucket/GoogleCode/etc, for those that
want it as an add-on.