]> git.mxchange.org Git - simgear.git/commitdiff
Add an OpenGL extension query function which should be cross platform
authorehofman <ehofman>
Tue, 17 Jun 2003 16:55:21 +0000 (16:55 +0000)
committerehofman <ehofman>
Tue, 17 Jun 2003 16:55:21 +0000 (16:55 +0000)
simgear/screen/Makefile.am
simgear/screen/extensions.hxx [new file with mode: 0644]

index c5c05dcc24331f94188d1c6c934127cfe1359c1a..86a547c59c90d99e9a583a29202c0f76da6d3dd7 100644 (file)
@@ -19,6 +19,7 @@ include_HEADERS = \
        texture.hxx \
        $(IMAGE_SERVER_INCL) \
        screen-dump.hxx \
+       extensions.hxx \
        tr.h
 
 libsgscreen_a_SOURCES = \
diff --git a/simgear/screen/extensions.hxx b/simgear/screen/extensions.hxx
new file mode 100644 (file)
index 0000000..949345a
--- /dev/null
@@ -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