summaryrefslogtreecommitdiff
path: root/progs/trivial
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-12-03 11:43:19 -0700
committerBrian Paul <brianp@vmware.com>2009-12-03 11:43:19 -0700
commit52081f0a2c5d1d54d9e0f323c681b30d7186d8e4 (patch)
treedfdf8151a65670255a85d612298a5195bed85445 /progs/trivial
parent51663f0506ed2534e57b798cdfaf8a0d376eb7a2 (diff)
progs/trivial: readback and print Z value in tri-z-eq.c
Diffstat (limited to 'progs/trivial')
-rw-r--r--progs/trivial/tri-z-eq.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/progs/trivial/tri-z-eq.c b/progs/trivial/tri-z-eq.c
index b81c992f7d..195e8a26f6 100644
--- a/progs/trivial/tri-z-eq.c
+++ b/progs/trivial/tri-z-eq.c
@@ -69,6 +69,8 @@ static void Key(unsigned char key, int x, int y)
static void Draw(void)
{
+ float z = 1.0;
+
glClearColor(0.0, 0.0, 1.0, 0.0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -77,15 +79,21 @@ static void Draw(void)
glBegin(GL_TRIANGLES);
glColor3f(0,0,.7);
- glVertex3f( 0.9, -0.9, 1.0);
+ glVertex3f( 0.9, -0.9, z);
glColor3f(.8,0,0);
- glVertex3f( 0.9, 0.9, 1.0);
+ glVertex3f( 0.9, 0.9, z);
glColor3f(0,.9,0);
- glVertex3f(-0.9, 0.0, 1.0);
+ glVertex3f(-0.9, 0.0, z);
glEnd();
glFlush();
+ {
+ GLfloat z;
+ glReadPixels(125, 125, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
+ printf("Z at (125, 125) = %f\n", z);
+ }
+
if (doubleBuffer) {
glutSwapBuffers();
}