diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-12-04 10:48:05 -0700 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-12-04 14:07:08 -0700 |
commit | df198d24bcb48c7f51ba9d814d97496d998b5db9 (patch) | |
tree | 8f98f6ff86da65d213742f8fef6ce2e8d4aa4872 /progs/tests | |
parent | fc7ddea8535f1a9c196bf30f7864414e4ac18b8a (diff) |
added culling/wireframe options
Diffstat (limited to 'progs/tests')
-rw-r--r-- | progs/tests/fbotexture.c | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/progs/tests/fbotexture.c b/progs/tests/fbotexture.c index aa9f617122..88d0549c80 100644 --- a/progs/tests/fbotexture.c +++ b/progs/tests/fbotexture.c @@ -38,6 +38,8 @@ static GLfloat Rot = 0.0; static GLboolean UsePackedDepthStencil = GL_FALSE; static GLuint TextureLevel = 1; /* 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; static void @@ -115,6 +117,22 @@ RenderTexture(void) CheckError(__LINE__); + if (Wireframe) { + glPolygonMode(GL_FRONT, GL_LINE); + } + else { + glPolygonMode(GL_FRONT, GL_FILL); + } + + if (Cull) { + /* cull back */ + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + } + else { + glDisable(GL_CULL_FACE); + } + #if 0 glBegin(GL_POLYGON); glColor3f(1, 0, 0); @@ -129,7 +147,9 @@ RenderTexture(void) glEnable(GL_LIGHT0); glPushMatrix(); glRotatef(0.5 * Rot, 1.0, 0.0, 0.0); + glFrontFace(GL_CW); /* Teapot patches backward */ glutSolidTeapot(0.5); + glFrontFace(GL_CCW); glPopMatrix(); glDisable(GL_LIGHTING); /* @@ -139,6 +159,8 @@ RenderTexture(void) glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); + glDisable(GL_CULL_FACE); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); #if DRAW /* Bind normal framebuffer */ @@ -245,25 +267,46 @@ Key(unsigned char key, int x, int y) (void) x; (void) y; switch (key) { - case 'a': - Anim = !Anim; - if (Anim) - glutIdleFunc(Idle); - else - glutIdleFunc(NULL); - break; - case 's': - Rot += 2.0; - break; - case 27: - CleanUp(); - break; + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 'c': + Cull = !Cull; + break; + case 'w': + Wireframe = !Wireframe; + break; + case 's': + Rot += 2.0; + break; + case 'S': + Rot -= 2.0; + break; + case 27: + CleanUp(); + break; } glutPostRedisplay(); } static void +Usage(void) +{ + printf("Usage:\n"); + printf(" a Toggle animation\n"); + printf(" s/s Step/rotate\n"); + printf(" c Toggle back-face culling\n"); + printf(" w Toggle wireframe mode (front-face only)\n"); + printf(" Esc Exit\n"); +} + + +static void Init(int argc, char *argv[]) { static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 }; @@ -402,6 +445,7 @@ main(int argc, char *argv[]) if (Anim) glutIdleFunc(Idle); Init(argc, argv); + Usage(); glutMainLoop(); return 0; } |