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