3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2007 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"
41 #include "api_arrayelt.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
48 state ? "Enable" : "Disable", CAP); \
54 * Helper to enable/disable client-side state.
57 client_state(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
64 var
= &ctx
->Array
.ArrayObj
->Vertex
.Enabled
;
65 flag
= _NEW_ARRAY_VERTEX
;
68 var
= &ctx
->Array
.ArrayObj
->Normal
.Enabled
;
69 flag
= _NEW_ARRAY_NORMAL
;
72 var
= &ctx
->Array
.ArrayObj
->Color
.Enabled
;
73 flag
= _NEW_ARRAY_COLOR0
;
76 var
= &ctx
->Array
.ArrayObj
->Index
.Enabled
;
77 flag
= _NEW_ARRAY_INDEX
;
79 case GL_TEXTURE_COORD_ARRAY
:
80 var
= &ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
81 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
83 case GL_EDGE_FLAG_ARRAY
:
84 var
= &ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
;
85 flag
= _NEW_ARRAY_EDGEFLAG
;
87 case GL_FOG_COORDINATE_ARRAY_EXT
:
88 var
= &ctx
->Array
.ArrayObj
->FogCoord
.Enabled
;
89 flag
= _NEW_ARRAY_FOGCOORD
;
91 case GL_SECONDARY_COLOR_ARRAY_EXT
:
92 var
= &ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
;
93 flag
= _NEW_ARRAY_COLOR1
;
96 #if FEATURE_point_size_array
97 case GL_POINT_SIZE_ARRAY_OES
:
98 var
= &ctx
->Array
.ArrayObj
->PointSize
.Enabled
;
99 flag
= _NEW_ARRAY_POINT_SIZE
;
103 #if FEATURE_NV_vertex_program
104 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
118 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
119 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
120 CHECK_EXTENSION(NV_vertex_program
, cap
);
122 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
123 var
= &ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
;
124 flag
= _NEW_ARRAY_ATTRIB(n
);
127 #endif /* FEATURE_NV_vertex_program */
130 _mesa_error( ctx
, GL_INVALID_ENUM
,
131 "glEnable/DisableClientState(0x%x)", cap
);
138 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
139 ctx
->Array
.NewState
|= flag
;
141 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
146 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
148 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
150 if (ctx
->Driver
.Enable
) {
151 ctx
->Driver
.Enable( ctx
, cap
, state
);
157 * Enable GL capability.
158 * \param cap state to enable/disable.
160 * Get's the current context, assures that we're outside glBegin()/glEnd() and
161 * calls client_state().
164 _mesa_EnableClientState( GLenum cap
)
166 GET_CURRENT_CONTEXT(ctx
);
167 ASSERT_OUTSIDE_BEGIN_END(ctx
);
168 client_state( ctx
, cap
, GL_TRUE
);
173 * Disable GL capability.
174 * \param cap state to enable/disable.
176 * Get's the current context, assures that we're outside glBegin()/glEnd() and
177 * calls client_state().
180 _mesa_DisableClientState( GLenum cap
)
182 GET_CURRENT_CONTEXT(ctx
);
183 ASSERT_OUTSIDE_BEGIN_END(ctx
);
184 client_state( ctx
, cap
, GL_FALSE
);
188 #undef CHECK_EXTENSION
189 #define CHECK_EXTENSION(EXTNAME, CAP) \
190 if (!ctx->Extensions.EXTNAME) { \
191 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
192 state ? "Enable" : "Disable", CAP); \
196 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
197 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
198 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
199 state ? "Enable" : "Disable", CAP); \
206 * Return pointer to current texture unit for setting/getting coordinate
208 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
209 * higher than the number of supported coordinate units. And we'll return NULL.
211 static struct gl_texture_unit
*
212 get_texcoord_unit(GLcontext
*ctx
)
214 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
215 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
219 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
225 * Helper function to enable or disable a texture target.
228 enable_texture(GLcontext
*ctx
, GLboolean state
, GLbitfield bit
)
230 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
231 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
232 const GLuint newenabled
= (!state
)
233 ? (texUnit
->Enabled
& ~bit
) : (texUnit
->Enabled
| bit
);
235 if (!ctx
->DrawBuffer
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
238 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
239 texUnit
->Enabled
= newenabled
;
245 * Helper function to enable or disable state.
247 * \param ctx GL context.
248 * \param cap the state to enable/disable
249 * \param state whether to enable or disable the specified capability.
251 * Updates the current context and flushes the vertices as needed. For
252 * capabilities associated with extensions it verifies that those extensions
253 * are effectivly present before updating. Notifies the driver via
254 * dd_function_table::Enable.
257 _mesa_set_enable(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
259 if (MESA_VERBOSE
& VERBOSE_API
)
260 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
261 state
? "glEnable" : "glDisable",
262 _mesa_lookup_enum_by_nr(cap
),
267 if (ctx
->Color
.AlphaEnabled
== state
)
269 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
270 ctx
->Color
.AlphaEnabled
= state
;
273 if (ctx
->Eval
.AutoNormal
== state
)
275 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
276 ctx
->Eval
.AutoNormal
= state
;
279 if (ctx
->Color
.BlendEnabled
== state
)
281 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
282 ctx
->Color
.BlendEnabled
= state
;
292 const GLuint p
= cap
- GL_CLIP_PLANE0
;
294 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
297 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
300 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
302 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
303 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
305 /* This derived state also calculated in clip.c and
306 * from _mesa_update_state() on changes to EyeUserPlane
307 * and ctx->ProjectionMatrix respectively.
309 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
310 ctx
->Transform
.EyeUserPlane
[p
],
311 ctx
->ProjectionMatrixStack
.Top
->inv
);
314 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
319 case GL_COLOR_MATERIAL
:
320 if (ctx
->Light
.ColorMaterialEnabled
== state
)
322 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
323 FLUSH_CURRENT(ctx
, 0);
324 ctx
->Light
.ColorMaterialEnabled
= state
;
326 _mesa_update_color_material( ctx
,
327 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
331 if (ctx
->Polygon
.CullFlag
== state
)
333 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
334 ctx
->Polygon
.CullFlag
= state
;
336 case GL_CULL_VERTEX_EXT
:
337 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
338 if (ctx
->Transform
.CullVertexFlag
== state
)
340 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
341 ctx
->Transform
.CullVertexFlag
= state
;
344 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
345 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
348 if (ctx
->Depth
.Test
== state
)
350 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
351 ctx
->Depth
.Test
= state
;
355 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
357 if (ctx
->Color
.DitherFlag
== state
)
359 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
360 ctx
->Color
.DitherFlag
= state
;
363 if (ctx
->Fog
.Enabled
== state
)
365 FLUSH_VERTICES(ctx
, _NEW_FOG
);
366 ctx
->Fog
.Enabled
= state
;
369 CHECK_EXTENSION(EXT_histogram
, cap
);
370 if (ctx
->Pixel
.HistogramEnabled
== state
)
372 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
373 ctx
->Pixel
.HistogramEnabled
= state
;
383 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
385 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
386 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
388 insert_at_tail(&ctx
->Light
.EnabledList
,
389 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
392 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
396 if (ctx
->Light
.Enabled
== state
)
398 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
399 ctx
->Light
.Enabled
= state
;
400 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
401 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
403 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
406 if (ctx
->Line
.SmoothFlag
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_LINE
);
409 ctx
->Line
.SmoothFlag
= state
;
410 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
412 case GL_LINE_STIPPLE
:
413 if (ctx
->Line
.StippleFlag
== state
)
415 FLUSH_VERTICES(ctx
, _NEW_LINE
);
416 ctx
->Line
.StippleFlag
= state
;
417 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
419 case GL_INDEX_LOGIC_OP
:
420 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
422 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
423 ctx
->Color
.IndexLogicOpEnabled
= state
;
425 case GL_COLOR_LOGIC_OP
:
426 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
429 ctx
->Color
.ColorLogicOpEnabled
= state
;
431 case GL_MAP1_COLOR_4
:
432 if (ctx
->Eval
.Map1Color4
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
435 ctx
->Eval
.Map1Color4
= state
;
438 if (ctx
->Eval
.Map1Index
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
441 ctx
->Eval
.Map1Index
= state
;
444 if (ctx
->Eval
.Map1Normal
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
447 ctx
->Eval
.Map1Normal
= state
;
449 case GL_MAP1_TEXTURE_COORD_1
:
450 if (ctx
->Eval
.Map1TextureCoord1
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map1TextureCoord1
= state
;
455 case GL_MAP1_TEXTURE_COORD_2
:
456 if (ctx
->Eval
.Map1TextureCoord2
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map1TextureCoord2
= state
;
461 case GL_MAP1_TEXTURE_COORD_3
:
462 if (ctx
->Eval
.Map1TextureCoord3
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map1TextureCoord3
= state
;
467 case GL_MAP1_TEXTURE_COORD_4
:
468 if (ctx
->Eval
.Map1TextureCoord4
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map1TextureCoord4
= state
;
473 case GL_MAP1_VERTEX_3
:
474 if (ctx
->Eval
.Map1Vertex3
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map1Vertex3
= state
;
479 case GL_MAP1_VERTEX_4
:
480 if (ctx
->Eval
.Map1Vertex4
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map1Vertex4
= state
;
485 case GL_MAP2_COLOR_4
:
486 if (ctx
->Eval
.Map2Color4
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map2Color4
= state
;
492 if (ctx
->Eval
.Map2Index
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map2Index
= state
;
498 if (ctx
->Eval
.Map2Normal
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
501 ctx
->Eval
.Map2Normal
= state
;
503 case GL_MAP2_TEXTURE_COORD_1
:
504 if (ctx
->Eval
.Map2TextureCoord1
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map2TextureCoord1
= state
;
509 case GL_MAP2_TEXTURE_COORD_2
:
510 if (ctx
->Eval
.Map2TextureCoord2
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map2TextureCoord2
= state
;
515 case GL_MAP2_TEXTURE_COORD_3
:
516 if (ctx
->Eval
.Map2TextureCoord3
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map2TextureCoord3
= state
;
521 case GL_MAP2_TEXTURE_COORD_4
:
522 if (ctx
->Eval
.Map2TextureCoord4
== state
)
524 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
525 ctx
->Eval
.Map2TextureCoord4
= state
;
527 case GL_MAP2_VERTEX_3
:
528 if (ctx
->Eval
.Map2Vertex3
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
531 ctx
->Eval
.Map2Vertex3
= state
;
533 case GL_MAP2_VERTEX_4
:
534 if (ctx
->Eval
.Map2Vertex4
== state
)
536 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
537 ctx
->Eval
.Map2Vertex4
= state
;
540 if (ctx
->Pixel
.MinMaxEnabled
== state
)
542 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
543 ctx
->Pixel
.MinMaxEnabled
= state
;
546 if (ctx
->Transform
.Normalize
== state
)
548 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
549 ctx
->Transform
.Normalize
= state
;
551 case GL_POINT_SMOOTH
:
552 if (ctx
->Point
.SmoothFlag
== state
)
554 FLUSH_VERTICES(ctx
, _NEW_POINT
);
555 ctx
->Point
.SmoothFlag
= state
;
556 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
558 case GL_POLYGON_SMOOTH
:
559 if (ctx
->Polygon
.SmoothFlag
== state
)
561 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
562 ctx
->Polygon
.SmoothFlag
= state
;
563 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
565 case GL_POLYGON_STIPPLE
:
566 if (ctx
->Polygon
.StippleFlag
== state
)
568 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
569 ctx
->Polygon
.StippleFlag
= state
;
570 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
572 case GL_POLYGON_OFFSET_POINT
:
573 if (ctx
->Polygon
.OffsetPoint
== state
)
575 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
576 ctx
->Polygon
.OffsetPoint
= state
;
578 case GL_POLYGON_OFFSET_LINE
:
579 if (ctx
->Polygon
.OffsetLine
== state
)
581 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
582 ctx
->Polygon
.OffsetLine
= state
;
584 case GL_POLYGON_OFFSET_FILL
:
585 /*case GL_POLYGON_OFFSET_EXT:*/
586 if (ctx
->Polygon
.OffsetFill
== state
)
588 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
589 ctx
->Polygon
.OffsetFill
= state
;
591 case GL_RESCALE_NORMAL_EXT
:
592 if (ctx
->Transform
.RescaleNormals
== state
)
594 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
595 ctx
->Transform
.RescaleNormals
= state
;
597 case GL_SCISSOR_TEST
:
598 if (ctx
->Scissor
.Enabled
== state
)
600 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
601 ctx
->Scissor
.Enabled
= state
;
603 case GL_SHARED_TEXTURE_PALETTE_EXT
:
604 if (ctx
->Texture
.SharedPalette
== state
)
606 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
607 ctx
->Texture
.SharedPalette
= state
;
609 case GL_STENCIL_TEST
:
610 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
612 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
615 if (ctx
->Stencil
.Enabled
== state
)
617 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
618 ctx
->Stencil
.Enabled
= state
;
621 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
626 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
631 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
635 case GL_TEXTURE_GEN_Q
:
637 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
639 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
642 if (texUnit
->TexGenEnabled
== newenabled
)
644 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
645 texUnit
->TexGenEnabled
= newenabled
;
649 case GL_TEXTURE_GEN_R
:
651 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
653 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
656 if (texUnit
->TexGenEnabled
== newenabled
)
658 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
659 texUnit
->TexGenEnabled
= newenabled
;
663 case GL_TEXTURE_GEN_S
:
665 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
667 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
670 if (texUnit
->TexGenEnabled
== newenabled
)
672 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
673 texUnit
->TexGenEnabled
= newenabled
;
677 case GL_TEXTURE_GEN_T
:
679 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
681 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
684 if (texUnit
->TexGenEnabled
== newenabled
)
686 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
687 texUnit
->TexGenEnabled
= newenabled
;
695 case GL_VERTEX_ARRAY
:
696 case GL_NORMAL_ARRAY
:
699 case GL_TEXTURE_COORD_ARRAY
:
700 case GL_EDGE_FLAG_ARRAY
:
701 case GL_FOG_COORDINATE_ARRAY_EXT
:
702 case GL_SECONDARY_COLOR_ARRAY_EXT
:
703 case GL_POINT_SIZE_ARRAY_OES
:
704 client_state( ctx
, cap
, state
);
707 /* GL_SGI_color_table */
708 case GL_COLOR_TABLE_SGI
:
709 CHECK_EXTENSION(SGI_color_table
, cap
);
710 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] == state
)
712 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
713 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] = state
;
715 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
716 CHECK_EXTENSION(SGI_color_table
, cap
);
717 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] == state
)
719 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
720 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] = state
;
722 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
723 CHECK_EXTENSION(SGI_color_table
, cap
);
724 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] == state
)
726 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
727 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] = state
;
729 case GL_TEXTURE_COLOR_TABLE_SGI
:
730 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
731 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
733 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
734 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
737 /* GL_EXT_convolution */
738 case GL_CONVOLUTION_1D
:
739 CHECK_EXTENSION(EXT_convolution
, cap
);
740 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
743 ctx
->Pixel
.Convolution1DEnabled
= state
;
745 case GL_CONVOLUTION_2D
:
746 CHECK_EXTENSION(EXT_convolution
, cap
);
747 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
749 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
750 ctx
->Pixel
.Convolution2DEnabled
= state
;
752 case GL_SEPARABLE_2D
:
753 CHECK_EXTENSION(EXT_convolution
, cap
);
754 if (ctx
->Pixel
.Separable2DEnabled
== state
)
756 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
757 ctx
->Pixel
.Separable2DEnabled
= state
;
760 /* GL_ARB_texture_cube_map */
761 case GL_TEXTURE_CUBE_MAP_ARB
:
762 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
763 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
768 /* GL_EXT_secondary_color */
769 case GL_COLOR_SUM_EXT
:
770 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
771 if (ctx
->Fog
.ColorSumEnabled
== state
)
773 FLUSH_VERTICES(ctx
, _NEW_FOG
);
774 ctx
->Fog
.ColorSumEnabled
= state
;
777 /* GL_ARB_multisample */
778 case GL_MULTISAMPLE_ARB
:
779 CHECK_EXTENSION(ARB_multisample
, cap
);
780 if (ctx
->Multisample
.Enabled
== state
)
782 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
783 ctx
->Multisample
.Enabled
= state
;
785 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
786 CHECK_EXTENSION(ARB_multisample
, cap
);
787 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
789 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
790 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
792 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
793 CHECK_EXTENSION(ARB_multisample
, cap
);
794 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
796 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
797 ctx
->Multisample
.SampleAlphaToOne
= state
;
799 case GL_SAMPLE_COVERAGE_ARB
:
800 CHECK_EXTENSION(ARB_multisample
, cap
);
801 if (ctx
->Multisample
.SampleCoverage
== state
)
803 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
804 ctx
->Multisample
.SampleCoverage
= state
;
806 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
807 CHECK_EXTENSION(ARB_multisample
, cap
);
808 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
810 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
811 ctx
->Multisample
.SampleCoverageInvert
= state
;
814 /* GL_IBM_rasterpos_clip */
815 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
816 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
817 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
819 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
820 ctx
->Transform
.RasterPositionUnclipped
= state
;
823 /* GL_NV_point_sprite */
824 case GL_POINT_SPRITE_NV
:
825 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
826 if (ctx
->Point
.PointSprite
== state
)
828 FLUSH_VERTICES(ctx
, _NEW_POINT
);
829 ctx
->Point
.PointSprite
= state
;
832 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
833 case GL_VERTEX_PROGRAM_ARB
:
834 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
835 if (ctx
->VertexProgram
.Enabled
== state
)
837 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
838 ctx
->VertexProgram
.Enabled
= state
;
840 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
841 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
842 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
844 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
845 ctx
->VertexProgram
.PointSizeEnabled
= state
;
847 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
848 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
849 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
851 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
852 ctx
->VertexProgram
.TwoSideEnabled
= state
;
855 #if FEATURE_NV_vertex_program
856 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
857 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
858 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
859 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
860 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
861 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
862 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
863 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
864 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
865 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
866 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
867 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
868 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
869 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
870 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
871 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
872 CHECK_EXTENSION(NV_vertex_program
, cap
);
874 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
875 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
876 ctx
->Eval
.Map1Attrib
[map
] = state
;
879 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
880 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
881 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
882 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
883 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
884 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
885 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
886 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
887 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
888 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
889 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
890 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
891 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
892 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
893 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
894 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
895 CHECK_EXTENSION(NV_vertex_program
, cap
);
897 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
898 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
899 ctx
->Eval
.Map2Attrib
[map
] = state
;
902 #endif /* FEATURE_NV_vertex_program */
904 #if FEATURE_NV_fragment_program
905 case GL_FRAGMENT_PROGRAM_NV
:
906 CHECK_EXTENSION(NV_fragment_program
, cap
);
907 if (ctx
->FragmentProgram
.Enabled
== state
)
909 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
910 ctx
->FragmentProgram
.Enabled
= state
;
912 #endif /* FEATURE_NV_fragment_program */
914 /* GL_NV_texture_rectangle */
915 case GL_TEXTURE_RECTANGLE_NV
:
916 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
917 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
922 /* GL_EXT_stencil_two_side */
923 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
924 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
925 if (ctx
->Stencil
.TestTwoSide
== state
)
927 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
928 ctx
->Stencil
.TestTwoSide
= state
;
930 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
932 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
935 #if FEATURE_ARB_fragment_program
936 case GL_FRAGMENT_PROGRAM_ARB
:
937 CHECK_EXTENSION(ARB_fragment_program
, cap
);
938 if (ctx
->FragmentProgram
.Enabled
== state
)
940 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
941 ctx
->FragmentProgram
.Enabled
= state
;
943 #endif /* FEATURE_ARB_fragment_program */
945 /* GL_EXT_depth_bounds_test */
946 case GL_DEPTH_BOUNDS_TEST_EXT
:
947 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
948 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
950 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
953 if (ctx
->Depth
.BoundsTest
== state
)
955 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
956 ctx
->Depth
.BoundsTest
= state
;
959 /* GL_MESA_program_debug */
960 #if FEATURE_MESA_program_debug
961 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
962 CHECK_EXTENSION(MESA_program_debug
, cap
);
963 ctx
->FragmentProgram
.CallbackEnabled
= state
;
965 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
966 CHECK_EXTENSION(MESA_program_debug
, cap
);
967 ctx
->VertexProgram
.CallbackEnabled
= state
;
971 #if FEATURE_ATI_fragment_shader
972 case GL_FRAGMENT_SHADER_ATI
:
973 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
974 if (ctx
->ATIFragmentShader
.Enabled
== state
)
976 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
977 ctx
->ATIFragmentShader
.Enabled
= state
;
981 /* GL_MESA_texture_array */
982 case GL_TEXTURE_1D_ARRAY_EXT
:
983 CHECK_EXTENSION(MESA_texture_array
, cap
);
984 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
989 case GL_TEXTURE_2D_ARRAY_EXT
:
990 CHECK_EXTENSION(MESA_texture_array
, cap
);
991 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
997 _mesa_error(ctx
, GL_INVALID_ENUM
,
998 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
1002 if (ctx
->Driver
.Enable
) {
1003 ctx
->Driver
.Enable( ctx
, cap
, state
);
1009 * Enable GL capability. Called by glEnable()
1010 * \param cap state to enable.
1013 _mesa_Enable( GLenum cap
)
1015 GET_CURRENT_CONTEXT(ctx
);
1016 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1018 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1023 * Disable GL capability. Called by glDisable()
1024 * \param cap state to disable.
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"); \
1043 #undef CHECK_EXTENSION2
1044 #define CHECK_EXTENSION2(EXT1, EXT2) \
1045 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1046 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1052 * Helper function to determine whether a texture target is enabled.
1055 is_texture_enabled(GLcontext
*ctx
, GLbitfield bit
)
1057 const struct gl_texture_unit
*const texUnit
=
1058 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1059 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1064 * Return simple enable/disable state.
1066 * \param cap state variable to query.
1068 * Returns the state of the specified capability from the current GL context.
1069 * For the capabilities associated with extensions verifies that those
1070 * extensions are effectively present before reporting.
1072 GLboolean GLAPIENTRY
1073 _mesa_IsEnabled( GLenum cap
)
1075 GET_CURRENT_CONTEXT(ctx
);
1078 return ctx
->Color
.AlphaEnabled
;
1079 case GL_AUTO_NORMAL
:
1080 return ctx
->Eval
.AutoNormal
;
1082 return ctx
->Color
.BlendEnabled
;
1083 case GL_CLIP_PLANE0
:
1084 case GL_CLIP_PLANE1
:
1085 case GL_CLIP_PLANE2
:
1086 case GL_CLIP_PLANE3
:
1087 case GL_CLIP_PLANE4
:
1088 case GL_CLIP_PLANE5
:
1089 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1090 case GL_COLOR_MATERIAL
:
1091 return ctx
->Light
.ColorMaterialEnabled
;
1093 return ctx
->Polygon
.CullFlag
;
1095 return ctx
->Depth
.Test
;
1097 return ctx
->Color
.DitherFlag
;
1099 return ctx
->Fog
.Enabled
;
1101 return ctx
->Light
.Enabled
;
1110 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1111 case GL_LINE_SMOOTH
:
1112 return ctx
->Line
.SmoothFlag
;
1113 case GL_LINE_STIPPLE
:
1114 return ctx
->Line
.StippleFlag
;
1115 case GL_INDEX_LOGIC_OP
:
1116 return ctx
->Color
.IndexLogicOpEnabled
;
1117 case GL_COLOR_LOGIC_OP
:
1118 return ctx
->Color
.ColorLogicOpEnabled
;
1119 case GL_MAP1_COLOR_4
:
1120 return ctx
->Eval
.Map1Color4
;
1122 return ctx
->Eval
.Map1Index
;
1123 case GL_MAP1_NORMAL
:
1124 return ctx
->Eval
.Map1Normal
;
1125 case GL_MAP1_TEXTURE_COORD_1
:
1126 return ctx
->Eval
.Map1TextureCoord1
;
1127 case GL_MAP1_TEXTURE_COORD_2
:
1128 return ctx
->Eval
.Map1TextureCoord2
;
1129 case GL_MAP1_TEXTURE_COORD_3
:
1130 return ctx
->Eval
.Map1TextureCoord3
;
1131 case GL_MAP1_TEXTURE_COORD_4
:
1132 return ctx
->Eval
.Map1TextureCoord4
;
1133 case GL_MAP1_VERTEX_3
:
1134 return ctx
->Eval
.Map1Vertex3
;
1135 case GL_MAP1_VERTEX_4
:
1136 return ctx
->Eval
.Map1Vertex4
;
1137 case GL_MAP2_COLOR_4
:
1138 return ctx
->Eval
.Map2Color4
;
1140 return ctx
->Eval
.Map2Index
;
1141 case GL_MAP2_NORMAL
:
1142 return ctx
->Eval
.Map2Normal
;
1143 case GL_MAP2_TEXTURE_COORD_1
:
1144 return ctx
->Eval
.Map2TextureCoord1
;
1145 case GL_MAP2_TEXTURE_COORD_2
:
1146 return ctx
->Eval
.Map2TextureCoord2
;
1147 case GL_MAP2_TEXTURE_COORD_3
:
1148 return ctx
->Eval
.Map2TextureCoord3
;
1149 case GL_MAP2_TEXTURE_COORD_4
:
1150 return ctx
->Eval
.Map2TextureCoord4
;
1151 case GL_MAP2_VERTEX_3
:
1152 return ctx
->Eval
.Map2Vertex3
;
1153 case GL_MAP2_VERTEX_4
:
1154 return ctx
->Eval
.Map2Vertex4
;
1156 return ctx
->Transform
.Normalize
;
1157 case GL_POINT_SMOOTH
:
1158 return ctx
->Point
.SmoothFlag
;
1159 case GL_POLYGON_SMOOTH
:
1160 return ctx
->Polygon
.SmoothFlag
;
1161 case GL_POLYGON_STIPPLE
:
1162 return ctx
->Polygon
.StippleFlag
;
1163 case GL_POLYGON_OFFSET_POINT
:
1164 return ctx
->Polygon
.OffsetPoint
;
1165 case GL_POLYGON_OFFSET_LINE
:
1166 return ctx
->Polygon
.OffsetLine
;
1167 case GL_POLYGON_OFFSET_FILL
:
1168 /*case GL_POLYGON_OFFSET_EXT:*/
1169 return ctx
->Polygon
.OffsetFill
;
1170 case GL_RESCALE_NORMAL_EXT
:
1171 return ctx
->Transform
.RescaleNormals
;
1172 case GL_SCISSOR_TEST
:
1173 return ctx
->Scissor
.Enabled
;
1174 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1175 return ctx
->Texture
.SharedPalette
;
1176 case GL_STENCIL_TEST
:
1177 return ctx
->Stencil
.Enabled
;
1179 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1181 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1183 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1184 case GL_TEXTURE_GEN_Q
:
1186 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1188 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1192 case GL_TEXTURE_GEN_R
:
1194 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1196 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1200 case GL_TEXTURE_GEN_S
:
1202 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1204 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1208 case GL_TEXTURE_GEN_T
:
1210 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1212 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1220 case GL_VERTEX_ARRAY
:
1221 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1222 case GL_NORMAL_ARRAY
:
1223 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1224 case GL_COLOR_ARRAY
:
1225 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1226 case GL_INDEX_ARRAY
:
1227 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1228 case GL_TEXTURE_COORD_ARRAY
:
1229 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1230 case GL_EDGE_FLAG_ARRAY
:
1231 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1232 case GL_FOG_COORDINATE_ARRAY_EXT
:
1233 CHECK_EXTENSION(EXT_fog_coord
);
1234 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1235 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1236 CHECK_EXTENSION(EXT_secondary_color
);
1237 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1238 #if FEATURE_point_size_array
1239 case GL_POINT_SIZE_ARRAY_OES
:
1240 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1243 /* GL_EXT_histogram */
1245 CHECK_EXTENSION(EXT_histogram
);
1246 return ctx
->Pixel
.HistogramEnabled
;
1248 CHECK_EXTENSION(EXT_histogram
);
1249 return ctx
->Pixel
.MinMaxEnabled
;
1251 /* GL_SGI_color_table */
1252 case GL_COLOR_TABLE_SGI
:
1253 CHECK_EXTENSION(SGI_color_table
);
1254 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
];
1255 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1256 CHECK_EXTENSION(SGI_color_table
);
1257 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
];
1258 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1259 CHECK_EXTENSION(SGI_color_table
);
1260 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
];
1262 /* GL_SGI_texture_color_table */
1263 case GL_TEXTURE_COLOR_TABLE_SGI
:
1264 CHECK_EXTENSION(SGI_texture_color_table
);
1265 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1267 /* GL_EXT_convolution */
1268 case GL_CONVOLUTION_1D
:
1269 CHECK_EXTENSION(EXT_convolution
);
1270 return ctx
->Pixel
.Convolution1DEnabled
;
1271 case GL_CONVOLUTION_2D
:
1272 CHECK_EXTENSION(EXT_convolution
);
1273 return ctx
->Pixel
.Convolution2DEnabled
;
1274 case GL_SEPARABLE_2D
:
1275 CHECK_EXTENSION(EXT_convolution
);
1276 return ctx
->Pixel
.Separable2DEnabled
;
1278 /* GL_ARB_texture_cube_map */
1279 case GL_TEXTURE_CUBE_MAP_ARB
:
1280 CHECK_EXTENSION(ARB_texture_cube_map
);
1281 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1283 /* GL_EXT_secondary_color */
1284 case GL_COLOR_SUM_EXT
:
1285 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1286 return ctx
->Fog
.ColorSumEnabled
;
1288 /* GL_ARB_multisample */
1289 case GL_MULTISAMPLE_ARB
:
1290 CHECK_EXTENSION(ARB_multisample
);
1291 return ctx
->Multisample
.Enabled
;
1292 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1293 CHECK_EXTENSION(ARB_multisample
);
1294 return ctx
->Multisample
.SampleAlphaToCoverage
;
1295 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1296 CHECK_EXTENSION(ARB_multisample
);
1297 return ctx
->Multisample
.SampleAlphaToOne
;
1298 case GL_SAMPLE_COVERAGE_ARB
:
1299 CHECK_EXTENSION(ARB_multisample
);
1300 return ctx
->Multisample
.SampleCoverage
;
1301 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1302 CHECK_EXTENSION(ARB_multisample
);
1303 return ctx
->Multisample
.SampleCoverageInvert
;
1305 /* GL_IBM_rasterpos_clip */
1306 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1307 CHECK_EXTENSION(IBM_rasterpos_clip
);
1308 return ctx
->Transform
.RasterPositionUnclipped
;
1310 /* GL_NV_point_sprite */
1311 case GL_POINT_SPRITE_NV
:
1312 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1313 return ctx
->Point
.PointSprite
;
1315 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1316 case GL_VERTEX_PROGRAM_ARB
:
1317 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1318 return ctx
->VertexProgram
.Enabled
;
1319 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1320 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1321 return ctx
->VertexProgram
.PointSizeEnabled
;
1322 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1323 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1324 return ctx
->VertexProgram
.TwoSideEnabled
;
1326 #if FEATURE_NV_vertex_program
1327 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1328 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1329 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1330 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1331 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1332 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1333 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1334 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1335 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1336 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1337 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1338 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1339 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1340 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1341 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1342 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1343 CHECK_EXTENSION(NV_vertex_program
);
1345 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1346 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1348 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1349 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1350 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1351 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1352 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1353 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1354 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1355 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1356 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1357 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1358 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1359 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1360 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1361 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1362 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1363 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1364 CHECK_EXTENSION(NV_vertex_program
);
1366 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1367 return ctx
->Eval
.Map1Attrib
[map
];
1369 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1370 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1371 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1372 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1373 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1374 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1375 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1376 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1377 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1378 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1379 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1380 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1381 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1382 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1383 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1384 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1385 CHECK_EXTENSION(NV_vertex_program
);
1387 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1388 return ctx
->Eval
.Map2Attrib
[map
];
1390 #endif /* FEATURE_NV_vertex_program */
1392 #if FEATURE_NV_fragment_program
1393 case GL_FRAGMENT_PROGRAM_NV
:
1394 CHECK_EXTENSION(NV_fragment_program
);
1395 return ctx
->FragmentProgram
.Enabled
;
1396 #endif /* FEATURE_NV_fragment_program */
1398 /* GL_NV_texture_rectangle */
1399 case GL_TEXTURE_RECTANGLE_NV
:
1400 CHECK_EXTENSION(NV_texture_rectangle
);
1401 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1403 /* GL_EXT_stencil_two_side */
1404 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1405 CHECK_EXTENSION(EXT_stencil_two_side
);
1406 return ctx
->Stencil
.TestTwoSide
;
1408 #if FEATURE_ARB_fragment_program
1409 case GL_FRAGMENT_PROGRAM_ARB
:
1410 return ctx
->FragmentProgram
.Enabled
;
1411 #endif /* FEATURE_ARB_fragment_program */
1413 /* GL_EXT_depth_bounds_test */
1414 case GL_DEPTH_BOUNDS_TEST_EXT
:
1415 CHECK_EXTENSION(EXT_depth_bounds_test
);
1416 return ctx
->Depth
.BoundsTest
;
1418 /* GL_MESA_program_debug */
1419 #if FEATURE_MESA_program_debug
1420 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1421 CHECK_EXTENSION(MESA_program_debug
);
1422 return ctx
->FragmentProgram
.CallbackEnabled
;
1423 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1424 CHECK_EXTENSION(MESA_program_debug
);
1425 return ctx
->VertexProgram
.CallbackEnabled
;
1428 #if FEATURE_ATI_fragment_shader
1429 case GL_FRAGMENT_SHADER_ATI
:
1430 CHECK_EXTENSION(ATI_fragment_shader
);
1431 return ctx
->ATIFragmentShader
.Enabled
;
1432 #endif /* FEATURE_ATI_fragment_shader */
1434 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);