]> git.mxchange.org Git - simgear.git/blob - simgear/screen/extensions.hxx
Add an OpenGL extension query function which should be cross platform
[simgear.git] / simgear / screen / extensions.hxx
1 #ifndef __SG_EXTENSIONS_HXX
2 #define __SG_EXTENSIONS_HXX 1
3
4 #ifndef WIN32
5 #include <dlfcn.h>
6 #endif
7
8 inline void (*SGLookupFunction(const char *func))() {
9
10 #if defined( WIN32 )
11         return (void (*)()) wglGetProcAddress(func);
12
13 #else
14
15   // If the target system s UNIX and the ARB_get_proc_address
16   // GLX extension is *not* guaranteed to be supported. An alternative
17   // dlsym-based approach will be used instead.
18   #if defined( linux ) || defined ( sgi )
19         void *libHandle;
20         void (*fptr)();
21         libHandle = dlopen("libGL.so", RTLD_LAZY);
22         fptr = (void (*)()) dlsym(libHandle, func);
23         dlclose(libHandle);
24         return fptr;
25   #else
26         return glXGetProcAddressARB(func);
27   #endif
28 #endif
29 }
30
31 #endif