From ba5316ca8e8e2799a05ab3510c68cdc623896861 Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 17 Jun 2003 16:55:21 +0000 Subject: [PATCH] Add an OpenGL extension query function which should be cross platform --- simgear/screen/Makefile.am | 1 + simgear/screen/extensions.hxx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 simgear/screen/extensions.hxx diff --git a/simgear/screen/Makefile.am b/simgear/screen/Makefile.am index c5c05dcc..86a547c5 100644 --- a/simgear/screen/Makefile.am +++ b/simgear/screen/Makefile.am @@ -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 index 00000000..949345a8 --- /dev/null +++ b/simgear/screen/extensions.hxx @@ -0,0 +1,31 @@ +#ifndef __SG_EXTENSIONS_HXX +#define __SG_EXTENSIONS_HXX 1 + +#ifndef WIN32 +#include +#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 -- 2.39.5