summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-09-05 12:59:40 -0600
committerBrian Paul <[email protected]>2008-09-11 10:39:27 -0600
commit8df4c3a21fe51280956e35d09ebacc9791b6a613 (patch)
treeec2040c131d6d0240da43a2a1b4d409dbcd02362
parenteb5b16d278e0f7ee0121049e43dfee1d52f2b0f7 (diff)
press 'f' to cycle through depth test funcs
-rw-r--r--progs/trivial/tri-z.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c
index ae25900a358..c8296a97043 100644
--- a/progs/trivial/tri-z.c
+++ b/progs/trivial/tri-z.c
@@ -37,9 +37,27 @@
#include <GL/glut.h>
#include <stdlib.h>
+#include <stdio.h>
static int leftFirst = GL_TRUE;
+static struct { GLenum func; const char *str; } funcs[] =
+ {
+ { GL_LESS, "GL_LESS" },
+ { GL_LEQUAL, "GL_LEQUAL" },
+ { GL_GREATER, "GL_GREATER" },
+ { GL_GEQUAL, "GL_GEQUAL" },
+ { GL_EQUAL, "GL_EQUAL" },
+ { GL_NOTEQUAL, "GL_NOTEQUAL" },
+ { GL_ALWAYS, "GL_ALWAYS" },
+ { GL_NEVER, "GL_NEVER" },
+ };
+
+#define NUM_FUNCS (sizeof(funcs) / sizeof(funcs[0]))
+
+static int curFunc = 0;
+
+
static void init(void)
{
glEnable(GL_DEPTH_TEST);
@@ -72,6 +90,9 @@ void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ printf("GL_DEPTH_FUNC = %s\n", funcs[curFunc].str);
+ glDepthFunc(funcs[curFunc].func);
+
if (leftFirst) {
drawLeftTriangle();
drawRightTriangle();
@@ -99,6 +120,11 @@ void reshape(int w, int h)
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
+ case 'f':
+ case 'F':
+ curFunc = (curFunc + 1) % NUM_FUNCS;
+ glutPostRedisplay();
+ break;
case 't':
case 'T':
leftFirst = !leftFirst;