PDA

View Full Version : GL Extensions under Linux / Solaris



Nutty
04-10-2001, 11:40 AM
Hello.

Right, extensions under win32 are done with a few basic steps.

1. Declare function style.
2. Declare function pointers.
3. Get function address with wglGetProcAddress.

How are extensions gotten under Linux and Solaris. Obviously I can't use wglGetProcAddress. What is the quivelent under the other OS's, and what header file are they in?

I looked at nehe's linux port of multi-texturing, but could not find anything about getting extension addresses in it. Are certain extensions automatically supported in Linux, i.e. what current version of OpenGL is it running.

Basically I'm trying to make my demos platform independant. To do that I need to know how to get extension information under different OS's.

Thanks.

Nutty

lobsterclaw
04-10-2001, 11:54 AM
hey there

this is just a little snippet of code that will give u some ideas how its done... do a 'man dlopen' for more specifics on the dlopen function

#include <dlfcn.h>


void *dlHandle;
int (*fnPtr)();

// open the shared library...

if ((dlHandle = dlopen("/usr/lib/libtest.so", RTLD_LAZY | RTLD_GLOBAL)==NULL)){
perror("ERROR:");
printf("Could not open shared object file\n");
exit(1);
}

// set the function pointer

fnPtr = dlsym(dlHandle, "myFunc");

rts
04-10-2001, 12:00 PM
glXGetProcAddressARB

works pretty much exactly like wglGetProcAddress.



[This message has been edited by rts (edited 04-10-2001).]

Nutty
04-10-2001, 12:15 PM
Can't do a 'man dlopen' cos I aint got Linux/Solaris.

What header file is glXGetProcAddressARB in rts?

Can you give me the function definition of it as well, as I dont have access to any linux docs/headers.

Cheers,

Nutty

rts
04-10-2001, 12:28 PM
/usr/include/GL/glx.h

extern void (*glXGetProcAddressARB(const GLubyte *procName))( void );

More info available here: http://oss.sgi.com/projects/ogl-sample/ABI/#3

Scroll down to section 3.6

Hope this helps.

rts
04-10-2001, 12:33 PM
The following is an excerpt from TuxRacer (http://www.tuxracer.com), from gl_util.c:




PFNGLLOCKARRAYSEXTPROC glLockArraysEXT_p;
PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT_p;

typedef void (*(*get_gl_proc_fptr_t)(const GLubyte *))();

void init_opengl_extensions()
{
get_gl_proc_fptr_t get_gl_proc;
#ifdef WIN32
get_gl_proc = (get_gl_proc_fptr_t) wglGetProcAddress;
#else
get_gl_proc = (get_gl_proc_fptr_t) glXGetProcAddressARB;
#endif

if ( glutExtensionSupported( "GL_EXT_compiled_vertex_array" ) ) {
print_debug( DEBUG_GL_EXT, "GL_EXT_compiled_vertex_array extension "
"supported" );
glLockArraysEXT_p = (PFNGLLOCKARRAYSEXTPROC)
get_gl_proc( (GLubyte*) "glLockArraysEXT" );
glUnlockArraysEXT_p = (PFNGLUNLOCKARRAYSEXTPROC)
get_gl_proc( (GLubyte*) "glUnlockArraysEXT" );
} else {
print_debug( DEBUG_GL_EXT, "GL_EXT_compiled_vertex_array extension "
"NOT supported" );
glLockArraysEXT_p = NULL;
glUnlockArraysEXT_p = NULL;
}

if ( glutExtensionSupported( "GL_ARB_texture_cube_map" ) ) {
print_debug( DEBUG_GL_EXT, "GL_ARB_texture_cube_map extension "
"supported" );
} else {
print_debug( DEBUG_GL_EXT, "GL_ARB_texture_cube_map extension "
"NOT supported" );
}
}


Hope that helps.

(The preceeding code is Copyright (C) 1999-2000 Jasmin F. Patry and is under the GPL)

Nutty
04-10-2001, 11:40 PM
Nice one!

Nutty