OpenGL extensions

Hi everyone,

I seem to have problems getting the OGL extensions in SDL (both 1.2.8 and
the CVS version). I use the function SDL_GL_GetProcAddress for all
functions, and it works just fine for things like glBegin, etc but when I
want to get extension functions like glActiveTextureARB or glTexImage3DEXT,
the only thing I get is a NULL pointer. I loaded the OGL library with
SDL_GL_LoadLibrary(NULL). I’m sure my card supports both these extensions,
so does anyone know what I’m doing wrong here?

Thanks
Bram_________________________________________________________________
Talk with your online friends with MSN Messenger http://messenger.msn.nl/

Not answer to your question, but try http://glew.sf.net to handle the
extensions for you…

– Pasi

                               ^
                            .     .
                             Linux
                          /    -    \
                         Choice.of.the
                       .Next.Generation.On Tue, Feb 01, 2005 at 01:27:08PM +0100, Bram Thijssen wrote:

Hi everyone,

I seem to have problems getting the OGL extensions in SDL (both 1.2.8 and
the CVS version). I use the function SDL_GL_GetProcAddress for all
functions, and it works just fine for things like glBegin, etc but when I
want to get extension functions like glActiveTextureARB or glTexImage3DEXT,
the only thing I get is a NULL pointer. I loaded the OGL library with
SDL_GL_LoadLibrary(NULL). I’m sure my card supports both these extensions,
so does anyone know what I’m doing wrong here?

Bram Thijssen wrote:

Hi everyone,

I seem to have problems getting the OGL extensions in SDL (both 1.2.8
and the CVS version). I use the function SDL_GL_GetProcAddress for all
functions, and it works just fine for things like glBegin, etc but
when I want to get extension functions like glActiveTextureARB or
glTexImage3DEXT, the only thing I get is a NULL pointer. I loaded the
OGL library with SDL_GL_LoadLibrary(NULL).

So, there are two ways to work with OpenGL/SDL :

  • use dynamic library loading (with SDL_GL_LoadLibrary) and then
    retrieve function pointers for all OpenGL functions like shown in the
    testdyngl.c sample code
  • don’t use dynamic library loading and retrieve function pointers only
    for the extensions.
    But you can’t mix the two.

Stephane

Stephane Marchesin <stephane.marchesin wanadoo.fr> writes:

Bram Thijssen wrote:

Hi everyone,

I seem to have problems getting the OGL extensions in SDL (both 1.2.8
and the CVS version). I use the function SDL_GL_GetProcAddress for all
functions, and it works just fine for things like glBegin, etc but
when I want to get extension functions like glActiveTextureARB or
glTexImage3DEXT, the only thing I get is a NULL pointer. I loaded the
OGL library with SDL_GL_LoadLibrary(NULL).

So, there are two ways to work with OpenGL/SDL :

  • use dynamic library loading (with SDL_GL_LoadLibrary) and then
    retrieve function pointers for all OpenGL functions like shown in the
    testdyngl.c sample code
  • don’t use dynamic library loading and retrieve function pointers only
    for the extensions.
    But you can’t mix the two.

Stephane

I did in fact get all OpenGL functions using SDL_GL_GetProcAddress. I didn’t
notice the testdyngl.c sample code, so I tried loading extensions with that.
That did work properly, so then I still wonder what I’m doing wrong in my own
code, since it looks very similar to me:

SDL_GL_LoadLibrary(NULL);
struct OpenGLFunctions
{
void (APIENTRYenable)(GLenum cap);
//…
void (APIENTRY
activeTextureARB)(GLenum);
};
OpenGLFunctions OGL;

std::map<char *, void **> functions;
functions[“glEnable”] = (void **)&OGL.enable;
//…
functions[“glActiveTextureARB”] = (void **)&OGL.activeTextureARB;

for (std::map<char *, void **>::iterator fi=functions.begin(); fi!=functions.end
(); fi++)
{
*fi->second = SDL_GL_GetProcAddress(fi->first);
if (!*fi->second)
{
printf(fi->first);
return false;
}
}

Like I said, the glBegin etc work fine with this method, but not the extension
functions.

Bram wrote:

I did in fact get all OpenGL functions using SDL_GL_GetProcAddress. I didn’t
notice the testdyngl.c sample code, so I tried loading extensions with that.
That did work properly, so then I still wonder what I’m doing wrong in my own
code, since it looks very similar to me:

SDL_GL_LoadLibrary(NULL);
struct OpenGLFunctions
{
void (APIENTRYenable)(GLenum cap);
//…
void (APIENTRY
activeTextureARB)(GLenum);
};
OpenGLFunctions OGL;

std::map<char *, void **> functions;
functions[“glEnable”] = (void **)&OGL.enable;
//…
functions[“glActiveTextureARB”] = (void **)&OGL.activeTextureARB;

for (std::map<char *, void **>::iterator fi=functions.begin(); fi!=functions.end
(); fi++)
{
*fi->second = SDL_GL_GetProcAddress(fi->first);
if (!*fi->second)
{
printf(fi->first);
return false;
}
}

Like I said, the glBegin etc work fine with this method, but not the extension
functions.

Nvidia/gentoo user ?
This problem was already reported in such a setup, and I know of no
solution if that’s your case.

Stephane

Stephane Marchesin <stephane.marchesin wanadoo.fr> writes:

Nvidia/gentoo user ?
This problem was already reported in such a setup, and I know of no
solution if that’s your case.

Stephane

Hmm no, I’m on Windows XP with an ATI Mobility Radeon…

just tossing this out there but maybe your card doesnt support the
extensions you’re trying to use?> ----- Original Message -----

From: bramt@hotmail.com (Bram Thijssen)
To:
Sent: Tuesday, February 01, 2005 10:13 AM
Subject: [SDL] Re: OpenGL extensions

Stephane Marchesin <stephane.marchesin wanadoo.fr> writes:

Nvidia/gentoo user ?
This problem was already reported in such a setup, and I know of no
solution if that’s your case.

Stephane

Hmm no, I’m on Windows XP with an ATI Mobility Radeon…


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Alan Wolfe <atrix2 cox.net> writes:

just tossing this out there but maybe your card doesnt support the
extensions you’re trying to use?

Ah I’ve found the problem - I moved the calls to SDL_GL_GetProcAddress to after
SDL_SetVideoMode, then also the extension functions work. I assumed it had to
be done before, since SDL_GL_LoadLibrary() has to be before as well.
So is that indeed the case, that it has to be after the SDL_SetVideoMode call
or is there some kind of other problem?
Thanks for the help :slight_smile:

Bram wrote:

Alan Wolfe <atrix2 cox.net> writes:

just tossing this out there but maybe your card doesnt support the
extensions you’re trying to use?

Ah I’ve found the problem - I moved the calls to SDL_GL_GetProcAddress to after
SDL_SetVideoMode, then also the extension functions work. I assumed it had to
be done before, since SDL_GL_LoadLibrary() has to be before as well.
So is that indeed the case, that it has to be after the SDL_SetVideoMode call
or is there some kind of other problem?

That’s the case. SDL_GL_GetProcAddress can be used only when an OpenGL
context exists.
The OpenGL context is created bu SDL_SetVideoMode(…SDL_OPENGL…).

Stephane