3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2004 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); \
53 client_state( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
60 var
= &ctx
->Array
.Vertex
.Enabled
;
61 flag
= _NEW_ARRAY_VERTEX
;
64 var
= &ctx
->Array
.Normal
.Enabled
;
65 flag
= _NEW_ARRAY_NORMAL
;
68 var
= &ctx
->Array
.Color
.Enabled
;
69 flag
= _NEW_ARRAY_COLOR0
;
72 var
= &ctx
->Array
.Index
.Enabled
;
73 flag
= _NEW_ARRAY_INDEX
;
75 case GL_TEXTURE_COORD_ARRAY
:
76 var
= &ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
77 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
79 case GL_EDGE_FLAG_ARRAY
:
80 var
= &ctx
->Array
.EdgeFlag
.Enabled
;
81 flag
= _NEW_ARRAY_EDGEFLAG
;
83 case GL_FOG_COORDINATE_ARRAY_EXT
:
84 var
= &ctx
->Array
.FogCoord
.Enabled
;
85 flag
= _NEW_ARRAY_FOGCOORD
;
87 case GL_SECONDARY_COLOR_ARRAY_EXT
:
88 var
= &ctx
->Array
.SecondaryColor
.Enabled
;
89 flag
= _NEW_ARRAY_COLOR1
;
92 #if FEATURE_NV_vertex_program
93 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
94 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
95 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
96 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
97 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
98 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
99 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
100 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
101 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
102 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
103 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
109 CHECK_EXTENSION(NV_vertex_program
, cap
);
111 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
112 var
= &ctx
->Array
.VertexAttrib
[n
].Enabled
;
113 flag
= _NEW_ARRAY_ATTRIB(n
);
116 #endif /* FEATURE_NV_vertex_program */
119 _mesa_error( ctx
, GL_INVALID_ENUM
,
120 "glEnable/DisableClientState(0x%x)", cap
);
127 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
128 ctx
->Array
.NewState
|= flag
;
132 ctx
->Array
._Enabled
|= flag
;
134 ctx
->Array
._Enabled
&= ~flag
;
136 if (ctx
->Driver
.Enable
) {
137 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
143 * Enable GL capability.
145 * \param cap capability.
149 * Get's the current context, assures that we're outside glBegin()/glEnd() and
150 * calls client_state().
153 _mesa_EnableClientState( GLenum cap
)
155 GET_CURRENT_CONTEXT(ctx
);
156 ASSERT_OUTSIDE_BEGIN_END(ctx
);
157 client_state( ctx
, cap
, GL_TRUE
);
162 * Disable GL capability.
164 * \param cap capability.
168 * Get's the current context, assures that we're outside glBegin()/glEnd() and
169 * calls client_state().
172 _mesa_DisableClientState( GLenum cap
)
174 GET_CURRENT_CONTEXT(ctx
);
175 ASSERT_OUTSIDE_BEGIN_END(ctx
);
176 client_state( ctx
, cap
, GL_FALSE
);
180 #undef CHECK_EXTENSION
181 #define CHECK_EXTENSION(EXTNAME, CAP) \
182 if (!ctx->Extensions.EXTNAME) { \
183 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
184 state ? "Enable" : "Disable", CAP); \
188 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
189 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
190 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
191 state ? "Enable" : "Disable", CAP); \
198 * Perform glEnable() and glDisable() calls.
200 * \param ctx GL context.
201 * \param cap capability.
202 * \param state whether to enable or disable the specified capability.
204 * Updates the current context and flushes the vertices as needed. For
205 * capabilities associated with extensions it verifies that those extensions
206 * are effectivly present before updating. Notifies the driver via
207 * dd_function_table::Enable.
209 void _mesa_set_enable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
211 if (MESA_VERBOSE
& VERBOSE_API
)
212 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
213 state
? "glEnable" : "glDisable",
214 _mesa_lookup_enum_by_nr(cap
),
219 if (ctx
->Color
.AlphaEnabled
== state
)
221 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
222 ctx
->Color
.AlphaEnabled
= state
;
225 if (ctx
->Eval
.AutoNormal
== state
)
227 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
228 ctx
->Eval
.AutoNormal
= state
;
231 if (ctx
->Color
.BlendEnabled
== state
)
233 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
234 ctx
->Color
.BlendEnabled
= state
;
235 /* This is needed to support 1.1's RGB logic ops AND
236 * 1.0's blending logicops.
238 ctx
->Color
._LogicOpEnabled
=
239 (ctx
->Color
.ColorLogicOpEnabled
||
240 (state
&& ctx
->Color
.BlendEquationRGB
== GL_LOGIC_OP
));
250 const GLuint p
= cap
- GL_CLIP_PLANE0
;
252 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
255 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
258 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
260 if (ctx
->ProjectionMatrixStack
.Top
->flags
& MAT_DIRTY
)
261 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
263 /* This derived state also calculated in clip.c and
264 * from _mesa_update_state() on changes to EyeUserPlane
265 * and ctx->ProjectionMatrix respectively.
267 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
268 ctx
->Transform
.EyeUserPlane
[p
],
269 ctx
->ProjectionMatrixStack
.Top
->inv
);
272 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
277 case GL_COLOR_MATERIAL
:
278 if (ctx
->Light
.ColorMaterialEnabled
== state
)
280 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
281 FLUSH_CURRENT(ctx
, 0);
282 ctx
->Light
.ColorMaterialEnabled
= state
;
284 _mesa_update_color_material( ctx
,
285 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
289 if (ctx
->Polygon
.CullFlag
== state
)
291 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
292 ctx
->Polygon
.CullFlag
= state
;
295 case GL_CULL_VERTEX_EXT
:
296 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
297 if (ctx
->Transform
.CullVertexFlag
== state
)
299 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
300 ctx
->Transform
.CullVertexFlag
= state
;
304 if (state
&& ctx
->Visual
.depthBits
==0) {
305 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
308 if (ctx
->Depth
.Test
==state
)
310 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
311 ctx
->Depth
.Test
= state
;
315 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
317 if (ctx
->Color
.DitherFlag
==state
)
319 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
320 ctx
->Color
.DitherFlag
= state
;
323 if (ctx
->Fog
.Enabled
==state
)
325 FLUSH_VERTICES(ctx
, _NEW_FOG
);
326 ctx
->Fog
.Enabled
= state
;
329 CHECK_EXTENSION(EXT_histogram
, cap
);
330 if (ctx
->Pixel
.HistogramEnabled
== state
)
332 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
333 ctx
->Pixel
.HistogramEnabled
= state
;
343 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
345 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
346 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
348 insert_at_tail(&ctx
->Light
.EnabledList
,
349 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
352 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
356 if (ctx
->Light
.Enabled
== state
)
358 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
359 ctx
->Light
.Enabled
= state
;
361 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
362 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
364 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
368 if (ctx
->Line
.SmoothFlag
== state
)
370 FLUSH_VERTICES(ctx
, _NEW_LINE
);
371 ctx
->Line
.SmoothFlag
= state
;
372 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
374 case GL_LINE_STIPPLE
:
375 if (ctx
->Line
.StippleFlag
== state
)
377 FLUSH_VERTICES(ctx
, _NEW_LINE
);
378 ctx
->Line
.StippleFlag
= state
;
379 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
381 case GL_INDEX_LOGIC_OP
:
382 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
384 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
385 ctx
->Color
.IndexLogicOpEnabled
= state
;
387 case GL_COLOR_LOGIC_OP
:
388 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
391 ctx
->Color
.ColorLogicOpEnabled
= state
;
392 /* This is needed to support 1.1's RGB logic ops AND
393 * 1.0's blending logicops.
395 ctx
->Color
._LogicOpEnabled
=
396 (state
|| (ctx
->Color
.BlendEnabled
&&
397 ctx
->Color
.BlendEquationRGB
== GL_LOGIC_OP
));
399 case GL_MAP1_COLOR_4
:
400 if (ctx
->Eval
.Map1Color4
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
403 ctx
->Eval
.Map1Color4
= state
;
406 if (ctx
->Eval
.Map1Index
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
409 ctx
->Eval
.Map1Index
= state
;
412 if (ctx
->Eval
.Map1Normal
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
415 ctx
->Eval
.Map1Normal
= state
;
417 case GL_MAP1_TEXTURE_COORD_1
:
418 if (ctx
->Eval
.Map1TextureCoord1
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
421 ctx
->Eval
.Map1TextureCoord1
= state
;
423 case GL_MAP1_TEXTURE_COORD_2
:
424 if (ctx
->Eval
.Map1TextureCoord2
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
427 ctx
->Eval
.Map1TextureCoord2
= state
;
429 case GL_MAP1_TEXTURE_COORD_3
:
430 if (ctx
->Eval
.Map1TextureCoord3
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
433 ctx
->Eval
.Map1TextureCoord3
= state
;
435 case GL_MAP1_TEXTURE_COORD_4
:
436 if (ctx
->Eval
.Map1TextureCoord4
== state
)
438 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
439 ctx
->Eval
.Map1TextureCoord4
= state
;
441 case GL_MAP1_VERTEX_3
:
442 if (ctx
->Eval
.Map1Vertex3
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
445 ctx
->Eval
.Map1Vertex3
= state
;
447 case GL_MAP1_VERTEX_4
:
448 if (ctx
->Eval
.Map1Vertex4
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
451 ctx
->Eval
.Map1Vertex4
= state
;
453 case GL_MAP2_COLOR_4
:
454 if (ctx
->Eval
.Map2Color4
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 ctx
->Eval
.Map2Color4
= state
;
460 if (ctx
->Eval
.Map2Index
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map2Index
= state
;
466 if (ctx
->Eval
.Map2Normal
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map2Normal
= state
;
471 case GL_MAP2_TEXTURE_COORD_1
:
472 if (ctx
->Eval
.Map2TextureCoord1
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map2TextureCoord1
= state
;
477 case GL_MAP2_TEXTURE_COORD_2
:
478 if (ctx
->Eval
.Map2TextureCoord2
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map2TextureCoord2
= state
;
483 case GL_MAP2_TEXTURE_COORD_3
:
484 if (ctx
->Eval
.Map2TextureCoord3
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
487 ctx
->Eval
.Map2TextureCoord3
= state
;
489 case GL_MAP2_TEXTURE_COORD_4
:
490 if (ctx
->Eval
.Map2TextureCoord4
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
493 ctx
->Eval
.Map2TextureCoord4
= state
;
495 case GL_MAP2_VERTEX_3
:
496 if (ctx
->Eval
.Map2Vertex3
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map2Vertex3
= state
;
501 case GL_MAP2_VERTEX_4
:
502 if (ctx
->Eval
.Map2Vertex4
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
505 ctx
->Eval
.Map2Vertex4
= state
;
508 if (ctx
->Pixel
.MinMaxEnabled
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
511 ctx
->Pixel
.MinMaxEnabled
= state
;
514 if (ctx
->Transform
.Normalize
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
517 ctx
->Transform
.Normalize
= state
;
519 case GL_POINT_SMOOTH
:
520 if (ctx
->Point
.SmoothFlag
==state
)
522 FLUSH_VERTICES(ctx
, _NEW_POINT
);
523 ctx
->Point
.SmoothFlag
= state
;
524 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
526 case GL_POLYGON_SMOOTH
:
527 if (ctx
->Polygon
.SmoothFlag
==state
)
529 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
530 ctx
->Polygon
.SmoothFlag
= state
;
531 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
533 case GL_POLYGON_STIPPLE
:
534 if (ctx
->Polygon
.StippleFlag
==state
)
536 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
537 ctx
->Polygon
.StippleFlag
= state
;
538 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
540 case GL_POLYGON_OFFSET_POINT
:
541 if (ctx
->Polygon
.OffsetPoint
==state
)
543 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
544 ctx
->Polygon
.OffsetPoint
= state
;
546 case GL_POLYGON_OFFSET_LINE
:
547 if (ctx
->Polygon
.OffsetLine
==state
)
549 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
550 ctx
->Polygon
.OffsetLine
= state
;
552 case GL_POLYGON_OFFSET_FILL
:
553 /*case GL_POLYGON_OFFSET_EXT:*/
554 if (ctx
->Polygon
.OffsetFill
==state
)
556 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
557 ctx
->Polygon
.OffsetFill
= state
;
559 case GL_RESCALE_NORMAL_EXT
:
560 if (ctx
->Transform
.RescaleNormals
== state
)
562 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
563 ctx
->Transform
.RescaleNormals
= state
;
565 case GL_SCISSOR_TEST
:
566 if (ctx
->Scissor
.Enabled
==state
)
568 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
569 ctx
->Scissor
.Enabled
= state
;
571 case GL_SHARED_TEXTURE_PALETTE_EXT
:
572 if (ctx
->Texture
.SharedPalette
== state
)
574 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
575 ctx
->Texture
.SharedPalette
= state
;
577 case GL_STENCIL_TEST
:
578 if (state
&& ctx
->Visual
.stencilBits
==0) {
580 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
583 if (ctx
->Stencil
.Enabled
==state
)
585 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
586 ctx
->Stencil
.Enabled
= state
;
588 case GL_TEXTURE_1D
: {
589 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
590 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
591 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_1D_BIT
;
593 newenabled
|= TEXTURE_1D_BIT
;
594 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
596 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
597 texUnit
->Enabled
= newenabled
;
600 case GL_TEXTURE_2D
: {
601 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
602 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
603 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_2D_BIT
;
605 newenabled
|= TEXTURE_2D_BIT
;
606 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
608 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
609 texUnit
->Enabled
= newenabled
;
612 case GL_TEXTURE_3D
: {
613 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
614 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
615 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_3D_BIT
;
617 newenabled
|= TEXTURE_3D_BIT
;
618 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
620 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
621 texUnit
->Enabled
= newenabled
;
624 case GL_TEXTURE_GEN_Q
: {
625 GLuint unit
= ctx
->Texture
.CurrentUnit
;
626 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
627 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
630 if (texUnit
->TexGenEnabled
== newenabled
)
632 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
633 texUnit
->TexGenEnabled
= newenabled
;
636 case GL_TEXTURE_GEN_R
: {
637 GLuint unit
= ctx
->Texture
.CurrentUnit
;
638 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
639 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
642 if (texUnit
->TexGenEnabled
== newenabled
)
644 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
645 texUnit
->TexGenEnabled
= newenabled
;
648 case GL_TEXTURE_GEN_S
: {
649 GLuint unit
= ctx
->Texture
.CurrentUnit
;
650 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
651 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
654 if (texUnit
->TexGenEnabled
== newenabled
)
656 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
657 texUnit
->TexGenEnabled
= newenabled
;
660 case GL_TEXTURE_GEN_T
: {
661 GLuint unit
= ctx
->Texture
.CurrentUnit
;
662 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
663 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
666 if (texUnit
->TexGenEnabled
== newenabled
)
668 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
669 texUnit
->TexGenEnabled
= newenabled
;
676 case GL_VERTEX_ARRAY
:
677 case GL_NORMAL_ARRAY
:
680 case GL_TEXTURE_COORD_ARRAY
:
681 case GL_EDGE_FLAG_ARRAY
:
682 case GL_FOG_COORDINATE_ARRAY_EXT
:
683 case GL_SECONDARY_COLOR_ARRAY_EXT
:
684 client_state( ctx
, cap
, state
);
687 /* GL_HP_occlusion_test */
688 case GL_OCCLUSION_TEST_HP
:
689 CHECK_EXTENSION(HP_occlusion_test
, cap
);
690 if (ctx
->Depth
.OcclusionTest
== state
)
692 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
693 ctx
->Depth
.OcclusionTest
= state
;
695 ctx
->OcclusionResult
= ctx
->OcclusionResultSaved
;
697 ctx
->OcclusionResultSaved
= ctx
->OcclusionResult
;
700 /* GL_SGIS_pixel_texture */
701 case GL_PIXEL_TEXTURE_SGIS
:
702 CHECK_EXTENSION(SGIS_pixel_texture
, cap
);
703 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
705 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
706 ctx
->Pixel
.PixelTextureEnabled
= state
;
709 /* GL_SGIX_pixel_texture */
710 case GL_PIXEL_TEX_GEN_SGIX
:
711 CHECK_EXTENSION(SGIX_pixel_texture
, cap
);
712 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
714 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
715 ctx
->Pixel
.PixelTextureEnabled
= state
;
718 /* GL_SGI_color_table */
719 case GL_COLOR_TABLE_SGI
:
720 CHECK_EXTENSION(SGI_color_table
, cap
);
721 if (ctx
->Pixel
.ColorTableEnabled
== state
)
723 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
724 ctx
->Pixel
.ColorTableEnabled
= state
;
726 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
727 CHECK_EXTENSION(SGI_color_table
, cap
);
728 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
== state
)
730 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
731 ctx
->Pixel
.PostConvolutionColorTableEnabled
= state
;
733 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
734 CHECK_EXTENSION(SGI_color_table
, cap
);
735 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
== state
)
737 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
738 ctx
->Pixel
.PostColorMatrixColorTableEnabled
= state
;
740 case GL_TEXTURE_COLOR_TABLE_SGI
:
741 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
742 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
744 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
745 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
748 /* GL_EXT_convolution */
749 case GL_CONVOLUTION_1D
:
750 CHECK_EXTENSION(EXT_convolution
, cap
);
751 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
753 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
754 ctx
->Pixel
.Convolution1DEnabled
= state
;
756 case GL_CONVOLUTION_2D
:
757 CHECK_EXTENSION(EXT_convolution
, cap
);
758 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
760 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
761 ctx
->Pixel
.Convolution2DEnabled
= state
;
763 case GL_SEPARABLE_2D
:
764 CHECK_EXTENSION(EXT_convolution
, cap
);
765 if (ctx
->Pixel
.Separable2DEnabled
== state
)
767 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
768 ctx
->Pixel
.Separable2DEnabled
= state
;
771 /* GL_ARB_texture_cube_map */
772 case GL_TEXTURE_CUBE_MAP_ARB
:
774 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
775 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
776 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_CUBE_BIT
;
777 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
779 newenabled
|= TEXTURE_CUBE_BIT
;
780 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
782 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
783 texUnit
->Enabled
= newenabled
;
787 /* GL_EXT_secondary_color */
788 case GL_COLOR_SUM_EXT
:
789 CHECK_EXTENSION(EXT_secondary_color
, cap
);
790 if (ctx
->Fog
.ColorSumEnabled
== state
)
792 FLUSH_VERTICES(ctx
, _NEW_FOG
);
793 ctx
->Fog
.ColorSumEnabled
= state
;
796 /* GL_ARB_multisample */
797 case GL_MULTISAMPLE_ARB
:
798 CHECK_EXTENSION(ARB_multisample
, cap
);
799 if (ctx
->Multisample
.Enabled
== state
)
801 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
802 ctx
->Multisample
.Enabled
= state
;
804 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
805 CHECK_EXTENSION(ARB_multisample
, cap
);
806 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
808 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
809 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
811 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
812 CHECK_EXTENSION(ARB_multisample
, cap
);
813 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
815 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
816 ctx
->Multisample
.SampleAlphaToOne
= state
;
818 case GL_SAMPLE_COVERAGE_ARB
:
819 CHECK_EXTENSION(ARB_multisample
, cap
);
820 if (ctx
->Multisample
.SampleCoverage
== state
)
822 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
823 ctx
->Multisample
.SampleCoverage
= state
;
825 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
826 CHECK_EXTENSION(ARB_multisample
, cap
);
827 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
829 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
830 ctx
->Multisample
.SampleCoverageInvert
= state
;
833 /* GL_IBM_rasterpos_clip */
834 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
835 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
836 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
838 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
839 ctx
->Transform
.RasterPositionUnclipped
= state
;
842 /* GL_NV_point_sprite */
843 case GL_POINT_SPRITE_NV
:
844 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
845 if (ctx
->Point
.PointSprite
== state
)
847 FLUSH_VERTICES(ctx
, _NEW_POINT
);
848 ctx
->Point
.PointSprite
= state
;
851 #if FEATURE_NV_vertex_program
852 case GL_VERTEX_PROGRAM_NV
:
853 CHECK_EXTENSION2(NV_vertex_program
, ARB_vertex_program
, cap
);
854 if (ctx
->VertexProgram
.Enabled
== state
)
856 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
857 ctx
->VertexProgram
.Enabled
= state
;
859 case GL_VERTEX_PROGRAM_POINT_SIZE_NV
:
860 CHECK_EXTENSION2(NV_vertex_program
, ARB_vertex_program
, cap
);
861 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
863 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
864 ctx
->VertexProgram
.PointSizeEnabled
= state
;
866 case GL_VERTEX_PROGRAM_TWO_SIDE_NV
:
867 CHECK_EXTENSION2(NV_vertex_program
, ARB_vertex_program
, cap
);
868 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
870 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
871 ctx
->VertexProgram
.TwoSideEnabled
= state
;
873 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
874 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
875 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
876 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
877 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
878 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
879 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
880 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
881 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
882 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
883 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
884 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
885 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
886 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
887 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
888 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
889 CHECK_EXTENSION(NV_vertex_program
, cap
);
891 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
892 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
893 ctx
->Eval
.Map1Attrib
[map
] = state
;
896 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
897 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
898 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
899 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
900 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
901 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
902 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
903 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
904 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
905 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
906 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
907 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
908 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
909 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
910 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
911 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
912 CHECK_EXTENSION(NV_vertex_program
, cap
);
914 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
915 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
916 ctx
->Eval
.Map2Attrib
[map
] = state
;
919 #endif /* FEATURE_NV_vertex_program */
921 #if FEATURE_NV_fragment_program
922 case GL_FRAGMENT_PROGRAM_NV
:
923 CHECK_EXTENSION(NV_fragment_program
, cap
);
924 if (ctx
->FragmentProgram
.Enabled
== state
)
926 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
927 ctx
->FragmentProgram
.Enabled
= state
;
929 #endif /* FEATURE_NV_fragment_program */
931 /* GL_NV_texture_rectangle */
932 case GL_TEXTURE_RECTANGLE_NV
:
933 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
935 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
936 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
937 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_RECT_BIT
;
938 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
940 newenabled
|= TEXTURE_RECT_BIT
;
941 if (!ctx
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
943 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
944 texUnit
->Enabled
= newenabled
;
948 /* GL_EXT_stencil_two_side */
949 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
950 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
951 if (ctx
->Stencil
.TestTwoSide
== state
)
953 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
954 ctx
->Stencil
.TestTwoSide
= state
;
956 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
958 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
962 #if FEATURE_ARB_fragment_program
963 case GL_FRAGMENT_PROGRAM_ARB
:
964 CHECK_EXTENSION(ARB_fragment_program
, cap
);
965 if (ctx
->FragmentProgram
.Enabled
== state
)
967 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
968 ctx
->FragmentProgram
.Enabled
= state
;
970 #endif /* FEATURE_ARB_fragment_program */
972 /* GL_EXT_depth_bounds_test */
973 case GL_DEPTH_BOUNDS_TEST_EXT
:
974 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
975 if (state
&& ctx
->Visual
.depthBits
==0) {
977 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
980 if (ctx
->Depth
.BoundsTest
== state
)
982 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
983 ctx
->Depth
.BoundsTest
= state
;
986 /* GL_MESA_program_debug */
987 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
988 CHECK_EXTENSION(MESA_program_debug
, cap
);
989 ctx
->FragmentProgram
.CallbackEnabled
= state
;
991 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
992 CHECK_EXTENSION(MESA_program_debug
, cap
);
993 ctx
->VertexProgram
.CallbackEnabled
= state
;
996 #if FEATURE_ATI_fragment_shader
997 case GL_FRAGMENT_SHADER_ATI
:
998 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
999 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1001 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1002 ctx
->ATIFragmentShader
.Enabled
= state
;
1006 _mesa_error(ctx
, GL_INVALID_ENUM
,
1007 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
1011 if (ctx
->Driver
.Enable
) {
1012 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
1018 * Enable GL capability.
1020 * \param cap capability.
1024 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1025 * calls _mesa_set_enable().
1028 _mesa_Enable( GLenum cap
)
1030 GET_CURRENT_CONTEXT(ctx
);
1031 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1033 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1038 * Disable GL capability.
1040 * \param cap capability.
1044 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1045 * calls _mesa_set_enable().
1048 _mesa_Disable( GLenum cap
)
1050 GET_CURRENT_CONTEXT(ctx
);
1051 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1053 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1057 #undef CHECK_EXTENSION
1058 #define CHECK_EXTENSION(EXTNAME) \
1059 if (!ctx->Extensions.EXTNAME) { \
1060 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1066 * Test whether a capability is enabled.
1068 * \param cap capability.
1070 * Returns the state of the specified capability from the current GL context.
1071 * For the capabilities associated with extensions verifies that those
1072 * extensions are effectively present before reporting.
1074 GLboolean GLAPIENTRY
1075 _mesa_IsEnabled( GLenum cap
)
1077 GET_CURRENT_CONTEXT(ctx
);
1080 return ctx
->Color
.AlphaEnabled
;
1081 case GL_AUTO_NORMAL
:
1082 return ctx
->Eval
.AutoNormal
;
1084 return ctx
->Color
.BlendEnabled
;
1085 case GL_CLIP_PLANE0
:
1086 case GL_CLIP_PLANE1
:
1087 case GL_CLIP_PLANE2
:
1088 case GL_CLIP_PLANE3
:
1089 case GL_CLIP_PLANE4
:
1090 case GL_CLIP_PLANE5
:
1091 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1092 case GL_COLOR_MATERIAL
:
1093 return ctx
->Light
.ColorMaterialEnabled
;
1095 return ctx
->Polygon
.CullFlag
;
1097 return ctx
->Depth
.Test
;
1099 return ctx
->Color
.DitherFlag
;
1101 return ctx
->Fog
.Enabled
;
1103 return ctx
->Light
.Enabled
;
1112 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1113 case GL_LINE_SMOOTH
:
1114 return ctx
->Line
.SmoothFlag
;
1115 case GL_LINE_STIPPLE
:
1116 return ctx
->Line
.StippleFlag
;
1117 case GL_INDEX_LOGIC_OP
:
1118 return ctx
->Color
.IndexLogicOpEnabled
;
1119 case GL_COLOR_LOGIC_OP
:
1120 return ctx
->Color
.ColorLogicOpEnabled
;
1121 case GL_MAP1_COLOR_4
:
1122 return ctx
->Eval
.Map1Color4
;
1124 return ctx
->Eval
.Map1Index
;
1125 case GL_MAP1_NORMAL
:
1126 return ctx
->Eval
.Map1Normal
;
1127 case GL_MAP1_TEXTURE_COORD_1
:
1128 return ctx
->Eval
.Map1TextureCoord1
;
1129 case GL_MAP1_TEXTURE_COORD_2
:
1130 return ctx
->Eval
.Map1TextureCoord2
;
1131 case GL_MAP1_TEXTURE_COORD_3
:
1132 return ctx
->Eval
.Map1TextureCoord3
;
1133 case GL_MAP1_TEXTURE_COORD_4
:
1134 return ctx
->Eval
.Map1TextureCoord4
;
1135 case GL_MAP1_VERTEX_3
:
1136 return ctx
->Eval
.Map1Vertex3
;
1137 case GL_MAP1_VERTEX_4
:
1138 return ctx
->Eval
.Map1Vertex4
;
1139 case GL_MAP2_COLOR_4
:
1140 return ctx
->Eval
.Map2Color4
;
1142 return ctx
->Eval
.Map2Index
;
1143 case GL_MAP2_NORMAL
:
1144 return ctx
->Eval
.Map2Normal
;
1145 case GL_MAP2_TEXTURE_COORD_1
:
1146 return ctx
->Eval
.Map2TextureCoord1
;
1147 case GL_MAP2_TEXTURE_COORD_2
:
1148 return ctx
->Eval
.Map2TextureCoord2
;
1149 case GL_MAP2_TEXTURE_COORD_3
:
1150 return ctx
->Eval
.Map2TextureCoord3
;
1151 case GL_MAP2_TEXTURE_COORD_4
:
1152 return ctx
->Eval
.Map2TextureCoord4
;
1153 case GL_MAP2_VERTEX_3
:
1154 return ctx
->Eval
.Map2Vertex3
;
1155 case GL_MAP2_VERTEX_4
:
1156 return ctx
->Eval
.Map2Vertex4
;
1158 return ctx
->Transform
.Normalize
;
1159 case GL_POINT_SMOOTH
:
1160 return ctx
->Point
.SmoothFlag
;
1161 case GL_POLYGON_SMOOTH
:
1162 return ctx
->Polygon
.SmoothFlag
;
1163 case GL_POLYGON_STIPPLE
:
1164 return ctx
->Polygon
.StippleFlag
;
1165 case GL_POLYGON_OFFSET_POINT
:
1166 return ctx
->Polygon
.OffsetPoint
;
1167 case GL_POLYGON_OFFSET_LINE
:
1168 return ctx
->Polygon
.OffsetLine
;
1169 case GL_POLYGON_OFFSET_FILL
:
1170 /*case GL_POLYGON_OFFSET_EXT:*/
1171 return ctx
->Polygon
.OffsetFill
;
1172 case GL_RESCALE_NORMAL_EXT
:
1173 return ctx
->Transform
.RescaleNormals
;
1174 case GL_SCISSOR_TEST
:
1175 return ctx
->Scissor
.Enabled
;
1176 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1177 return ctx
->Texture
.SharedPalette
;
1178 case GL_STENCIL_TEST
:
1179 return ctx
->Stencil
.Enabled
;
1182 const struct gl_texture_unit
*texUnit
;
1183 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1184 return (texUnit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
;
1188 const struct gl_texture_unit
*texUnit
;
1189 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1190 return (texUnit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
;
1194 const struct gl_texture_unit
*texUnit
;
1195 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1196 return (texUnit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
;
1198 case GL_TEXTURE_GEN_Q
:
1200 const struct gl_texture_unit
*texUnit
;
1201 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1202 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1204 case GL_TEXTURE_GEN_R
:
1206 const struct gl_texture_unit
*texUnit
;
1207 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1208 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1210 case GL_TEXTURE_GEN_S
:
1212 const struct gl_texture_unit
*texUnit
;
1213 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1214 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1216 case GL_TEXTURE_GEN_T
:
1218 const struct gl_texture_unit
*texUnit
;
1219 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1220 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1226 case GL_VERTEX_ARRAY
:
1227 return (ctx
->Array
.Vertex
.Enabled
!= 0);
1228 case GL_NORMAL_ARRAY
:
1229 return (ctx
->Array
.Normal
.Enabled
!= 0);
1230 case GL_COLOR_ARRAY
:
1231 return (ctx
->Array
.Color
.Enabled
!= 0);
1232 case GL_INDEX_ARRAY
:
1233 return (ctx
->Array
.Index
.Enabled
!= 0);
1234 case GL_TEXTURE_COORD_ARRAY
:
1235 return (ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1236 case GL_EDGE_FLAG_ARRAY
:
1237 return (ctx
->Array
.EdgeFlag
.Enabled
!= 0);
1238 case GL_FOG_COORDINATE_ARRAY_EXT
:
1239 CHECK_EXTENSION(EXT_fog_coord
);
1240 return (ctx
->Array
.FogCoord
.Enabled
!= 0);
1241 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1242 CHECK_EXTENSION(EXT_secondary_color
);
1243 return (ctx
->Array
.SecondaryColor
.Enabled
!= 0);
1245 /* GL_EXT_histogram */
1247 CHECK_EXTENSION(EXT_histogram
);
1248 return ctx
->Pixel
.HistogramEnabled
;
1250 CHECK_EXTENSION(EXT_histogram
);
1251 return ctx
->Pixel
.MinMaxEnabled
;
1253 /* GL_HP_occlusion_test */
1254 case GL_OCCLUSION_TEST_HP
:
1255 CHECK_EXTENSION(HP_occlusion_test
);
1256 return ctx
->Depth
.OcclusionTest
;
1258 /* GL_SGIS_pixel_texture */
1259 case GL_PIXEL_TEXTURE_SGIS
:
1260 CHECK_EXTENSION(SGIS_pixel_texture
);
1261 return ctx
->Pixel
.PixelTextureEnabled
;
1263 /* GL_SGIX_pixel_texture */
1264 case GL_PIXEL_TEX_GEN_SGIX
:
1265 CHECK_EXTENSION(SGIX_pixel_texture
);
1266 return ctx
->Pixel
.PixelTextureEnabled
;
1268 /* GL_SGI_color_table */
1269 case GL_COLOR_TABLE_SGI
:
1270 CHECK_EXTENSION(SGI_color_table
);
1271 return ctx
->Pixel
.ColorTableEnabled
;
1272 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1273 CHECK_EXTENSION(SGI_color_table
);
1274 return ctx
->Pixel
.PostConvolutionColorTableEnabled
;
1275 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1276 CHECK_EXTENSION(SGI_color_table
);
1277 return ctx
->Pixel
.PostColorMatrixColorTableEnabled
;
1279 /* GL_SGI_texture_color_table */
1280 case GL_TEXTURE_COLOR_TABLE_SGI
:
1281 CHECK_EXTENSION(SGI_texture_color_table
);
1282 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1284 /* GL_EXT_convolution */
1285 case GL_CONVOLUTION_1D
:
1286 CHECK_EXTENSION(EXT_convolution
);
1287 return ctx
->Pixel
.Convolution1DEnabled
;
1288 case GL_CONVOLUTION_2D
:
1289 CHECK_EXTENSION(EXT_convolution
);
1290 return ctx
->Pixel
.Convolution2DEnabled
;
1291 case GL_SEPARABLE_2D
:
1292 CHECK_EXTENSION(EXT_convolution
);
1293 return ctx
->Pixel
.Separable2DEnabled
;
1295 /* GL_ARB_texture_cube_map */
1296 case GL_TEXTURE_CUBE_MAP_ARB
:
1297 CHECK_EXTENSION(ARB_texture_cube_map
);
1299 const struct gl_texture_unit
*texUnit
;
1300 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1301 return (texUnit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
;
1304 /* GL_ARB_multisample */
1305 case GL_MULTISAMPLE_ARB
:
1306 CHECK_EXTENSION(ARB_multisample
);
1307 return ctx
->Multisample
.Enabled
;
1308 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1309 CHECK_EXTENSION(ARB_multisample
);
1310 return ctx
->Multisample
.SampleAlphaToCoverage
;
1311 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1312 CHECK_EXTENSION(ARB_multisample
);
1313 return ctx
->Multisample
.SampleAlphaToOne
;
1314 case GL_SAMPLE_COVERAGE_ARB
:
1315 CHECK_EXTENSION(ARB_multisample
);
1316 return ctx
->Multisample
.SampleCoverage
;
1317 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1318 CHECK_EXTENSION(ARB_multisample
);
1319 return ctx
->Multisample
.SampleCoverageInvert
;
1321 /* GL_IBM_rasterpos_clip */
1322 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1323 CHECK_EXTENSION(IBM_rasterpos_clip
);
1324 return ctx
->Transform
.RasterPositionUnclipped
;
1326 /* GL_NV_point_sprite */
1327 case GL_POINT_SPRITE_NV
:
1328 return ctx
->Point
.PointSprite
;
1330 #if FEATURE_NV_vertex_program
1331 case GL_VERTEX_PROGRAM_NV
:
1332 CHECK_EXTENSION(NV_vertex_program
);
1333 return ctx
->VertexProgram
.Enabled
;
1334 case GL_VERTEX_PROGRAM_POINT_SIZE_NV
:
1335 CHECK_EXTENSION(NV_vertex_program
);
1336 return ctx
->VertexProgram
.PointSizeEnabled
;
1337 case GL_VERTEX_PROGRAM_TWO_SIDE_NV
:
1338 CHECK_EXTENSION(NV_vertex_program
);
1339 return ctx
->VertexProgram
.TwoSideEnabled
;
1340 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1341 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1342 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1343 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1344 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1345 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1346 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1347 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1348 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1349 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1350 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1351 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1352 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1353 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1354 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1355 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1356 CHECK_EXTENSION(NV_vertex_program
);
1358 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1359 return (ctx
->Array
.VertexAttrib
[n
].Enabled
!= 0);
1361 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1362 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1363 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1364 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1365 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1366 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1367 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1368 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1369 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1370 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1371 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1372 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1373 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1374 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1375 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1376 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1377 CHECK_EXTENSION(NV_vertex_program
);
1379 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1380 return ctx
->Eval
.Map1Attrib
[map
];
1382 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1383 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1384 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1385 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1386 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1387 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1388 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1389 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1390 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1391 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1392 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1393 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1394 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1395 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1396 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1397 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1398 CHECK_EXTENSION(NV_vertex_program
);
1400 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1401 return ctx
->Eval
.Map2Attrib
[map
];
1403 #endif /* FEATURE_NV_vertex_program */
1405 #if FEATURE_NV_fragment_program
1406 case GL_FRAGMENT_PROGRAM_NV
:
1407 CHECK_EXTENSION(NV_fragment_program
);
1408 return ctx
->FragmentProgram
.Enabled
;
1409 #endif /* FEATURE_NV_fragment_program */
1411 /* GL_NV_texture_rectangle */
1412 case GL_TEXTURE_RECTANGLE_NV
:
1413 CHECK_EXTENSION(NV_texture_rectangle
);
1415 const struct gl_texture_unit
*texUnit
;
1416 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1417 return (texUnit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
;
1420 /* GL_EXT_stencil_two_side */
1421 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1422 CHECK_EXTENSION(EXT_stencil_two_side
);
1423 return ctx
->Stencil
.TestTwoSide
;
1425 #if FEATURE_ARB_fragment_program
1426 case GL_FRAGMENT_PROGRAM_ARB
:
1427 return ctx
->FragmentProgram
.Enabled
;
1428 #endif /* FEATURE_ARB_fragment_program */
1430 /* GL_EXT_depth_bounds_test */
1431 case GL_DEPTH_BOUNDS_TEST_EXT
:
1432 CHECK_EXTENSION(EXT_depth_bounds_test
);
1433 return ctx
->Depth
.BoundsTest
;
1435 /* GL_MESA_program_debug */
1436 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1437 CHECK_EXTENSION(MESA_program_debug
);
1438 return ctx
->FragmentProgram
.CallbackEnabled
;
1439 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1440 CHECK_EXTENSION(MESA_program_debug
);
1441 return ctx
->VertexProgram
.CallbackEnabled
;
1442 #if FEATURE_ATI_fragment_shader
1443 case GL_FRAGMENT_SHADER_ATI
:
1444 CHECK_EXTENSION(ATI_fragment_shader
);
1445 return ctx
->ATIFragmentShader
.Enabled
;
1446 #endif /* FEATURE_ATI_fragment_shader */
1448 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);