2 * Enable as much fixed-function vertex processing state as possible
3 * to test fixed-function -> program code generation.
8 #define GL_GLEXT_PROTOTYPES
16 Reshape(int width
, int height
)
18 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
19 glMatrixMode(GL_PROJECTION
);
21 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
22 glMatrixMode(GL_MODELVIEW
);
29 glClear(GL_COLOR_BUFFER_BIT
);
31 glBegin(GL_TRIANGLES
);
33 glVertex3f(-0.9, -0.9, -30.0);
35 glVertex3f( 0.9, -0.9, -30.0);
37 glVertex3f( 0.0, 0.9, -30.0);
49 GLubyte tex
[16][16][4];
50 GLfloat pos
[4] = {5, 10, 3, 1.0};
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
));
57 glClearColor(0.3, 0.1, 0.3, 0.0);
59 for (i
= 0; i
< 16; i
++) {
60 for (j
= 0; j
< 16; j
++) {
77 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE
, 1);
78 glFogi(GL_FOG_MODE
, GL_LINEAR
);
81 glPointParameterfv(GL_DISTANCE_ATTENUATION_EXT
, pos
);
83 for (i
= 0; i
< 8; i
++) {
86 glEnable(GL_LIGHT0
+ i
);
87 glLightf(GL_LIGHT0
+ i
, GL_SPOT_EXPONENT
, 3.5);
88 glLightf(GL_LIGHT0
+ i
, GL_SPOT_CUTOFF
, 30.);
89 glLightf(GL_LIGHT0
+ i
, GL_CONSTANT_ATTENUATION
, 3.);
90 glLightf(GL_LIGHT0
+ i
, GL_LINEAR_ATTENUATION
, 3.);
91 glLightf(GL_LIGHT0
+ i
, GL_QUADRATIC_ATTENUATION
, 3.);
92 glLightfv(GL_LIGHT0
+ i
, GL_POSITION
, pos
);
94 glActiveTexture(GL_TEXTURE0
+ i
);
95 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
96 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
97 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
98 glTexGeni(GL_Q
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
99 glEnable(GL_TEXTURE_GEN_S
);
100 glEnable(GL_TEXTURE_GEN_T
);
101 glEnable(GL_TEXTURE_GEN_R
);
102 glEnable(GL_TEXTURE_GEN_Q
);
103 glEnable(GL_TEXTURE_2D
);
105 glMatrixMode(GL_TEXTURE
);
106 glScalef(2.0, 1.0, 3.0);
108 glGenTextures(1, &texObj
);
109 glBindTexture(GL_TEXTURE_2D
, texObj
);
110 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 16, 16, 0,
111 GL_RGBA
, GL_UNSIGNED_BYTE
, tex
);
112 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
113 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
114 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
117 glEnable(GL_LIGHTING
);
118 glActiveTexture(GL_TEXTURE0
);
119 glMatrixMode(GL_MODELVIEW
);
124 Key(unsigned char key
, int x
, int y
)
134 main(int argc
, char **argv
)
136 GLenum type
= GLUT_RGB
| GLUT_DOUBLE
;
138 glutInit(&argc
, argv
);
139 glutInitWindowPosition(0, 0);
140 glutInitWindowSize( 250, 250);
141 glutInitDisplayMode(type
);
142 if (glutCreateWindow("tri-long-fixedfunc") == GL_FALSE
) {
145 glutReshapeFunc(Reshape
);
146 glutKeyboardFunc(Key
);
147 glutDisplayFunc(Draw
);