3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
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.
36 #include "simple_list.h"
39 #include "math/m_matrix.h"
40 #include "math/m_xform.h"
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); \
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); \
60 client_state( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
67 var
= &ctx
->Array
.Vertex
.Enabled
;
68 flag
= _NEW_ARRAY_VERTEX
;
71 var
= &ctx
->Array
.Normal
.Enabled
;
72 flag
= _NEW_ARRAY_NORMAL
;
75 var
= &ctx
->Array
.Color
.Enabled
;
76 flag
= _NEW_ARRAY_COLOR0
;
79 var
= &ctx
->Array
.Index
.Enabled
;
80 flag
= _NEW_ARRAY_INDEX
;
82 case GL_TEXTURE_COORD_ARRAY
:
83 var
= &ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
84 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
86 case GL_EDGE_FLAG_ARRAY
:
87 var
= &ctx
->Array
.EdgeFlag
.Enabled
;
88 flag
= _NEW_ARRAY_EDGEFLAG
;
90 case GL_FOG_COORDINATE_ARRAY_EXT
:
91 var
= &ctx
->Array
.FogCoord
.Enabled
;
92 flag
= _NEW_ARRAY_FOGCOORD
;
94 case GL_SECONDARY_COLOR_ARRAY_EXT
:
95 var
= &ctx
->Array
.SecondaryColor
.Enabled
;
96 flag
= _NEW_ARRAY_COLOR1
;
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
);
118 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
119 var
= &ctx
->Array
.VertexAttrib
[n
].Enabled
;
120 flag
= _NEW_ARRAY_ATTRIB(n
);
123 #endif /* FEATURE_NV_vertex_program */
126 _mesa_error( ctx
, GL_INVALID_ENUM
,
127 "glEnable/DisableClientState(0x%x)", cap
);
134 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
135 ctx
->Array
.NewState
|= flag
;
139 ctx
->Array
._Enabled
|= flag
;
141 ctx
->Array
._Enabled
&= ~flag
;
143 if (ctx
->Driver
.Enable
) {
144 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
150 * Enable GL capability.
152 * \param cap capability.
156 * Get's the current context, assures that we're outside glBegin()/glEnd() and
157 * calls client_state().
160 _mesa_EnableClientState( GLenum cap
)
162 GET_CURRENT_CONTEXT(ctx
);
163 ASSERT_OUTSIDE_BEGIN_END(ctx
);
164 client_state( ctx
, cap
, GL_TRUE
);
169 * Disable GL capability.
171 * \param cap capability.
175 * Get's the current context, assures that we're outside glBegin()/glEnd() and
176 * calls client_state().
179 _mesa_DisableClientState( GLenum cap
)
181 GET_CURRENT_CONTEXT(ctx
);
182 ASSERT_OUTSIDE_BEGIN_END(ctx
);
183 client_state( ctx
, cap
, GL_FALSE
);
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); \
197 * Perform glEnable() and glDisable() calls.
199 * \param ctx GL context.
200 * \param cap capability.
201 * \param state whether to enable or disable the specified capability.
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.
208 void _mesa_set_enable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
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
),
218 if (ctx
->Color
.AlphaEnabled
== state
)
220 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
221 ctx
->Color
.AlphaEnabled
= state
;
224 if (ctx
->Eval
.AutoNormal
== state
)
226 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
227 ctx
->Eval
.AutoNormal
= state
;
230 if (ctx
->Color
.BlendEnabled
== state
)
232 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
233 ctx
->Color
.BlendEnabled
= state
;
234 /* This is needed to support 1.1's RGB logic ops AND
235 * 1.0's blending logicops.
237 ctx
->Color
._LogicOpEnabled
=
238 (ctx
->Color
.ColorLogicOpEnabled
||
239 (state
&& ctx
->Color
.BlendEquationRGB
== GL_LOGIC_OP
));
249 const GLuint p
= cap
- GL_CLIP_PLANE0
;
251 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
254 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
257 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
259 if (ctx
->ProjectionMatrixStack
.Top
->flags
& MAT_DIRTY
)
260 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
262 /* This derived state also calculated in clip.c and
263 * from _mesa_update_state() on changes to EyeUserPlane
264 * and ctx->ProjectionMatrix respectively.
266 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
267 ctx
->Transform
.EyeUserPlane
[p
],
268 ctx
->ProjectionMatrixStack
.Top
->inv
);
271 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
276 case GL_COLOR_MATERIAL
:
277 if (ctx
->Light
.ColorMaterialEnabled
== state
)
279 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
280 FLUSH_CURRENT(ctx
, 0);
281 ctx
->Light
.ColorMaterialEnabled
= state
;
283 _mesa_update_color_material( ctx
,
284 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
288 if (ctx
->Polygon
.CullFlag
== state
)
290 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
291 ctx
->Polygon
.CullFlag
= state
;
294 if (state
&& ctx
->Visual
.depthBits
==0) {
295 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
298 if (ctx
->Depth
.Test
==state
)
300 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
301 ctx
->Depth
.Test
= state
;
305 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
307 if (ctx
->Color
.DitherFlag
==state
)
309 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
310 ctx
->Color
.DitherFlag
= state
;
313 if (ctx
->Fog
.Enabled
==state
)
315 FLUSH_VERTICES(ctx
, _NEW_FOG
);
316 ctx
->Fog
.Enabled
= state
;
319 CHECK_EXTENSION(EXT_histogram
, cap
);
320 if (ctx
->Pixel
.HistogramEnabled
== state
)
322 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
323 ctx
->Pixel
.HistogramEnabled
= state
;
333 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
335 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
336 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
338 insert_at_tail(&ctx
->Light
.EnabledList
,
339 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
342 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
346 if (ctx
->Light
.Enabled
== state
)
348 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
349 ctx
->Light
.Enabled
= state
;
351 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
352 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
354 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
358 if (ctx
->Line
.SmoothFlag
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_LINE
);
361 ctx
->Line
.SmoothFlag
= state
;
362 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
364 case GL_LINE_STIPPLE
:
365 if (ctx
->Line
.StippleFlag
== state
)
367 FLUSH_VERTICES(ctx
, _NEW_LINE
);
368 ctx
->Line
.StippleFlag
= state
;
369 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
371 case GL_INDEX_LOGIC_OP
:
372 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
374 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
375 ctx
->Color
.IndexLogicOpEnabled
= state
;
377 case GL_COLOR_LOGIC_OP
:
378 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
380 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
381 ctx
->Color
.ColorLogicOpEnabled
= state
;
382 /* This is needed to support 1.1's RGB logic ops AND
383 * 1.0's blending logicops.
385 ctx
->Color
._LogicOpEnabled
=
386 (state
|| (ctx
->Color
.BlendEnabled
&&
387 ctx
->Color
.BlendEquationRGB
== GL_LOGIC_OP
));
389 case GL_MAP1_COLOR_4
:
390 if (ctx
->Eval
.Map1Color4
== state
)
392 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
393 ctx
->Eval
.Map1Color4
= state
;
396 if (ctx
->Eval
.Map1Index
== state
)
398 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
399 ctx
->Eval
.Map1Index
= state
;
402 if (ctx
->Eval
.Map1Normal
== state
)
404 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
405 ctx
->Eval
.Map1Normal
= state
;
407 case GL_MAP1_TEXTURE_COORD_1
:
408 if (ctx
->Eval
.Map1TextureCoord1
== state
)
410 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
411 ctx
->Eval
.Map1TextureCoord1
= state
;
413 case GL_MAP1_TEXTURE_COORD_2
:
414 if (ctx
->Eval
.Map1TextureCoord2
== state
)
416 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
417 ctx
->Eval
.Map1TextureCoord2
= state
;
419 case GL_MAP1_TEXTURE_COORD_3
:
420 if (ctx
->Eval
.Map1TextureCoord3
== state
)
422 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
423 ctx
->Eval
.Map1TextureCoord3
= state
;
425 case GL_MAP1_TEXTURE_COORD_4
:
426 if (ctx
->Eval
.Map1TextureCoord4
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
429 ctx
->Eval
.Map1TextureCoord4
= state
;
431 case GL_MAP1_VERTEX_3
:
432 if (ctx
->Eval
.Map1Vertex3
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
435 ctx
->Eval
.Map1Vertex3
= state
;
437 case GL_MAP1_VERTEX_4
:
438 if (ctx
->Eval
.Map1Vertex4
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
441 ctx
->Eval
.Map1Vertex4
= state
;
443 case GL_MAP2_COLOR_4
:
444 if (ctx
->Eval
.Map2Color4
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
447 ctx
->Eval
.Map2Color4
= state
;
450 if (ctx
->Eval
.Map2Index
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map2Index
= state
;
456 if (ctx
->Eval
.Map2Normal
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map2Normal
= state
;
461 case GL_MAP2_TEXTURE_COORD_1
:
462 if (ctx
->Eval
.Map2TextureCoord1
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map2TextureCoord1
= state
;
467 case GL_MAP2_TEXTURE_COORD_2
:
468 if (ctx
->Eval
.Map2TextureCoord2
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map2TextureCoord2
= state
;
473 case GL_MAP2_TEXTURE_COORD_3
:
474 if (ctx
->Eval
.Map2TextureCoord3
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map2TextureCoord3
= state
;
479 case GL_MAP2_TEXTURE_COORD_4
:
480 if (ctx
->Eval
.Map2TextureCoord4
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map2TextureCoord4
= state
;
485 case GL_MAP2_VERTEX_3
:
486 if (ctx
->Eval
.Map2Vertex3
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map2Vertex3
= state
;
491 case GL_MAP2_VERTEX_4
:
492 if (ctx
->Eval
.Map2Vertex4
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map2Vertex4
= state
;
498 if (ctx
->Pixel
.MinMaxEnabled
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
501 ctx
->Pixel
.MinMaxEnabled
= state
;
504 if (ctx
->Transform
.Normalize
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
507 ctx
->Transform
.Normalize
= state
;
509 case GL_POINT_SMOOTH
:
510 if (ctx
->Point
.SmoothFlag
==state
)
512 FLUSH_VERTICES(ctx
, _NEW_POINT
);
513 ctx
->Point
.SmoothFlag
= state
;
514 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
516 case GL_POLYGON_SMOOTH
:
517 if (ctx
->Polygon
.SmoothFlag
==state
)
519 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
520 ctx
->Polygon
.SmoothFlag
= state
;
521 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
523 case GL_POLYGON_STIPPLE
:
524 if (ctx
->Polygon
.StippleFlag
==state
)
526 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
527 ctx
->Polygon
.StippleFlag
= state
;
528 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
530 case GL_POLYGON_OFFSET_POINT
:
531 if (ctx
->Polygon
.OffsetPoint
==state
)
533 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
534 ctx
->Polygon
.OffsetPoint
= state
;
536 case GL_POLYGON_OFFSET_LINE
:
537 if (ctx
->Polygon
.OffsetLine
==state
)
539 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
540 ctx
->Polygon
.OffsetLine
= state
;
542 case GL_POLYGON_OFFSET_FILL
:
543 /*case GL_POLYGON_OFFSET_EXT:*/
544 if (ctx
->Polygon
.OffsetFill
==state
)
546 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
547 ctx
->Polygon
.OffsetFill
= state
;
549 case GL_RESCALE_NORMAL_EXT
:
550 if (ctx
->Transform
.RescaleNormals
== state
)
552 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
553 ctx
->Transform
.RescaleNormals
= state
;
555 case GL_SCISSOR_TEST
:
556 if (ctx
->Scissor
.Enabled
==state
)
558 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
559 ctx
->Scissor
.Enabled
= state
;
561 case GL_SHARED_TEXTURE_PALETTE_EXT
:
562 if (ctx
->Texture
.SharedPalette
== state
)
564 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
565 ctx
->Texture
.SharedPalette
= state
;
567 case GL_STENCIL_TEST
:
568 if (state
&& ctx
->Visual
.stencilBits
==0) {
570 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
573 if (ctx
->Stencil
.Enabled
==state
)
575 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
576 ctx
->Stencil
.Enabled
= state
;
578 case GL_TEXTURE_1D
: {
579 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
580 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
581 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_1D_BIT
;
583 newenabled
|= TEXTURE_1D_BIT
;
584 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
586 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
587 texUnit
->Enabled
= newenabled
;
590 case GL_TEXTURE_2D
: {
591 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
592 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
593 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_2D_BIT
;
595 newenabled
|= TEXTURE_2D_BIT
;
596 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
598 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
599 texUnit
->Enabled
= newenabled
;
602 case GL_TEXTURE_3D
: {
603 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
604 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
605 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_3D_BIT
;
607 newenabled
|= TEXTURE_3D_BIT
;
608 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
610 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
611 texUnit
->Enabled
= newenabled
;
614 case GL_TEXTURE_GEN_Q
: {
615 GLuint unit
= ctx
->Texture
.CurrentUnit
;
616 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
617 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
620 if (texUnit
->TexGenEnabled
== newenabled
)
622 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
623 texUnit
->TexGenEnabled
= newenabled
;
626 case GL_TEXTURE_GEN_R
: {
627 GLuint unit
= ctx
->Texture
.CurrentUnit
;
628 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
629 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
632 if (texUnit
->TexGenEnabled
== newenabled
)
634 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
635 texUnit
->TexGenEnabled
= newenabled
;
639 case GL_TEXTURE_GEN_S
: {
640 GLuint unit
= ctx
->Texture
.CurrentUnit
;
641 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
642 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
645 if (texUnit
->TexGenEnabled
== newenabled
)
647 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
648 texUnit
->TexGenEnabled
= newenabled
;
652 case GL_TEXTURE_GEN_T
: {
653 GLuint unit
= ctx
->Texture
.CurrentUnit
;
654 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
655 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
658 if (texUnit
->TexGenEnabled
== newenabled
)
660 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
661 texUnit
->TexGenEnabled
= newenabled
;
669 case GL_VERTEX_ARRAY
:
670 case GL_NORMAL_ARRAY
:
673 case GL_TEXTURE_COORD_ARRAY
:
674 case GL_EDGE_FLAG_ARRAY
:
675 case GL_FOG_COORDINATE_ARRAY_EXT
:
676 case GL_SECONDARY_COLOR_ARRAY_EXT
:
677 client_state( ctx
, cap
, state
);
680 /* GL_HP_occlusion_test */
681 case GL_OCCLUSION_TEST_HP
:
682 CHECK_EXTENSION(HP_occlusion_test
, cap
);
683 if (ctx
->Depth
.OcclusionTest
== state
)
685 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
686 ctx
->Depth
.OcclusionTest
= state
;
688 ctx
->OcclusionResult
= ctx
->OcclusionResultSaved
;
690 ctx
->OcclusionResultSaved
= ctx
->OcclusionResult
;
693 /* GL_SGIS_pixel_texture */
694 case GL_PIXEL_TEXTURE_SGIS
:
695 CHECK_EXTENSION(SGIS_pixel_texture
, cap
);
696 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
698 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
699 ctx
->Pixel
.PixelTextureEnabled
= state
;
702 /* GL_SGIX_pixel_texture */
703 case GL_PIXEL_TEX_GEN_SGIX
:
704 CHECK_EXTENSION(SGIX_pixel_texture
, cap
);
705 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
707 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
708 ctx
->Pixel
.PixelTextureEnabled
= state
;
711 /* GL_SGI_color_table */
712 case GL_COLOR_TABLE_SGI
:
713 CHECK_EXTENSION(SGI_color_table
, cap
);
714 if (ctx
->Pixel
.ColorTableEnabled
== state
)
716 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
717 ctx
->Pixel
.ColorTableEnabled
= state
;
719 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
720 CHECK_EXTENSION(SGI_color_table
, cap
);
721 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
== state
)
723 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
724 ctx
->Pixel
.PostConvolutionColorTableEnabled
= state
;
726 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
727 CHECK_EXTENSION(SGI_color_table
, cap
);
728 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
== state
)
730 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
731 ctx
->Pixel
.PostColorMatrixColorTableEnabled
= state
;
733 case GL_TEXTURE_COLOR_TABLE_SGI
:
734 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
735 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
737 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
738 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
741 /* GL_EXT_convolution */
742 case GL_CONVOLUTION_1D
:
743 CHECK_EXTENSION(EXT_convolution
, cap
);
744 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
746 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
747 ctx
->Pixel
.Convolution1DEnabled
= state
;
749 case GL_CONVOLUTION_2D
:
750 CHECK_EXTENSION(EXT_convolution
, cap
);
751 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
753 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
754 ctx
->Pixel
.Convolution2DEnabled
= state
;
756 case GL_SEPARABLE_2D
:
757 CHECK_EXTENSION(EXT_convolution
, cap
);
758 if (ctx
->Pixel
.Separable2DEnabled
== state
)
760 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
761 ctx
->Pixel
.Separable2DEnabled
= state
;
764 /* GL_ARB_texture_cube_map */
765 case GL_TEXTURE_CUBE_MAP_ARB
:
767 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
768 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
769 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_CUBE_BIT
;
770 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
772 newenabled
|= TEXTURE_CUBE_BIT
;
773 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
775 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
776 texUnit
->Enabled
= newenabled
;
780 /* GL_EXT_secondary_color */
781 case GL_COLOR_SUM_EXT
:
782 CHECK_EXTENSION(EXT_secondary_color
, cap
);
783 if (ctx
->Fog
.ColorSumEnabled
== state
)
785 FLUSH_VERTICES(ctx
, _NEW_FOG
);
786 ctx
->Fog
.ColorSumEnabled
= state
;
789 /* GL_ARB_multisample */
790 case GL_MULTISAMPLE_ARB
:
791 CHECK_EXTENSION(ARB_multisample
, cap
);
792 if (ctx
->Multisample
.Enabled
== state
)
794 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
795 ctx
->Multisample
.Enabled
= state
;
797 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
798 CHECK_EXTENSION(ARB_multisample
, cap
);
799 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
801 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
802 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
804 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
805 CHECK_EXTENSION(ARB_multisample
, cap
);
806 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
808 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
809 ctx
->Multisample
.SampleAlphaToOne
= state
;
811 case GL_SAMPLE_COVERAGE_ARB
:
812 CHECK_EXTENSION(ARB_multisample
, cap
);
813 if (ctx
->Multisample
.SampleCoverage
== state
)
815 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
816 ctx
->Multisample
.SampleCoverage
= state
;
818 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
819 CHECK_EXTENSION(ARB_multisample
, cap
);
820 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
822 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
823 ctx
->Multisample
.SampleCoverageInvert
= state
;
826 /* GL_IBM_rasterpos_clip */
827 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
828 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
829 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
831 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
832 ctx
->Transform
.RasterPositionUnclipped
= state
;
835 /* GL_NV_point_sprite */
836 case GL_POINT_SPRITE_NV
:
837 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
838 if (ctx
->Point
.PointSprite
== state
)
840 FLUSH_VERTICES(ctx
, _NEW_POINT
);
841 ctx
->Point
.PointSprite
= state
;
844 #if FEATURE_NV_vertex_program
845 case GL_VERTEX_PROGRAM_NV
:
846 CHECK_EXTENSION(NV_vertex_program
, cap
);
847 if (ctx
->VertexProgram
.Enabled
== state
)
849 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
850 ctx
->VertexProgram
.Enabled
= state
;
852 case GL_VERTEX_PROGRAM_POINT_SIZE_NV
:
853 CHECK_EXTENSION(NV_vertex_program
, cap
);
854 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
856 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
857 ctx
->VertexProgram
.PointSizeEnabled
= state
;
859 case GL_VERTEX_PROGRAM_TWO_SIDE_NV
:
860 CHECK_EXTENSION(NV_vertex_program
, cap
);
861 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
863 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
864 ctx
->VertexProgram
.TwoSideEnabled
= state
;
866 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
867 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
868 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
869 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
870 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
871 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
872 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
873 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
874 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
875 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
876 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
877 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
878 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
879 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
880 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
881 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
882 CHECK_EXTENSION(NV_vertex_program
, cap
);
884 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
885 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
886 ctx
->Eval
.Map1Attrib
[map
] = state
;
889 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
890 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
891 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
892 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
893 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
894 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
895 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
896 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
897 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
898 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
899 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
900 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
901 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
902 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
903 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
904 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
905 CHECK_EXTENSION(NV_vertex_program
, cap
);
907 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
908 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
909 ctx
->Eval
.Map2Attrib
[map
] = state
;
912 #endif /* FEATURE_NV_vertex_program */
914 #if FEATURE_NV_fragment_program
915 case GL_FRAGMENT_PROGRAM_NV
:
916 CHECK_EXTENSION(NV_fragment_program
, cap
);
917 if (ctx
->FragmentProgram
.Enabled
== state
)
919 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
920 ctx
->FragmentProgram
.Enabled
= state
;
922 #endif /* FEATURE_NV_fragment_program */
924 /* GL_NV_texture_rectangle */
925 case GL_TEXTURE_RECTANGLE_NV
:
926 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
928 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
929 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
930 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_RECT_BIT
;
931 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
933 newenabled
|= TEXTURE_RECT_BIT
;
934 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
936 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
937 texUnit
->Enabled
= newenabled
;
941 /* GL_EXT_stencil_two_side */
942 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
943 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
944 if (ctx
->Stencil
.TestTwoSide
== state
)
946 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
947 ctx
->Stencil
.TestTwoSide
= state
;
950 #if FEATURE_ARB_fragment_program
951 case GL_FRAGMENT_PROGRAM_ARB
:
952 CHECK_EXTENSION(ARB_fragment_program
, cap
);
953 if (ctx
->FragmentProgram
.Enabled
== state
)
955 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
956 ctx
->FragmentProgram
.Enabled
= state
;
958 #endif /* FEATURE_ARB_fragment_program */
960 /* GL_EXT_depth_bounds_test */
961 case GL_DEPTH_BOUNDS_TEST_EXT
:
962 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
963 if (state
&& ctx
->Visual
.depthBits
==0) {
965 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
968 if (ctx
->Depth
.BoundsTest
== state
)
970 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
971 ctx
->Depth
.BoundsTest
= state
;
974 /* GL_MESA_program_debug */
975 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
976 CHECK_EXTENSION(MESA_program_debug
, cap
);
977 ctx
->FragmentProgram
.CallbackEnabled
= state
;
979 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
980 CHECK_EXTENSION(MESA_program_debug
, cap
);
981 ctx
->VertexProgram
.CallbackEnabled
= state
;
985 _mesa_error(ctx
, GL_INVALID_ENUM
,
986 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
990 if (ctx
->Driver
.Enable
) {
991 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
997 * Enable GL capability.
999 * \param cap capability.
1003 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1004 * calls _mesa_set_enable().
1007 _mesa_Enable( GLenum cap
)
1009 GET_CURRENT_CONTEXT(ctx
);
1010 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1012 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1017 * Disable GL capability.
1019 * \param cap capability.
1023 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1024 * calls _mesa_set_enable().
1027 _mesa_Disable( GLenum cap
)
1029 GET_CURRENT_CONTEXT(ctx
);
1030 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1032 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1036 #undef CHECK_EXTENSION
1037 #define CHECK_EXTENSION(EXTNAME) \
1038 if (!ctx->Extensions.EXTNAME) { \
1039 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1045 * Test whether a capability is enabled.
1047 * \param cap capability.
1049 * Returns the state of the specified capability from the current GL context.
1050 * For the capabilities associated with extensions verifies that those
1051 * extensions are effectively present before reporting.
1053 GLboolean GLAPIENTRY
1054 _mesa_IsEnabled( GLenum cap
)
1056 GET_CURRENT_CONTEXT(ctx
);
1059 return ctx
->Color
.AlphaEnabled
;
1060 case GL_AUTO_NORMAL
:
1061 return ctx
->Eval
.AutoNormal
;
1063 return ctx
->Color
.BlendEnabled
;
1064 case GL_CLIP_PLANE0
:
1065 case GL_CLIP_PLANE1
:
1066 case GL_CLIP_PLANE2
:
1067 case GL_CLIP_PLANE3
:
1068 case GL_CLIP_PLANE4
:
1069 case GL_CLIP_PLANE5
:
1070 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1071 case GL_COLOR_MATERIAL
:
1072 return ctx
->Light
.ColorMaterialEnabled
;
1074 return ctx
->Polygon
.CullFlag
;
1076 return ctx
->Depth
.Test
;
1078 return ctx
->Color
.DitherFlag
;
1080 return ctx
->Fog
.Enabled
;
1082 return ctx
->Light
.Enabled
;
1091 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1092 case GL_LINE_SMOOTH
:
1093 return ctx
->Line
.SmoothFlag
;
1094 case GL_LINE_STIPPLE
:
1095 return ctx
->Line
.StippleFlag
;
1096 case GL_INDEX_LOGIC_OP
:
1097 return ctx
->Color
.IndexLogicOpEnabled
;
1098 case GL_COLOR_LOGIC_OP
:
1099 return ctx
->Color
.ColorLogicOpEnabled
;
1100 case GL_MAP1_COLOR_4
:
1101 return ctx
->Eval
.Map1Color4
;
1103 return ctx
->Eval
.Map1Index
;
1104 case GL_MAP1_NORMAL
:
1105 return ctx
->Eval
.Map1Normal
;
1106 case GL_MAP1_TEXTURE_COORD_1
:
1107 return ctx
->Eval
.Map1TextureCoord1
;
1108 case GL_MAP1_TEXTURE_COORD_2
:
1109 return ctx
->Eval
.Map1TextureCoord2
;
1110 case GL_MAP1_TEXTURE_COORD_3
:
1111 return ctx
->Eval
.Map1TextureCoord3
;
1112 case GL_MAP1_TEXTURE_COORD_4
:
1113 return ctx
->Eval
.Map1TextureCoord4
;
1114 case GL_MAP1_VERTEX_3
:
1115 return ctx
->Eval
.Map1Vertex3
;
1116 case GL_MAP1_VERTEX_4
:
1117 return ctx
->Eval
.Map1Vertex4
;
1118 case GL_MAP2_COLOR_4
:
1119 return ctx
->Eval
.Map2Color4
;
1121 return ctx
->Eval
.Map2Index
;
1122 case GL_MAP2_NORMAL
:
1123 return ctx
->Eval
.Map2Normal
;
1124 case GL_MAP2_TEXTURE_COORD_1
:
1125 return ctx
->Eval
.Map2TextureCoord1
;
1126 case GL_MAP2_TEXTURE_COORD_2
:
1127 return ctx
->Eval
.Map2TextureCoord2
;
1128 case GL_MAP2_TEXTURE_COORD_3
:
1129 return ctx
->Eval
.Map2TextureCoord3
;
1130 case GL_MAP2_TEXTURE_COORD_4
:
1131 return ctx
->Eval
.Map2TextureCoord4
;
1132 case GL_MAP2_VERTEX_3
:
1133 return ctx
->Eval
.Map2Vertex3
;
1134 case GL_MAP2_VERTEX_4
:
1135 return ctx
->Eval
.Map2Vertex4
;
1137 return ctx
->Transform
.Normalize
;
1138 case GL_POINT_SMOOTH
:
1139 return ctx
->Point
.SmoothFlag
;
1140 case GL_POLYGON_SMOOTH
:
1141 return ctx
->Polygon
.SmoothFlag
;
1142 case GL_POLYGON_STIPPLE
:
1143 return ctx
->Polygon
.StippleFlag
;
1144 case GL_POLYGON_OFFSET_POINT
:
1145 return ctx
->Polygon
.OffsetPoint
;
1146 case GL_POLYGON_OFFSET_LINE
:
1147 return ctx
->Polygon
.OffsetLine
;
1148 case GL_POLYGON_OFFSET_FILL
:
1149 /*case GL_POLYGON_OFFSET_EXT:*/
1150 return ctx
->Polygon
.OffsetFill
;
1151 case GL_RESCALE_NORMAL_EXT
:
1152 return ctx
->Transform
.RescaleNormals
;
1153 case GL_SCISSOR_TEST
:
1154 return ctx
->Scissor
.Enabled
;
1155 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1156 return ctx
->Texture
.SharedPalette
;
1157 case GL_STENCIL_TEST
:
1158 return ctx
->Stencil
.Enabled
;
1161 const struct gl_texture_unit
*texUnit
;
1162 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1163 return (texUnit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
;
1167 const struct gl_texture_unit
*texUnit
;
1168 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1169 return (texUnit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
;
1173 const struct gl_texture_unit
*texUnit
;
1174 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1175 return (texUnit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
;
1177 case GL_TEXTURE_GEN_Q
:
1179 const struct gl_texture_unit
*texUnit
;
1180 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1181 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1183 case GL_TEXTURE_GEN_R
:
1185 const struct gl_texture_unit
*texUnit
;
1186 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1187 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1189 case GL_TEXTURE_GEN_S
:
1191 const struct gl_texture_unit
*texUnit
;
1192 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1193 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1195 case GL_TEXTURE_GEN_T
:
1197 const struct gl_texture_unit
*texUnit
;
1198 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1199 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1205 case GL_VERTEX_ARRAY
:
1206 return (ctx
->Array
.Vertex
.Enabled
!= 0);
1207 case GL_NORMAL_ARRAY
:
1208 return (ctx
->Array
.Normal
.Enabled
!= 0);
1209 case GL_COLOR_ARRAY
:
1210 return (ctx
->Array
.Color
.Enabled
!= 0);
1211 case GL_INDEX_ARRAY
:
1212 return (ctx
->Array
.Index
.Enabled
!= 0);
1213 case GL_TEXTURE_COORD_ARRAY
:
1214 return (ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1215 case GL_EDGE_FLAG_ARRAY
:
1216 return (ctx
->Array
.EdgeFlag
.Enabled
!= 0);
1217 case GL_FOG_COORDINATE_ARRAY_EXT
:
1218 CHECK_EXTENSION(EXT_fog_coord
);
1219 return (ctx
->Array
.FogCoord
.Enabled
!= 0);
1220 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1221 CHECK_EXTENSION(EXT_secondary_color
);
1222 return (ctx
->Array
.SecondaryColor
.Enabled
!= 0);
1224 /* GL_EXT_histogram */
1226 CHECK_EXTENSION(EXT_histogram
);
1227 return ctx
->Pixel
.HistogramEnabled
;
1229 CHECK_EXTENSION(EXT_histogram
);
1230 return ctx
->Pixel
.MinMaxEnabled
;
1232 /* GL_HP_occlusion_test */
1233 case GL_OCCLUSION_TEST_HP
:
1234 CHECK_EXTENSION(HP_occlusion_test
);
1235 return ctx
->Depth
.OcclusionTest
;
1237 /* GL_SGIS_pixel_texture */
1238 case GL_PIXEL_TEXTURE_SGIS
:
1239 CHECK_EXTENSION(SGIS_pixel_texture
);
1240 return ctx
->Pixel
.PixelTextureEnabled
;
1242 /* GL_SGIX_pixel_texture */
1243 case GL_PIXEL_TEX_GEN_SGIX
:
1244 CHECK_EXTENSION(SGIX_pixel_texture
);
1245 return ctx
->Pixel
.PixelTextureEnabled
;
1247 /* GL_SGI_color_table */
1248 case GL_COLOR_TABLE_SGI
:
1249 CHECK_EXTENSION(SGI_color_table
);
1250 return ctx
->Pixel
.ColorTableEnabled
;
1251 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1252 CHECK_EXTENSION(SGI_color_table
);
1253 return ctx
->Pixel
.PostConvolutionColorTableEnabled
;
1254 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1255 CHECK_EXTENSION(SGI_color_table
);
1256 return ctx
->Pixel
.PostColorMatrixColorTableEnabled
;
1258 /* GL_SGI_texture_color_table */
1259 case GL_TEXTURE_COLOR_TABLE_SGI
:
1260 CHECK_EXTENSION(SGI_texture_color_table
);
1261 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1263 /* GL_EXT_convolution */
1264 case GL_CONVOLUTION_1D
:
1265 CHECK_EXTENSION(EXT_convolution
);
1266 return ctx
->Pixel
.Convolution1DEnabled
;
1267 case GL_CONVOLUTION_2D
:
1268 CHECK_EXTENSION(EXT_convolution
);
1269 return ctx
->Pixel
.Convolution2DEnabled
;
1270 case GL_SEPARABLE_2D
:
1271 CHECK_EXTENSION(EXT_convolution
);
1272 return ctx
->Pixel
.Separable2DEnabled
;
1274 /* GL_ARB_texture_cube_map */
1275 case GL_TEXTURE_CUBE_MAP_ARB
:
1276 CHECK_EXTENSION(ARB_texture_cube_map
);
1278 const struct gl_texture_unit
*texUnit
;
1279 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1280 return (texUnit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
;
1283 /* GL_ARB_multisample */
1284 case GL_MULTISAMPLE_ARB
:
1285 CHECK_EXTENSION(ARB_multisample
);
1286 return ctx
->Multisample
.Enabled
;
1287 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1288 CHECK_EXTENSION(ARB_multisample
);
1289 return ctx
->Multisample
.SampleAlphaToCoverage
;
1290 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1291 CHECK_EXTENSION(ARB_multisample
);
1292 return ctx
->Multisample
.SampleAlphaToOne
;
1293 case GL_SAMPLE_COVERAGE_ARB
:
1294 CHECK_EXTENSION(ARB_multisample
);
1295 return ctx
->Multisample
.SampleCoverage
;
1296 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1297 CHECK_EXTENSION(ARB_multisample
);
1298 return ctx
->Multisample
.SampleCoverageInvert
;
1300 /* GL_IBM_rasterpos_clip */
1301 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1302 CHECK_EXTENSION(IBM_rasterpos_clip
);
1303 return ctx
->Transform
.RasterPositionUnclipped
;
1305 /* GL_NV_point_sprite */
1306 case GL_POINT_SPRITE_NV
:
1307 return ctx
->Point
.PointSprite
;
1309 #if FEATURE_NV_vertex_program
1310 case GL_VERTEX_PROGRAM_NV
:
1311 CHECK_EXTENSION(NV_vertex_program
);
1312 return ctx
->VertexProgram
.Enabled
;
1313 case GL_VERTEX_PROGRAM_POINT_SIZE_NV
:
1314 CHECK_EXTENSION(NV_vertex_program
);
1315 return ctx
->VertexProgram
.PointSizeEnabled
;
1316 case GL_VERTEX_PROGRAM_TWO_SIDE_NV
:
1317 CHECK_EXTENSION(NV_vertex_program
);
1318 return ctx
->VertexProgram
.TwoSideEnabled
;
1319 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1320 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1321 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1322 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1323 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1324 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1325 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1326 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1327 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1328 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1329 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1330 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1331 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1332 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1333 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1334 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1335 CHECK_EXTENSION(NV_vertex_program
);
1337 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1338 return (ctx
->Array
.VertexAttrib
[n
].Enabled
!= 0);
1340 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1341 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1342 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1343 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1344 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1345 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1346 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1347 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1348 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1349 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1350 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1351 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1352 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1353 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1354 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1355 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1356 CHECK_EXTENSION(NV_vertex_program
);
1358 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1359 return ctx
->Eval
.Map1Attrib
[map
];
1361 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1362 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1363 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1364 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1365 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1366 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1367 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1368 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1369 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1370 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1371 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1372 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1373 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1374 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1375 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1376 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1377 CHECK_EXTENSION(NV_vertex_program
);
1379 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1380 return ctx
->Eval
.Map2Attrib
[map
];
1382 #endif /* FEATURE_NV_vertex_program */
1384 #if FEATURE_NV_fragment_program
1385 case GL_FRAGMENT_PROGRAM_NV
:
1386 CHECK_EXTENSION(NV_fragment_program
);
1387 return ctx
->FragmentProgram
.Enabled
;
1388 #endif /* FEATURE_NV_fragment_program */
1390 /* GL_NV_texture_rectangle */
1391 case GL_TEXTURE_RECTANGLE_NV
:
1392 CHECK_EXTENSION(NV_texture_rectangle
);
1394 const struct gl_texture_unit
*texUnit
;
1395 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1396 return (texUnit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
;
1399 /* GL_EXT_stencil_two_side */
1400 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1401 CHECK_EXTENSION(EXT_stencil_two_side
);
1402 return ctx
->Stencil
.TestTwoSide
;
1404 #if FEATURE_ARB_fragment_program
1405 case GL_FRAGMENT_PROGRAM_ARB
:
1406 return ctx
->FragmentProgram
.Enabled
;
1407 #endif /* FEATURE_ARB_fragment_program */
1409 /* GL_EXT_depth_bounds_test */
1410 case GL_DEPTH_BOUNDS_TEST_EXT
:
1411 CHECK_EXTENSION(EXT_depth_bounds_test
);
1412 return ctx
->Depth
.BoundsTest
;
1414 /* GL_MESA_program_debug */
1415 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1416 CHECK_EXTENSION(MESA_program_debug
);
1417 return ctx
->FragmentProgram
.CallbackEnabled
;
1418 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1419 CHECK_EXTENSION(MESA_program_debug
);
1420 return ctx
->VertexProgram
.CallbackEnabled
;
1423 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);