summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-02-27 15:46:40 -0700
committerBrian Paul <[email protected]>2009-02-27 15:57:46 -0700
commit07f96a6d8e7f0352423540235f50da91dea4c637 (patch)
tree52c9eac84450386a0a95548638b750bcefe8f830 /progs
parentc6bde8873fbda6d8467600b7491d8543c75b0509 (diff)
demos: fix renderbuffer leak in progs/tests/fbotexture.c
And re-org some code for testing purposes.
Diffstat (limited to 'progs')
-rw-r--r--progs/tests/fbotexture.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/progs/tests/fbotexture.c b/progs/tests/fbotexture.c
index 1f7c45fc794..ae993576b02 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);
}