X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=progs%2Ftrivial%2Fquad-clip-nearplane.c;h=9380e4f9ae1c44e6d7221add7d0a03660c9d0f2d;hb=8a23105fa016ec4368f407ca64e7763f110da4e5;hp=e76eb29f890b4729ec252e8706f87946738c2885;hpb=477e18cb026b287e8fd0cb415b81f777fe0db39e;p=mesa.git diff --git a/progs/trivial/quad-clip-nearplane.c b/progs/trivial/quad-clip-nearplane.c index e76eb29f890..9380e4f9ae1 100644 --- a/progs/trivial/quad-clip-nearplane.c +++ b/progs/trivial/quad-clip-nearplane.c @@ -33,37 +33,45 @@ GLenum doubleBuffer; +float Z = -6; static void Init(void) { fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + fflush(stderr); - 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 +79,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,13 +131,14 @@ int main(int argc, char **argv) exit(1); } - glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + glutInitWindowPosition(0, 0); + glutInitWindowSize( 250, 250); type = GLUT_RGB | GLUT_ALPHA; type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } @@ -134,5 +148,5 @@ int main(int argc, char **argv) glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); - return 0; + return 0; }