Browse Source

fc5 issues

David Rose 19 years ago
parent
commit
05ff700750

+ 7 - 3
dtool/Config.pp

@@ -475,19 +475,23 @@
 
 
 // Is OpenGL installed, and where?  This should include libGL as well
 // Is OpenGL installed, and where?  This should include libGL as well
 // as libGLU, if they are in different places.
 // as libGLU, if they are in different places.
-#defer GL_IPATH
+#defer GL_IPATH /usr/include
 #defer GL_LPATH
 #defer GL_LPATH
 #defer GL_LIBS
 #defer GL_LIBS
 #if $[WINDOWS_PLATFORM]
 #if $[WINDOWS_PLATFORM]
-  #define GL_LIBS opengl32.lib glu32.lib
+  #define GL_LIBS opengl32.lib $[if $[HAVE_GLU],glu32.lib]
 #elif $[OSX_PLATFORM]
 #elif $[OSX_PLATFORM]
   #defer GL_FRAMEWORK OpenGL
   #defer GL_FRAMEWORK OpenGL
 #else
 #else
   #defer GL_LPATH /usr/X11R6/lib
   #defer GL_LPATH /usr/X11R6/lib
-  #defer GL_LIBS GL GLU
+  #defer GL_LIBS GL $[if $[HAVE_GLU],GLU]
 #endif
 #endif
 #defer HAVE_GL $[libtest $[GL_LPATH],$[GL_LIBS]]
 #defer HAVE_GL $[libtest $[GL_LPATH],$[GL_LIBS]]
 
 
+// GLU is an auxiliary library that is usually provided with OpenGL,
+// but is sometimes missing (e.g. the default FC5 installation).
+#defer HAVE_GLU $[HAVE_GL]
+
 // Is Mesa installed separately from OpenGL?  Mesa is an open-source
 // Is Mesa installed separately from OpenGL?  Mesa is an open-source
 // software-only OpenGL renderer.  Panda can link with it
 // software-only OpenGL renderer.  Panda can link with it
 // independently from OpenGL (and if Mesa is built statically, and/or
 // independently from OpenGL (and if Mesa is built statically, and/or

+ 1 - 0
dtool/LocalSetup.pp

@@ -205,6 +205,7 @@ $[cdefine HAVE_ZLIB]
 
 
 /* Define if we have OpenGL installed and want to build for GL.  */
 /* Define if we have OpenGL installed and want to build for GL.  */
 $[cdefine HAVE_GL]
 $[cdefine HAVE_GL]
+$[cdefine HAVE_GLU]
 
 
 /* Define if we have OpenCV installed and want to build for OpenCV.  */
 /* Define if we have OpenCV installed and want to build for OpenCV.  */
 $[cdefine HAVE_OPENCV]
 $[cdefine HAVE_OPENCV]

+ 1 - 0
dtool/Package.pp

@@ -182,6 +182,7 @@
 #set GL_LPATH $[unixfilename $[GL_LPATH]]
 #set GL_LPATH $[unixfilename $[GL_LPATH]]
 #set GL_LIBS $[GL_LIBS]
 #set GL_LIBS $[GL_LIBS]
 #set HAVE_GL $[HAVE_GL]
 #set HAVE_GL $[HAVE_GL]
+#set HAVE_GLU $[HAVE_GLU]
 
 
 #set MESA_IPATH $[unixfilename $[MESA_IPATH]]
 #set MESA_IPATH $[unixfilename $[MESA_IPATH]]
 #set MESA_LPATH $[unixfilename $[MESA_LPATH]]
 #set MESA_LPATH $[unixfilename $[MESA_LPATH]]

+ 1 - 0
dtool/src/dtoolbase/mutexPosixImpl.h

@@ -26,6 +26,7 @@
 
 
 #include <pthread.h>
 #include <pthread.h>
 #include <errno.h>
 #include <errno.h>
+#include <assert.h>
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : MutexPosixImpl
 //       Class : MutexPosixImpl

+ 2 - 0
panda/src/glgsg/glgsg.h

@@ -49,7 +49,9 @@
 #include <OpenGL/glu.h>
 #include <OpenGL/glu.h>
 #else
 #else
 #include <GL/gl.h>
 #include <GL/gl.h>
+#ifdef HAVE_GLU
 #include <GL/glu.h>
 #include <GL/glu.h>
+#endif
 #endif 
 #endif 
 
 
 #include "glstuff_src.h"
 #include "glstuff_src.h"

