Преглед изворни кода

make report_errors available to wgldisplay

cxgeorge пре 24 година
родитељ
комит
c25fcddc69

+ 6 - 3
panda/src/glgsg/glGraphicsStateGuardian.I

@@ -1203,14 +1203,17 @@ issue_scene_graph_color() {
 
 ////////////////////////////////////////////////////////////////////
 //     Function: GLGraphicsStateGuardian::report_errors
-//       Access: Protected
+//       Access: Public
 //  Description: Checks for any outstanding error codes and outputs
 //               them, if found.  If NDEBUG is defined, this function
 //               does nothing.
 ////////////////////////////////////////////////////////////////////
-INLINE void GLGraphicsStateGuardian::
-report_errors() const {
+INLINE void 
+report_errors() {
+    // pulling this out of gsg since I'd like to call it when there's no gsg ptr around
 #ifndef NDEBUG
+  extern void report_errors_loop(GLenum error_code);
+
   GLenum error_code = glGetError();
   if (error_code != GL_NO_ERROR) {
     report_errors_loop(error_code);

+ 11 - 7
panda/src/glgsg/glGraphicsStateGuardian.cxx

@@ -1768,7 +1768,9 @@ release_texture(TextureContext *tc) {
   GLTextureContext *gtc = DCAST(GLTextureContext, tc);
   Texture *tex = tc->_texture;
 
-  glDeleteTextures(1, &gtc->_index);
+  HGLRC curcxt=wglGetCurrentContext();
+  if(curcxt!=NULL)
+      glDeleteTextures(1, &gtc->_index);
   gtc->_index = 0;
 
   bool erased = unmark_prepared_texture(gtc);
@@ -3536,19 +3538,21 @@ compute_distance_to(const LPoint3f &point) const {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: GLGraphicsStateGuardian::report_errors_loop
+//     Function: report_errors_loop
 //       Access: Protected
 //  Description: The internal implementation of report_errors().
 //               Don't call this function; use report_errors()
 //               instead.
 ////////////////////////////////////////////////////////////////////
-void GLGraphicsStateGuardian::
-report_errors_loop(GLenum error_code) const {
+
+void report_errors_loop(GLenum error_code) {
 #ifndef NDEBUG
-  while (error_code != GL_NO_ERROR) {
-    glgsg_cat.error()
-      << gluErrorString(error_code) << "\n";
+#define MAXGLERRORSREPORTED 20
+  int cnt=0;
+  while ((cnt<MAXGLERRORSREPORTED) && (error_code != GL_NO_ERROR)) {
+    glgsg_cat.error() << gluErrorString(error_code) << "\n";
     error_code = glGetError();
+    cnt++;
   }
 #endif
 }

+ 0 - 3
panda/src/glgsg/glGraphicsStateGuardian.h

@@ -244,9 +244,6 @@ protected:
 
   INLINE void issue_scene_graph_color();
 
-  INLINE void report_errors() const;
-  void report_errors_loop(GLenum error_code) const;
-
   void set_draw_buffer(const RenderBuffer &rb);
   void set_read_buffer(const RenderBuffer &rb);