{steinsoft.net}
 
 
 
 
 
Home/News
Code Snippets
Board
Projects
What's That?
I am using it actively
I planning to use/learn it
I don't plan to lean/use it
5th option
Leipzig
Home :: Programming :: Code Snippets :: SDL :: SDL & OpenGL extensions

[ 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!

 Last edited 2003-07-28 14:51:19 by André Stein - printable version
» copyright by andré stein
» using stCM v1.0
» steinsoft.net revision 5.0