Commit 44c8dac0 authored by Brian's avatar Brian

better front-plane clip test

parent a11b6f02
......@@ -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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment