SteinSOFT.net
  SDL & OpenGL extensions

As graphics hardware is getting better and better these days, OpenGL had to be invented with a mechanism that allows to add new functionality - which might be optional - but doesn't change the whole API. That's the extension mechanism. Anyway every operating system has an other way to handle libraries so you would have to program your own code for every system in order to get the OpenGL function addresses. But SDL saves us all...

As SDL is fully platform-independent and also supports OpenGL, it features a very nice function that combines both worlds. That's SDL_GL_GetProcAddress(..):

#include "SDL.h"

void *SDL_GL_GetProcAddress(const char* proc);

It can be used like wglGetProcProcess(..) under Windows and exactly behaves like it expect that it is fully platform-indepent. It returns the address of the OpenGL function - if found - and if not it returns NULL. First check whether the extension is available than get the function addresses:

#include "SDL.h"
#include <GL/glext.h>

/** little extension test **/
bool multiTexturing = false;

if (strstr(glGetString(GL_EXTENSIONS),"ARB_multitexture"))
{
   multiTexturing = true;    
}

/** get the function address(es) **/
if (multiTexturing)
{
   pglMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) 
      SDL_GL_GetProcAddress("glMultiTexCoord2fARB");
}

Don't forget to check glext.h from the code section. The code snippet about OpenGL extensions might be interesting for you as well. Happy Coding!

Copyright © by SteinSOFT