summaryrefslogtreecommitdiffstats
path: root/progs/tests/fbotexture.c
diff options
context:
space:
mode:
Diffstat (limited to 'progs/tests/fbotexture.c')
-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);
}