please review the following patch and apply it to celestia 1.3.1, if it's ok.
It fixes the crash I reported last week when using Walton's virtual 32k .dds earth texture on my Radeon 9600 on Linux with ATI's driver and libGL.so.
Problem was that glXGetProcAddressARB("glCompressedTexImage2DARB") gives 0. In that case, the patch introduces a second try by using the dynamic loader to lookup glCompressedTexImage2DARB.
Using the dynamic loader is described in an (old) paper by Paul Brian:
http://www.mesa3d.org/brianp/sig97/exten.htm, Section 4.1.2. Since Celestia is linked against libGL.so anyway, I just dlopen(0).
Thanks,
Wolfgang
P.S.: is anyone using Celestia on Linux with an ATI card? Am I the only one seeing this crash? Just wondering ...
Code: Select all
woho@kristall:~/work/lvr/build/celestia-1.3.1 > diff -Naur src/celengine/glext.cpp_orig src/celengine/glext.cpp
--- src/celengine/glext.cpp_orig 2002-12-13 19:43:41.000000000 +0100
+++ src/celengine/glext.cpp 2003-09-28 11:28:16.000000000 +0200
@@ -221,11 +221,25 @@
extern "C" {
extern void (*glXGetProcAddressARB(const GLubyte *procName))();
}
-#define GET_GL_PROC_ADDRESS(name) glXGetProcAddressARB((GLubyte*) name)
+#define GET_GL_PROC_ADDRESS(name) myGetProcAddressARB((GLubyte*) name)
#else
-#define GET_GL_PROC_ADDRESS(name) glXGetProcAddressARB((GLubyte*) name)
+#define GET_GL_PROC_ADDRESS(name) myGetProcAddressARB((GLubyte*) name)
#endif
+#include <dlfcn.h>
+typedef void (*FUNCS) (void);
+extern "C" FUNCS myGetProcAddressARB(const GLubyte *procName)
+ {
+ FUNCS myPtr = glXGetProcAddressARB(procName);
+ if (myPtr == 0)
+ {
+ void *libGL = dlopen(0, RTLD_LAZY);
+ myPtr = (FUNCS)dlsym(libGL, (const char *)procName);
+ dlclose(libGL);
+ }
+ return myPtr;
+ }
+
#endif // defined(WIN32)
#endif /* !MACOSX */
#ifdef MACOSX