Pārlūkot izejas kodu

LINK_IN_GLXGETPROCADDRESS

David Rose 20 gadi atpakaļ
vecāks
revīzija
92a5776b2c

+ 11 - 0
dtool/Config.pp

@@ -533,6 +533,17 @@
 #define GLX_LPATH
 #defer HAVE_GLX $[and $[HAVE_GL],$[UNIX_PLATFORM]]
 
+// glXGetProcAddress() is the function used to query OpenGL extensions
+// under X.  However, this function is itself an extension function,
+// leading to a chicken-and-egg problem.  One approach is to compile
+// in a hard reference to the function, another is to pull the
+// function address from the dynamic runtime.  Each has its share of
+// problems.  Panda's default behavior is to pull it from the dynamic
+// runtime; define this to compile in a reference to the function.
+// This is only relevant from platforms using OpenGL under X (for
+// instance, Linux).
+#define LINK_IN_GLXGETPROCADDRESS
+
 // Should we try to build the WGL interface?
 #defer HAVE_WGL $[and $[HAVE_GL],$[WINDOWS_PLATFORM]]
 

+ 3 - 0
panda/src/glxdisplay/Sources.pp

@@ -3,6 +3,9 @@
 #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
                    dtoolutil:c dtoolbase:c dtool:m
 #define USE_PACKAGES gl glx cg
+#if $[LINK_IN_GLXGETPROCADDRESS]
+  #define EXTRA_CDEFS LINK_IN_GLXGETPROCADDRESS
+#endif
 
 #begin lib_target
   #define TARGET glxdisplay

+ 5 - 3
panda/src/glxdisplay/glxGraphicsStateGuardian.cxx

@@ -234,13 +234,15 @@ get_extension_func(const char *prefix, const char *name) {
     // First, check if we have glXGetProcAddress available.  This will
     // be superior if we can get it.
     
-#if defined(HAVE_GLXGETPROCADDRESS)
+#if defined(LINK_IN_GLXGETPROCADDRESS) && defined(HAVE_GLXGETPROCADDRESS)
       // If we are confident the system headers defined it, we can
       // call it directly.  This is more reliable than trying to
-      // determine its address dynamically.
+      // determine its address dynamically, but it may make
+      // libpandagl.so fail to load if the symbol isn't in the runtime
+      // library.
     return (void *)glXGetProcAddress((const GLubyte *)fullname.c_str());
       
-#elif defined(HAVE_GLXGETPROCADDRESSARB)
+#elif defined(LINK_IN_GLXGETPROCADDRESS) && defined(HAVE_GLXGETPROCADDRESSARB)
     // The ARB extension version is OK too.  Sometimes the prototype
     // isn't supplied for some reason.
     return (void *)glXGetProcAddressARB((const GLubyte *)fullname.c_str());