Linux +SDL +loading extensions

Hi,
I’h going to switch from GLFW to SDL and I don’t know how to substitute glfwGetProcAddress.
Can anyone help me?

http://sdldoc.csn.ul.ie/sdlglgetprocaddress.php

Damn, you’re good

THX

Again me.
I used SDL_GL_GetProcAddress this way:
glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC) SDL_GL_GetProcAddress ( “glLockArraysEXT” );
and it doesn’t work.
Can anyone provide me with a good example of loading EXTs with SDL, or at least tell me how to do it?

In header file:
typedef void (APIENTRY * glBindBufferARB_Func) (GLenum target, GLuint buffer);
extern glBindBufferARB_Func glBindBufferARB_ptr;// Get function pointer

In cpp:
glBindBufferARB_Func glBindBufferARB_ptr;// Get function pointer

glBindBufferARB_ptr=0;// Zero function pointer 
glBindBufferARB_ptr = (glBindBufferARB_Func) SDL_GL_GetProcAddress("glBindBufferARB");
if (glBindBufferARB_ptr==0)
  sprintf(buffer,"glBindBufferARB is NOT BOUND 

");
else
sprintf(buffer,"glBindBufferARB is BOUND
");

Hope that helps…

O.K.
I did it your way, but IMHO it doesn’t differ from using PFNGGLGLOCKARRAYSEXT.
When I ran it I got SegFault at a call to glLockArraysEXT. At compile I receive sth like this:
/usr/bin/ld: Warning: type of symbol glLockArraysEXT' changed from 2 to 1 in main.o /usr/bin/ld: Warning: type of symbolglUnlockArraysEXT’ changed from 2 to 1 in main.o

I use gcc3.3 if that matters and the same code under GLFW works fine.

What about glXGetProcAddress and wglGetProcAddress ? It’s a bit annoying to embrace with #ifdef’s but it works for sure. But then you can define your own myGlGetProcAddress function which automatically loads the extension according to the right platform.

OK, seems reasonable, but which library do I have to link in order to compile? Now with -lGL -lGLU and stuff I receive undefined reference to `glXGetProcAddress’. I use Nvidia drivers 43.63
.

I can get it with sdl-config --libs as well as the obvious -lGL

I use the same nvidia drivers, except that I’ve copied the new GL binaries to /usr/X11R6/lib

No,
the answer is a bit more complex. You see: glx.h defines a function called glXGetProcAddress(…). But libGL.so implements function called glXGetProcAddressARB(…). So including glx.h and linking libGL.so (the one provided by NVidia) resoults in undefined reference. It is solved by hand-editing the glx.h.

I use the headers from nvidia (and replace the ones in /usr/include/GL) and link to the libs from nvidia and it works fine because I call glXGetProcAddressARB and not glXGetProcAddress in fact. Originally, GLX_ARB_get_proc_address is an extension (the second ARB extension to be more precise) and so forth it’s understandable to add the “ARB” suffix to that function, imho.

Originally posted by LordOfTheUniverse:
Hi,
I’h going to switch from GLFW to SDL and I don’t know how to substitute glfwGetProcAddress.
Can anyone help me?

Why don’t you use extgl or glew?
http://glew.sf.net
http://www.levp.de/3d/

Both work with SDL, and support both Linux and Windows.

Originally posted by nrg:
Both work with SDL, and support both Linux and Windows.

GLEW works on IRIX, too, and we’ll gladly take patches to support more platforms. The only question is if glXGetProcAddress is available or not. If it is, it’s straighforward. If it isn’t, you just need to modify a Makefile. For very exotic platforms, you might need to patch the dlopen code, too.

Why would you need glXGetProcAddress if you use dlopen ?

Originally posted by vincoof:
Why would you need glXGetProcAddress if you use dlopen ?

Because nothing actually guarantees that the symbols are exported or even available with their public names in libGL (or more correctly estated, in the libraries that get mapped when the program links against libGL).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.