From 92a5776b2cbba4428a1c523d8a552419392a1857 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 29 Mar 2006 22:08:06 +0000 Subject: [PATCH] LINK_IN_GLXGETPROCADDRESS --- dtool/Config.pp | 11 +++++++++++ panda/src/glxdisplay/Sources.pp | 3 +++ panda/src/glxdisplay/glxGraphicsStateGuardian.cxx | 8 +++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dtool/Config.pp b/dtool/Config.pp index 0842282674..1dbd17cddb 100644 --- a/dtool/Config.pp +++ b/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]] diff --git a/panda/src/glxdisplay/Sources.pp b/panda/src/glxdisplay/Sources.pp index a31263f7ed..fcc65a4bdc 100644 --- a/panda/src/glxdisplay/Sources.pp +++ b/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 diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 856ca5752e..d9efa71aa3 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/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());