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.
35 #include "simple_list.h"
38 #include "api_arrayelt.h"
43 #define CHECK_EXTENSION(EXTNAME, CAP) \
44 if (!ctx->Extensions.EXTNAME) { \
45 goto invalid_enum_error; \
50 * Helper to enable/disable client-side state.
53 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
55 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
61 var
= &arrayObj
->Vertex
.Enabled
;
62 flag
= _NEW_ARRAY_VERTEX
;
65 var
= &arrayObj
->Normal
.Enabled
;
66 flag
= _NEW_ARRAY_NORMAL
;
69 var
= &arrayObj
->Color
.Enabled
;
70 flag
= _NEW_ARRAY_COLOR0
;
73 var
= &arrayObj
->Index
.Enabled
;
74 flag
= _NEW_ARRAY_INDEX
;
76 case GL_TEXTURE_COORD_ARRAY
:
77 var
= &arrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
78 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
80 case GL_EDGE_FLAG_ARRAY
:
81 var
= &arrayObj
->EdgeFlag
.Enabled
;
82 flag
= _NEW_ARRAY_EDGEFLAG
;
84 case GL_FOG_COORDINATE_ARRAY_EXT
:
85 var
= &arrayObj
->FogCoord
.Enabled
;
86 flag
= _NEW_ARRAY_FOGCOORD
;
88 case GL_SECONDARY_COLOR_ARRAY_EXT
:
89 var
= &arrayObj
->SecondaryColor
.Enabled
;
90 flag
= _NEW_ARRAY_COLOR1
;
93 #if FEATURE_point_size_array
94 case GL_POINT_SIZE_ARRAY_OES
:
95 var
= &arrayObj
->PointSize
.Enabled
;
96 flag
= _NEW_ARRAY_POINT_SIZE
;
100 #if FEATURE_NV_vertex_program
101 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
102 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
103 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
117 CHECK_EXTENSION(NV_vertex_program
, cap
);
119 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
120 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
121 var
= &arrayObj
->VertexAttrib
[n
].Enabled
;
122 flag
= _NEW_ARRAY_ATTRIB(n
);
125 #endif /* FEATURE_NV_vertex_program */
127 /* GL_NV_primitive_restart */
128 case GL_PRIMITIVE_RESTART_NV
:
129 if (!ctx
->Extensions
.NV_primitive_restart
) {
130 goto invalid_enum_error
;
132 var
= &ctx
->Array
.PrimitiveRestart
;
137 goto invalid_enum_error
;
143 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
144 ctx
->Array
.NewState
|= flag
;
146 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
151 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
153 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
155 if (ctx
->Driver
.Enable
) {
156 ctx
->Driver
.Enable( ctx
, cap
, state
);
162 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(0x%x)",
163 state
? "Enable" : "Disable", cap
);
168 * Enable GL capability.
169 * \param cap state to enable/disable.
171 * Get's the current context, assures that we're outside glBegin()/glEnd() and
172 * calls client_state().
175 _mesa_EnableClientState( GLenum cap
)
177 GET_CURRENT_CONTEXT(ctx
);
178 ASSERT_OUTSIDE_BEGIN_END(ctx
);
179 client_state( ctx
, cap
, GL_TRUE
);
184 * Disable GL capability.
185 * \param cap state to enable/disable.
187 * Get's the current context, assures that we're outside glBegin()/glEnd() and
188 * calls client_state().
191 _mesa_DisableClientState( GLenum cap
)
193 GET_CURRENT_CONTEXT(ctx
);
194 ASSERT_OUTSIDE_BEGIN_END(ctx
);
195 client_state( ctx
, cap
, GL_FALSE
);
199 #undef CHECK_EXTENSION
200 #define CHECK_EXTENSION(EXTNAME, CAP) \
201 if (!ctx->Extensions.EXTNAME) { \
202 goto invalid_enum_error; \
205 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
206 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
207 goto invalid_enum_error; \
213 * Return pointer to current texture unit for setting/getting coordinate
215 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
216 * higher than the number of supported coordinate units. And we'll return NULL.
218 static struct gl_texture_unit
*
219 get_texcoord_unit(struct gl_context
*ctx
)
221 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
222 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
226 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
232 * Helper function to enable or disable a texture target.
233 * \param bit one of the TEXTURE_x_BIT values
234 * \return GL_TRUE if state is changing or GL_FALSE if no change
237 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
239 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
240 const GLbitfield newenabled
= state
241 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
243 if (texUnit
->Enabled
== newenabled
)
246 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
247 texUnit
->Enabled
= newenabled
;
253 * Helper function to enable or disable state.
255 * \param ctx GL context.
256 * \param cap the state to enable/disable
257 * \param state whether to enable or disable the specified capability.
259 * Updates the current context and flushes the vertices as needed. For
260 * capabilities associated with extensions it verifies that those extensions
261 * are effectivly present before updating. Notifies the driver via
262 * dd_function_table::Enable.
265 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
267 if (MESA_VERBOSE
& VERBOSE_API
)
268 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
269 state
? "glEnable" : "glDisable",
270 _mesa_lookup_enum_by_nr(cap
),
275 if (ctx
->Color
.AlphaEnabled
== state
)
277 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
278 ctx
->Color
.AlphaEnabled
= state
;
281 if (ctx
->Eval
.AutoNormal
== state
)
283 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
284 ctx
->Eval
.AutoNormal
= state
;
288 GLbitfield newEnabled
= state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
289 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
290 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
291 ctx
->Color
.BlendEnabled
= newEnabled
;
303 const GLuint p
= cap
- GL_CLIP_PLANE0
;
305 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
308 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
311 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
313 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
314 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
316 /* This derived state also calculated in clip.c and
317 * from _mesa_update_state() on changes to EyeUserPlane
318 * and ctx->ProjectionMatrix respectively.
320 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
321 ctx
->Transform
.EyeUserPlane
[p
],
322 ctx
->ProjectionMatrixStack
.Top
->inv
);
325 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
330 case GL_COLOR_MATERIAL
:
331 if (ctx
->Light
.ColorMaterialEnabled
== state
)
333 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
334 FLUSH_CURRENT(ctx
, 0);
335 ctx
->Light
.ColorMaterialEnabled
= state
;
337 _mesa_update_color_material( ctx
,
338 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
342 if (ctx
->Polygon
.CullFlag
== state
)
344 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
345 ctx
->Polygon
.CullFlag
= state
;
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
;
376 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
378 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
379 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
381 insert_at_tail(&ctx
->Light
.EnabledList
,
382 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
385 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
389 if (ctx
->Light
.Enabled
== state
)
391 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
392 ctx
->Light
.Enabled
= state
;
393 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
394 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
396 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
399 if (ctx
->Line
.SmoothFlag
== state
)
401 FLUSH_VERTICES(ctx
, _NEW_LINE
);
402 ctx
->Line
.SmoothFlag
= state
;
403 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
405 case GL_LINE_STIPPLE
:
406 if (ctx
->Line
.StippleFlag
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_LINE
);
409 ctx
->Line
.StippleFlag
= state
;
410 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
412 case GL_INDEX_LOGIC_OP
:
413 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
415 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
416 ctx
->Color
.IndexLogicOpEnabled
= state
;
418 case GL_COLOR_LOGIC_OP
:
419 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
421 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
422 ctx
->Color
.ColorLogicOpEnabled
= state
;
424 case GL_MAP1_COLOR_4
:
425 if (ctx
->Eval
.Map1Color4
== state
)
427 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
428 ctx
->Eval
.Map1Color4
= state
;
431 if (ctx
->Eval
.Map1Index
== state
)
433 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
434 ctx
->Eval
.Map1Index
= state
;
437 if (ctx
->Eval
.Map1Normal
== state
)
439 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
440 ctx
->Eval
.Map1Normal
= state
;
442 case GL_MAP1_TEXTURE_COORD_1
:
443 if (ctx
->Eval
.Map1TextureCoord1
== state
)
445 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
446 ctx
->Eval
.Map1TextureCoord1
= state
;
448 case GL_MAP1_TEXTURE_COORD_2
:
449 if (ctx
->Eval
.Map1TextureCoord2
== state
)
451 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
452 ctx
->Eval
.Map1TextureCoord2
= state
;
454 case GL_MAP1_TEXTURE_COORD_3
:
455 if (ctx
->Eval
.Map1TextureCoord3
== state
)
457 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
458 ctx
->Eval
.Map1TextureCoord3
= state
;
460 case GL_MAP1_TEXTURE_COORD_4
:
461 if (ctx
->Eval
.Map1TextureCoord4
== state
)
463 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
464 ctx
->Eval
.Map1TextureCoord4
= state
;
466 case GL_MAP1_VERTEX_3
:
467 if (ctx
->Eval
.Map1Vertex3
== state
)
469 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
470 ctx
->Eval
.Map1Vertex3
= state
;
472 case GL_MAP1_VERTEX_4
:
473 if (ctx
->Eval
.Map1Vertex4
== state
)
475 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
476 ctx
->Eval
.Map1Vertex4
= state
;
478 case GL_MAP2_COLOR_4
:
479 if (ctx
->Eval
.Map2Color4
== state
)
481 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
482 ctx
->Eval
.Map2Color4
= state
;
485 if (ctx
->Eval
.Map2Index
== state
)
487 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
488 ctx
->Eval
.Map2Index
= state
;
491 if (ctx
->Eval
.Map2Normal
== state
)
493 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
494 ctx
->Eval
.Map2Normal
= state
;
496 case GL_MAP2_TEXTURE_COORD_1
:
497 if (ctx
->Eval
.Map2TextureCoord1
== state
)
499 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
500 ctx
->Eval
.Map2TextureCoord1
= state
;
502 case GL_MAP2_TEXTURE_COORD_2
:
503 if (ctx
->Eval
.Map2TextureCoord2
== state
)
505 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
506 ctx
->Eval
.Map2TextureCoord2
= state
;
508 case GL_MAP2_TEXTURE_COORD_3
:
509 if (ctx
->Eval
.Map2TextureCoord3
== state
)
511 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
512 ctx
->Eval
.Map2TextureCoord3
= state
;
514 case GL_MAP2_TEXTURE_COORD_4
:
515 if (ctx
->Eval
.Map2TextureCoord4
== state
)
517 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
518 ctx
->Eval
.Map2TextureCoord4
= state
;
520 case GL_MAP2_VERTEX_3
:
521 if (ctx
->Eval
.Map2Vertex3
== state
)
523 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
524 ctx
->Eval
.Map2Vertex3
= state
;
526 case GL_MAP2_VERTEX_4
:
527 if (ctx
->Eval
.Map2Vertex4
== state
)
529 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
530 ctx
->Eval
.Map2Vertex4
= state
;
533 if (ctx
->Transform
.Normalize
== state
)
535 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
536 ctx
->Transform
.Normalize
= state
;
538 case GL_POINT_SMOOTH
:
539 if (ctx
->Point
.SmoothFlag
== state
)
541 FLUSH_VERTICES(ctx
, _NEW_POINT
);
542 ctx
->Point
.SmoothFlag
= state
;
543 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
545 case GL_POLYGON_SMOOTH
:
546 if (ctx
->Polygon
.SmoothFlag
== state
)
548 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
549 ctx
->Polygon
.SmoothFlag
= state
;
550 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
552 case GL_POLYGON_STIPPLE
:
553 if (ctx
->Polygon
.StippleFlag
== state
)
555 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
556 ctx
->Polygon
.StippleFlag
= state
;
557 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
559 case GL_POLYGON_OFFSET_POINT
:
560 if (ctx
->Polygon
.OffsetPoint
== state
)
562 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
563 ctx
->Polygon
.OffsetPoint
= state
;
565 case GL_POLYGON_OFFSET_LINE
:
566 if (ctx
->Polygon
.OffsetLine
== state
)
568 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
569 ctx
->Polygon
.OffsetLine
= state
;
571 case GL_POLYGON_OFFSET_FILL
:
572 /*case GL_POLYGON_OFFSET_EXT:*/
573 if (ctx
->Polygon
.OffsetFill
== state
)
575 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
576 ctx
->Polygon
.OffsetFill
= state
;
578 case GL_RESCALE_NORMAL_EXT
:
579 if (ctx
->Transform
.RescaleNormals
== state
)
581 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
582 ctx
->Transform
.RescaleNormals
= state
;
584 case GL_SCISSOR_TEST
:
585 if (ctx
->Scissor
.Enabled
== state
)
587 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
588 ctx
->Scissor
.Enabled
= state
;
590 case GL_SHARED_TEXTURE_PALETTE_EXT
:
591 if (ctx
->Texture
.SharedPalette
== state
)
593 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
594 ctx
->Texture
.SharedPalette
= state
;
596 case GL_STENCIL_TEST
:
597 if (ctx
->Stencil
.Enabled
== state
)
599 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
600 ctx
->Stencil
.Enabled
= state
;
603 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
608 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
613 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
617 case GL_TEXTURE_GEN_Q
:
619 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
621 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
624 if (texUnit
->TexGenEnabled
== newenabled
)
626 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
627 texUnit
->TexGenEnabled
= newenabled
;
631 case GL_TEXTURE_GEN_R
:
633 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
635 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
638 if (texUnit
->TexGenEnabled
== newenabled
)
640 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
641 texUnit
->TexGenEnabled
= newenabled
;
645 case GL_TEXTURE_GEN_S
:
647 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
649 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
652 if (texUnit
->TexGenEnabled
== newenabled
)
654 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
655 texUnit
->TexGenEnabled
= newenabled
;
659 case GL_TEXTURE_GEN_T
:
661 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
663 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
666 if (texUnit
->TexGenEnabled
== newenabled
)
668 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
669 texUnit
->TexGenEnabled
= newenabled
;
675 case GL_TEXTURE_GEN_STR_OES
:
676 /* disable S, T, and R at the same time */
678 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
681 texUnit
->TexGenEnabled
& ~STR_BITS
;
683 newenabled
|= STR_BITS
;
684 if (texUnit
->TexGenEnabled
== newenabled
)
686 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
687 texUnit
->TexGenEnabled
= newenabled
;
696 case GL_VERTEX_ARRAY
:
697 case GL_NORMAL_ARRAY
:
700 case GL_TEXTURE_COORD_ARRAY
:
701 case GL_EDGE_FLAG_ARRAY
:
702 case GL_FOG_COORDINATE_ARRAY_EXT
:
703 case GL_SECONDARY_COLOR_ARRAY_EXT
:
704 case GL_POINT_SIZE_ARRAY_OES
:
705 client_state( ctx
, cap
, state
);
708 /* GL_SGI_texture_color_table */
709 case GL_TEXTURE_COLOR_TABLE_SGI
:
710 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
711 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
713 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
714 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
717 /* GL_ARB_texture_cube_map */
718 case GL_TEXTURE_CUBE_MAP_ARB
:
719 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
720 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
725 /* GL_EXT_secondary_color */
726 case GL_COLOR_SUM_EXT
:
727 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
728 if (ctx
->Fog
.ColorSumEnabled
== state
)
730 FLUSH_VERTICES(ctx
, _NEW_FOG
);
731 ctx
->Fog
.ColorSumEnabled
= state
;
734 /* GL_ARB_multisample */
735 case GL_MULTISAMPLE_ARB
:
736 if (ctx
->Multisample
.Enabled
== state
)
738 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
739 ctx
->Multisample
.Enabled
= state
;
741 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
742 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
744 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
745 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
747 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
748 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
750 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
751 ctx
->Multisample
.SampleAlphaToOne
= state
;
753 case GL_SAMPLE_COVERAGE_ARB
:
754 if (ctx
->Multisample
.SampleCoverage
== state
)
756 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
757 ctx
->Multisample
.SampleCoverage
= state
;
759 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
760 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
762 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
763 ctx
->Multisample
.SampleCoverageInvert
= state
;
766 /* GL_IBM_rasterpos_clip */
767 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
768 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
769 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
771 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
772 ctx
->Transform
.RasterPositionUnclipped
= state
;
775 /* GL_NV_point_sprite */
776 case GL_POINT_SPRITE_NV
:
777 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
778 if (ctx
->Point
.PointSprite
== state
)
780 FLUSH_VERTICES(ctx
, _NEW_POINT
);
781 ctx
->Point
.PointSprite
= state
;
784 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
785 case GL_VERTEX_PROGRAM_ARB
:
786 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
787 if (ctx
->VertexProgram
.Enabled
== state
)
789 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
790 ctx
->VertexProgram
.Enabled
= state
;
792 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
793 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
794 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
796 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
797 ctx
->VertexProgram
.PointSizeEnabled
= state
;
799 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
800 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
801 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
803 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
804 ctx
->VertexProgram
.TwoSideEnabled
= state
;
807 #if FEATURE_NV_vertex_program
808 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
809 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
810 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
811 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
812 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
813 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
814 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
815 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
816 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
817 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
818 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
819 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
820 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
821 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
822 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
823 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
824 CHECK_EXTENSION(NV_vertex_program
, cap
);
826 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
827 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
828 ctx
->Eval
.Map1Attrib
[map
] = state
;
831 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
832 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
833 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
834 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
835 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
836 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
837 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
838 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
839 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
840 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
841 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
842 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
843 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
844 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
845 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
846 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
847 CHECK_EXTENSION(NV_vertex_program
, cap
);
849 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
850 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
851 ctx
->Eval
.Map2Attrib
[map
] = state
;
854 #endif /* FEATURE_NV_vertex_program */
856 #if FEATURE_NV_fragment_program
857 case GL_FRAGMENT_PROGRAM_NV
:
858 CHECK_EXTENSION(NV_fragment_program
, cap
);
859 if (ctx
->FragmentProgram
.Enabled
== state
)
861 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
862 ctx
->FragmentProgram
.Enabled
= state
;
864 #endif /* FEATURE_NV_fragment_program */
866 /* GL_NV_texture_rectangle */
867 case GL_TEXTURE_RECTANGLE_NV
:
868 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
869 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
874 /* GL_EXT_stencil_two_side */
875 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
876 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
877 if (ctx
->Stencil
.TestTwoSide
== state
)
879 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
880 ctx
->Stencil
.TestTwoSide
= state
;
882 ctx
->Stencil
._BackFace
= 2;
883 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
885 ctx
->Stencil
._BackFace
= 1;
886 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
890 #if FEATURE_ARB_fragment_program
891 case GL_FRAGMENT_PROGRAM_ARB
:
892 CHECK_EXTENSION(ARB_fragment_program
, cap
);
893 if (ctx
->FragmentProgram
.Enabled
== state
)
895 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
896 ctx
->FragmentProgram
.Enabled
= state
;
898 #endif /* FEATURE_ARB_fragment_program */
900 /* GL_EXT_depth_bounds_test */
901 case GL_DEPTH_BOUNDS_TEST_EXT
:
902 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
903 if (ctx
->Depth
.BoundsTest
== state
)
905 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
906 ctx
->Depth
.BoundsTest
= state
;
910 if (ctx
->Transform
.DepthClamp
== state
)
912 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
913 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
914 ctx
->Transform
.DepthClamp
= state
;
917 #if FEATURE_ATI_fragment_shader
918 case GL_FRAGMENT_SHADER_ATI
:
919 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
920 if (ctx
->ATIFragmentShader
.Enabled
== state
)
922 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
923 ctx
->ATIFragmentShader
.Enabled
= state
;
927 /* GL_MESA_texture_array */
928 case GL_TEXTURE_1D_ARRAY_EXT
:
929 CHECK_EXTENSION(MESA_texture_array
, cap
);
930 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
935 case GL_TEXTURE_2D_ARRAY_EXT
:
936 CHECK_EXTENSION(MESA_texture_array
, cap
);
937 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
942 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
943 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
944 ctx
->Texture
.CubeMapSeamless
= state
;
947 #if FEATURE_EXT_transform_feedback
948 case GL_RASTERIZER_DISCARD
:
949 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
950 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
951 ctx
->TransformFeedback
.RasterDiscard
= state
;
952 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
957 /* GL 3.1 primitive restart. Note: this enum is different from
958 * GL_PRIMITIVE_RESTART_NV (which is client state).
960 case GL_PRIMITIVE_RESTART
:
961 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
962 goto invalid_enum_error
;
964 if (ctx
->Array
.PrimitiveRestart
!= state
) {
965 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
966 ctx
->Array
.PrimitiveRestart
= state
;
971 goto invalid_enum_error
;
974 if (ctx
->Driver
.Enable
) {
975 ctx
->Driver
.Enable( ctx
, cap
, state
);
981 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
982 state
? "Enable" : "Disable", cap
);
987 * Enable GL capability. Called by glEnable()
988 * \param cap state to enable.
991 _mesa_Enable( GLenum cap
)
993 GET_CURRENT_CONTEXT(ctx
);
994 ASSERT_OUTSIDE_BEGIN_END(ctx
);
996 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1001 * Disable GL capability. Called by glDisable()
1002 * \param cap state to disable.
1005 _mesa_Disable( GLenum cap
)
1007 GET_CURRENT_CONTEXT(ctx
);
1008 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1010 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1016 * Enable/disable an indexed state var.
1019 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1021 ASSERT(state
== 0 || state
== 1);
1024 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1025 goto invalid_enum_error
;
1027 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1028 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1029 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1032 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1033 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1035 ctx
->Color
.BlendEnabled
|= (1 << index
);
1037 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1041 goto invalid_enum_error
;
1046 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1047 state
? "glEnablei" : "glDisablei",
1048 _mesa_lookup_enum_by_nr(cap
));
1053 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1055 GET_CURRENT_CONTEXT(ctx
);
1056 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1057 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1062 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1064 GET_CURRENT_CONTEXT(ctx
);
1065 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1066 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1070 GLboolean GLAPIENTRY
1071 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1073 GET_CURRENT_CONTEXT(ctx
);
1076 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1077 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1081 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1083 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1084 _mesa_lookup_enum_by_nr(cap
));
1092 #undef CHECK_EXTENSION
1093 #define CHECK_EXTENSION(EXTNAME) \
1094 if (!ctx->Extensions.EXTNAME) { \
1095 goto invalid_enum_error; \
1098 #undef CHECK_EXTENSION2
1099 #define CHECK_EXTENSION2(EXT1, EXT2) \
1100 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1101 goto invalid_enum_error; \
1106 * Helper function to determine whether a texture target is enabled.
1109 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1111 const struct gl_texture_unit
*const texUnit
=
1112 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1113 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1118 * Return simple enable/disable state.
1120 * \param cap state variable to query.
1122 * Returns the state of the specified capability from the current GL context.
1123 * For the capabilities associated with extensions verifies that those
1124 * extensions are effectively present before reporting.
1126 GLboolean GLAPIENTRY
1127 _mesa_IsEnabled( GLenum cap
)
1129 GET_CURRENT_CONTEXT(ctx
);
1132 return ctx
->Color
.AlphaEnabled
;
1133 case GL_AUTO_NORMAL
:
1134 return ctx
->Eval
.AutoNormal
;
1136 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1137 case GL_CLIP_PLANE0
:
1138 case GL_CLIP_PLANE1
:
1139 case GL_CLIP_PLANE2
:
1140 case GL_CLIP_PLANE3
:
1141 case GL_CLIP_PLANE4
:
1142 case GL_CLIP_PLANE5
:
1143 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1144 case GL_COLOR_MATERIAL
:
1145 return ctx
->Light
.ColorMaterialEnabled
;
1147 return ctx
->Polygon
.CullFlag
;
1149 return ctx
->Depth
.Test
;
1151 return ctx
->Color
.DitherFlag
;
1153 return ctx
->Fog
.Enabled
;
1155 return ctx
->Light
.Enabled
;
1164 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1165 case GL_LINE_SMOOTH
:
1166 return ctx
->Line
.SmoothFlag
;
1167 case GL_LINE_STIPPLE
:
1168 return ctx
->Line
.StippleFlag
;
1169 case GL_INDEX_LOGIC_OP
:
1170 return ctx
->Color
.IndexLogicOpEnabled
;
1171 case GL_COLOR_LOGIC_OP
:
1172 return ctx
->Color
.ColorLogicOpEnabled
;
1173 case GL_MAP1_COLOR_4
:
1174 return ctx
->Eval
.Map1Color4
;
1176 return ctx
->Eval
.Map1Index
;
1177 case GL_MAP1_NORMAL
:
1178 return ctx
->Eval
.Map1Normal
;
1179 case GL_MAP1_TEXTURE_COORD_1
:
1180 return ctx
->Eval
.Map1TextureCoord1
;
1181 case GL_MAP1_TEXTURE_COORD_2
:
1182 return ctx
->Eval
.Map1TextureCoord2
;
1183 case GL_MAP1_TEXTURE_COORD_3
:
1184 return ctx
->Eval
.Map1TextureCoord3
;
1185 case GL_MAP1_TEXTURE_COORD_4
:
1186 return ctx
->Eval
.Map1TextureCoord4
;
1187 case GL_MAP1_VERTEX_3
:
1188 return ctx
->Eval
.Map1Vertex3
;
1189 case GL_MAP1_VERTEX_4
:
1190 return ctx
->Eval
.Map1Vertex4
;
1191 case GL_MAP2_COLOR_4
:
1192 return ctx
->Eval
.Map2Color4
;
1194 return ctx
->Eval
.Map2Index
;
1195 case GL_MAP2_NORMAL
:
1196 return ctx
->Eval
.Map2Normal
;
1197 case GL_MAP2_TEXTURE_COORD_1
:
1198 return ctx
->Eval
.Map2TextureCoord1
;
1199 case GL_MAP2_TEXTURE_COORD_2
:
1200 return ctx
->Eval
.Map2TextureCoord2
;
1201 case GL_MAP2_TEXTURE_COORD_3
:
1202 return ctx
->Eval
.Map2TextureCoord3
;
1203 case GL_MAP2_TEXTURE_COORD_4
:
1204 return ctx
->Eval
.Map2TextureCoord4
;
1205 case GL_MAP2_VERTEX_3
:
1206 return ctx
->Eval
.Map2Vertex3
;
1207 case GL_MAP2_VERTEX_4
:
1208 return ctx
->Eval
.Map2Vertex4
;
1210 return ctx
->Transform
.Normalize
;
1211 case GL_POINT_SMOOTH
:
1212 return ctx
->Point
.SmoothFlag
;
1213 case GL_POLYGON_SMOOTH
:
1214 return ctx
->Polygon
.SmoothFlag
;
1215 case GL_POLYGON_STIPPLE
:
1216 return ctx
->Polygon
.StippleFlag
;
1217 case GL_POLYGON_OFFSET_POINT
:
1218 return ctx
->Polygon
.OffsetPoint
;
1219 case GL_POLYGON_OFFSET_LINE
:
1220 return ctx
->Polygon
.OffsetLine
;
1221 case GL_POLYGON_OFFSET_FILL
:
1222 /*case GL_POLYGON_OFFSET_EXT:*/
1223 return ctx
->Polygon
.OffsetFill
;
1224 case GL_RESCALE_NORMAL_EXT
:
1225 return ctx
->Transform
.RescaleNormals
;
1226 case GL_SCISSOR_TEST
:
1227 return ctx
->Scissor
.Enabled
;
1228 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1229 return ctx
->Texture
.SharedPalette
;
1230 case GL_STENCIL_TEST
:
1231 return ctx
->Stencil
.Enabled
;
1233 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1235 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1237 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1238 case GL_TEXTURE_GEN_Q
:
1240 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1242 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1246 case GL_TEXTURE_GEN_R
:
1248 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1250 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1254 case GL_TEXTURE_GEN_S
:
1256 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1258 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1262 case GL_TEXTURE_GEN_T
:
1264 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1266 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1271 case GL_TEXTURE_GEN_STR_OES
:
1273 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1275 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1283 case GL_VERTEX_ARRAY
:
1284 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1285 case GL_NORMAL_ARRAY
:
1286 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1287 case GL_COLOR_ARRAY
:
1288 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1289 case GL_INDEX_ARRAY
:
1290 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1291 case GL_TEXTURE_COORD_ARRAY
:
1292 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1293 case GL_EDGE_FLAG_ARRAY
:
1294 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1295 case GL_FOG_COORDINATE_ARRAY_EXT
:
1296 CHECK_EXTENSION(EXT_fog_coord
);
1297 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1298 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1299 CHECK_EXTENSION(EXT_secondary_color
);
1300 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1301 #if FEATURE_point_size_array
1302 case GL_POINT_SIZE_ARRAY_OES
:
1303 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1306 /* GL_SGI_texture_color_table */
1307 case GL_TEXTURE_COLOR_TABLE_SGI
:
1308 CHECK_EXTENSION(SGI_texture_color_table
);
1309 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1311 /* GL_ARB_texture_cube_map */
1312 case GL_TEXTURE_CUBE_MAP_ARB
:
1313 CHECK_EXTENSION(ARB_texture_cube_map
);
1314 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1316 /* GL_EXT_secondary_color */
1317 case GL_COLOR_SUM_EXT
:
1318 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1319 return ctx
->Fog
.ColorSumEnabled
;
1321 /* GL_ARB_multisample */
1322 case GL_MULTISAMPLE_ARB
:
1323 return ctx
->Multisample
.Enabled
;
1324 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1325 return ctx
->Multisample
.SampleAlphaToCoverage
;
1326 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1327 return ctx
->Multisample
.SampleAlphaToOne
;
1328 case GL_SAMPLE_COVERAGE_ARB
:
1329 return ctx
->Multisample
.SampleCoverage
;
1330 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1331 return ctx
->Multisample
.SampleCoverageInvert
;
1333 /* GL_IBM_rasterpos_clip */
1334 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1335 CHECK_EXTENSION(IBM_rasterpos_clip
);
1336 return ctx
->Transform
.RasterPositionUnclipped
;
1338 /* GL_NV_point_sprite */
1339 case GL_POINT_SPRITE_NV
:
1340 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1341 return ctx
->Point
.PointSprite
;
1343 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1344 case GL_VERTEX_PROGRAM_ARB
:
1345 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1346 return ctx
->VertexProgram
.Enabled
;
1347 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1348 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1349 return ctx
->VertexProgram
.PointSizeEnabled
;
1350 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1351 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1352 return ctx
->VertexProgram
.TwoSideEnabled
;
1354 #if FEATURE_NV_vertex_program
1355 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1356 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1357 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1358 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1359 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1360 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1361 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1362 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1363 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1364 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1365 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1366 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1367 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1368 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1369 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1370 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1371 CHECK_EXTENSION(NV_vertex_program
);
1373 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1374 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1375 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1377 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1378 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1379 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1380 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1381 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1382 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1383 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1384 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1385 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1386 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1387 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1388 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1389 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1390 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1391 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1392 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1393 CHECK_EXTENSION(NV_vertex_program
);
1395 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1396 return ctx
->Eval
.Map1Attrib
[map
];
1398 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1399 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1400 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1401 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1402 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1403 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1404 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1405 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1406 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1407 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1408 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1409 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1410 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1411 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1412 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1413 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1414 CHECK_EXTENSION(NV_vertex_program
);
1416 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1417 return ctx
->Eval
.Map2Attrib
[map
];
1419 #endif /* FEATURE_NV_vertex_program */
1421 #if FEATURE_NV_fragment_program
1422 case GL_FRAGMENT_PROGRAM_NV
:
1423 CHECK_EXTENSION(NV_fragment_program
);
1424 return ctx
->FragmentProgram
.Enabled
;
1425 #endif /* FEATURE_NV_fragment_program */
1427 /* GL_NV_texture_rectangle */
1428 case GL_TEXTURE_RECTANGLE_NV
:
1429 CHECK_EXTENSION(NV_texture_rectangle
);
1430 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1432 /* GL_EXT_stencil_two_side */
1433 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1434 CHECK_EXTENSION(EXT_stencil_two_side
);
1435 return ctx
->Stencil
.TestTwoSide
;
1437 #if FEATURE_ARB_fragment_program
1438 case GL_FRAGMENT_PROGRAM_ARB
:
1439 return ctx
->FragmentProgram
.Enabled
;
1440 #endif /* FEATURE_ARB_fragment_program */
1442 /* GL_EXT_depth_bounds_test */
1443 case GL_DEPTH_BOUNDS_TEST_EXT
:
1444 CHECK_EXTENSION(EXT_depth_bounds_test
);
1445 return ctx
->Depth
.BoundsTest
;
1447 /* GL_ARB_depth_clamp */
1448 case GL_DEPTH_CLAMP
:
1449 CHECK_EXTENSION(ARB_depth_clamp
);
1450 return ctx
->Transform
.DepthClamp
;
1452 #if FEATURE_ATI_fragment_shader
1453 case GL_FRAGMENT_SHADER_ATI
:
1454 CHECK_EXTENSION(ATI_fragment_shader
);
1455 return ctx
->ATIFragmentShader
.Enabled
;
1456 #endif /* FEATURE_ATI_fragment_shader */
1458 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1459 CHECK_EXTENSION(ARB_seamless_cube_map
);
1460 return ctx
->Texture
.CubeMapSeamless
;
1462 #if FEATURE_EXT_transform_feedback
1463 case GL_RASTERIZER_DISCARD
:
1464 CHECK_EXTENSION(EXT_transform_feedback
);
1465 return ctx
->TransformFeedback
.RasterDiscard
;
1468 /* GL_NV_primitive_restart */
1469 case GL_PRIMITIVE_RESTART_NV
:
1470 if (!ctx
->Extensions
.NV_primitive_restart
) {
1471 goto invalid_enum_error
;
1473 return ctx
->Array
.PrimitiveRestart
;
1475 /* GL 3.1 primitive restart */
1476 case GL_PRIMITIVE_RESTART
:
1477 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1478 goto invalid_enum_error
;
1480 return ctx
->Array
.PrimitiveRestart
;
1483 goto invalid_enum_error
;
1489 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);