1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include <stdio.h>
|
---|
8 | #include "state.h"
|
---|
9 | #include "state/cr_statetypes.h"
|
---|
10 | #include "state_internals.h"
|
---|
11 |
|
---|
12 | static void __enableSet (CRContext *g, CRStateBits *sb, CRbitvalue *neg_bitid,
|
---|
13 | GLenum cap, GLboolean val)
|
---|
14 | {
|
---|
15 | unsigned int i;
|
---|
16 | i = cap - GL_CLIP_PLANE0;
|
---|
17 | if (i < g->limits.maxClipPlanes) {
|
---|
18 | g->transform.clip[i] = val;
|
---|
19 | DIRTY(sb->transform.enable, neg_bitid);
|
---|
20 | DIRTY(sb->transform.dirty, neg_bitid);
|
---|
21 | return;
|
---|
22 | }
|
---|
23 | i = cap - GL_LIGHT0;
|
---|
24 | if (i < g->limits.maxLights) {
|
---|
25 | g->lighting.light[i].enable = val;
|
---|
26 | DIRTY(sb->lighting.light[i].dirty, neg_bitid);
|
---|
27 | DIRTY(sb->lighting.light[i].enable, neg_bitid);
|
---|
28 | DIRTY(sb->lighting.dirty, neg_bitid);
|
---|
29 | return;
|
---|
30 | }
|
---|
31 |
|
---|
32 | switch (cap) {
|
---|
33 | case GL_AUTO_NORMAL:
|
---|
34 | g->eval.autoNormal = val;
|
---|
35 | DIRTY(sb->eval.enable, neg_bitid);
|
---|
36 | DIRTY(sb->eval.dirty, neg_bitid);
|
---|
37 | break;
|
---|
38 | case GL_ALPHA_TEST:
|
---|
39 | g->buffer.alphaTest = val;
|
---|
40 | DIRTY(sb->buffer.enable, neg_bitid);
|
---|
41 | DIRTY(sb->buffer.dirty, neg_bitid);
|
---|
42 | break;
|
---|
43 | case GL_BLEND:
|
---|
44 | g->buffer.blend = val;
|
---|
45 | DIRTY(sb->buffer.enable, neg_bitid);
|
---|
46 | DIRTY(sb->buffer.dirty, neg_bitid);
|
---|
47 | break;
|
---|
48 | case GL_COLOR_MATERIAL :
|
---|
49 | if (!val)
|
---|
50 | {
|
---|
51 | /* We're TURNING OFF color material. In this case,
|
---|
52 | * we should make sure that the very very latest
|
---|
53 | * color that was specified gets copied into the
|
---|
54 | * material parameters, since this might be our
|
---|
55 | * last chance (see frame 1 of progs/kirchner
|
---|
56 | * for an example of why). */
|
---|
57 |
|
---|
58 | crStateCurrentRecover( );
|
---|
59 | crStateColorMaterialRecover( );
|
---|
60 | }
|
---|
61 | g->lighting.colorMaterial = val;
|
---|
62 | DIRTY(sb->lighting.enable, neg_bitid);
|
---|
63 | DIRTY(sb->lighting.dirty, neg_bitid);
|
---|
64 | break;
|
---|
65 | #ifdef CR_EXT_secondary_color
|
---|
66 | case GL_COLOR_SUM_EXT :
|
---|
67 | if (g->extensions.EXT_secondary_color) { /* XXX does EXT_separate_specular color support this enable, too? */
|
---|
68 | g->lighting.colorSumEXT = val;
|
---|
69 | DIRTY(sb->lighting.enable, neg_bitid);
|
---|
70 | DIRTY(sb->lighting.dirty, neg_bitid);
|
---|
71 | }
|
---|
72 | else {
|
---|
73 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(GL_COLOR_SUM_EXT) - No support for secondary color!");
|
---|
74 | return;
|
---|
75 | }
|
---|
76 | break;
|
---|
77 | #endif
|
---|
78 | case GL_CULL_FACE :
|
---|
79 | g->polygon.cullFace = val;
|
---|
80 | DIRTY(sb->polygon.enable, neg_bitid);
|
---|
81 | DIRTY(sb->polygon.dirty, neg_bitid);
|
---|
82 | break;
|
---|
83 | case GL_DEPTH_TEST :
|
---|
84 | g->buffer.depthTest = val;
|
---|
85 | DIRTY(sb->buffer.enable, neg_bitid);
|
---|
86 | DIRTY(sb->buffer.dirty, neg_bitid);
|
---|
87 | break;
|
---|
88 | case GL_DITHER :
|
---|
89 | g->buffer.dither = val;
|
---|
90 | DIRTY(sb->buffer.enable, neg_bitid);
|
---|
91 | DIRTY(sb->buffer.dirty, neg_bitid);
|
---|
92 | break;
|
---|
93 | case GL_FOG :
|
---|
94 | g->fog.enable = val;
|
---|
95 | DIRTY(sb->fog.enable, neg_bitid);
|
---|
96 | DIRTY(sb->fog.dirty, neg_bitid);
|
---|
97 | break;
|
---|
98 | case GL_LIGHTING :
|
---|
99 | g->lighting.lighting = val;
|
---|
100 | DIRTY(sb->lighting.enable, neg_bitid);
|
---|
101 | DIRTY(sb->lighting.dirty, neg_bitid);
|
---|
102 | break;
|
---|
103 | case GL_LINE_SMOOTH :
|
---|
104 | g->line.lineSmooth = val;
|
---|
105 | DIRTY(sb->line.enable, neg_bitid);
|
---|
106 | DIRTY(sb->line.dirty, neg_bitid);
|
---|
107 | break;
|
---|
108 | case GL_LINE_STIPPLE :
|
---|
109 | g->line.lineStipple = val;
|
---|
110 | DIRTY(sb->line.enable, neg_bitid);
|
---|
111 | DIRTY(sb->line.dirty, neg_bitid);
|
---|
112 | break;
|
---|
113 | case GL_COLOR_LOGIC_OP :
|
---|
114 | g->buffer.logicOp = val;
|
---|
115 | DIRTY(sb->buffer.enable, neg_bitid);
|
---|
116 | DIRTY(sb->buffer.dirty, neg_bitid);
|
---|
117 | break;
|
---|
118 | case GL_INDEX_LOGIC_OP :
|
---|
119 | g->buffer.indexLogicOp = val;
|
---|
120 | DIRTY(sb->buffer.enable, neg_bitid);
|
---|
121 | DIRTY(sb->buffer.dirty, neg_bitid);
|
---|
122 | break;
|
---|
123 | case GL_NORMALIZE :
|
---|
124 | g->transform.normalize = val;
|
---|
125 | DIRTY(sb->transform.enable, neg_bitid);
|
---|
126 | DIRTY(sb->transform.dirty, neg_bitid);
|
---|
127 | break;
|
---|
128 | case GL_POINT_SMOOTH :
|
---|
129 | g->point.pointSmooth = val;
|
---|
130 | DIRTY(sb->point.enableSmooth, neg_bitid);
|
---|
131 | DIRTY(sb->point.dirty, neg_bitid);
|
---|
132 | break;
|
---|
133 | case GL_POLYGON_OFFSET_FILL:
|
---|
134 | g->polygon.polygonOffsetFill = val;
|
---|
135 | DIRTY(sb->polygon.enable, neg_bitid);
|
---|
136 | DIRTY(sb->polygon.dirty, neg_bitid);
|
---|
137 | break;
|
---|
138 | case GL_POLYGON_OFFSET_LINE:
|
---|
139 | g->polygon.polygonOffsetLine = val;
|
---|
140 | DIRTY(sb->polygon.enable, neg_bitid);
|
---|
141 | DIRTY(sb->polygon.dirty, neg_bitid);
|
---|
142 | break;
|
---|
143 | case GL_POLYGON_OFFSET_POINT:
|
---|
144 | g->polygon.polygonOffsetPoint = val;
|
---|
145 | DIRTY(sb->polygon.enable, neg_bitid);
|
---|
146 | DIRTY(sb->polygon.dirty, neg_bitid);
|
---|
147 | break;
|
---|
148 | case GL_POLYGON_SMOOTH :
|
---|
149 | g->polygon.polygonSmooth = val;
|
---|
150 | DIRTY(sb->polygon.enable, neg_bitid);
|
---|
151 | DIRTY(sb->polygon.dirty, neg_bitid);
|
---|
152 | break;
|
---|
153 | case GL_POLYGON_STIPPLE :
|
---|
154 | g->polygon.polygonStipple = val;
|
---|
155 | DIRTY(sb->polygon.enable, neg_bitid);
|
---|
156 | DIRTY(sb->polygon.dirty, neg_bitid);
|
---|
157 | break;
|
---|
158 | #ifdef CR_NV_register_combiners
|
---|
159 | case GL_REGISTER_COMBINERS_NV :
|
---|
160 | if (g->extensions.NV_register_combiners) {
|
---|
161 | g->regcombiner.enabledRegCombiners = val;
|
---|
162 | DIRTY(sb->regcombiner.enable, neg_bitid);
|
---|
163 | DIRTY(sb->regcombiner.dirty, neg_bitid);
|
---|
164 | }
|
---|
165 | else {
|
---|
166 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(GL_REGISTER_COMBINERS_NV) - No support for NV_register_combiners");
|
---|
167 | return;
|
---|
168 | }
|
---|
169 | break;
|
---|
170 | #endif
|
---|
171 | #ifdef CR_NV_register_combiners2
|
---|
172 | case GL_PER_STAGE_CONSTANTS_NV :
|
---|
173 | if (g->extensions.NV_register_combiners2) {
|
---|
174 | g->regcombiner.enabledPerStageConstants = val;
|
---|
175 | DIRTY(sb->regcombiner.enable, neg_bitid);
|
---|
176 | DIRTY(sb->regcombiner.dirty, neg_bitid);
|
---|
177 | }
|
---|
178 | else {
|
---|
179 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(GL_PER_STAGE_CONSTANTS_NV) - No support for NV_register_combiners2");
|
---|
180 | return;
|
---|
181 | }
|
---|
182 | break;
|
---|
183 | #endif
|
---|
184 | #ifdef CR_NV_texture_rectangle
|
---|
185 | case GL_TEXTURE_RECTANGLE_NV:
|
---|
186 | if (g->extensions.NV_texture_rectangle) {
|
---|
187 | g->texture.unit[g->texture.curTextureUnit].enabledRect = val;
|
---|
188 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
189 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
190 | }
|
---|
191 | else {
|
---|
192 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap);
|
---|
193 | return;
|
---|
194 | }
|
---|
195 | break;
|
---|
196 | #endif /* CR_NV_texture_rectangle */
|
---|
197 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
198 | case GL_RESCALE_NORMAL :
|
---|
199 | g->transform.rescaleNormals = val;
|
---|
200 | DIRTY(sb->transform.enable, neg_bitid);
|
---|
201 | DIRTY(sb->transform.dirty, neg_bitid);
|
---|
202 | break;
|
---|
203 | #endif
|
---|
204 | case GL_SCISSOR_TEST :
|
---|
205 | g->viewport.scissorTest = val;
|
---|
206 | DIRTY(sb->viewport.enable, neg_bitid);
|
---|
207 | DIRTY(sb->viewport.dirty, neg_bitid);
|
---|
208 | break;
|
---|
209 | case GL_STENCIL_TEST :
|
---|
210 | g->stencil.stencilTest= val;
|
---|
211 | DIRTY(sb->stencil.enable, neg_bitid);
|
---|
212 | DIRTY(sb->stencil.dirty, neg_bitid);
|
---|
213 | break;
|
---|
214 | case GL_TEXTURE_1D :
|
---|
215 | g->texture.unit[g->texture.curTextureUnit].enabled1D = val;
|
---|
216 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
217 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
218 | break;
|
---|
219 | case GL_TEXTURE_2D :
|
---|
220 | g->texture.unit[g->texture.curTextureUnit].enabled2D = val;
|
---|
221 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
222 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
223 | break;
|
---|
224 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
225 | case GL_TEXTURE_3D :
|
---|
226 | g->texture.unit[g->texture.curTextureUnit].enabled3D = val;
|
---|
227 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
228 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
229 | break;
|
---|
230 | #endif
|
---|
231 | #ifdef CR_ARB_texture_cube_map
|
---|
232 | case GL_TEXTURE_CUBE_MAP_ARB:
|
---|
233 | if (g->extensions.ARB_texture_cube_map) {
|
---|
234 | g->texture.unit[g->texture.curTextureUnit].enabledCubeMap = val;
|
---|
235 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
236 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
237 | }
|
---|
238 | else {
|
---|
239 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap);
|
---|
240 | return;
|
---|
241 | }
|
---|
242 | break;
|
---|
243 | #endif /* CR_ARB_texture_cube_map */
|
---|
244 | case GL_TEXTURE_GEN_Q :
|
---|
245 | g->texture.unit[g->texture.curTextureUnit].textureGen.q = val;
|
---|
246 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
247 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
248 | break;
|
---|
249 | case GL_TEXTURE_GEN_R :
|
---|
250 | g->texture.unit[g->texture.curTextureUnit].textureGen.r = val;
|
---|
251 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
252 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
253 | break;
|
---|
254 | case GL_TEXTURE_GEN_S :
|
---|
255 | g->texture.unit[g->texture.curTextureUnit].textureGen.s = val;
|
---|
256 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
257 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
258 | break;
|
---|
259 | case GL_TEXTURE_GEN_T :
|
---|
260 | g->texture.unit[g->texture.curTextureUnit].textureGen.t = val;
|
---|
261 | DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid);
|
---|
262 | DIRTY(sb->texture.dirty, neg_bitid);
|
---|
263 | break;
|
---|
264 | case GL_MAP1_COLOR_4 :
|
---|
265 | case GL_MAP1_INDEX :
|
---|
266 | case GL_MAP1_NORMAL :
|
---|
267 | case GL_MAP1_TEXTURE_COORD_1 :
|
---|
268 | case GL_MAP1_TEXTURE_COORD_2 :
|
---|
269 | case GL_MAP1_TEXTURE_COORD_3 :
|
---|
270 | case GL_MAP1_TEXTURE_COORD_4 :
|
---|
271 | case GL_MAP1_VERTEX_3 :
|
---|
272 | case GL_MAP1_VERTEX_4 :
|
---|
273 | if (g->texture.curTextureUnit != 0)
|
---|
274 | {
|
---|
275 | crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "Map stuff was enabled while the current texture unit was not GL_TEXTURE0_ARB!" );
|
---|
276 | return;
|
---|
277 | }
|
---|
278 | g->eval.enable1D[cap - GL_MAP1_COLOR_4] = val;
|
---|
279 | DIRTY(sb->eval.enable1D[cap - GL_MAP1_COLOR_4], neg_bitid);
|
---|
280 | DIRTY(sb->eval.dirty, neg_bitid);
|
---|
281 | break;
|
---|
282 | case GL_MAP2_COLOR_4 :
|
---|
283 | case GL_MAP2_INDEX :
|
---|
284 | case GL_MAP2_NORMAL :
|
---|
285 | case GL_MAP2_TEXTURE_COORD_1 :
|
---|
286 | case GL_MAP2_TEXTURE_COORD_2 :
|
---|
287 | case GL_MAP2_TEXTURE_COORD_3 :
|
---|
288 | case GL_MAP2_TEXTURE_COORD_4 :
|
---|
289 | case GL_MAP2_VERTEX_3 :
|
---|
290 | case GL_MAP2_VERTEX_4 :
|
---|
291 | #if 0
|
---|
292 | if (g->texture.curTextureUnit != 0)
|
---|
293 | {
|
---|
294 | crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "Map stuff was enabled while the current texture unit was not GL_TEXTURE0_ARB!" );
|
---|
295 | return;
|
---|
296 | }
|
---|
297 | #endif
|
---|
298 | g->eval.enable2D[cap - GL_MAP2_COLOR_4] = val;
|
---|
299 | DIRTY(sb->eval.enable2D[cap - GL_MAP2_COLOR_4], neg_bitid);
|
---|
300 | DIRTY(sb->eval.dirty, neg_bitid);
|
---|
301 | break;
|
---|
302 | #ifdef CR_ARB_multisample
|
---|
303 | case GL_MULTISAMPLE_ARB:
|
---|
304 | g->multisample.enabled = val;
|
---|
305 | DIRTY(sb->multisample.enable, neg_bitid);
|
---|
306 | DIRTY(sb->multisample.dirty, neg_bitid);
|
---|
307 | break;
|
---|
308 | case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
|
---|
309 | g->multisample.sampleAlphaToCoverage = val;
|
---|
310 | DIRTY(sb->multisample.sampleAlphaToCoverage, neg_bitid);
|
---|
311 | DIRTY(sb->multisample.dirty, neg_bitid);
|
---|
312 | break;
|
---|
313 | case GL_SAMPLE_ALPHA_TO_ONE_ARB:
|
---|
314 | g->multisample.sampleAlphaToOne = val;
|
---|
315 | DIRTY(sb->multisample.sampleAlphaToOne, neg_bitid);
|
---|
316 | DIRTY(sb->multisample.dirty, neg_bitid);
|
---|
317 | break;
|
---|
318 | case GL_SAMPLE_COVERAGE_ARB:
|
---|
319 | g->multisample.sampleCoverage = val;
|
---|
320 | DIRTY(sb->multisample.sampleCoverage, neg_bitid);
|
---|
321 | DIRTY(sb->multisample.dirty, neg_bitid);
|
---|
322 | break;
|
---|
323 | #endif
|
---|
324 | #ifdef CR_NV_vertex_program
|
---|
325 | case GL_VERTEX_PROGRAM_NV:
|
---|
326 | if (g->extensions.NV_vertex_program) {
|
---|
327 | g->program.vpEnabled = val;
|
---|
328 | DIRTY(sb->program.vpEnable, neg_bitid);
|
---|
329 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
330 | }
|
---|
331 | else if (g->extensions.ARB_vertex_program) {
|
---|
332 | g->program.vpEnabled = val;
|
---|
333 | DIRTY(sb->program.vpEnable, neg_bitid);
|
---|
334 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
335 | }
|
---|
336 | else {
|
---|
337 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap);
|
---|
338 | return;
|
---|
339 | }
|
---|
340 | break;
|
---|
341 | case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
|
---|
342 | if (g->extensions.NV_vertex_program) {
|
---|
343 | g->program.vpPointSize = val;
|
---|
344 | DIRTY(sb->program.vpEnable, neg_bitid);
|
---|
345 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
346 | }
|
---|
347 | else if (g->extensions.ARB_vertex_program) {
|
---|
348 | g->program.vpPointSize = val;
|
---|
349 | DIRTY(sb->program.vpEnable, neg_bitid);
|
---|
350 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
351 | }
|
---|
352 | else {
|
---|
353 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap);
|
---|
354 | return;
|
---|
355 | }
|
---|
356 | break;
|
---|
357 | case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
|
---|
358 | if (g->extensions.NV_vertex_program) {
|
---|
359 | g->program.vpTwoSide = val;
|
---|
360 | DIRTY(sb->program.vpEnable, neg_bitid);
|
---|
361 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
362 | }
|
---|
363 | else if (g->extensions.ARB_vertex_program) {
|
---|
364 | g->program.vpTwoSide = val;
|
---|
365 | DIRTY(sb->program.vpEnable, neg_bitid);
|
---|
366 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
367 | }
|
---|
368 | else {
|
---|
369 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap);
|
---|
370 | return;
|
---|
371 | }
|
---|
372 | break;
|
---|
373 |
|
---|
374 | case GL_MAP1_VERTEX_ATTRIB0_4_NV:
|
---|
375 | case GL_MAP1_VERTEX_ATTRIB1_4_NV:
|
---|
376 | case GL_MAP1_VERTEX_ATTRIB2_4_NV:
|
---|
377 | case GL_MAP1_VERTEX_ATTRIB3_4_NV:
|
---|
378 | case GL_MAP1_VERTEX_ATTRIB4_4_NV:
|
---|
379 | case GL_MAP1_VERTEX_ATTRIB5_4_NV:
|
---|
380 | case GL_MAP1_VERTEX_ATTRIB6_4_NV:
|
---|
381 | case GL_MAP1_VERTEX_ATTRIB7_4_NV:
|
---|
382 | case GL_MAP1_VERTEX_ATTRIB8_4_NV:
|
---|
383 | case GL_MAP1_VERTEX_ATTRIB9_4_NV:
|
---|
384 | case GL_MAP1_VERTEX_ATTRIB10_4_NV:
|
---|
385 | case GL_MAP1_VERTEX_ATTRIB11_4_NV:
|
---|
386 | case GL_MAP1_VERTEX_ATTRIB12_4_NV:
|
---|
387 | case GL_MAP1_VERTEX_ATTRIB13_4_NV:
|
---|
388 | case GL_MAP1_VERTEX_ATTRIB14_4_NV:
|
---|
389 | case GL_MAP1_VERTEX_ATTRIB15_4_NV:
|
---|
390 | {
|
---|
391 | const GLint idx = cap - GL_MAP1_VERTEX_ATTRIB0_4_NV;
|
---|
392 | g->eval.enableAttrib1D[idx] = val;
|
---|
393 | DIRTY(sb->program.map1AttribArrayEnable[idx], neg_bitid);
|
---|
394 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
395 | }
|
---|
396 | break;
|
---|
397 | case GL_MAP2_VERTEX_ATTRIB0_4_NV:
|
---|
398 | case GL_MAP2_VERTEX_ATTRIB1_4_NV:
|
---|
399 | case GL_MAP2_VERTEX_ATTRIB2_4_NV:
|
---|
400 | case GL_MAP2_VERTEX_ATTRIB3_4_NV:
|
---|
401 | case GL_MAP2_VERTEX_ATTRIB4_4_NV:
|
---|
402 | case GL_MAP2_VERTEX_ATTRIB5_4_NV:
|
---|
403 | case GL_MAP2_VERTEX_ATTRIB6_4_NV:
|
---|
404 | case GL_MAP2_VERTEX_ATTRIB7_4_NV:
|
---|
405 | case GL_MAP2_VERTEX_ATTRIB8_4_NV:
|
---|
406 | case GL_MAP2_VERTEX_ATTRIB9_4_NV:
|
---|
407 | case GL_MAP2_VERTEX_ATTRIB10_4_NV:
|
---|
408 | case GL_MAP2_VERTEX_ATTRIB11_4_NV:
|
---|
409 | case GL_MAP2_VERTEX_ATTRIB12_4_NV:
|
---|
410 | case GL_MAP2_VERTEX_ATTRIB13_4_NV:
|
---|
411 | case GL_MAP2_VERTEX_ATTRIB14_4_NV:
|
---|
412 | case GL_MAP2_VERTEX_ATTRIB15_4_NV:
|
---|
413 | {
|
---|
414 | const GLint idx = cap - GL_MAP2_VERTEX_ATTRIB0_4_NV;
|
---|
415 | g->eval.enableAttrib2D[idx] = val;
|
---|
416 | DIRTY(sb->program.map2AttribArrayEnable[idx], neg_bitid);
|
---|
417 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
418 | }
|
---|
419 | break;
|
---|
420 | #endif
|
---|
421 | #ifdef CR_NV_fragment_program
|
---|
422 | case GL_FRAGMENT_PROGRAM_NV:
|
---|
423 | if (g->extensions.NV_fragment_program) {
|
---|
424 | g->program.fpEnabled = val;
|
---|
425 | DIRTY(sb->program.fpEnable, neg_bitid);
|
---|
426 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
427 | }
|
---|
428 | else {
|
---|
429 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap);
|
---|
430 | return;
|
---|
431 | }
|
---|
432 | break;
|
---|
433 | #endif
|
---|
434 | #ifdef CR_ARB_fragment_program
|
---|
435 | case GL_FRAGMENT_PROGRAM_ARB:
|
---|
436 | if (g->extensions.ARB_fragment_program) {
|
---|
437 | g->program.fpEnabledARB = val;
|
---|
438 | DIRTY(sb->program.fpEnable, neg_bitid);
|
---|
439 | DIRTY(sb->program.dirty, neg_bitid);
|
---|
440 | }
|
---|
441 | else {
|
---|
442 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap);
|
---|
443 | return;
|
---|
444 | }
|
---|
445 | break;
|
---|
446 | #endif
|
---|
447 | #ifdef CR_IBM_rasterpos_clip
|
---|
448 | case GL_RASTER_POSITION_UNCLIPPED_IBM:
|
---|
449 | g->transform.rasterPositionUnclipped = val;
|
---|
450 | DIRTY(sb->transform.enable, neg_bitid);
|
---|
451 | DIRTY(sb->transform.dirty, neg_bitid);
|
---|
452 | break;
|
---|
453 | #endif
|
---|
454 |
|
---|
455 | #ifdef CR_ARB_point_sprite
|
---|
456 | case GL_POINT_SPRITE_ARB:
|
---|
457 | g->point.pointSprite = val;
|
---|
458 | DIRTY(sb->point.enableSprite, neg_bitid);
|
---|
459 | DIRTY(sb->point.dirty, neg_bitid);
|
---|
460 | break;
|
---|
461 | #endif
|
---|
462 |
|
---|
463 | /* Client-side enables */
|
---|
464 | case GL_VERTEX_ARRAY:
|
---|
465 | case GL_COLOR_ARRAY:
|
---|
466 | case GL_NORMAL_ARRAY:
|
---|
467 | case GL_INDEX_ARRAY:
|
---|
468 | case GL_TEXTURE_COORD_ARRAY:
|
---|
469 | case GL_EDGE_FLAG_ARRAY:
|
---|
470 | #ifdef CR_EXT_fog_coord
|
---|
471 | case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
|
---|
472 | #endif
|
---|
473 | #ifdef CR_EXT_secondary_color
|
---|
474 | case GL_SECONDARY_COLOR_ARRAY_EXT:
|
---|
475 | #endif
|
---|
476 | #ifdef CR_NV_vertex_program
|
---|
477 | case GL_VERTEX_ATTRIB_ARRAY0_NV:
|
---|
478 | case GL_VERTEX_ATTRIB_ARRAY1_NV:
|
---|
479 | case GL_VERTEX_ATTRIB_ARRAY2_NV:
|
---|
480 | case GL_VERTEX_ATTRIB_ARRAY3_NV:
|
---|
481 | case GL_VERTEX_ATTRIB_ARRAY4_NV:
|
---|
482 | case GL_VERTEX_ATTRIB_ARRAY5_NV:
|
---|
483 | case GL_VERTEX_ATTRIB_ARRAY6_NV:
|
---|
484 | case GL_VERTEX_ATTRIB_ARRAY7_NV:
|
---|
485 | case GL_VERTEX_ATTRIB_ARRAY8_NV:
|
---|
486 | case GL_VERTEX_ATTRIB_ARRAY9_NV:
|
---|
487 | case GL_VERTEX_ATTRIB_ARRAY10_NV:
|
---|
488 | case GL_VERTEX_ATTRIB_ARRAY11_NV:
|
---|
489 | case GL_VERTEX_ATTRIB_ARRAY12_NV:
|
---|
490 | case GL_VERTEX_ATTRIB_ARRAY13_NV:
|
---|
491 | case GL_VERTEX_ATTRIB_ARRAY14_NV:
|
---|
492 | case GL_VERTEX_ATTRIB_ARRAY15_NV:
|
---|
493 | #endif
|
---|
494 | if (val)
|
---|
495 | crStateEnableClientState(cap);
|
---|
496 | else
|
---|
497 | crStateDisableClientState(cap);
|
---|
498 | break;
|
---|
499 | #ifdef CR_EXT_stencil_two_side
|
---|
500 | case GL_STENCIL_TEST_TWO_SIDE_EXT:
|
---|
501 | g->stencil.stencilTwoSideEXT= val;
|
---|
502 | DIRTY(sb->stencil.enableTwoSideEXT, neg_bitid);
|
---|
503 | DIRTY(sb->stencil.dirty, neg_bitid);
|
---|
504 | break;
|
---|
505 | #endif
|
---|
506 | default:
|
---|
507 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable called with bogus cap: 0x%x", cap);
|
---|
508 | return;
|
---|
509 | }
|
---|
510 | }
|
---|
511 |
|
---|
512 |
|
---|
513 | void STATE_APIENTRY crStateEnable (GLenum cap)
|
---|
514 | {
|
---|
515 | CRContext *g = GetCurrentContext();
|
---|
516 | CRStateBits *sb = GetCurrentBits();
|
---|
517 |
|
---|
518 | if (g->current.inBeginEnd)
|
---|
519 | {
|
---|
520 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEnable called in begin/end");
|
---|
521 | return;
|
---|
522 | }
|
---|
523 |
|
---|
524 | FLUSH();
|
---|
525 |
|
---|
526 | __enableSet(g, sb, g->neg_bitid, cap, GL_TRUE);
|
---|
527 | }
|
---|
528 |
|
---|
529 |
|
---|
530 | void STATE_APIENTRY crStateDisable (GLenum cap)
|
---|
531 | {
|
---|
532 | CRContext *g = GetCurrentContext();
|
---|
533 | CRStateBits *sb = GetCurrentBits();
|
---|
534 |
|
---|
535 | if (g->current.inBeginEnd)
|
---|
536 | {
|
---|
537 | crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDisable called in begin/end");
|
---|
538 | return;
|
---|
539 | }
|
---|
540 |
|
---|
541 | FLUSH();
|
---|
542 |
|
---|
543 | __enableSet(g, sb, g->neg_bitid, cap, GL_FALSE);
|
---|
544 | }
|
---|