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"
36 #include "mfeatures.h"
39 #include "api_arrayelt.h"
44 #define CHECK_EXTENSION(EXTNAME, CAP) \
45 if (!ctx->Extensions.EXTNAME) { \
46 goto invalid_enum_error; \
51 * Helper to enable/disable client-side state.
54 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
56 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
62 var
= &arrayObj
->Vertex
.Enabled
;
63 flag
= _NEW_ARRAY_VERTEX
;
66 var
= &arrayObj
->Normal
.Enabled
;
67 flag
= _NEW_ARRAY_NORMAL
;
70 var
= &arrayObj
->Color
.Enabled
;
71 flag
= _NEW_ARRAY_COLOR0
;
74 var
= &arrayObj
->Index
.Enabled
;
75 flag
= _NEW_ARRAY_INDEX
;
77 case GL_TEXTURE_COORD_ARRAY
:
78 var
= &arrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
79 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
81 case GL_EDGE_FLAG_ARRAY
:
82 var
= &arrayObj
->EdgeFlag
.Enabled
;
83 flag
= _NEW_ARRAY_EDGEFLAG
;
85 case GL_FOG_COORDINATE_ARRAY_EXT
:
86 var
= &arrayObj
->FogCoord
.Enabled
;
87 flag
= _NEW_ARRAY_FOGCOORD
;
89 case GL_SECONDARY_COLOR_ARRAY_EXT
:
90 var
= &arrayObj
->SecondaryColor
.Enabled
;
91 flag
= _NEW_ARRAY_COLOR1
;
94 #if FEATURE_point_size_array
95 case GL_POINT_SIZE_ARRAY_OES
:
96 var
= &arrayObj
->PointSize
.Enabled
;
97 flag
= _NEW_ARRAY_POINT_SIZE
;
101 #if FEATURE_NV_vertex_program
102 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
103 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
118 CHECK_EXTENSION(NV_vertex_program
, cap
);
120 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
121 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
122 var
= &arrayObj
->VertexAttrib
[n
].Enabled
;
123 flag
= _NEW_ARRAY_ATTRIB(n
);
126 #endif /* FEATURE_NV_vertex_program */
128 /* GL_NV_primitive_restart */
129 case GL_PRIMITIVE_RESTART_NV
:
130 if (!ctx
->Extensions
.NV_primitive_restart
) {
131 goto invalid_enum_error
;
133 var
= &ctx
->Array
.PrimitiveRestart
;
138 goto invalid_enum_error
;
144 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
145 ctx
->Array
.NewState
|= flag
;
147 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
152 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
154 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
156 if (ctx
->Driver
.Enable
) {
157 ctx
->Driver
.Enable( ctx
, cap
, state
);
163 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(0x%x)",
164 state
? "Enable" : "Disable", cap
);
169 * Enable GL capability.
170 * \param cap state to enable/disable.
172 * Get's the current context, assures that we're outside glBegin()/glEnd() and
173 * calls client_state().
176 _mesa_EnableClientState( GLenum cap
)
178 GET_CURRENT_CONTEXT(ctx
);
179 ASSERT_OUTSIDE_BEGIN_END(ctx
);
180 client_state( ctx
, cap
, GL_TRUE
);
185 * Disable GL capability.
186 * \param cap state to enable/disable.
188 * Get's the current context, assures that we're outside glBegin()/glEnd() and
189 * calls client_state().
192 _mesa_DisableClientState( GLenum cap
)
194 GET_CURRENT_CONTEXT(ctx
);
195 ASSERT_OUTSIDE_BEGIN_END(ctx
);
196 client_state( ctx
, cap
, GL_FALSE
);
200 #undef CHECK_EXTENSION
201 #define CHECK_EXTENSION(EXTNAME, CAP) \
202 if (!ctx->Extensions.EXTNAME) { \
203 goto invalid_enum_error; \
206 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
207 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
208 goto invalid_enum_error; \
214 * Return pointer to current texture unit for setting/getting coordinate
216 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
217 * higher than the number of supported coordinate units. And we'll return NULL.
219 static struct gl_texture_unit
*
220 get_texcoord_unit(struct gl_context
*ctx
)
222 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
223 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
227 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
233 * Helper function to enable or disable a texture target.
234 * \param bit one of the TEXTURE_x_BIT values
235 * \return GL_TRUE if state is changing or GL_FALSE if no change
238 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
240 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
241 const GLbitfield newenabled
= state
242 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
244 if (texUnit
->Enabled
== newenabled
)
247 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
248 texUnit
->Enabled
= newenabled
;
254 * Helper function to enable or disable state.
256 * \param ctx GL context.
257 * \param cap the state to enable/disable
258 * \param state whether to enable or disable the specified capability.
260 * Updates the current context and flushes the vertices as needed. For
261 * capabilities associated with extensions it verifies that those extensions
262 * are effectivly present before updating. Notifies the driver via
263 * dd_function_table::Enable.
266 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
268 if (MESA_VERBOSE
& VERBOSE_API
)
269 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
270 state
? "glEnable" : "glDisable",
271 _mesa_lookup_enum_by_nr(cap
),
276 if (ctx
->Color
.AlphaEnabled
== state
)
278 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
279 ctx
->Color
.AlphaEnabled
= state
;
282 if (ctx
->Eval
.AutoNormal
== state
)
284 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
285 ctx
->Eval
.AutoNormal
= state
;
289 GLbitfield newEnabled
= state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
290 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
291 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
292 ctx
->Color
.BlendEnabled
= newEnabled
;
304 const GLuint p
= cap
- GL_CLIP_PLANE0
;
306 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
309 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
312 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
314 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
315 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
317 /* This derived state also calculated in clip.c and
318 * from _mesa_update_state() on changes to EyeUserPlane
319 * and ctx->ProjectionMatrix respectively.
321 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
322 ctx
->Transform
.EyeUserPlane
[p
],
323 ctx
->ProjectionMatrixStack
.Top
->inv
);
326 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
331 case GL_COLOR_MATERIAL
:
332 if (ctx
->Light
.ColorMaterialEnabled
== state
)
334 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
335 FLUSH_CURRENT(ctx
, 0);
336 ctx
->Light
.ColorMaterialEnabled
= state
;
338 _mesa_update_color_material( ctx
,
339 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
343 if (ctx
->Polygon
.CullFlag
== state
)
345 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
346 ctx
->Polygon
.CullFlag
= state
;
349 if (ctx
->Depth
.Test
== state
)
351 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
352 ctx
->Depth
.Test
= state
;
356 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
358 if (ctx
->Color
.DitherFlag
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
361 ctx
->Color
.DitherFlag
= state
;
364 if (ctx
->Fog
.Enabled
== state
)
366 FLUSH_VERTICES(ctx
, _NEW_FOG
);
367 ctx
->Fog
.Enabled
= state
;
377 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
379 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
380 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
382 insert_at_tail(&ctx
->Light
.EnabledList
,
383 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
386 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
390 if (ctx
->Light
.Enabled
== state
)
392 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
393 ctx
->Light
.Enabled
= state
;
394 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
395 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
397 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
400 if (ctx
->Line
.SmoothFlag
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_LINE
);
403 ctx
->Line
.SmoothFlag
= state
;
404 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
406 case GL_LINE_STIPPLE
:
407 if (ctx
->Line
.StippleFlag
== state
)
409 FLUSH_VERTICES(ctx
, _NEW_LINE
);
410 ctx
->Line
.StippleFlag
= state
;
411 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
413 case GL_INDEX_LOGIC_OP
:
414 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
416 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
417 ctx
->Color
.IndexLogicOpEnabled
= state
;
419 case GL_COLOR_LOGIC_OP
:
420 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
422 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
423 ctx
->Color
.ColorLogicOpEnabled
= state
;
425 case GL_MAP1_COLOR_4
:
426 if (ctx
->Eval
.Map1Color4
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
429 ctx
->Eval
.Map1Color4
= state
;
432 if (ctx
->Eval
.Map1Index
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
435 ctx
->Eval
.Map1Index
= state
;
438 if (ctx
->Eval
.Map1Normal
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
441 ctx
->Eval
.Map1Normal
= state
;
443 case GL_MAP1_TEXTURE_COORD_1
:
444 if (ctx
->Eval
.Map1TextureCoord1
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
447 ctx
->Eval
.Map1TextureCoord1
= state
;
449 case GL_MAP1_TEXTURE_COORD_2
:
450 if (ctx
->Eval
.Map1TextureCoord2
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map1TextureCoord2
= state
;
455 case GL_MAP1_TEXTURE_COORD_3
:
456 if (ctx
->Eval
.Map1TextureCoord3
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map1TextureCoord3
= state
;
461 case GL_MAP1_TEXTURE_COORD_4
:
462 if (ctx
->Eval
.Map1TextureCoord4
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map1TextureCoord4
= state
;
467 case GL_MAP1_VERTEX_3
:
468 if (ctx
->Eval
.Map1Vertex3
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map1Vertex3
= state
;
473 case GL_MAP1_VERTEX_4
:
474 if (ctx
->Eval
.Map1Vertex4
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map1Vertex4
= state
;
479 case GL_MAP2_COLOR_4
:
480 if (ctx
->Eval
.Map2Color4
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map2Color4
= state
;
486 if (ctx
->Eval
.Map2Index
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map2Index
= state
;
492 if (ctx
->Eval
.Map2Normal
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map2Normal
= state
;
497 case GL_MAP2_TEXTURE_COORD_1
:
498 if (ctx
->Eval
.Map2TextureCoord1
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
501 ctx
->Eval
.Map2TextureCoord1
= state
;
503 case GL_MAP2_TEXTURE_COORD_2
:
504 if (ctx
->Eval
.Map2TextureCoord2
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map2TextureCoord2
= state
;
509 case GL_MAP2_TEXTURE_COORD_3
:
510 if (ctx
->Eval
.Map2TextureCoord3
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map2TextureCoord3
= state
;
515 case GL_MAP2_TEXTURE_COORD_4
:
516 if (ctx
->Eval
.Map2TextureCoord4
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map2TextureCoord4
= state
;
521 case GL_MAP2_VERTEX_3
:
522 if (ctx
->Eval
.Map2Vertex3
== state
)
524 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
525 ctx
->Eval
.Map2Vertex3
= state
;
527 case GL_MAP2_VERTEX_4
:
528 if (ctx
->Eval
.Map2Vertex4
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
531 ctx
->Eval
.Map2Vertex4
= state
;
534 if (ctx
->Transform
.Normalize
== state
)
536 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
537 ctx
->Transform
.Normalize
= state
;
539 case GL_POINT_SMOOTH
:
540 if (ctx
->Point
.SmoothFlag
== state
)
542 FLUSH_VERTICES(ctx
, _NEW_POINT
);
543 ctx
->Point
.SmoothFlag
= state
;
544 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
546 case GL_POLYGON_SMOOTH
:
547 if (ctx
->Polygon
.SmoothFlag
== state
)
549 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
550 ctx
->Polygon
.SmoothFlag
= state
;
551 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
553 case GL_POLYGON_STIPPLE
:
554 if (ctx
->Polygon
.StippleFlag
== state
)
556 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
557 ctx
->Polygon
.StippleFlag
= state
;
558 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
560 case GL_POLYGON_OFFSET_POINT
:
561 if (ctx
->Polygon
.OffsetPoint
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
564 ctx
->Polygon
.OffsetPoint
= state
;
566 case GL_POLYGON_OFFSET_LINE
:
567 if (ctx
->Polygon
.OffsetLine
== state
)
569 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
570 ctx
->Polygon
.OffsetLine
= state
;
572 case GL_POLYGON_OFFSET_FILL
:
573 /*case GL_POLYGON_OFFSET_EXT:*/
574 if (ctx
->Polygon
.OffsetFill
== state
)
576 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
577 ctx
->Polygon
.OffsetFill
= state
;
579 case GL_RESCALE_NORMAL_EXT
:
580 if (ctx
->Transform
.RescaleNormals
== state
)
582 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
583 ctx
->Transform
.RescaleNormals
= state
;
585 case GL_SCISSOR_TEST
:
586 if (ctx
->Scissor
.Enabled
== state
)
588 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
589 ctx
->Scissor
.Enabled
= state
;
591 case GL_SHARED_TEXTURE_PALETTE_EXT
:
592 if (ctx
->Texture
.SharedPalette
== state
)
594 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
595 ctx
->Texture
.SharedPalette
= state
;
597 case GL_STENCIL_TEST
:
598 if (ctx
->Stencil
.Enabled
== state
)
600 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
601 ctx
->Stencil
.Enabled
= state
;
604 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
609 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
614 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
618 case GL_TEXTURE_GEN_Q
:
620 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
622 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
625 if (texUnit
->TexGenEnabled
== newenabled
)
627 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
628 texUnit
->TexGenEnabled
= newenabled
;
632 case GL_TEXTURE_GEN_R
:
634 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
636 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
639 if (texUnit
->TexGenEnabled
== newenabled
)
641 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
642 texUnit
->TexGenEnabled
= newenabled
;
646 case GL_TEXTURE_GEN_S
:
648 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
650 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
653 if (texUnit
->TexGenEnabled
== newenabled
)
655 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
656 texUnit
->TexGenEnabled
= newenabled
;
660 case GL_TEXTURE_GEN_T
:
662 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
664 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
667 if (texUnit
->TexGenEnabled
== newenabled
)
669 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
670 texUnit
->TexGenEnabled
= newenabled
;
676 case GL_TEXTURE_GEN_STR_OES
:
677 /* disable S, T, and R at the same time */
679 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
682 texUnit
->TexGenEnabled
& ~STR_BITS
;
684 newenabled
|= STR_BITS
;
685 if (texUnit
->TexGenEnabled
== newenabled
)
687 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
688 texUnit
->TexGenEnabled
= newenabled
;
697 case GL_VERTEX_ARRAY
:
698 case GL_NORMAL_ARRAY
:
701 case GL_TEXTURE_COORD_ARRAY
:
702 case GL_EDGE_FLAG_ARRAY
:
703 case GL_FOG_COORDINATE_ARRAY_EXT
:
704 case GL_SECONDARY_COLOR_ARRAY_EXT
:
705 case GL_POINT_SIZE_ARRAY_OES
:
706 client_state( ctx
, cap
, state
);
709 /* GL_SGI_texture_color_table */
710 case GL_TEXTURE_COLOR_TABLE_SGI
:
711 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
712 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
714 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
715 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
718 /* GL_ARB_texture_cube_map */
719 case GL_TEXTURE_CUBE_MAP_ARB
:
720 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
721 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
726 /* GL_EXT_secondary_color */
727 case GL_COLOR_SUM_EXT
:
728 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
729 if (ctx
->Fog
.ColorSumEnabled
== state
)
731 FLUSH_VERTICES(ctx
, _NEW_FOG
);
732 ctx
->Fog
.ColorSumEnabled
= state
;
735 /* GL_ARB_multisample */
736 case GL_MULTISAMPLE_ARB
:
737 if (ctx
->Multisample
.Enabled
== state
)
739 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
740 ctx
->Multisample
.Enabled
= state
;
742 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
743 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
745 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
746 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
748 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
749 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
751 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
752 ctx
->Multisample
.SampleAlphaToOne
= state
;
754 case GL_SAMPLE_COVERAGE_ARB
:
755 if (ctx
->Multisample
.SampleCoverage
== state
)
757 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
758 ctx
->Multisample
.SampleCoverage
= state
;
760 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
761 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
763 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
764 ctx
->Multisample
.SampleCoverageInvert
= state
;
767 /* GL_IBM_rasterpos_clip */
768 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
769 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
770 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
772 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
773 ctx
->Transform
.RasterPositionUnclipped
= state
;
776 /* GL_NV_point_sprite */
777 case GL_POINT_SPRITE_NV
:
778 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
779 if (ctx
->Point
.PointSprite
== state
)
781 FLUSH_VERTICES(ctx
, _NEW_POINT
);
782 ctx
->Point
.PointSprite
= state
;
785 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
786 case GL_VERTEX_PROGRAM_ARB
:
787 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
788 if (ctx
->VertexProgram
.Enabled
== state
)
790 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
791 ctx
->VertexProgram
.Enabled
= state
;
793 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
794 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
795 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
797 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
798 ctx
->VertexProgram
.PointSizeEnabled
= state
;
800 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
801 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
802 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
804 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
805 ctx
->VertexProgram
.TwoSideEnabled
= state
;
808 #if FEATURE_NV_vertex_program
809 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
810 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
811 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
812 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
813 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
814 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
815 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
816 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
817 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
818 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
819 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
820 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
821 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
822 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
823 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
824 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
825 CHECK_EXTENSION(NV_vertex_program
, cap
);
827 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
828 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
829 ctx
->Eval
.Map1Attrib
[map
] = state
;
832 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
833 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
834 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
835 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
836 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
837 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
838 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
839 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
840 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
841 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
842 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
843 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
844 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
845 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
846 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
847 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
848 CHECK_EXTENSION(NV_vertex_program
, cap
);
850 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
851 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
852 ctx
->Eval
.Map2Attrib
[map
] = state
;
855 #endif /* FEATURE_NV_vertex_program */
857 #if FEATURE_NV_fragment_program
858 case GL_FRAGMENT_PROGRAM_NV
:
859 CHECK_EXTENSION(NV_fragment_program
, cap
);
860 if (ctx
->FragmentProgram
.Enabled
== state
)
862 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
863 ctx
->FragmentProgram
.Enabled
= state
;
865 #endif /* FEATURE_NV_fragment_program */
867 /* GL_NV_texture_rectangle */
868 case GL_TEXTURE_RECTANGLE_NV
:
869 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
870 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
875 /* GL_EXT_stencil_two_side */
876 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
877 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
878 if (ctx
->Stencil
.TestTwoSide
== state
)
880 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
881 ctx
->Stencil
.TestTwoSide
= state
;
883 ctx
->Stencil
._BackFace
= 2;
884 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
886 ctx
->Stencil
._BackFace
= 1;
887 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
891 #if FEATURE_ARB_fragment_program
892 case GL_FRAGMENT_PROGRAM_ARB
:
893 CHECK_EXTENSION(ARB_fragment_program
, cap
);
894 if (ctx
->FragmentProgram
.Enabled
== state
)
896 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
897 ctx
->FragmentProgram
.Enabled
= state
;
899 #endif /* FEATURE_ARB_fragment_program */
901 /* GL_EXT_depth_bounds_test */
902 case GL_DEPTH_BOUNDS_TEST_EXT
:
903 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
904 if (ctx
->Depth
.BoundsTest
== state
)
906 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
907 ctx
->Depth
.BoundsTest
= state
;
911 if (ctx
->Transform
.DepthClamp
== state
)
913 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
914 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
915 ctx
->Transform
.DepthClamp
= state
;
918 #if FEATURE_ATI_fragment_shader
919 case GL_FRAGMENT_SHADER_ATI
:
920 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
921 if (ctx
->ATIFragmentShader
.Enabled
== state
)
923 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
924 ctx
->ATIFragmentShader
.Enabled
= state
;
928 /* GL_MESA_texture_array */
929 case GL_TEXTURE_1D_ARRAY_EXT
:
930 CHECK_EXTENSION(MESA_texture_array
, cap
);
931 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
936 case GL_TEXTURE_2D_ARRAY_EXT
:
937 CHECK_EXTENSION(MESA_texture_array
, cap
);
938 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
943 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
944 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
945 ctx
->Texture
.CubeMapSeamless
= state
;
948 #if FEATURE_EXT_transform_feedback
949 case GL_RASTERIZER_DISCARD
:
950 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
951 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
952 ctx
->TransformFeedback
.RasterDiscard
= state
;
953 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
958 /* GL 3.1 primitive restart. Note: this enum is different from
959 * GL_PRIMITIVE_RESTART_NV (which is client state).
961 case GL_PRIMITIVE_RESTART
:
962 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
963 goto invalid_enum_error
;
965 if (ctx
->Array
.PrimitiveRestart
!= state
) {
966 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
967 ctx
->Array
.PrimitiveRestart
= state
;
971 /* GL3.0 - GL_framebuffer_sRGB */
972 case GL_FRAMEBUFFER_SRGB_EXT
:
973 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
974 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
975 ctx
->Color
.sRGBEnabled
= state
;
979 goto invalid_enum_error
;
982 if (ctx
->Driver
.Enable
) {
983 ctx
->Driver
.Enable( ctx
, cap
, state
);
989 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
990 state
? "Enable" : "Disable", cap
);
995 * Enable GL capability. Called by glEnable()
996 * \param cap state to enable.
999 _mesa_Enable( GLenum cap
)
1001 GET_CURRENT_CONTEXT(ctx
);
1002 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1004 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1009 * Disable GL capability. Called by glDisable()
1010 * \param cap state to disable.
1013 _mesa_Disable( GLenum cap
)
1015 GET_CURRENT_CONTEXT(ctx
);
1016 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1018 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1024 * Enable/disable an indexed state var.
1027 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1029 ASSERT(state
== 0 || state
== 1);
1032 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1033 goto invalid_enum_error
;
1035 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1036 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1037 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1040 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1041 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1043 ctx
->Color
.BlendEnabled
|= (1 << index
);
1045 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1049 goto invalid_enum_error
;
1054 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1055 state
? "glEnablei" : "glDisablei",
1056 _mesa_lookup_enum_by_nr(cap
));
1061 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1063 GET_CURRENT_CONTEXT(ctx
);
1064 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1065 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1070 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1072 GET_CURRENT_CONTEXT(ctx
);
1073 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1074 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1078 GLboolean GLAPIENTRY
1079 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1081 GET_CURRENT_CONTEXT(ctx
);
1084 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1085 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1089 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1091 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1092 _mesa_lookup_enum_by_nr(cap
));
1100 #undef CHECK_EXTENSION
1101 #define CHECK_EXTENSION(EXTNAME) \
1102 if (!ctx->Extensions.EXTNAME) { \
1103 goto invalid_enum_error; \
1106 #undef CHECK_EXTENSION2
1107 #define CHECK_EXTENSION2(EXT1, EXT2) \
1108 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1109 goto invalid_enum_error; \
1114 * Helper function to determine whether a texture target is enabled.
1117 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1119 const struct gl_texture_unit
*const texUnit
=
1120 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1121 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1126 * Return simple enable/disable state.
1128 * \param cap state variable to query.
1130 * Returns the state of the specified capability from the current GL context.
1131 * For the capabilities associated with extensions verifies that those
1132 * extensions are effectively present before reporting.
1134 GLboolean GLAPIENTRY
1135 _mesa_IsEnabled( GLenum cap
)
1137 GET_CURRENT_CONTEXT(ctx
);
1140 return ctx
->Color
.AlphaEnabled
;
1141 case GL_AUTO_NORMAL
:
1142 return ctx
->Eval
.AutoNormal
;
1144 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1145 case GL_CLIP_PLANE0
:
1146 case GL_CLIP_PLANE1
:
1147 case GL_CLIP_PLANE2
:
1148 case GL_CLIP_PLANE3
:
1149 case GL_CLIP_PLANE4
:
1150 case GL_CLIP_PLANE5
:
1151 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1152 case GL_COLOR_MATERIAL
:
1153 return ctx
->Light
.ColorMaterialEnabled
;
1155 return ctx
->Polygon
.CullFlag
;
1157 return ctx
->Depth
.Test
;
1159 return ctx
->Color
.DitherFlag
;
1161 return ctx
->Fog
.Enabled
;
1163 return ctx
->Light
.Enabled
;
1172 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1173 case GL_LINE_SMOOTH
:
1174 return ctx
->Line
.SmoothFlag
;
1175 case GL_LINE_STIPPLE
:
1176 return ctx
->Line
.StippleFlag
;
1177 case GL_INDEX_LOGIC_OP
:
1178 return ctx
->Color
.IndexLogicOpEnabled
;
1179 case GL_COLOR_LOGIC_OP
:
1180 return ctx
->Color
.ColorLogicOpEnabled
;
1181 case GL_MAP1_COLOR_4
:
1182 return ctx
->Eval
.Map1Color4
;
1184 return ctx
->Eval
.Map1Index
;
1185 case GL_MAP1_NORMAL
:
1186 return ctx
->Eval
.Map1Normal
;
1187 case GL_MAP1_TEXTURE_COORD_1
:
1188 return ctx
->Eval
.Map1TextureCoord1
;
1189 case GL_MAP1_TEXTURE_COORD_2
:
1190 return ctx
->Eval
.Map1TextureCoord2
;
1191 case GL_MAP1_TEXTURE_COORD_3
:
1192 return ctx
->Eval
.Map1TextureCoord3
;
1193 case GL_MAP1_TEXTURE_COORD_4
:
1194 return ctx
->Eval
.Map1TextureCoord4
;
1195 case GL_MAP1_VERTEX_3
:
1196 return ctx
->Eval
.Map1Vertex3
;
1197 case GL_MAP1_VERTEX_4
:
1198 return ctx
->Eval
.Map1Vertex4
;
1199 case GL_MAP2_COLOR_4
:
1200 return ctx
->Eval
.Map2Color4
;
1202 return ctx
->Eval
.Map2Index
;
1203 case GL_MAP2_NORMAL
:
1204 return ctx
->Eval
.Map2Normal
;
1205 case GL_MAP2_TEXTURE_COORD_1
:
1206 return ctx
->Eval
.Map2TextureCoord1
;
1207 case GL_MAP2_TEXTURE_COORD_2
:
1208 return ctx
->Eval
.Map2TextureCoord2
;
1209 case GL_MAP2_TEXTURE_COORD_3
:
1210 return ctx
->Eval
.Map2TextureCoord3
;
1211 case GL_MAP2_TEXTURE_COORD_4
:
1212 return ctx
->Eval
.Map2TextureCoord4
;
1213 case GL_MAP2_VERTEX_3
:
1214 return ctx
->Eval
.Map2Vertex3
;
1215 case GL_MAP2_VERTEX_4
:
1216 return ctx
->Eval
.Map2Vertex4
;
1218 return ctx
->Transform
.Normalize
;
1219 case GL_POINT_SMOOTH
:
1220 return ctx
->Point
.SmoothFlag
;
1221 case GL_POLYGON_SMOOTH
:
1222 return ctx
->Polygon
.SmoothFlag
;
1223 case GL_POLYGON_STIPPLE
:
1224 return ctx
->Polygon
.StippleFlag
;
1225 case GL_POLYGON_OFFSET_POINT
:
1226 return ctx
->Polygon
.OffsetPoint
;
1227 case GL_POLYGON_OFFSET_LINE
:
1228 return ctx
->Polygon
.OffsetLine
;
1229 case GL_POLYGON_OFFSET_FILL
:
1230 /*case GL_POLYGON_OFFSET_EXT:*/
1231 return ctx
->Polygon
.OffsetFill
;
1232 case GL_RESCALE_NORMAL_EXT
:
1233 return ctx
->Transform
.RescaleNormals
;
1234 case GL_SCISSOR_TEST
:
1235 return ctx
->Scissor
.Enabled
;
1236 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1237 return ctx
->Texture
.SharedPalette
;
1238 case GL_STENCIL_TEST
:
1239 return ctx
->Stencil
.Enabled
;
1241 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1243 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1245 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1246 case GL_TEXTURE_GEN_Q
:
1248 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1250 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1254 case GL_TEXTURE_GEN_R
:
1256 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1258 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1262 case GL_TEXTURE_GEN_S
:
1264 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1266 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1270 case GL_TEXTURE_GEN_T
:
1272 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1274 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1279 case GL_TEXTURE_GEN_STR_OES
:
1281 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1283 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1291 case GL_VERTEX_ARRAY
:
1292 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1293 case GL_NORMAL_ARRAY
:
1294 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1295 case GL_COLOR_ARRAY
:
1296 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1297 case GL_INDEX_ARRAY
:
1298 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1299 case GL_TEXTURE_COORD_ARRAY
:
1300 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1301 case GL_EDGE_FLAG_ARRAY
:
1302 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1303 case GL_FOG_COORDINATE_ARRAY_EXT
:
1304 CHECK_EXTENSION(EXT_fog_coord
);
1305 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1306 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1307 CHECK_EXTENSION(EXT_secondary_color
);
1308 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1309 #if FEATURE_point_size_array
1310 case GL_POINT_SIZE_ARRAY_OES
:
1311 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1314 /* GL_SGI_texture_color_table */
1315 case GL_TEXTURE_COLOR_TABLE_SGI
:
1316 CHECK_EXTENSION(SGI_texture_color_table
);
1317 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1319 /* GL_ARB_texture_cube_map */
1320 case GL_TEXTURE_CUBE_MAP_ARB
:
1321 CHECK_EXTENSION(ARB_texture_cube_map
);
1322 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1324 /* GL_EXT_secondary_color */
1325 case GL_COLOR_SUM_EXT
:
1326 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1327 return ctx
->Fog
.ColorSumEnabled
;
1329 /* GL_ARB_multisample */
1330 case GL_MULTISAMPLE_ARB
:
1331 return ctx
->Multisample
.Enabled
;
1332 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1333 return ctx
->Multisample
.SampleAlphaToCoverage
;
1334 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1335 return ctx
->Multisample
.SampleAlphaToOne
;
1336 case GL_SAMPLE_COVERAGE_ARB
:
1337 return ctx
->Multisample
.SampleCoverage
;
1338 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1339 return ctx
->Multisample
.SampleCoverageInvert
;
1341 /* GL_IBM_rasterpos_clip */
1342 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1343 CHECK_EXTENSION(IBM_rasterpos_clip
);
1344 return ctx
->Transform
.RasterPositionUnclipped
;
1346 /* GL_NV_point_sprite */
1347 case GL_POINT_SPRITE_NV
:
1348 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1349 return ctx
->Point
.PointSprite
;
1351 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1352 case GL_VERTEX_PROGRAM_ARB
:
1353 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1354 return ctx
->VertexProgram
.Enabled
;
1355 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1356 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1357 return ctx
->VertexProgram
.PointSizeEnabled
;
1358 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1359 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1360 return ctx
->VertexProgram
.TwoSideEnabled
;
1362 #if FEATURE_NV_vertex_program
1363 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1364 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1365 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1366 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1367 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1368 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1369 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1370 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1371 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1372 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1373 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1374 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1375 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1376 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1377 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1378 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1379 CHECK_EXTENSION(NV_vertex_program
);
1381 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1382 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1383 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1385 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1386 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1387 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1388 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1389 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1390 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1391 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1392 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1393 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1394 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1395 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1396 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1397 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1398 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1399 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1400 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1401 CHECK_EXTENSION(NV_vertex_program
);
1403 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1404 return ctx
->Eval
.Map1Attrib
[map
];
1406 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1407 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1408 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1409 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1410 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1411 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1412 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1413 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1414 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1415 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1416 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1417 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1418 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1419 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1420 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1421 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1422 CHECK_EXTENSION(NV_vertex_program
);
1424 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1425 return ctx
->Eval
.Map2Attrib
[map
];
1427 #endif /* FEATURE_NV_vertex_program */
1429 #if FEATURE_NV_fragment_program
1430 case GL_FRAGMENT_PROGRAM_NV
:
1431 CHECK_EXTENSION(NV_fragment_program
);
1432 return ctx
->FragmentProgram
.Enabled
;
1433 #endif /* FEATURE_NV_fragment_program */
1435 /* GL_NV_texture_rectangle */
1436 case GL_TEXTURE_RECTANGLE_NV
:
1437 CHECK_EXTENSION(NV_texture_rectangle
);
1438 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1440 /* GL_EXT_stencil_two_side */
1441 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1442 CHECK_EXTENSION(EXT_stencil_two_side
);
1443 return ctx
->Stencil
.TestTwoSide
;
1445 #if FEATURE_ARB_fragment_program
1446 case GL_FRAGMENT_PROGRAM_ARB
:
1447 return ctx
->FragmentProgram
.Enabled
;
1448 #endif /* FEATURE_ARB_fragment_program */
1450 /* GL_EXT_depth_bounds_test */
1451 case GL_DEPTH_BOUNDS_TEST_EXT
:
1452 CHECK_EXTENSION(EXT_depth_bounds_test
);
1453 return ctx
->Depth
.BoundsTest
;
1455 /* GL_ARB_depth_clamp */
1456 case GL_DEPTH_CLAMP
:
1457 CHECK_EXTENSION(ARB_depth_clamp
);
1458 return ctx
->Transform
.DepthClamp
;
1460 #if FEATURE_ATI_fragment_shader
1461 case GL_FRAGMENT_SHADER_ATI
:
1462 CHECK_EXTENSION(ATI_fragment_shader
);
1463 return ctx
->ATIFragmentShader
.Enabled
;
1464 #endif /* FEATURE_ATI_fragment_shader */
1466 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1467 CHECK_EXTENSION(ARB_seamless_cube_map
);
1468 return ctx
->Texture
.CubeMapSeamless
;
1470 #if FEATURE_EXT_transform_feedback
1471 case GL_RASTERIZER_DISCARD
:
1472 CHECK_EXTENSION(EXT_transform_feedback
);
1473 return ctx
->TransformFeedback
.RasterDiscard
;
1476 /* GL_NV_primitive_restart */
1477 case GL_PRIMITIVE_RESTART_NV
:
1478 if (!ctx
->Extensions
.NV_primitive_restart
) {
1479 goto invalid_enum_error
;
1481 return ctx
->Array
.PrimitiveRestart
;
1483 /* GL 3.1 primitive restart */
1484 case GL_PRIMITIVE_RESTART
:
1485 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1486 goto invalid_enum_error
;
1488 return ctx
->Array
.PrimitiveRestart
;
1490 /* GL3.0 - GL_framebuffer_sRGB */
1491 case GL_FRAMEBUFFER_SRGB_EXT
:
1492 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1493 return ctx
->Color
.sRGBEnabled
;
1496 goto invalid_enum_error
;
1502 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);