Revert "wglgears: show stereo-option in usage"
[mesa-demos.git] / src / trivial / long-fixed-func.c
bloba1667f9ffe11620cd41ed36a29bc5429143b17a8
1 /**
2 * Enable as much fixed-function vertex processing state as possible
3 * to test fixed-function -> program code generation.
4 */
8 #include <GL/glew.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <stdlib.h>
12 #include "glut_wrap.h"
15 static void
16 Reshape(int width, int height)
18 glViewport(0, 0, (GLint)width, (GLint)height);
19 glMatrixMode(GL_PROJECTION);
20 glLoadIdentity();
21 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
22 glMatrixMode(GL_MODELVIEW);
26 static void
27 Draw(void)
29 glClear(GL_COLOR_BUFFER_BIT);
31 glBegin(GL_TRIANGLES);
32 glColor3f(.8,0,0);
33 glVertex3f(-0.9, -0.9, -30.0);
34 glColor3f(0,.9,0);
35 glVertex3f( 0.9, -0.9, -30.0);
36 glColor3f(0,0,.7);
37 glVertex3f( 0.0, 0.9, -30.0);
38 glEnd();
40 glFlush();
42 glutSwapBuffers();
46 static void
47 Init(void)
49 GLubyte tex[16][16][4];
50 GLfloat pos[4] = {5, 10, 3, 1.0};
51 int i, j;
53 fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
54 fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
55 fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
56 fflush(stderr);
58 glClearColor(0.3, 0.1, 0.3, 0.0);
60 for (i = 0; i < 16; i++) {
61 for (j = 0; j < 16; j++) {
62 if ((i+j) & 1) {
63 tex[i][j][0] = 100;
64 tex[i][j][1] = 100;
65 tex[i][j][2] = 100;
66 tex[i][j][3] = 255;
68 else {
69 tex[i][j][0] = 200;
70 tex[i][j][1] = 200;
71 tex[i][j][2] = 200;
72 tex[i][j][3] = 255;
78 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
79 glFogi(GL_FOG_MODE, GL_LINEAR);
80 glEnable(GL_FOG);
82 glPointParameterfv(GL_DISTANCE_ATTENUATION_EXT, pos);
84 for (i = 0; i < 8; i++) {
85 GLuint texObj;
87 glEnable(GL_LIGHT0 + i);
88 glLightf(GL_LIGHT0 + i, GL_SPOT_EXPONENT, 3.5);
89 glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, 30.);
90 glLightf(GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 3.);
91 glLightf(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 3.);
92 glLightf(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 3.);
93 glLightfv(GL_LIGHT0 + i, GL_POSITION, pos);
95 glActiveTexture(GL_TEXTURE0 + i);
96 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
97 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
98 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
99 glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
100 glEnable(GL_TEXTURE_GEN_S);
101 glEnable(GL_TEXTURE_GEN_T);
102 glEnable(GL_TEXTURE_GEN_R);
103 glEnable(GL_TEXTURE_GEN_Q);
104 glEnable(GL_TEXTURE_2D);
106 glMatrixMode(GL_TEXTURE);
107 glScalef(2.0, 1.0, 3.0);
109 glGenTextures(1, &texObj);
110 glBindTexture(GL_TEXTURE_2D, texObj);
111 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0,
112 GL_RGBA, GL_UNSIGNED_BYTE, tex);
113 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
114 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
115 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
118 glEnable(GL_LIGHTING);
119 glActiveTexture(GL_TEXTURE0);
120 glMatrixMode(GL_MODELVIEW);
124 static void
125 Key(unsigned char key, int x, int y)
127 if (key == 27) {
128 exit(0);
130 glutPostRedisplay();
135 main(int argc, char **argv)
137 GLenum type = GLUT_RGB | GLUT_DOUBLE;
139 glutInit(&argc, argv);
140 glutInitWindowPosition(0, 0);
141 glutInitWindowSize( 250, 250);
142 glutInitDisplayMode(type);
143 if (glutCreateWindow(*argv) == GL_FALSE) {
144 exit(1);
146 glewInit();
147 glutReshapeFunc(Reshape);
148 glutKeyboardFunc(Key);
149 glutDisplayFunc(Draw);
150 Init();
151 glutMainLoop();
152 return 0;