[Patch] make dds textures work with Linux/ATI

Report bugs, bug fixes and workarounds here.
Topic author
woho

[Patch] make dds textures work with Linux/ATI

Post #1by woho » 28.09.2003, 10:49

Chris,

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

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #2by chris » 29.09.2003, 16:05

Wolfgang,

Thank you for this patch . . . I'll add it to the Celestia source, but I'd like to understand better what's going on with glXGetProcAddressARB. Do you have any idea why it is returning 0?

--Chris

Topic author
woho

Post #3by woho » 29.09.2003, 22:58

No, sorry, I don't have any clue.

ATI's libGL.so is binary only, so I don't know how to look into that deeper.

If you have any idea on what to try or look at, I'm very willing to do that, just let me know.

Personally, I think it's a bug in ATI's libGL.so of the 3.2.5 driver. I think I'll file a report to ATI. Nevertheless, I'm happy that you include my workaround to Celestia.

Wolfgang

driver999dev

I didn't need this patch

Post #4by driver999dev » 08.10.2003, 10:57

Well, I have
- XFree 4.3.0
- a Radeon 9600 Pro
- the 3.2.5 drivers

...and I didn't need this patch to use DDS textures.

Well at least I now know that I am not alone in doing Linux-ATI-celestia.

I have a different problem: The moon/mars is bump-mapped just fine,
however the specular shader that produces specular highlights on the earth's oceans is not working under Linux.
It's just fine under Windows, so it's probably the linux-driver's bug.
I 've filled a report on the ATI site for this.
Anyone else seen it happen?


Return to “Bugs”