PDA

View Full Version : Linux +SDL +loading extensions



LordOfTheUniverse
06-20-2003, 12:16 PM
Hi,
I'h going to switch from GLFW to SDL and I don't know how to substitute glfwGetProcAddress.
Can anyone help me?

jra101
06-20-2003, 01:17 PM
http://sdldoc.csn.ul.ie/sdlglgetprocaddress.php

LordOfTheUniverse
06-20-2003, 10:04 PM
Damn, you're good

THX

LordOfTheUniverse
06-22-2003, 01:49 AM
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?

azcoder
06-22-2003, 04:37 AM
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 \n");
else
sprintf(buffer,"glBindBufferARB is BOUND \n");


Hope that helps....

LordOfTheUniverse
07-02-2003, 08:48 PM
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 symbol `glUnlockArraysEXT' changed from 2 to 1 in main.o

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

vincoof
07-07-2003, 12:19 AM
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.

LordOfTheUniverse
07-07-2003, 02:29 AM
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
.

vincoof
07-07-2003, 03:49 AM
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

LordOfTheUniverse
07-09-2003, 10:07 AM
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.

vincoof
07-09-2003, 11:40 PM
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.

nrg
07-10-2003, 04:02 AM
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.

m2
07-11-2003, 10:04 AM
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.

vincoof
07-11-2003, 01:39 PM
Why would you need glXGetProcAddress if you use dlopen ?

m2
07-12-2003, 05:32 AM
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).