gallium: change remaining util functions to use cso sampler views
[mesa/mesa-lb.git] / progs / trivial / dlist-degenerate.c
blobc7f2d2a6e9e849abe6cdde31c033a642944a52d8
1 /**
2 * Test display list corner cases.
3 */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <math.h>
9 #include <GL/glut.h>
12 static int Win;
13 static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
14 static GLboolean Anim = GL_FALSE;
15 static GLuint List1 = 0, List2 = 0;
18 static void
19 Idle(void)
21 Xrot += 3.0;
22 Yrot += 4.0;
23 Zrot += 2.0;
24 glutPostRedisplay();
28 static void
29 Draw(void)
31 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
33 glPushMatrix();
34 glRotatef(Xrot, 1, 0, 0);
35 glRotatef(Yrot, 0, 1, 0);
36 glRotatef(Zrot, 0, 0, 1);
38 glCallList(List1);
39 glCallList(List2);
41 glPopMatrix();
43 glutSwapBuffers();
47 static void
48 Reshape(int width, int height)
50 glViewport(0, 0, width, height);
51 glMatrixMode(GL_PROJECTION);
52 glLoadIdentity();
53 glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
54 glMatrixMode(GL_MODELVIEW);
55 glLoadIdentity();
56 glTranslatef(0.0, 0.0, -15.0);
60 static void
61 Key(unsigned char key, int x, int y)
63 const GLfloat step = 3.0;
64 (void) x;
65 (void) y;
66 switch (key) {
67 case 'a':
68 Anim = !Anim;
69 if (Anim)
70 glutIdleFunc(Idle);
71 else
72 glutIdleFunc(NULL);
73 break;
74 case 'z':
75 Zrot -= step;
76 break;
77 case 'Z':
78 Zrot += step;
79 break;
80 case 27:
81 glutDestroyWindow(Win);
82 exit(0);
83 break;
85 glutPostRedisplay();
89 static void
90 SpecialKey(int key, int x, int y)
92 const GLfloat step = 3.0;
93 (void) x;
94 (void) y;
95 switch (key) {
96 case GLUT_KEY_UP:
97 Xrot -= step;
98 break;
99 case GLUT_KEY_DOWN:
100 Xrot += step;
101 break;
102 case GLUT_KEY_LEFT:
103 Yrot -= step;
104 break;
105 case GLUT_KEY_RIGHT:
106 Yrot += step;
107 break;
109 glutPostRedisplay();
113 static void
114 Init(void)
116 /* List1: start of primitive */
117 List1 = glGenLists(1);
118 glNewList(List1, GL_COMPILE);
119 glBegin(GL_POLYGON);
120 glVertex2f(-1, -1);
121 glVertex2f( 1, -1);
122 glEndList();
124 /* List2: end of primitive */
125 List2 = glGenLists(1);
126 glNewList(List2, GL_COMPILE);
127 glVertex2f( 1, 1);
128 glVertex2f(-1, 1);
129 glEnd();
130 glEndList();
132 glEnable(GL_DEPTH_TEST);
137 main(int argc, char *argv[])
139 glutInit(&argc, argv);
140 glutInitWindowPosition(0, 0);
141 glutInitWindowSize(400, 400);
142 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
143 Win = glutCreateWindow(argv[0]);
144 glutReshapeFunc(Reshape);
145 glutKeyboardFunc(Key);
146 glutSpecialFunc(SpecialKey);
147 glutDisplayFunc(Draw);
148 if (Anim)
149 glutIdleFunc(Idle);
150 Init();
151 glutMainLoop();
152 return 0;