Mesa (gallium-cylindrical-wrap): progs/tests: add x/y rotation to cylwrap.c

Brian Paul brianp at kemper.freedesktop.org
Fri Feb 5 17:24:05 UTC 2010


Module: Mesa
Branch: gallium-cylindrical-wrap
Commit: 2b02cc702eb3e0086d2c4f101a1c8b3aa9d0024c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b02cc702eb3e0086d2c4f101a1c8b3aa9d0024c

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Feb  5 10:21:15 2010 -0700

progs/tests: add x/y rotation to cylwrap.c

---

 progs/tests/cylwrap.c |   59 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/progs/tests/cylwrap.c b/progs/tests/cylwrap.c
index 9d541e3..95d4644 100644
--- a/progs/tests/cylwrap.c
+++ b/progs/tests/cylwrap.c
@@ -10,6 +10,7 @@
 
 static int Win;
 static int WinWidth = 600, WinHeight = 400;
+static GLfloat Xrot = 0, Yrot = 0;
 static GLboolean CylWrap = GL_TRUE;
 
 
@@ -83,20 +84,26 @@ Draw(void)
    glClear(GL_COLOR_BUFFER_BIT);
 
    glPushMatrix();
-      glTranslatef(0, +1.2, 0);
-      DrawSample(GL_FALSE);
-   glPopMatrix();
+      glRotatef(Xrot, 1, 0, 0);
+      glRotatef(Yrot, 0, 1, 0);
 
-   /* set Mesa back-door state for testing cylindrical wrap mode */
-   if (CylWrap)
-      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0.125);
+      glPushMatrix();
+         glTranslatef(0, +1.2, 0);
+         DrawSample(GL_FALSE);
+      glPopMatrix();
 
-   glPushMatrix();
-      glTranslatef(0, -1.2, 0);
-      DrawSample(GL_TRUE);
-   glPopMatrix();
+      /* set Mesa back-door state for testing cylindrical wrap mode */
+      if (CylWrap)
+         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0.125);
+
+      glPushMatrix();
+         glTranslatef(0, -1.2, 0);
+         DrawSample(GL_TRUE);
+      glPopMatrix();
+
+      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0);
 
-   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0);
+   glPopMatrix();
 
    glutSwapBuffers();
 }
@@ -110,17 +117,16 @@ Reshape(int width, int height)
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
-   glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+   glFrustum(-1.0, 1.0, -1.0, 1.0, 3.0, 25.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
-   glTranslatef(0.0, 0.0, -15.0);
+   glTranslatef(0.0, 0.0, -10.0);
 }
 
 
 static void
 Key(unsigned char key, int x, int y)
 {
-   const GLfloat step = 3.0;
    (void) x;
    (void) y;
    switch (key) {
@@ -142,6 +148,30 @@ Key(unsigned char key, int x, int y)
 
 
 static void
+SpecialKey(int key, int x, int y)
+{
+   const GLfloat step = 3.0;
+   (void) x;
+   (void) y;
+   switch (key) {
+   case GLUT_KEY_UP:
+      Xrot -= step;
+      break;
+   case GLUT_KEY_DOWN:
+      Xrot += step;
+      break;
+   case GLUT_KEY_LEFT:
+      Yrot -= step;
+      break;
+   case GLUT_KEY_RIGHT:
+      Yrot += step;
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
 MakeSineWaveTexture(void)
 {
    GLubyte tex[128][512][4];
@@ -196,6 +226,7 @@ main(int argc, char *argv[])
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    Win = glutCreateWindow(argv[0]);
    glutReshapeFunc(Reshape);
+   glutSpecialFunc(SpecialKey);
    glutKeyboardFunc(Key);
    glutDisplayFunc(Draw);
    Init();




More information about the mesa-commit mailing list