Mesa (master): demos: fix renderbuffer leak in progs/tests/fbotexture.c

Brian Paul brianp at kemper.freedesktop.org
Fri Feb 27 22:59:20 UTC 2009


Module: Mesa
Branch: master
Commit: 07f96a6d8e7f0352423540235f50da91dea4c637
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=07f96a6d8e7f0352423540235f50da91dea4c637

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Feb 27 15:46:40 2009 -0700

demos: fix renderbuffer leak in progs/tests/fbotexture.c

And re-org some code for testing purposes.

---

 progs/tests/fbotexture.c |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/progs/tests/fbotexture.c b/progs/tests/fbotexture.c
index 1f7c45f..ae99357 100644
--- a/progs/tests/fbotexture.c
+++ b/progs/tests/fbotexture.c
@@ -26,9 +26,16 @@
 static int Win = 0;
 static int Width = 400, Height = 400;
 
-static GLenum TexTarget = GL_TEXTURE_2D; /*GL_TEXTURE_RECTANGLE_ARB;*/
+#if 1
+static GLenum TexTarget = GL_TEXTURE_2D;
 static int TexWidth = 512, TexHeight = 512;
-/*static int TexWidth = 600, TexHeight = 600;*/
+static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */
+#else
+static GLenum TexTarget = GL_TEXTURE_RECTANGLE_ARB;
+static int TexWidth = 200, TexHeight = 200;
+static GLenum TexIntFormat = GL_RGB5; /* either GL_RGB or GL_RGBA */
+#endif
+static GLuint TextureLevel = 0;  /* which texture level to render to */
 
 static GLuint MyFB;
 static GLuint TexObj;
@@ -38,8 +45,6 @@ static GLfloat Rot = 0.0;
 static GLboolean UsePackedDepthStencil = GL_FALSE;
 static GLboolean UsePackedDepthStencilBoth = GL_FALSE;
 static GLboolean Use_ARB_fbo = GL_FALSE;
-static GLuint TextureLevel = 0;  /* which texture level to render to */
-static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */
 static GLboolean Cull = GL_FALSE;
 static GLboolean Wireframe = GL_FALSE;
 
@@ -404,8 +409,12 @@ AttachDepthAndStencilBuffers(GLuint fbo,
          return GL_FALSE;
 
       status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-      if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
+      if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+         glDeleteRenderbuffersEXT(1, depthRbOut);
+         *depthRbOut = 0;
+         glDeleteRenderbuffersEXT(1, &rb);
          return GL_FALSE;
+      }
 
       *stencilRbOut = rb;
    }
@@ -554,15 +563,17 @@ Init(void)
       /* make two image levels */
       glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0,
                    GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-      glTexImage2D(TexTarget, 1, TexIntFormat, TexWidth/2, TexHeight/2, 0,
-                   GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-      TexWidth = TexWidth >> TextureLevel;
-      TexHeight = TexHeight >> TextureLevel;
+      if (TexTarget == GL_TEXTURE_2D) {
+         glTexImage2D(TexTarget, 1, TexIntFormat, TexWidth/2, TexHeight/2, 0,
+                      GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+         TexWidth = TexWidth >> TextureLevel;
+         TexHeight = TexHeight >> TextureLevel;
+         glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel);
+      }
 
       glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
       glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, TextureLevel);
-      glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel);
       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    }
 




More information about the mesa-commit mailing list