First, you need to check for the extensions. Use a function like this:
SDL_bool HasExtension (char *ext)
{
const char *p;
const char *last;
int len;
int i;
p = glGetString (GL_EXTENSIONS);
if (!p)
return SDL_FALSE;
len = strlen (ext);
last = p + strlen (p);
while (p < last)
{
i = strcspn (p, " ");
if (len == i && strncmp(ext, p, i) == 0)
return SDL_TRUE;
p += (i + 1);
}
return SDL_FALSE;
}
DO NOT FALL INTO THE TEMPTATION TO USE strstr () OR strtok ()!!! Use of
strstr () is pretty much guaranteed to break the first time someone
decides to name an extension GL_FOO_something and another
GL_FOO_something_else, so don’t do that! Also, you should never modify
the string returned by glGetString (), which strtok () does for you quite
handily (and illegally in this case…)
You’ll need to declare a function pointer for each function you wish to
use, and it should not be named the same as the function in the file, but
should be similar. Use the qgl namespace, all of the Quake’s did so it’s
quite permanently taken for this purpose. Here are a few examples:
extern void (APIENTRY * qglActiveTextureARB) (GLenum);
extern void (APIENTRY * qglLockArraysEXT) (GLint, GLsizei);
extern void (APIENTRY * qglUnlockArraysEXT) (void);
Note, that should be extern “C” for C++ code… To assign the function
pointers, do this:
if (HasExtension ("GL_ARB_multitexture"))
{
use_mtex = SDL_TRUE;
if (! (qglActiveTextureARB =
SDL_GL_GetProcAddress ("glActiveTextureARB")))
use_mtex = SDL_FALSE;
}
if (HasExtension ("GL_EXT_compiled_vertex_array"))
{
use_cva = SDL_TRUE;
if (! (qglLockArraysEXT =
SDL_GL_GetProcAddress ("glLockArraysEXT")))
use_cva = SDL_FALSE;
if (! (qglUnlockArraysEXT =
SDL_GL_GetProcAddress ("glUnlockArraysEXT")))
use_cva = SDL_FALSE;
}
Obviously I’m missing a few functions you’d need for GL_ARB_multitexture
above, but you get the idea.
Note, this is generally a lot of hard work - and I’ve done most of it
already. If you’re interested, send me an email off-list and I’ll send
you my DynGL generation 3 code. It makes all OpenGL loading completely
dynamic. You don’t even need a GL/gl.h when you compile (and in fact, if
you use DynGL I recommend that you don’t include one…) The code needs a
few more minor tweaks before I put it online, but those are mostly in the
documentation.On Thu, May 16, 2002 at 09:26:07PM +0200, Eike Umlauf wrote:
since windows still is shipped with openGL 1.1 i have to get some
commands like glActiveTextureARB via SDL_GetProcAddress() which works
fine. however i need some constants to work with those commands, like
GL_TEXTURE0_ARB etc. how do i get those, i surely can’t pull them out of
the dll too?
–
Joseph Carter The guy with a rocket launcher
im fcucking druk
- Knghtbrd makes sure to log everything Crow- says tonight …
heheh
He said he’d marry me! damnit!!
dude no way
MrBump - he’s not THAT drunk
Knghtbrd: I’m crushed :o)
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020516/97c2198e/attachment.pgp