aboutsummaryrefslogtreecommitdiffstats
path: root/progs/trivial/clear-fbo-scissor.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-03-10 12:19:26 -0700
committerBrian Paul <[email protected]>2010-03-10 12:19:41 -0700
commit3c48f40f61d8122009175273b3c15e108927b146 (patch)
treec59756cb4c37613bd3f21731405badc2ea3ed0bd /progs/trivial/clear-fbo-scissor.c
parent48dca99feb394febc3af44e14f23fb12a9cc9204 (diff)
progs/trivial: add -t (RTT) option for clear-fbo-scissor.c
Diffstat (limited to 'progs/trivial/clear-fbo-scissor.c')
-rw-r--r--progs/trivial/clear-fbo-scissor.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/progs/trivial/clear-fbo-scissor.c b/progs/trivial/clear-fbo-scissor.c
index b0d9651772e..5ec0b57328b 100644
--- a/progs/trivial/clear-fbo-scissor.c
+++ b/progs/trivial/clear-fbo-scissor.c
@@ -15,6 +15,7 @@
static int Width = 512, Height = 512;
static GLuint MyFB, MyRB;
+static GLboolean UseTex = GL_FALSE;
#define CheckError() assert(glGetError() == 0)
@@ -38,12 +39,25 @@ Init(void)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB);
+ if (UseTex) {
+ GLuint tex;
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, tex, 0);
+ }
+ else {
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT, MyRB);
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_RENDERBUFFER_EXT, MyRB);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+ }
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
@@ -60,7 +74,9 @@ Reshape(int width, int height)
Width = width;
Height = height;
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+ if (!UseTex) {
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+ }
}
@@ -167,11 +183,23 @@ Draw(void)
int
main(int argc, char *argv[])
{
+ int i;
+
glutInit(&argc, argv);
glutInitWindowPosition(100, 0);
glutInitWindowSize(Width, Height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-t") == 0)
+ UseTex = GL_TRUE;
+ }
+
+ if (UseTex)
+ printf("Using render to texture\n");
+ else
+ printf("Using user-created render buffer\n");
+
if (!glutCreateWindow(argv[0])) {
exit(1);
}