summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-11-30 09:08:11 -0700
committerBrian <brian.paul@tungstengraphics.com>2007-11-30 09:09:12 -0700
commit43e902f774f8c3cd58310eeb44eec9d3f8f81746 (patch)
treefe49544338fe87671e21c42dc5b7a45a95bdce88
parentb0a800e249990de0cbc577f8b48a1a301a3b9361 (diff)
better front-plane clip test
-rw-r--r--progs/trivial/quad-clip-nearplane.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/progs/trivial/quad-clip-nearplane.c b/progs/trivial/quad-clip-nearplane.c
index 7e12e58a196..be9b9c619ae 100644
--- a/progs/trivial/quad-clip-nearplane.c
+++ b/progs/trivial/quad-clip-nearplane.c
@@ -33,6 +33,7 @@
GLenum doubleBuffer;
+float Z = -6;
static void Init(void)
{
@@ -40,30 +41,36 @@ static void Init(void)
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
- glClearColor(0.0, 0.0, 1.0, 0.0);
+ fprintf(stderr, "Press z/Z to translate quad\n");
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
}
static void Reshape(int width, int height)
{
-
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5, 100.0);
glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
-
switch (key) {
- case 27:
- exit(1);
- default:
- return;
+ case 'z':
+ Z += 0.5;
+ break;
+ case 'Z':
+ Z -= 0.5;
+ break;
+ case 27:
+ exit(1);
+ default:
+ return;
}
-
+ printf("Z = %f\n", Z);
glutPostRedisplay();
}
@@ -71,17 +78,22 @@ static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
+ glPushMatrix();
+ glTranslatef(0, -0.5, Z);
+
glBegin(GL_QUADS);
glColor3f(1,0,0);
- glVertex3f( 0.9, -0.9, 30.0);
+ glVertex3f( -0.8, 0, -4.0);
glColor3f(1,1,0);
- glVertex3f( 0.9, 0.9, 30.0);
+ glVertex3f( 0.8, 0, -4.0);
glColor3f(1,0,1);
- glVertex3f(-1.9, 0.9, 30.0);
+ glVertex3f( 0.8, 0, 4.0);
glColor3f(0,1,1);
- glVertex3f(-1.9, -0.9, -30.0);
+ glVertex3f( -0.8, 0, 4.0);
glEnd();
+ glPopMatrix();
+
glFlush();
if (doubleBuffer) {
@@ -118,7 +130,8 @@ int main(int argc, char **argv)
exit(1);
}
- glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize( 250, 250);
type = GLUT_RGB;
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
@@ -134,5 +147,5 @@ int main(int argc, char **argv)
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
- return 0;
+ return 0;
}