gallium: change remaining util functions to use cso sampler views
[mesa/mesa-lb.git] / progs / trivial / dlist-recursive-call.c
blob90224f63cb223068039a010b42c302fbd1d8436f
1 /*
2 * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that (i) the above copyright notices and this permission notice appear in
7 * all copies of the software and related documentation, and (ii) the name of
8 * Silicon Graphics may not be used in any advertising or
9 * publicity relating to the software without the specific, prior written
10 * permission of Silicon Graphics.
12 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
13 * ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <GL/glut.h>
31 #define CI_OFFSET_1 16
32 #define CI_OFFSET_2 32
35 GLenum doubleBuffer;
36 GLint first_list, list;
38 static void Init(void)
40 fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
41 fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
42 fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
43 fflush(stderr);
45 glClearColor(0.0, 0.0, 1.0, 0.0);
47 /* First list will disrupt state which might potentially be
48 * short-circuited in calling list:
50 first_list = glGenLists(1);
51 glNewList(first_list, GL_COMPILE);
52 glShadeModel( GL_SMOOTH );
53 glEndList();
56 /* List that looks like it might have redundant state:
58 list = glGenLists(1);
59 glNewList(list, GL_COMPILE);
61 glBegin(GL_TRIANGLES);
62 glColor3f(0,0,.7);
63 glVertex3f( 0.9, -0.9, -30.0);
64 glColor3f(.8,0,0);
65 glVertex3f( 0.9, 0.9, -30.0);
66 glColor3f(0,.9,0);
67 glVertex3f(-0.9, 0.0, -30.0);
68 glEnd();
70 glShadeModel( GL_FLAT );
71 glBegin(GL_TRIANGLES);
72 glColor3f(0,0,.7);
73 glVertex3f( -0.9, 0.9, -30.0);
74 glColor3f(0,.9,0);
75 glVertex3f( -0.9, -0.9, -30.0);
76 glColor3f(.8,0,0);
77 glVertex3f( 0.9, 0.0, -30.0);
78 glEnd();
80 glCallList( first_list );
82 /* Do a quick begin/end to ensure we are not inside a dangling
83 * primitive from the called list:
85 glBegin( GL_POINTS );
86 glEnd();
88 /* This statechange is NOT redundant:
90 glShadeModel( GL_FLAT );
91 glBegin(GL_TRIANGLES);
92 glColor3f(1,0,0);
93 glVertex3f( -0.5, 0.5, -30.0);
94 glColor3f(0,1,0);
95 glVertex3f( -0.5, -0.5, -30.0);
96 glColor3f(0,0,1);
97 glVertex3f( 0.5, 0.0, -30.0);
98 glEnd();
100 glEndList();
103 static void Reshape(int width, int height)
106 glViewport(0, 0, (GLint)width, (GLint)height);
108 glMatrixMode(GL_PROJECTION);
109 glLoadIdentity();
110 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
111 glMatrixMode(GL_MODELVIEW);
114 static void Key(unsigned char key, int x, int y)
117 switch (key) {
118 case 27:
119 exit(1);
120 default:
121 break;
124 glutPostRedisplay();
130 static void Draw(void)
132 glClear(GL_COLOR_BUFFER_BIT);
134 glShadeModel( GL_SMOOTH );
135 glCallList(list);
137 glFlush();
139 if (doubleBuffer) {
140 glutSwapBuffers();
144 static GLenum Args(int argc, char **argv)
146 GLint i;
148 doubleBuffer = GL_FALSE;
150 for (i = 1; i < argc; i++) {
151 if (strcmp(argv[i], "-sb") == 0) {
152 doubleBuffer = GL_FALSE;
153 } else if (strcmp(argv[i], "-db") == 0) {
154 doubleBuffer = GL_TRUE;
155 } else {
156 fprintf(stderr, "%s (Bad option).\n", argv[i]);
157 return GL_FALSE;
160 return GL_TRUE;
163 int main(int argc, char **argv)
165 GLenum type;
167 glutInit(&argc, argv);
169 if (Args(argc, argv) == GL_FALSE) {
170 exit(1);
173 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
175 type = GLUT_RGB | GLUT_ALPHA;
176 type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
177 glutInitDisplayMode(type);
179 if (glutCreateWindow(*argv) == GL_FALSE) {
180 exit(1);
183 Init();
185 glutReshapeFunc(Reshape);
186 glutKeyboardFunc(Key);
187 glutDisplayFunc(Draw);
188 glutMainLoop();
189 return 0;