Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
55 | pj | 1 | /* $Id: enable.c,v 1.1 2003-02-28 11:42:00 pj Exp $ */ |
2 | |||
3 | /* |
||
4 | * Mesa 3-D graphics library |
||
5 | * Version: 4.1 |
||
6 | * |
||
7 | * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
||
8 | * |
||
9 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
10 | * copy of this software and associated documentation files (the "Software"), |
||
11 | * to deal in the Software without restriction, including without limitation |
||
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
13 | * and/or sell copies of the Software, and to permit persons to whom the |
||
14 | * Software is furnished to do so, subject to the following conditions: |
||
15 | * |
||
16 | * The above copyright notice and this permission notice shall be included |
||
17 | * in all copies or substantial portions of the Software. |
||
18 | * |
||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
25 | */ |
||
26 | |||
27 | |||
28 | #include "glheader.h" |
||
29 | #include "context.h" |
||
30 | #include "enable.h" |
||
31 | #include "light.h" |
||
32 | #include "macros.h" |
||
33 | #include "mmath.h" |
||
34 | #include "simple_list.h" |
||
35 | #include "mtypes.h" |
||
36 | #include "enums.h" |
||
37 | #include "math/m_matrix.h" |
||
38 | #include "math/m_xform.h" |
||
39 | |||
40 | |||
41 | |||
42 | #define CHECK_EXTENSION(EXTNAME, CAP) \ |
||
43 | if (!ctx->Extensions.EXTNAME) { \ |
||
44 | _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \ |
||
45 | state ? "Enable" : "Disable", CAP); \ |
||
46 | return; \ |
||
47 | } |
||
48 | |||
49 | |||
50 | |||
51 | static void |
||
52 | client_state( GLcontext *ctx, GLenum cap, GLboolean state ) |
||
53 | { |
||
54 | GLuint flag; |
||
55 | GLuint *var; |
||
56 | |||
57 | switch (cap) { |
||
58 | case GL_VERTEX_ARRAY: |
||
59 | var = &ctx->Array.Vertex.Enabled; |
||
60 | flag = _NEW_ARRAY_VERTEX; |
||
61 | break; |
||
62 | case GL_NORMAL_ARRAY: |
||
63 | var = &ctx->Array.Normal.Enabled; |
||
64 | flag = _NEW_ARRAY_NORMAL; |
||
65 | break; |
||
66 | case GL_COLOR_ARRAY: |
||
67 | var = &ctx->Array.Color.Enabled; |
||
68 | flag = _NEW_ARRAY_COLOR0; |
||
69 | break; |
||
70 | case GL_INDEX_ARRAY: |
||
71 | var = &ctx->Array.Index.Enabled; |
||
72 | flag = _NEW_ARRAY_INDEX; |
||
73 | break; |
||
74 | case GL_TEXTURE_COORD_ARRAY: |
||
75 | var = &ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled; |
||
76 | flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); |
||
77 | break; |
||
78 | case GL_EDGE_FLAG_ARRAY: |
||
79 | var = &ctx->Array.EdgeFlag.Enabled; |
||
80 | flag = _NEW_ARRAY_EDGEFLAG; |
||
81 | break; |
||
82 | case GL_FOG_COORDINATE_ARRAY_EXT: |
||
83 | var = &ctx->Array.FogCoord.Enabled; |
||
84 | flag = _NEW_ARRAY_FOGCOORD; |
||
85 | break; |
||
86 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
||
87 | var = &ctx->Array.SecondaryColor.Enabled; |
||
88 | flag = _NEW_ARRAY_COLOR1; |
||
89 | break; |
||
90 | |||
91 | #if FEATURE_NV_vertex_program |
||
92 | case GL_VERTEX_ATTRIB_ARRAY0_NV: |
||
93 | case GL_VERTEX_ATTRIB_ARRAY1_NV: |
||
94 | case GL_VERTEX_ATTRIB_ARRAY2_NV: |
||
95 | case GL_VERTEX_ATTRIB_ARRAY3_NV: |
||
96 | case GL_VERTEX_ATTRIB_ARRAY4_NV: |
||
97 | case GL_VERTEX_ATTRIB_ARRAY5_NV: |
||
98 | case GL_VERTEX_ATTRIB_ARRAY6_NV: |
||
99 | case GL_VERTEX_ATTRIB_ARRAY7_NV: |
||
100 | case GL_VERTEX_ATTRIB_ARRAY8_NV: |
||
101 | case GL_VERTEX_ATTRIB_ARRAY9_NV: |
||
102 | case GL_VERTEX_ATTRIB_ARRAY10_NV: |
||
103 | case GL_VERTEX_ATTRIB_ARRAY11_NV: |
||
104 | case GL_VERTEX_ATTRIB_ARRAY12_NV: |
||
105 | case GL_VERTEX_ATTRIB_ARRAY13_NV: |
||
106 | case GL_VERTEX_ATTRIB_ARRAY14_NV: |
||
107 | case GL_VERTEX_ATTRIB_ARRAY15_NV: |
||
108 | CHECK_EXTENSION(NV_vertex_program, cap); |
||
109 | { |
||
110 | GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; |
||
111 | var = &ctx->Array.VertexAttrib[n].Enabled; |
||
112 | flag = _NEW_ARRAY_ATTRIB(n); |
||
113 | } |
||
114 | break; |
||
115 | #endif /* FEATURE_NV_vertex_program */ |
||
116 | |||
117 | default: |
||
118 | _mesa_error( ctx, GL_INVALID_ENUM, |
||
119 | "glEnable/DisableClientState(0x%x)", cap); |
||
120 | return; |
||
121 | } |
||
122 | |||
123 | if (*var == state) |
||
124 | return; |
||
125 | |||
126 | FLUSH_VERTICES(ctx, _NEW_ARRAY); |
||
127 | ctx->Array.NewState |= flag; |
||
128 | *var = state; |
||
129 | |||
130 | if (state) |
||
131 | ctx->Array._Enabled |= flag; |
||
132 | else |
||
133 | ctx->Array._Enabled &= ~flag; |
||
134 | |||
135 | if (ctx->Driver.Enable) { |
||
136 | (*ctx->Driver.Enable)( ctx, cap, state ); |
||
137 | } |
||
138 | } |
||
139 | |||
140 | |||
141 | |||
142 | void |
||
143 | _mesa_EnableClientState( GLenum cap ) |
||
144 | { |
||
145 | GET_CURRENT_CONTEXT(ctx); |
||
146 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
147 | client_state( ctx, cap, GL_TRUE ); |
||
148 | } |
||
149 | |||
150 | |||
151 | |||
152 | void |
||
153 | _mesa_DisableClientState( GLenum cap ) |
||
154 | { |
||
155 | GET_CURRENT_CONTEXT(ctx); |
||
156 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
157 | client_state( ctx, cap, GL_FALSE ); |
||
158 | } |
||
159 | |||
160 | |||
161 | #undef CHECK_EXTENSION |
||
162 | #define CHECK_EXTENSION(EXTNAME, CAP) \ |
||
163 | if (!ctx->Extensions.EXTNAME) { \ |
||
164 | _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \ |
||
165 | state ? "Enable" : "Disable", CAP); \ |
||
166 | return; \ |
||
167 | } |
||
168 | |||
169 | |||
170 | /* |
||
171 | * Perform glEnable and glDisable calls. |
||
172 | */ |
||
173 | void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) |
||
174 | { |
||
175 | if (MESA_VERBOSE & VERBOSE_API) |
||
176 | _mesa_debug(ctx, "%s %s (newstate is %x)\n", |
||
177 | state ? "glEnable" : "glDisable", |
||
178 | _mesa_lookup_enum_by_nr(cap), |
||
179 | ctx->NewState); |
||
180 | |||
181 | switch (cap) { |
||
182 | case GL_ALPHA_TEST: |
||
183 | if (ctx->Color.AlphaEnabled == state) |
||
184 | return; |
||
185 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
||
186 | ctx->Color.AlphaEnabled = state; |
||
187 | break; |
||
188 | case GL_AUTO_NORMAL: |
||
189 | if (ctx->Eval.AutoNormal == state) |
||
190 | return; |
||
191 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
192 | ctx->Eval.AutoNormal = state; |
||
193 | break; |
||
194 | case GL_BLEND: |
||
195 | if (ctx->Color.BlendEnabled == state) |
||
196 | return; |
||
197 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
||
198 | ctx->Color.BlendEnabled = state; |
||
199 | /* The following needed to accomodate 1.0 RGB logic op blending */ |
||
200 | ctx->Color.ColorLogicOpEnabled = |
||
201 | (ctx->Color.BlendEquation == GL_LOGIC_OP && state); |
||
202 | break; |
||
203 | case GL_CLIP_PLANE0: |
||
204 | case GL_CLIP_PLANE1: |
||
205 | case GL_CLIP_PLANE2: |
||
206 | case GL_CLIP_PLANE3: |
||
207 | case GL_CLIP_PLANE4: |
||
208 | case GL_CLIP_PLANE5: |
||
209 | { |
||
210 | const GLuint p = cap - GL_CLIP_PLANE0; |
||
211 | |||
212 | if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) |
||
213 | return; |
||
214 | |||
215 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
||
216 | |||
217 | if (state) { |
||
218 | ctx->Transform.ClipPlanesEnabled |= (1 << p); |
||
219 | |||
220 | if (ctx->ProjectionMatrixStack.Top->flags & MAT_DIRTY) |
||
221 | _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); |
||
222 | |||
223 | /* This derived state also calculated in clip.c and |
||
224 | * from _mesa_update_state() on changes to EyeUserPlane |
||
225 | * and ctx->ProjectionMatrix respectively. |
||
226 | */ |
||
227 | _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], |
||
228 | ctx->Transform.EyeUserPlane[p], |
||
229 | ctx->ProjectionMatrixStack.Top->inv ); |
||
230 | } |
||
231 | else { |
||
232 | ctx->Transform.ClipPlanesEnabled &= ~(1 << p); |
||
233 | } |
||
234 | } |
||
235 | break; |
||
236 | case GL_COLOR_MATERIAL: |
||
237 | if (ctx->Light.ColorMaterialEnabled == state) |
||
238 | return; |
||
239 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
||
240 | ctx->Light.ColorMaterialEnabled = state; |
||
241 | if (state) { |
||
242 | FLUSH_CURRENT(ctx, 0); |
||
243 | _mesa_update_color_material( ctx, |
||
244 | ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); |
||
245 | } |
||
246 | break; |
||
247 | case GL_CULL_FACE: |
||
248 | if (ctx->Polygon.CullFlag == state) |
||
249 | return; |
||
250 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
||
251 | ctx->Polygon.CullFlag = state; |
||
252 | break; |
||
253 | case GL_DEPTH_TEST: |
||
254 | if (state && ctx->Visual.depthBits==0) { |
||
255 | _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); |
||
256 | return; |
||
257 | } |
||
258 | if (ctx->Depth.Test==state) |
||
259 | return; |
||
260 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
||
261 | ctx->Depth.Test = state; |
||
262 | break; |
||
263 | case GL_DITHER: |
||
264 | if (ctx->NoDither) { |
||
265 | state = GL_FALSE; /* MESA_NO_DITHER env var */ |
||
266 | } |
||
267 | if (ctx->Color.DitherFlag==state) |
||
268 | return; |
||
269 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
||
270 | ctx->Color.DitherFlag = state; |
||
271 | break; |
||
272 | case GL_FOG: |
||
273 | if (ctx->Fog.Enabled==state) |
||
274 | return; |
||
275 | FLUSH_VERTICES(ctx, _NEW_FOG); |
||
276 | ctx->Fog.Enabled = state; |
||
277 | break; |
||
278 | case GL_HISTOGRAM: |
||
279 | CHECK_EXTENSION(EXT_histogram, cap); |
||
280 | if (ctx->Pixel.HistogramEnabled == state) |
||
281 | return; |
||
282 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
283 | ctx->Pixel.HistogramEnabled = state; |
||
284 | break; |
||
285 | case GL_LIGHT0: |
||
286 | case GL_LIGHT1: |
||
287 | case GL_LIGHT2: |
||
288 | case GL_LIGHT3: |
||
289 | case GL_LIGHT4: |
||
290 | case GL_LIGHT5: |
||
291 | case GL_LIGHT6: |
||
292 | case GL_LIGHT7: |
||
293 | if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) |
||
294 | return; |
||
295 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
||
296 | ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; |
||
297 | if (state) { |
||
298 | insert_at_tail(&ctx->Light.EnabledList, |
||
299 | &ctx->Light.Light[cap-GL_LIGHT0]); |
||
300 | } |
||
301 | else { |
||
302 | remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); |
||
303 | } |
||
304 | break; |
||
305 | case GL_LIGHTING: |
||
306 | if (ctx->Light.Enabled == state) |
||
307 | return; |
||
308 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
||
309 | ctx->Light.Enabled = state; |
||
310 | |||
311 | if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) |
||
312 | ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; |
||
313 | else |
||
314 | ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; |
||
315 | |||
316 | if ((ctx->Light.Enabled && |
||
317 | ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) |
||
318 | || ctx->Fog.ColorSumEnabled) |
||
319 | ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; |
||
320 | else |
||
321 | ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; |
||
322 | |||
323 | break; |
||
324 | case GL_LINE_SMOOTH: |
||
325 | if (ctx->Line.SmoothFlag == state) |
||
326 | return; |
||
327 | FLUSH_VERTICES(ctx, _NEW_LINE); |
||
328 | ctx->Line.SmoothFlag = state; |
||
329 | ctx->_TriangleCaps ^= DD_LINE_SMOOTH; |
||
330 | break; |
||
331 | case GL_LINE_STIPPLE: |
||
332 | if (ctx->Line.StippleFlag == state) |
||
333 | return; |
||
334 | FLUSH_VERTICES(ctx, _NEW_LINE); |
||
335 | ctx->Line.StippleFlag = state; |
||
336 | ctx->_TriangleCaps ^= DD_LINE_STIPPLE; |
||
337 | break; |
||
338 | case GL_INDEX_LOGIC_OP: |
||
339 | if (ctx->Color.IndexLogicOpEnabled == state) |
||
340 | return; |
||
341 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
||
342 | ctx->Color.IndexLogicOpEnabled = state; |
||
343 | break; |
||
344 | case GL_COLOR_LOGIC_OP: |
||
345 | if (ctx->Color.ColorLogicOpEnabled == state) |
||
346 | return; |
||
347 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
||
348 | ctx->Color.ColorLogicOpEnabled = state; |
||
349 | break; |
||
350 | case GL_MAP1_COLOR_4: |
||
351 | if (ctx->Eval.Map1Color4 == state) |
||
352 | return; |
||
353 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
354 | ctx->Eval.Map1Color4 = state; |
||
355 | break; |
||
356 | case GL_MAP1_INDEX: |
||
357 | if (ctx->Eval.Map1Index == state) |
||
358 | return; |
||
359 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
360 | ctx->Eval.Map1Index = state; |
||
361 | break; |
||
362 | case GL_MAP1_NORMAL: |
||
363 | if (ctx->Eval.Map1Normal == state) |
||
364 | return; |
||
365 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
366 | ctx->Eval.Map1Normal = state; |
||
367 | break; |
||
368 | case GL_MAP1_TEXTURE_COORD_1: |
||
369 | if (ctx->Eval.Map1TextureCoord1 == state) |
||
370 | return; |
||
371 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
372 | ctx->Eval.Map1TextureCoord1 = state; |
||
373 | break; |
||
374 | case GL_MAP1_TEXTURE_COORD_2: |
||
375 | if (ctx->Eval.Map1TextureCoord2 == state) |
||
376 | return; |
||
377 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
378 | ctx->Eval.Map1TextureCoord2 = state; |
||
379 | break; |
||
380 | case GL_MAP1_TEXTURE_COORD_3: |
||
381 | if (ctx->Eval.Map1TextureCoord3 == state) |
||
382 | return; |
||
383 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
384 | ctx->Eval.Map1TextureCoord3 = state; |
||
385 | break; |
||
386 | case GL_MAP1_TEXTURE_COORD_4: |
||
387 | if (ctx->Eval.Map1TextureCoord4 == state) |
||
388 | return; |
||
389 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
390 | ctx->Eval.Map1TextureCoord4 = state; |
||
391 | break; |
||
392 | case GL_MAP1_VERTEX_3: |
||
393 | if (ctx->Eval.Map1Vertex3 == state) |
||
394 | return; |
||
395 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
396 | ctx->Eval.Map1Vertex3 = state; |
||
397 | break; |
||
398 | case GL_MAP1_VERTEX_4: |
||
399 | if (ctx->Eval.Map1Vertex4 == state) |
||
400 | return; |
||
401 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
402 | ctx->Eval.Map1Vertex4 = state; |
||
403 | break; |
||
404 | case GL_MAP2_COLOR_4: |
||
405 | if (ctx->Eval.Map2Color4 == state) |
||
406 | return; |
||
407 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
408 | ctx->Eval.Map2Color4 = state; |
||
409 | break; |
||
410 | case GL_MAP2_INDEX: |
||
411 | if (ctx->Eval.Map2Index == state) |
||
412 | return; |
||
413 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
414 | ctx->Eval.Map2Index = state; |
||
415 | break; |
||
416 | case GL_MAP2_NORMAL: |
||
417 | if (ctx->Eval.Map2Normal == state) |
||
418 | return; |
||
419 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
420 | ctx->Eval.Map2Normal = state; |
||
421 | break; |
||
422 | case GL_MAP2_TEXTURE_COORD_1: |
||
423 | if (ctx->Eval.Map2TextureCoord1 == state) |
||
424 | return; |
||
425 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
426 | ctx->Eval.Map2TextureCoord1 = state; |
||
427 | break; |
||
428 | case GL_MAP2_TEXTURE_COORD_2: |
||
429 | if (ctx->Eval.Map2TextureCoord2 == state) |
||
430 | return; |
||
431 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
432 | ctx->Eval.Map2TextureCoord2 = state; |
||
433 | break; |
||
434 | case GL_MAP2_TEXTURE_COORD_3: |
||
435 | if (ctx->Eval.Map2TextureCoord3 == state) |
||
436 | return; |
||
437 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
438 | ctx->Eval.Map2TextureCoord3 = state; |
||
439 | break; |
||
440 | case GL_MAP2_TEXTURE_COORD_4: |
||
441 | if (ctx->Eval.Map2TextureCoord4 == state) |
||
442 | return; |
||
443 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
444 | ctx->Eval.Map2TextureCoord4 = state; |
||
445 | break; |
||
446 | case GL_MAP2_VERTEX_3: |
||
447 | if (ctx->Eval.Map2Vertex3 == state) |
||
448 | return; |
||
449 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
450 | ctx->Eval.Map2Vertex3 = state; |
||
451 | break; |
||
452 | case GL_MAP2_VERTEX_4: |
||
453 | if (ctx->Eval.Map2Vertex4 == state) |
||
454 | return; |
||
455 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
456 | ctx->Eval.Map2Vertex4 = state; |
||
457 | break; |
||
458 | case GL_MINMAX: |
||
459 | if (ctx->Pixel.MinMaxEnabled == state) |
||
460 | return; |
||
461 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
462 | ctx->Pixel.MinMaxEnabled = state; |
||
463 | break; |
||
464 | case GL_NORMALIZE: |
||
465 | if (ctx->Transform.Normalize == state) |
||
466 | return; |
||
467 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
||
468 | ctx->Transform.Normalize = state; |
||
469 | break; |
||
470 | case GL_POINT_SMOOTH: |
||
471 | if (ctx->Point.SmoothFlag==state) |
||
472 | return; |
||
473 | FLUSH_VERTICES(ctx, _NEW_POINT); |
||
474 | ctx->Point.SmoothFlag = state; |
||
475 | ctx->_TriangleCaps ^= DD_POINT_SMOOTH; |
||
476 | break; |
||
477 | case GL_POLYGON_SMOOTH: |
||
478 | if (ctx->Polygon.SmoothFlag==state) |
||
479 | return; |
||
480 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
||
481 | ctx->Polygon.SmoothFlag = state; |
||
482 | ctx->_TriangleCaps ^= DD_TRI_SMOOTH; |
||
483 | break; |
||
484 | case GL_POLYGON_STIPPLE: |
||
485 | if (ctx->Polygon.StippleFlag==state) |
||
486 | return; |
||
487 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
||
488 | ctx->Polygon.StippleFlag = state; |
||
489 | ctx->_TriangleCaps ^= DD_TRI_STIPPLE; |
||
490 | break; |
||
491 | case GL_POLYGON_OFFSET_POINT: |
||
492 | if (ctx->Polygon.OffsetPoint==state) |
||
493 | return; |
||
494 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
||
495 | ctx->Polygon.OffsetPoint = state; |
||
496 | break; |
||
497 | case GL_POLYGON_OFFSET_LINE: |
||
498 | if (ctx->Polygon.OffsetLine==state) |
||
499 | return; |
||
500 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
||
501 | ctx->Polygon.OffsetLine = state; |
||
502 | break; |
||
503 | case GL_POLYGON_OFFSET_FILL: |
||
504 | /*case GL_POLYGON_OFFSET_EXT:*/ |
||
505 | if (ctx->Polygon.OffsetFill==state) |
||
506 | return; |
||
507 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
||
508 | ctx->Polygon.OffsetFill = state; |
||
509 | break; |
||
510 | case GL_RESCALE_NORMAL_EXT: |
||
511 | if (ctx->Transform.RescaleNormals == state) |
||
512 | return; |
||
513 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
||
514 | ctx->Transform.RescaleNormals = state; |
||
515 | break; |
||
516 | case GL_SCISSOR_TEST: |
||
517 | if (ctx->Scissor.Enabled==state) |
||
518 | return; |
||
519 | FLUSH_VERTICES(ctx, _NEW_SCISSOR); |
||
520 | ctx->Scissor.Enabled = state; |
||
521 | break; |
||
522 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
||
523 | if (ctx->Texture.SharedPalette == state) |
||
524 | return; |
||
525 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
526 | ctx->Texture.SharedPalette = state; |
||
527 | break; |
||
528 | case GL_STENCIL_TEST: |
||
529 | if (state && ctx->Visual.stencilBits==0) { |
||
530 | _mesa_warning(ctx, |
||
531 | "glEnable(GL_STENCIL_TEST) but no stencil buffer"); |
||
532 | return; |
||
533 | } |
||
534 | if (ctx->Stencil.Enabled==state) |
||
535 | return; |
||
536 | FLUSH_VERTICES(ctx, _NEW_STENCIL); |
||
537 | ctx->Stencil.Enabled = state; |
||
538 | break; |
||
539 | case GL_TEXTURE_1D: { |
||
540 | const GLuint curr = ctx->Texture.CurrentUnit; |
||
541 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
||
542 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT; |
||
543 | if (state) |
||
544 | newenabled |= TEXTURE_1D_BIT; |
||
545 | if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled) |
||
546 | return; |
||
547 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
548 | texUnit->Enabled = newenabled; |
||
549 | break; |
||
550 | } |
||
551 | case GL_TEXTURE_2D: { |
||
552 | const GLuint curr = ctx->Texture.CurrentUnit; |
||
553 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
||
554 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT; |
||
555 | if (state) |
||
556 | newenabled |= TEXTURE_2D_BIT; |
||
557 | if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled) |
||
558 | return; |
||
559 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
560 | texUnit->Enabled = newenabled; |
||
561 | break; |
||
562 | } |
||
563 | case GL_TEXTURE_3D: { |
||
564 | const GLuint curr = ctx->Texture.CurrentUnit; |
||
565 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
||
566 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT; |
||
567 | if (state) |
||
568 | newenabled |= TEXTURE_3D_BIT; |
||
569 | if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled) |
||
570 | return; |
||
571 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
572 | texUnit->Enabled = newenabled; |
||
573 | break; |
||
574 | } |
||
575 | case GL_TEXTURE_GEN_Q: { |
||
576 | GLuint unit = ctx->Texture.CurrentUnit; |
||
577 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
||
578 | GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; |
||
579 | if (state) |
||
580 | newenabled |= Q_BIT; |
||
581 | if (texUnit->TexGenEnabled == newenabled) |
||
582 | return; |
||
583 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
584 | texUnit->TexGenEnabled = newenabled; |
||
585 | break; |
||
586 | } |
||
587 | case GL_TEXTURE_GEN_R: { |
||
588 | GLuint unit = ctx->Texture.CurrentUnit; |
||
589 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
||
590 | GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; |
||
591 | if (state) |
||
592 | newenabled |= R_BIT; |
||
593 | if (texUnit->TexGenEnabled == newenabled) |
||
594 | return; |
||
595 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
596 | texUnit->TexGenEnabled = newenabled; |
||
597 | break; |
||
598 | } |
||
599 | break; |
||
600 | case GL_TEXTURE_GEN_S: { |
||
601 | GLuint unit = ctx->Texture.CurrentUnit; |
||
602 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
||
603 | GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; |
||
604 | if (state) |
||
605 | newenabled |= S_BIT; |
||
606 | if (texUnit->TexGenEnabled == newenabled) |
||
607 | return; |
||
608 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
609 | texUnit->TexGenEnabled = newenabled; |
||
610 | break; |
||
611 | } |
||
612 | break; |
||
613 | case GL_TEXTURE_GEN_T: { |
||
614 | GLuint unit = ctx->Texture.CurrentUnit; |
||
615 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
||
616 | GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; |
||
617 | if (state) |
||
618 | newenabled |= T_BIT; |
||
619 | if (texUnit->TexGenEnabled == newenabled) |
||
620 | return; |
||
621 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
622 | texUnit->TexGenEnabled = newenabled; |
||
623 | break; |
||
624 | } |
||
625 | break; |
||
626 | |||
627 | /* |
||
628 | * CLIENT STATE!!! |
||
629 | */ |
||
630 | case GL_VERTEX_ARRAY: |
||
631 | case GL_NORMAL_ARRAY: |
||
632 | case GL_COLOR_ARRAY: |
||
633 | case GL_INDEX_ARRAY: |
||
634 | case GL_TEXTURE_COORD_ARRAY: |
||
635 | case GL_EDGE_FLAG_ARRAY: |
||
636 | case GL_FOG_COORDINATE_ARRAY_EXT: |
||
637 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
||
638 | client_state( ctx, cap, state ); |
||
639 | return; |
||
640 | |||
641 | /* GL_HP_occlusion_test */ |
||
642 | case GL_OCCLUSION_TEST_HP: |
||
643 | CHECK_EXTENSION(HP_occlusion_test, cap); |
||
644 | if (ctx->Depth.OcclusionTest == state) |
||
645 | return; |
||
646 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
||
647 | ctx->Depth.OcclusionTest = state; |
||
648 | if (state) |
||
649 | ctx->OcclusionResult = ctx->OcclusionResultSaved; |
||
650 | else |
||
651 | ctx->OcclusionResultSaved = ctx->OcclusionResult; |
||
652 | break; |
||
653 | |||
654 | /* GL_SGIS_pixel_texture */ |
||
655 | case GL_PIXEL_TEXTURE_SGIS: |
||
656 | CHECK_EXTENSION(SGIS_pixel_texture, cap); |
||
657 | if (ctx->Pixel.PixelTextureEnabled == state) |
||
658 | return; |
||
659 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
660 | ctx->Pixel.PixelTextureEnabled = state; |
||
661 | break; |
||
662 | |||
663 | /* GL_SGIX_pixel_texture */ |
||
664 | case GL_PIXEL_TEX_GEN_SGIX: |
||
665 | CHECK_EXTENSION(SGIX_pixel_texture, cap); |
||
666 | if (ctx->Pixel.PixelTextureEnabled == state) |
||
667 | return; |
||
668 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
669 | ctx->Pixel.PixelTextureEnabled = state; |
||
670 | break; |
||
671 | |||
672 | /* GL_SGI_color_table */ |
||
673 | case GL_COLOR_TABLE_SGI: |
||
674 | CHECK_EXTENSION(SGI_color_table, cap); |
||
675 | if (ctx->Pixel.ColorTableEnabled == state) |
||
676 | return; |
||
677 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
678 | ctx->Pixel.ColorTableEnabled = state; |
||
679 | break; |
||
680 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
||
681 | CHECK_EXTENSION(SGI_color_table, cap); |
||
682 | if (ctx->Pixel.PostConvolutionColorTableEnabled == state) |
||
683 | return; |
||
684 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
685 | ctx->Pixel.PostConvolutionColorTableEnabled = state; |
||
686 | break; |
||
687 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
||
688 | CHECK_EXTENSION(SGI_color_table, cap); |
||
689 | if (ctx->Pixel.PostColorMatrixColorTableEnabled == state) |
||
690 | return; |
||
691 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
692 | ctx->Pixel.PostColorMatrixColorTableEnabled = state; |
||
693 | break; |
||
694 | |||
695 | /* GL_EXT_convolution */ |
||
696 | case GL_CONVOLUTION_1D: |
||
697 | CHECK_EXTENSION(EXT_convolution, cap); |
||
698 | if (ctx->Pixel.Convolution1DEnabled == state) |
||
699 | return; |
||
700 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
701 | ctx->Pixel.Convolution1DEnabled = state; |
||
702 | break; |
||
703 | case GL_CONVOLUTION_2D: |
||
704 | CHECK_EXTENSION(EXT_convolution, cap); |
||
705 | if (ctx->Pixel.Convolution2DEnabled == state) |
||
706 | return; |
||
707 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
708 | ctx->Pixel.Convolution2DEnabled = state; |
||
709 | break; |
||
710 | case GL_SEPARABLE_2D: |
||
711 | CHECK_EXTENSION(EXT_convolution, cap); |
||
712 | if (ctx->Pixel.Separable2DEnabled == state) |
||
713 | return; |
||
714 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
||
715 | ctx->Pixel.Separable2DEnabled = state; |
||
716 | break; |
||
717 | |||
718 | /* GL_ARB_texture_cube_map */ |
||
719 | case GL_TEXTURE_CUBE_MAP_ARB: |
||
720 | { |
||
721 | const GLuint curr = ctx->Texture.CurrentUnit; |
||
722 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
||
723 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT; |
||
724 | CHECK_EXTENSION(ARB_texture_cube_map, cap); |
||
725 | if (state) |
||
726 | newenabled |= TEXTURE_CUBE_BIT; |
||
727 | if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled) |
||
728 | return; |
||
729 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
730 | texUnit->Enabled = newenabled; |
||
731 | } |
||
732 | break; |
||
733 | |||
734 | /* GL_EXT_secondary_color */ |
||
735 | case GL_COLOR_SUM_EXT: |
||
736 | CHECK_EXTENSION(EXT_secondary_color, cap); |
||
737 | if (ctx->Fog.ColorSumEnabled == state) |
||
738 | return; |
||
739 | FLUSH_VERTICES(ctx, _NEW_FOG); |
||
740 | ctx->Fog.ColorSumEnabled = state; |
||
741 | |||
742 | if ((ctx->Light.Enabled && |
||
743 | ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) |
||
744 | || ctx->Fog.ColorSumEnabled) |
||
745 | ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; |
||
746 | else |
||
747 | ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; |
||
748 | |||
749 | break; |
||
750 | |||
751 | /* GL_ARB_multisample */ |
||
752 | case GL_MULTISAMPLE_ARB: |
||
753 | CHECK_EXTENSION(ARB_multisample, cap); |
||
754 | if (ctx->Multisample.Enabled == state) |
||
755 | return; |
||
756 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
||
757 | ctx->Multisample.Enabled = state; |
||
758 | break; |
||
759 | case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: |
||
760 | CHECK_EXTENSION(ARB_multisample, cap); |
||
761 | if (ctx->Multisample.SampleAlphaToCoverage == state) |
||
762 | return; |
||
763 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
||
764 | ctx->Multisample.SampleAlphaToCoverage = state; |
||
765 | break; |
||
766 | case GL_SAMPLE_ALPHA_TO_ONE_ARB: |
||
767 | CHECK_EXTENSION(ARB_multisample, cap); |
||
768 | if (ctx->Multisample.SampleAlphaToOne == state) |
||
769 | return; |
||
770 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
||
771 | ctx->Multisample.SampleAlphaToOne = state; |
||
772 | break; |
||
773 | case GL_SAMPLE_COVERAGE_ARB: |
||
774 | CHECK_EXTENSION(ARB_multisample, cap); |
||
775 | if (ctx->Multisample.SampleCoverage == state) |
||
776 | return; |
||
777 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
||
778 | ctx->Multisample.SampleCoverage = state; |
||
779 | break; |
||
780 | case GL_SAMPLE_COVERAGE_INVERT_ARB: |
||
781 | CHECK_EXTENSION(ARB_multisample, cap); |
||
782 | if (ctx->Multisample.SampleCoverageInvert == state) |
||
783 | return; |
||
784 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
||
785 | ctx->Multisample.SampleCoverageInvert = state; |
||
786 | break; |
||
787 | |||
788 | /* GL_IBM_rasterpos_clip */ |
||
789 | case GL_RASTER_POSITION_UNCLIPPED_IBM: |
||
790 | CHECK_EXTENSION(IBM_rasterpos_clip, cap); |
||
791 | if (ctx->Transform.RasterPositionUnclipped == state) |
||
792 | return; |
||
793 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
||
794 | ctx->Transform.RasterPositionUnclipped = state; |
||
795 | break; |
||
796 | |||
797 | /* GL_NV_point_sprite */ |
||
798 | case GL_POINT_SPRITE_NV: |
||
799 | CHECK_EXTENSION(NV_point_sprite, cap); |
||
800 | if (ctx->Point.PointSprite == state) |
||
801 | return; |
||
802 | FLUSH_VERTICES(ctx, _NEW_POINT); |
||
803 | ctx->Point.PointSprite = state; |
||
804 | break; |
||
805 | |||
806 | #if FEATURE_NV_vertex_program |
||
807 | case GL_VERTEX_PROGRAM_NV: |
||
808 | CHECK_EXTENSION(NV_vertex_program, cap); |
||
809 | if (ctx->VertexProgram.Enabled == state) |
||
810 | return; |
||
811 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_PROGRAM); /* XXX OK? */ |
||
812 | ctx->VertexProgram.Enabled = state; |
||
813 | break; |
||
814 | case GL_VERTEX_PROGRAM_POINT_SIZE_NV: |
||
815 | CHECK_EXTENSION(NV_vertex_program, cap); |
||
816 | if (ctx->VertexProgram.PointSizeEnabled == state) |
||
817 | return; |
||
818 | FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_PROGRAM); |
||
819 | ctx->VertexProgram.PointSizeEnabled = state; |
||
820 | break; |
||
821 | case GL_VERTEX_PROGRAM_TWO_SIDE_NV: |
||
822 | CHECK_EXTENSION(NV_vertex_program, cap); |
||
823 | if (ctx->VertexProgram.TwoSideEnabled == state) |
||
824 | return; |
||
825 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); /* XXX OK? */ |
||
826 | ctx->VertexProgram.TwoSideEnabled = state; |
||
827 | break; |
||
828 | case GL_MAP1_VERTEX_ATTRIB0_4_NV: |
||
829 | case GL_MAP1_VERTEX_ATTRIB1_4_NV: |
||
830 | case GL_MAP1_VERTEX_ATTRIB2_4_NV: |
||
831 | case GL_MAP1_VERTEX_ATTRIB3_4_NV: |
||
832 | case GL_MAP1_VERTEX_ATTRIB4_4_NV: |
||
833 | case GL_MAP1_VERTEX_ATTRIB5_4_NV: |
||
834 | case GL_MAP1_VERTEX_ATTRIB6_4_NV: |
||
835 | case GL_MAP1_VERTEX_ATTRIB7_4_NV: |
||
836 | case GL_MAP1_VERTEX_ATTRIB8_4_NV: |
||
837 | case GL_MAP1_VERTEX_ATTRIB9_4_NV: |
||
838 | case GL_MAP1_VERTEX_ATTRIB10_4_NV: |
||
839 | case GL_MAP1_VERTEX_ATTRIB11_4_NV: |
||
840 | case GL_MAP1_VERTEX_ATTRIB12_4_NV: |
||
841 | case GL_MAP1_VERTEX_ATTRIB13_4_NV: |
||
842 | case GL_MAP1_VERTEX_ATTRIB14_4_NV: |
||
843 | case GL_MAP1_VERTEX_ATTRIB15_4_NV: |
||
844 | CHECK_EXTENSION(NV_vertex_program, cap); |
||
845 | { |
||
846 | const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); |
||
847 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
848 | ctx->Eval.Map1Attrib[map] = state; |
||
849 | } |
||
850 | break; |
||
851 | case GL_MAP2_VERTEX_ATTRIB0_4_NV: |
||
852 | case GL_MAP2_VERTEX_ATTRIB1_4_NV: |
||
853 | case GL_MAP2_VERTEX_ATTRIB2_4_NV: |
||
854 | case GL_MAP2_VERTEX_ATTRIB3_4_NV: |
||
855 | case GL_MAP2_VERTEX_ATTRIB4_4_NV: |
||
856 | case GL_MAP2_VERTEX_ATTRIB5_4_NV: |
||
857 | case GL_MAP2_VERTEX_ATTRIB6_4_NV: |
||
858 | case GL_MAP2_VERTEX_ATTRIB7_4_NV: |
||
859 | case GL_MAP2_VERTEX_ATTRIB8_4_NV: |
||
860 | case GL_MAP2_VERTEX_ATTRIB9_4_NV: |
||
861 | case GL_MAP2_VERTEX_ATTRIB10_4_NV: |
||
862 | case GL_MAP2_VERTEX_ATTRIB11_4_NV: |
||
863 | case GL_MAP2_VERTEX_ATTRIB12_4_NV: |
||
864 | case GL_MAP2_VERTEX_ATTRIB13_4_NV: |
||
865 | case GL_MAP2_VERTEX_ATTRIB14_4_NV: |
||
866 | case GL_MAP2_VERTEX_ATTRIB15_4_NV: |
||
867 | CHECK_EXTENSION(NV_vertex_program, cap); |
||
868 | { |
||
869 | const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); |
||
870 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
||
871 | ctx->Eval.Map2Attrib[map] = state; |
||
872 | } |
||
873 | break; |
||
874 | #endif /* FEATURE_NV_vertex_program */ |
||
875 | |||
876 | /* GL_NV_texture_rectangle */ |
||
877 | case GL_TEXTURE_RECTANGLE_NV: |
||
878 | CHECK_EXTENSION(NV_texture_rectangle, cap); |
||
879 | { |
||
880 | const GLuint curr = ctx->Texture.CurrentUnit; |
||
881 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
||
882 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT; |
||
883 | CHECK_EXTENSION(NV_texture_rectangle, cap); |
||
884 | if (state) |
||
885 | newenabled |= TEXTURE_RECT_BIT; |
||
886 | if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled) |
||
887 | return; |
||
888 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
||
889 | texUnit->Enabled = newenabled; |
||
890 | } |
||
891 | break; |
||
892 | |||
893 | /* GL_EXT_stencil_two_side */ |
||
894 | case GL_STENCIL_TEST_TWO_SIDE_EXT: |
||
895 | CHECK_EXTENSION(EXT_stencil_two_side, cap); |
||
896 | if (ctx->Stencil.TestTwoSide == state) |
||
897 | return; |
||
898 | FLUSH_VERTICES(ctx, _NEW_STENCIL); |
||
899 | ctx->Stencil.TestTwoSide = state; |
||
900 | break; |
||
901 | |||
902 | default: |
||
903 | _mesa_error(ctx, GL_INVALID_ENUM, |
||
904 | "%s(0x%x)", state ? "glEnable" : "glDisable", cap); |
||
905 | return; |
||
906 | } |
||
907 | |||
908 | if (ctx->Driver.Enable) { |
||
909 | (*ctx->Driver.Enable)( ctx, cap, state ); |
||
910 | } |
||
911 | } |
||
912 | |||
913 | |||
914 | void |
||
915 | _mesa_Enable( GLenum cap ) |
||
916 | { |
||
917 | GET_CURRENT_CONTEXT(ctx); |
||
918 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
919 | |||
920 | _mesa_set_enable( ctx, cap, GL_TRUE ); |
||
921 | } |
||
922 | |||
923 | |||
924 | void |
||
925 | _mesa_Disable( GLenum cap ) |
||
926 | { |
||
927 | GET_CURRENT_CONTEXT(ctx); |
||
928 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
929 | |||
930 | _mesa_set_enable( ctx, cap, GL_FALSE ); |
||
931 | } |
||
932 | |||
933 | |||
934 | #undef CHECK_EXTENSION |
||
935 | #define CHECK_EXTENSION(EXTNAME) \ |
||
936 | if (!ctx->Extensions.EXTNAME) { \ |
||
937 | _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \ |
||
938 | return GL_FALSE; \ |
||
939 | } |
||
940 | |||
941 | |||
942 | GLboolean |
||
943 | _mesa_IsEnabled( GLenum cap ) |
||
944 | { |
||
945 | GET_CURRENT_CONTEXT(ctx); |
||
946 | switch (cap) { |
||
947 | case GL_ALPHA_TEST: |
||
948 | return ctx->Color.AlphaEnabled; |
||
949 | case GL_AUTO_NORMAL: |
||
950 | return ctx->Eval.AutoNormal; |
||
951 | case GL_BLEND: |
||
952 | return ctx->Color.BlendEnabled; |
||
953 | case GL_CLIP_PLANE0: |
||
954 | case GL_CLIP_PLANE1: |
||
955 | case GL_CLIP_PLANE2: |
||
956 | case GL_CLIP_PLANE3: |
||
957 | case GL_CLIP_PLANE4: |
||
958 | case GL_CLIP_PLANE5: |
||
959 | return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; |
||
960 | case GL_COLOR_MATERIAL: |
||
961 | return ctx->Light.ColorMaterialEnabled; |
||
962 | case GL_CULL_FACE: |
||
963 | return ctx->Polygon.CullFlag; |
||
964 | case GL_DEPTH_TEST: |
||
965 | return ctx->Depth.Test; |
||
966 | case GL_DITHER: |
||
967 | return ctx->Color.DitherFlag; |
||
968 | case GL_FOG: |
||
969 | return ctx->Fog.Enabled; |
||
970 | case GL_LIGHTING: |
||
971 | return ctx->Light.Enabled; |
||
972 | case GL_LIGHT0: |
||
973 | case GL_LIGHT1: |
||
974 | case GL_LIGHT2: |
||
975 | case GL_LIGHT3: |
||
976 | case GL_LIGHT4: |
||
977 | case GL_LIGHT5: |
||
978 | case GL_LIGHT6: |
||
979 | case GL_LIGHT7: |
||
980 | return ctx->Light.Light[cap-GL_LIGHT0].Enabled; |
||
981 | case GL_LINE_SMOOTH: |
||
982 | return ctx->Line.SmoothFlag; |
||
983 | case GL_LINE_STIPPLE: |
||
984 | return ctx->Line.StippleFlag; |
||
985 | case GL_INDEX_LOGIC_OP: |
||
986 | return ctx->Color.IndexLogicOpEnabled; |
||
987 | case GL_COLOR_LOGIC_OP: |
||
988 | return ctx->Color.ColorLogicOpEnabled; |
||
989 | case GL_MAP1_COLOR_4: |
||
990 | return ctx->Eval.Map1Color4; |
||
991 | case GL_MAP1_INDEX: |
||
992 | return ctx->Eval.Map1Index; |
||
993 | case GL_MAP1_NORMAL: |
||
994 | return ctx->Eval.Map1Normal; |
||
995 | case GL_MAP1_TEXTURE_COORD_1: |
||
996 | return ctx->Eval.Map1TextureCoord1; |
||
997 | case GL_MAP1_TEXTURE_COORD_2: |
||
998 | return ctx->Eval.Map1TextureCoord2; |
||
999 | case GL_MAP1_TEXTURE_COORD_3: |
||
1000 | return ctx->Eval.Map1TextureCoord3; |
||
1001 | case GL_MAP1_TEXTURE_COORD_4: |
||
1002 | return ctx->Eval.Map1TextureCoord4; |
||
1003 | case GL_MAP1_VERTEX_3: |
||
1004 | return ctx->Eval.Map1Vertex3; |
||
1005 | case GL_MAP1_VERTEX_4: |
||
1006 | return ctx->Eval.Map1Vertex4; |
||
1007 | case GL_MAP2_COLOR_4: |
||
1008 | return ctx->Eval.Map2Color4; |
||
1009 | case GL_MAP2_INDEX: |
||
1010 | return ctx->Eval.Map2Index; |
||
1011 | case GL_MAP2_NORMAL: |
||
1012 | return ctx->Eval.Map2Normal; |
||
1013 | case GL_MAP2_TEXTURE_COORD_1: |
||
1014 | return ctx->Eval.Map2TextureCoord1; |
||
1015 | case GL_MAP2_TEXTURE_COORD_2: |
||
1016 | return ctx->Eval.Map2TextureCoord2; |
||
1017 | case GL_MAP2_TEXTURE_COORD_3: |
||
1018 | return ctx->Eval.Map2TextureCoord3; |
||
1019 | case GL_MAP2_TEXTURE_COORD_4: |
||
1020 | return ctx->Eval.Map2TextureCoord4; |
||
1021 | case GL_MAP2_VERTEX_3: |
||
1022 | return ctx->Eval.Map2Vertex3; |
||
1023 | case GL_MAP2_VERTEX_4: |
||
1024 | return ctx->Eval.Map2Vertex4; |
||
1025 | case GL_NORMALIZE: |
||
1026 | return ctx->Transform.Normalize; |
||
1027 | case GL_POINT_SMOOTH: |
||
1028 | return ctx->Point.SmoothFlag; |
||
1029 | case GL_POLYGON_SMOOTH: |
||
1030 | return ctx->Polygon.SmoothFlag; |
||
1031 | case GL_POLYGON_STIPPLE: |
||
1032 | return ctx->Polygon.StippleFlag; |
||
1033 | case GL_POLYGON_OFFSET_POINT: |
||
1034 | return ctx->Polygon.OffsetPoint; |
||
1035 | case GL_POLYGON_OFFSET_LINE: |
||
1036 | return ctx->Polygon.OffsetLine; |
||
1037 | case GL_POLYGON_OFFSET_FILL: |
||
1038 | /*case GL_POLYGON_OFFSET_EXT:*/ |
||
1039 | return ctx->Polygon.OffsetFill; |
||
1040 | case GL_RESCALE_NORMAL_EXT: |
||
1041 | return ctx->Transform.RescaleNormals; |
||
1042 | case GL_SCISSOR_TEST: |
||
1043 | return ctx->Scissor.Enabled; |
||
1044 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
||
1045 | return ctx->Texture.SharedPalette; |
||
1046 | case GL_STENCIL_TEST: |
||
1047 | return ctx->Stencil.Enabled; |
||
1048 | case GL_TEXTURE_1D: |
||
1049 | { |
||
1050 | const struct gl_texture_unit *texUnit; |
||
1051 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1052 | return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE; |
||
1053 | } |
||
1054 | case GL_TEXTURE_2D: |
||
1055 | { |
||
1056 | const struct gl_texture_unit *texUnit; |
||
1057 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1058 | return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE; |
||
1059 | } |
||
1060 | case GL_TEXTURE_3D: |
||
1061 | { |
||
1062 | const struct gl_texture_unit *texUnit; |
||
1063 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1064 | return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE; |
||
1065 | } |
||
1066 | case GL_TEXTURE_GEN_Q: |
||
1067 | { |
||
1068 | const struct gl_texture_unit *texUnit; |
||
1069 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1070 | return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; |
||
1071 | } |
||
1072 | case GL_TEXTURE_GEN_R: |
||
1073 | { |
||
1074 | const struct gl_texture_unit *texUnit; |
||
1075 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1076 | return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; |
||
1077 | } |
||
1078 | case GL_TEXTURE_GEN_S: |
||
1079 | { |
||
1080 | const struct gl_texture_unit *texUnit; |
||
1081 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1082 | return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; |
||
1083 | } |
||
1084 | case GL_TEXTURE_GEN_T: |
||
1085 | { |
||
1086 | const struct gl_texture_unit *texUnit; |
||
1087 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1088 | return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; |
||
1089 | } |
||
1090 | |||
1091 | /* |
||
1092 | * CLIENT STATE!!! |
||
1093 | */ |
||
1094 | case GL_VERTEX_ARRAY: |
||
1095 | return (ctx->Array.Vertex.Enabled != 0); |
||
1096 | case GL_NORMAL_ARRAY: |
||
1097 | return (ctx->Array.Normal.Enabled != 0); |
||
1098 | case GL_COLOR_ARRAY: |
||
1099 | return (ctx->Array.Color.Enabled != 0); |
||
1100 | case GL_INDEX_ARRAY: |
||
1101 | return (ctx->Array.Index.Enabled != 0); |
||
1102 | case GL_TEXTURE_COORD_ARRAY: |
||
1103 | return (ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled != 0); |
||
1104 | case GL_EDGE_FLAG_ARRAY: |
||
1105 | return (ctx->Array.EdgeFlag.Enabled != 0); |
||
1106 | case GL_FOG_COORDINATE_ARRAY_EXT: |
||
1107 | CHECK_EXTENSION(EXT_fog_coord); |
||
1108 | return (ctx->Array.FogCoord.Enabled != 0); |
||
1109 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
||
1110 | CHECK_EXTENSION(EXT_secondary_color); |
||
1111 | return (ctx->Array.SecondaryColor.Enabled != 0); |
||
1112 | |||
1113 | /* GL_EXT_histogram */ |
||
1114 | case GL_HISTOGRAM: |
||
1115 | CHECK_EXTENSION(EXT_histogram); |
||
1116 | return ctx->Pixel.HistogramEnabled; |
||
1117 | case GL_MINMAX: |
||
1118 | CHECK_EXTENSION(EXT_histogram); |
||
1119 | return ctx->Pixel.MinMaxEnabled; |
||
1120 | |||
1121 | /* GL_HP_occlusion_test */ |
||
1122 | case GL_OCCLUSION_TEST_HP: |
||
1123 | CHECK_EXTENSION(HP_occlusion_test); |
||
1124 | return ctx->Depth.OcclusionTest; |
||
1125 | |||
1126 | /* GL_SGIS_pixel_texture */ |
||
1127 | case GL_PIXEL_TEXTURE_SGIS: |
||
1128 | CHECK_EXTENSION(SGIS_pixel_texture); |
||
1129 | return ctx->Pixel.PixelTextureEnabled; |
||
1130 | |||
1131 | /* GL_SGIX_pixel_texture */ |
||
1132 | case GL_PIXEL_TEX_GEN_SGIX: |
||
1133 | CHECK_EXTENSION(SGIX_pixel_texture); |
||
1134 | return ctx->Pixel.PixelTextureEnabled; |
||
1135 | |||
1136 | /* GL_SGI_color_table */ |
||
1137 | case GL_COLOR_TABLE_SGI: |
||
1138 | CHECK_EXTENSION(SGI_color_table); |
||
1139 | return ctx->Pixel.ColorTableEnabled; |
||
1140 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
||
1141 | CHECK_EXTENSION(SGI_color_table); |
||
1142 | return ctx->Pixel.PostConvolutionColorTableEnabled; |
||
1143 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
||
1144 | CHECK_EXTENSION(SGI_color_table); |
||
1145 | return ctx->Pixel.PostColorMatrixColorTableEnabled; |
||
1146 | |||
1147 | /* GL_EXT_convolution */ |
||
1148 | case GL_CONVOLUTION_1D: |
||
1149 | CHECK_EXTENSION(EXT_convolution); |
||
1150 | return ctx->Pixel.Convolution1DEnabled; |
||
1151 | case GL_CONVOLUTION_2D: |
||
1152 | CHECK_EXTENSION(EXT_convolution); |
||
1153 | return ctx->Pixel.Convolution2DEnabled; |
||
1154 | case GL_SEPARABLE_2D: |
||
1155 | CHECK_EXTENSION(EXT_convolution); |
||
1156 | return ctx->Pixel.Separable2DEnabled; |
||
1157 | |||
1158 | /* GL_ARB_texture_cube_map */ |
||
1159 | case GL_TEXTURE_CUBE_MAP_ARB: |
||
1160 | CHECK_EXTENSION(ARB_texture_cube_map); |
||
1161 | { |
||
1162 | const struct gl_texture_unit *texUnit; |
||
1163 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1164 | return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE; |
||
1165 | } |
||
1166 | |||
1167 | /* GL_ARB_multisample */ |
||
1168 | case GL_MULTISAMPLE_ARB: |
||
1169 | CHECK_EXTENSION(ARB_multisample); |
||
1170 | return ctx->Multisample.Enabled; |
||
1171 | case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: |
||
1172 | CHECK_EXTENSION(ARB_multisample); |
||
1173 | return ctx->Multisample.SampleAlphaToCoverage; |
||
1174 | case GL_SAMPLE_ALPHA_TO_ONE_ARB: |
||
1175 | CHECK_EXTENSION(ARB_multisample); |
||
1176 | return ctx->Multisample.SampleAlphaToOne; |
||
1177 | case GL_SAMPLE_COVERAGE_ARB: |
||
1178 | CHECK_EXTENSION(ARB_multisample); |
||
1179 | return ctx->Multisample.SampleCoverage; |
||
1180 | case GL_SAMPLE_COVERAGE_INVERT_ARB: |
||
1181 | CHECK_EXTENSION(ARB_multisample); |
||
1182 | return ctx->Multisample.SampleCoverageInvert; |
||
1183 | |||
1184 | /* GL_IBM_rasterpos_clip */ |
||
1185 | case GL_RASTER_POSITION_UNCLIPPED_IBM: |
||
1186 | CHECK_EXTENSION(IBM_rasterpos_clip); |
||
1187 | return ctx->Transform.RasterPositionUnclipped; |
||
1188 | |||
1189 | /* GL_NV_point_sprite */ |
||
1190 | case GL_POINT_SPRITE_NV: |
||
1191 | return ctx->Point.PointSprite; |
||
1192 | |||
1193 | #if FEATURE_NV_vertex_program |
||
1194 | case GL_VERTEX_PROGRAM_NV: |
||
1195 | CHECK_EXTENSION(NV_vertex_program); |
||
1196 | return ctx->VertexProgram.Enabled; |
||
1197 | case GL_VERTEX_PROGRAM_POINT_SIZE_NV: |
||
1198 | CHECK_EXTENSION(NV_vertex_program); |
||
1199 | return ctx->VertexProgram.PointSizeEnabled; |
||
1200 | case GL_VERTEX_PROGRAM_TWO_SIDE_NV: |
||
1201 | CHECK_EXTENSION(NV_vertex_program); |
||
1202 | return ctx->VertexProgram.TwoSideEnabled; |
||
1203 | case GL_VERTEX_ATTRIB_ARRAY0_NV: |
||
1204 | case GL_VERTEX_ATTRIB_ARRAY1_NV: |
||
1205 | case GL_VERTEX_ATTRIB_ARRAY2_NV: |
||
1206 | case GL_VERTEX_ATTRIB_ARRAY3_NV: |
||
1207 | case GL_VERTEX_ATTRIB_ARRAY4_NV: |
||
1208 | case GL_VERTEX_ATTRIB_ARRAY5_NV: |
||
1209 | case GL_VERTEX_ATTRIB_ARRAY6_NV: |
||
1210 | case GL_VERTEX_ATTRIB_ARRAY7_NV: |
||
1211 | case GL_VERTEX_ATTRIB_ARRAY8_NV: |
||
1212 | case GL_VERTEX_ATTRIB_ARRAY9_NV: |
||
1213 | case GL_VERTEX_ATTRIB_ARRAY10_NV: |
||
1214 | case GL_VERTEX_ATTRIB_ARRAY11_NV: |
||
1215 | case GL_VERTEX_ATTRIB_ARRAY12_NV: |
||
1216 | case GL_VERTEX_ATTRIB_ARRAY13_NV: |
||
1217 | case GL_VERTEX_ATTRIB_ARRAY14_NV: |
||
1218 | case GL_VERTEX_ATTRIB_ARRAY15_NV: |
||
1219 | CHECK_EXTENSION(NV_vertex_program); |
||
1220 | { |
||
1221 | GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; |
||
1222 | return (ctx->Array.VertexAttrib[n].Enabled != 0); |
||
1223 | } |
||
1224 | case GL_MAP1_VERTEX_ATTRIB0_4_NV: |
||
1225 | case GL_MAP1_VERTEX_ATTRIB1_4_NV: |
||
1226 | case GL_MAP1_VERTEX_ATTRIB2_4_NV: |
||
1227 | case GL_MAP1_VERTEX_ATTRIB3_4_NV: |
||
1228 | case GL_MAP1_VERTEX_ATTRIB4_4_NV: |
||
1229 | case GL_MAP1_VERTEX_ATTRIB5_4_NV: |
||
1230 | case GL_MAP1_VERTEX_ATTRIB6_4_NV: |
||
1231 | case GL_MAP1_VERTEX_ATTRIB7_4_NV: |
||
1232 | case GL_MAP1_VERTEX_ATTRIB8_4_NV: |
||
1233 | case GL_MAP1_VERTEX_ATTRIB9_4_NV: |
||
1234 | case GL_MAP1_VERTEX_ATTRIB10_4_NV: |
||
1235 | case GL_MAP1_VERTEX_ATTRIB11_4_NV: |
||
1236 | case GL_MAP1_VERTEX_ATTRIB12_4_NV: |
||
1237 | case GL_MAP1_VERTEX_ATTRIB13_4_NV: |
||
1238 | case GL_MAP1_VERTEX_ATTRIB14_4_NV: |
||
1239 | case GL_MAP1_VERTEX_ATTRIB15_4_NV: |
||
1240 | CHECK_EXTENSION(NV_vertex_program); |
||
1241 | { |
||
1242 | const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); |
||
1243 | return ctx->Eval.Map1Attrib[map]; |
||
1244 | } |
||
1245 | case GL_MAP2_VERTEX_ATTRIB0_4_NV: |
||
1246 | case GL_MAP2_VERTEX_ATTRIB1_4_NV: |
||
1247 | case GL_MAP2_VERTEX_ATTRIB2_4_NV: |
||
1248 | case GL_MAP2_VERTEX_ATTRIB3_4_NV: |
||
1249 | case GL_MAP2_VERTEX_ATTRIB4_4_NV: |
||
1250 | case GL_MAP2_VERTEX_ATTRIB5_4_NV: |
||
1251 | case GL_MAP2_VERTEX_ATTRIB6_4_NV: |
||
1252 | case GL_MAP2_VERTEX_ATTRIB7_4_NV: |
||
1253 | case GL_MAP2_VERTEX_ATTRIB8_4_NV: |
||
1254 | case GL_MAP2_VERTEX_ATTRIB9_4_NV: |
||
1255 | case GL_MAP2_VERTEX_ATTRIB10_4_NV: |
||
1256 | case GL_MAP2_VERTEX_ATTRIB11_4_NV: |
||
1257 | case GL_MAP2_VERTEX_ATTRIB12_4_NV: |
||
1258 | case GL_MAP2_VERTEX_ATTRIB13_4_NV: |
||
1259 | case GL_MAP2_VERTEX_ATTRIB14_4_NV: |
||
1260 | case GL_MAP2_VERTEX_ATTRIB15_4_NV: |
||
1261 | CHECK_EXTENSION(NV_vertex_program); |
||
1262 | { |
||
1263 | const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); |
||
1264 | return ctx->Eval.Map2Attrib[map]; |
||
1265 | } |
||
1266 | #endif /* FEATURE_NV_vertex_program */ |
||
1267 | |||
1268 | /* GL_NV_texture_rectangle */ |
||
1269 | case GL_TEXTURE_RECTANGLE_NV: |
||
1270 | CHECK_EXTENSION(NV_texture_rectangle); |
||
1271 | { |
||
1272 | const struct gl_texture_unit *texUnit; |
||
1273 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
||
1274 | return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE; |
||
1275 | } |
||
1276 | |||
1277 | /* GL_EXT_stencil_two_side */ |
||
1278 | case GL_STENCIL_TEST_TWO_SIDE_EXT: |
||
1279 | CHECK_EXTENSION(EXT_stencil_two_side); |
||
1280 | return ctx->Stencil.TestTwoSide; |
||
1281 | |||
1282 | default: |
||
1283 | _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); |
||
1284 | return GL_FALSE; |
||
1285 | } |
||
1286 | } |