#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)
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();
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;
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;
}