+ 33 - 42
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -2320,15 +2320,9 @@ extract_texture_data(Texture *tex) {
   // Make sure we were able to query those parameters properly.
   // Make sure we were able to query those parameters properly.
   GLenum error_code = GLP(GetError)();
   GLenum error_code = GLP(GetError)();
   if (error_code != GL_NO_ERROR) {
   if (error_code != GL_NO_ERROR) {
-    const GLubyte *error_string = GLUP(ErrorString)(error_code);
     GLCAT.error()
     GLCAT.error()
-      << "Unable to query texture parameters for " << tex->get_name();
-    if (error_string != (const GLubyte *)NULL) {
-      GLCAT.error(false)
-        << " : " << error_string;
-    }
-    GLCAT.error(false)
-      << "\n";
+      << "Unable to query texture parameters for " << tex->get_name()
+      << " : " << get_error_string(error_code) << "\n";
 
 
     return false;
     return false;
   }
   }
@@ -4021,16 +4015,10 @@ report_errors_loop(int line, const char *source_file, GLenum error_code,
 
 
   while ((error_count < max_gl_errors_reported) &&
   while ((error_count < max_gl_errors_reported) &&
          (error_code != GL_NO_ERROR)) {
          (error_code != GL_NO_ERROR)) {
-    const GLubyte *error_string = GLUP(ErrorString)(error_code);
-    if (error_string != (const GLubyte *)NULL) {
-      GLCAT.error()
-        << "at " << line << " of " << source_file << ": "
-        << error_string << "\n";
-    } else {
-      GLCAT.error()
-        << "at " << line << " of " << source_file << ": "
-        << "GL error " << (int)error_code << "\n";
-    }
+    GLCAT.error()
+      << "at " << line << " of " << source_file << " : "
+      << get_error_string(error_code) << "\n";
+
     error_code = GLP(GetError)();
     error_code = GLP(GetError)();
     error_count++;
     error_count++;
   }
   }
@@ -4039,6 +4027,27 @@ report_errors_loop(int line, const char *source_file, GLenum error_code,
   return (error_code == GL_NO_ERROR);
   return (error_code == GL_NO_ERROR);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GLGraphicsStateGuardian::get_error_string
+//       Access: Protected, Static
+//  Description: Returns gluGetErrorString(), if GLU is available;
+//               otherwise, returns some default error message.
+////////////////////////////////////////////////////////////////////
+string CLP(GraphicsStateGuardian)::
+get_error_string(GLenum error_code) {
+#ifdef HAVE_GLU
+  const GLubyte *error_string = GLUP(ErrorString)(error_code);
+  if (error_string != (const GLubyte *)NULL) {
+    return string((const char *)error_string);
+  }
+#endif  // HAVE_GLU
+
+  ostringstream strm;
+  strm << "GL error " << (int)error_code;
+
+  return strm.str();
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::show_gl_string
 //     Function: GLGraphicsStateGuardian::show_gl_string
 //       Access: Protected
 //       Access: Protected
@@ -6855,15 +6864,9 @@ upload_texture_image(CLP(TextureContext) *gtc,
   // failed.
   // failed.
   GLenum error_code = GLP(GetError)();
   GLenum error_code = GLP(GetError)();
   if (error_code != GL_NO_ERROR) {
   if (error_code != GL_NO_ERROR) {
-    const GLubyte *error_string = GLUP(ErrorString)(error_code);
     GLCAT.error()
     GLCAT.error()
-      << "GL texture creation failed for " << tex->get_name();
-    if (error_string != (const GLubyte *)NULL) {
-      GLCAT.error(false)
-        << " : " << error_string;
-    }
-    GLCAT.error(false)
-      << "\n";
+      << "GL texture creation failed for " << tex->get_name()
+      << " : " << get_error_string(error_code) << "\n";
 
 
     return false;
     return false;
   }
   }
@@ -6907,15 +6910,9 @@ get_texture_memory_size(Texture *tex) {
     GLenum error_code = GLP(GetError)();
     GLenum error_code = GLP(GetError)();
     if (error_code != GL_NO_ERROR) {
     if (error_code != GL_NO_ERROR) {
       if (GLCAT.is_debug()) {
       if (GLCAT.is_debug()) {
-	const GLubyte *error_string = GLUP(ErrorString)(error_code);
 	GLCAT.debug()
 	GLCAT.debug()
-	  << "Couldn't get compressed size for " << tex->get_name();
-	if (error_string != (const GLubyte *)NULL) {
-	  GLCAT.debug(false)
-	    << " : " << error_string;
-	}
-	GLCAT.debug(false)
-	  << "\n";
+	  << "Couldn't get compressed size for " << tex->get_name()
+	  << " : " << get_error_string(error_code) << "\n";
       }
       }
       // Fall through to the noncompressed case.
       // Fall through to the noncompressed case.
     } else {
     } else {
@@ -7074,16 +7071,10 @@ extract_texture_image(PTA_uchar &image, size_t &page_size,
   // Now see if we were successful.
   // Now see if we were successful.
   GLenum error_code = GLP(GetError)();
   GLenum error_code = GLP(GetError)();
   if (error_code != GL_NO_ERROR) {
   if (error_code != GL_NO_ERROR) {
-    const GLubyte *error_string = GLUP(ErrorString)(error_code);
     GLCAT.error()
     GLCAT.error()
       << "Unable to extract texture for " << *tex
       << "Unable to extract texture for " << *tex
-      << ", mipmap level " << n << ": ";
-    if (error_string != (const GLubyte *)NULL) {
-      GLCAT.error(false)
-        << " : " << error_string;
-    }
-    GLCAT.error(false)
-      << "\n";
+      << ", mipmap level " << n
+      << " : " << get_error_string(error_code) << "\n";
 
 
     return false;
     return false;
   }
   }

+ 1 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -209,6 +209,7 @@ protected:
 
 
   static bool report_errors_loop(int line, const char *source_file, 
   static bool report_errors_loop(int line, const char *source_file, 
                                  GLenum error_code, int &error_count);
                                  GLenum error_code, int &error_count);
+  static string get_error_string(GLenum error_code);
   string show_gl_string(const string &name, GLenum id);
   string show_gl_string(const string &name, GLenum id);
   virtual void query_gl_version();
   virtual void query_gl_version();
   void save_extensions(const char *extensions);
   void save_extensions(const char *extensions);