summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-09-05 13:07:43 -0600
committerBrian Paul <[email protected]>2008-09-11 10:39:27 -0600
commit83054d9297d12dbd7bd7c86a6bed6a5fc63debdc (patch)
tree92ed929d4014f5863393c12eb34be015a87c0dd6
parent8df4c3a21fe51280956e35d09ebacc9791b6a613 (diff)
press 'c' to toggle Z clear value between 0/1
-rw-r--r--progs/trivial/tri-z.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c
index c8296a97043..335d2b90e2b 100644
--- a/progs/trivial/tri-z.c
+++ b/progs/trivial/tri-z.c
@@ -56,6 +56,15 @@ static struct { GLenum func; const char *str; } funcs[] =
#define NUM_FUNCS (sizeof(funcs) / sizeof(funcs[0]))
static int curFunc = 0;
+static double clearVal = 1.0;
+
+
+static void usage(void)
+{
+ printf("t - toggle rendering order of triangles\n");
+ printf("c - toggle Z clear value between 0, 1\n");
+ printf("f - cycle through depth test functions\n");
+}
static void init(void)
@@ -88,11 +97,13 @@ static void drawRightTriangle(void)
void display(void)
{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- printf("GL_DEPTH_FUNC = %s\n", funcs[curFunc].str);
+ printf("GL_CLEAR_DEPTH = %f GL_DEPTH_FUNC = %s\n",
+ clearVal, funcs[curFunc].str);
+ glClearDepth(clearVal);
glDepthFunc(funcs[curFunc].func);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
if (leftFirst) {
drawLeftTriangle();
drawRightTriangle();
@@ -120,6 +131,11 @@ void reshape(int w, int h)
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
+ case 'c':
+ case 'C':
+ clearVal = 1.0 - clearVal;
+ glutPostRedisplay();
+ break;
case 'f':
case 'F':
curFunc = (curFunc + 1) % NUM_FUNCS;
@@ -148,10 +164,11 @@ int main(int argc, char** argv)
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (200, 200);
glutCreateWindow (argv[0]);
- init();
glutReshapeFunc (reshape);
glutKeyboardFunc (keyboard);
glutDisplayFunc (display);
+ init();
+ usage();
glutMainLoop();
return 0;
}