Add an OpenGL extension query function which should be cross platform

This commit is contained in:
ehofman
2003-06-17 16:55:21 +00:00
parent f957227576
commit ba5316ca8e
2 changed files with 32 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ include_HEADERS = \
texture.hxx \
$(IMAGE_SERVER_INCL) \
screen-dump.hxx \
extensions.hxx \
tr.h
libsgscreen_a_SOURCES = \

View File

@@ -0,0 +1,31 @@
#ifndef __SG_EXTENSIONS_HXX
#define __SG_EXTENSIONS_HXX 1
#ifndef WIN32
#include <dlfcn.h>
#endif
inline void (*SGLookupFunction(const char *func))() {
#if defined( WIN32 )
return (void (*)()) wglGetProcAddress(func);
#else
// If the target system s UNIX and the ARB_get_proc_address
// GLX extension is *not* guaranteed to be supported. An alternative
// dlsym-based approach will be used instead.
#if defined( linux ) || defined ( sgi )
void *libHandle;
void (*fptr)();
libHandle = dlopen("libGL.so", RTLD_LAZY);
fptr = (void (*)()) dlsym(libHandle, func);
dlclose(libHandle);
return fptr;
#else
return glXGetProcAddressARB(func);
#endif
#endif
}
#endif