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
;
355 if (ctx
->Color
.DitherFlag
== state
)
357 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
358 ctx
->Color
.DitherFlag
= state
;
361 if (ctx
->Fog
.Enabled
== state
)
363 FLUSH_VERTICES(ctx
, _NEW_FOG
);
364 ctx
->Fog
.Enabled
= state
;
374 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
376 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
377 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
379 insert_at_tail(&ctx
->Light
.EnabledList
,
380 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
383 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
387 if (ctx
->Light
.Enabled
== state
)
389 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
390 ctx
->Light
.Enabled
= state
;
391 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
392 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
394 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
397 if (ctx
->Line
.SmoothFlag
== state
)
399 FLUSH_VERTICES(ctx
, _NEW_LINE
);
400 ctx
->Line
.SmoothFlag
= state
;
401 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
403 case GL_LINE_STIPPLE
:
404 if (ctx
->Line
.StippleFlag
== state
)
406 FLUSH_VERTICES(ctx
, _NEW_LINE
);
407 ctx
->Line
.StippleFlag
= state
;
408 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
410 case GL_INDEX_LOGIC_OP
:
411 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
413 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
414 ctx
->Color
.IndexLogicOpEnabled
= state
;
416 case GL_COLOR_LOGIC_OP
:
417 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
419 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
420 ctx
->Color
.ColorLogicOpEnabled
= state
;
422 case GL_MAP1_COLOR_4
:
423 if (ctx
->Eval
.Map1Color4
== state
)
425 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
426 ctx
->Eval
.Map1Color4
= state
;
429 if (ctx
->Eval
.Map1Index
== state
)
431 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
432 ctx
->Eval
.Map1Index
= state
;
435 if (ctx
->Eval
.Map1Normal
== state
)
437 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
438 ctx
->Eval
.Map1Normal
= state
;
440 case GL_MAP1_TEXTURE_COORD_1
:
441 if (ctx
->Eval
.Map1TextureCoord1
== state
)
443 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
444 ctx
->Eval
.Map1TextureCoord1
= state
;
446 case GL_MAP1_TEXTURE_COORD_2
:
447 if (ctx
->Eval
.Map1TextureCoord2
== state
)
449 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
450 ctx
->Eval
.Map1TextureCoord2
= state
;
452 case GL_MAP1_TEXTURE_COORD_3
:
453 if (ctx
->Eval
.Map1TextureCoord3
== state
)
455 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
456 ctx
->Eval
.Map1TextureCoord3
= state
;
458 case GL_MAP1_TEXTURE_COORD_4
:
459 if (ctx
->Eval
.Map1TextureCoord4
== state
)
461 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
462 ctx
->Eval
.Map1TextureCoord4
= state
;
464 case GL_MAP1_VERTEX_3
:
465 if (ctx
->Eval
.Map1Vertex3
== state
)
467 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
468 ctx
->Eval
.Map1Vertex3
= state
;
470 case GL_MAP1_VERTEX_4
:
471 if (ctx
->Eval
.Map1Vertex4
== state
)
473 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
474 ctx
->Eval
.Map1Vertex4
= state
;
476 case GL_MAP2_COLOR_4
:
477 if (ctx
->Eval
.Map2Color4
== state
)
479 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
480 ctx
->Eval
.Map2Color4
= state
;
483 if (ctx
->Eval
.Map2Index
== state
)
485 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
486 ctx
->Eval
.Map2Index
= state
;
489 if (ctx
->Eval
.Map2Normal
== state
)
491 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
492 ctx
->Eval
.Map2Normal
= state
;
494 case GL_MAP2_TEXTURE_COORD_1
:
495 if (ctx
->Eval
.Map2TextureCoord1
== state
)
497 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
498 ctx
->Eval
.Map2TextureCoord1
= state
;
500 case GL_MAP2_TEXTURE_COORD_2
:
501 if (ctx
->Eval
.Map2TextureCoord2
== state
)
503 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
504 ctx
->Eval
.Map2TextureCoord2
= state
;
506 case GL_MAP2_TEXTURE_COORD_3
:
507 if (ctx
->Eval
.Map2TextureCoord3
== state
)
509 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
510 ctx
->Eval
.Map2TextureCoord3
= state
;
512 case GL_MAP2_TEXTURE_COORD_4
:
513 if (ctx
->Eval
.Map2TextureCoord4
== state
)
515 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
516 ctx
->Eval
.Map2TextureCoord4
= state
;
518 case GL_MAP2_VERTEX_3
:
519 if (ctx
->Eval
.Map2Vertex3
== state
)
521 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
522 ctx
->Eval
.Map2Vertex3
= state
;
524 case GL_MAP2_VERTEX_4
:
525 if (ctx
->Eval
.Map2Vertex4
== state
)
527 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
528 ctx
->Eval
.Map2Vertex4
= state
;
531 if (ctx
->Transform
.Normalize
== state
)
533 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
534 ctx
->Transform
.Normalize
= state
;
536 case GL_POINT_SMOOTH
:
537 if (ctx
->Point
.SmoothFlag
== state
)
539 FLUSH_VERTICES(ctx
, _NEW_POINT
);
540 ctx
->Point
.SmoothFlag
= state
;
541 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
543 case GL_POLYGON_SMOOTH
:
544 if (ctx
->Polygon
.SmoothFlag
== state
)
546 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
547 ctx
->Polygon
.SmoothFlag
= state
;
548 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
550 case GL_POLYGON_STIPPLE
:
551 if (ctx
->Polygon
.StippleFlag
== state
)
553 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
554 ctx
->Polygon
.StippleFlag
= state
;
555 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
557 case GL_POLYGON_OFFSET_POINT
:
558 if (ctx
->Polygon
.OffsetPoint
== state
)
560 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
561 ctx
->Polygon
.OffsetPoint
= state
;
563 case GL_POLYGON_OFFSET_LINE
:
564 if (ctx
->Polygon
.OffsetLine
== state
)
566 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
567 ctx
->Polygon
.OffsetLine
= state
;
569 case GL_POLYGON_OFFSET_FILL
:
570 /*case GL_POLYGON_OFFSET_EXT:*/
571 if (ctx
->Polygon
.OffsetFill
== state
)
573 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
574 ctx
->Polygon
.OffsetFill
= state
;
576 case GL_RESCALE_NORMAL_EXT
:
577 if (ctx
->Transform
.RescaleNormals
== state
)
579 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
580 ctx
->Transform
.RescaleNormals
= state
;
582 case GL_SCISSOR_TEST
:
583 if (ctx
->Scissor
.Enabled
== state
)
585 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
586 ctx
->Scissor
.Enabled
= state
;
588 case GL_SHARED_TEXTURE_PALETTE_EXT
:
589 if (ctx
->Texture
.SharedPalette
== state
)
591 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
592 ctx
->Texture
.SharedPalette
= state
;
594 case GL_STENCIL_TEST
:
595 if (ctx
->Stencil
.Enabled
== state
)
597 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
598 ctx
->Stencil
.Enabled
= state
;
601 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
606 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
611 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
615 case GL_TEXTURE_GEN_Q
:
617 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
619 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
622 if (texUnit
->TexGenEnabled
== newenabled
)
624 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
625 texUnit
->TexGenEnabled
= newenabled
;
629 case GL_TEXTURE_GEN_R
:
631 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
633 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
636 if (texUnit
->TexGenEnabled
== newenabled
)
638 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
639 texUnit
->TexGenEnabled
= newenabled
;
643 case GL_TEXTURE_GEN_S
:
645 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
647 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
650 if (texUnit
->TexGenEnabled
== newenabled
)
652 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
653 texUnit
->TexGenEnabled
= newenabled
;
657 case GL_TEXTURE_GEN_T
:
659 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
661 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
664 if (texUnit
->TexGenEnabled
== newenabled
)
666 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
667 texUnit
->TexGenEnabled
= newenabled
;
673 case GL_TEXTURE_GEN_STR_OES
:
674 /* disable S, T, and R at the same time */
676 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
679 texUnit
->TexGenEnabled
& ~STR_BITS
;
681 newenabled
|= STR_BITS
;
682 if (texUnit
->TexGenEnabled
== newenabled
)
684 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
685 texUnit
->TexGenEnabled
= newenabled
;
694 case GL_VERTEX_ARRAY
:
695 case GL_NORMAL_ARRAY
:
698 case GL_TEXTURE_COORD_ARRAY
:
699 case GL_EDGE_FLAG_ARRAY
:
700 case GL_FOG_COORDINATE_ARRAY_EXT
:
701 case GL_SECONDARY_COLOR_ARRAY_EXT
:
702 case GL_POINT_SIZE_ARRAY_OES
:
703 client_state( ctx
, cap
, state
);
706 /* GL_ARB_texture_cube_map */
707 case GL_TEXTURE_CUBE_MAP_ARB
:
708 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
709 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
714 /* GL_EXT_secondary_color */
715 case GL_COLOR_SUM_EXT
:
716 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
717 if (ctx
->Fog
.ColorSumEnabled
== state
)
719 FLUSH_VERTICES(ctx
, _NEW_FOG
);
720 ctx
->Fog
.ColorSumEnabled
= state
;
723 /* GL_ARB_multisample */
724 case GL_MULTISAMPLE_ARB
:
725 if (ctx
->Multisample
.Enabled
== state
)
727 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
728 ctx
->Multisample
.Enabled
= state
;
730 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
731 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
733 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
734 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
736 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
737 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
739 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
740 ctx
->Multisample
.SampleAlphaToOne
= state
;
742 case GL_SAMPLE_COVERAGE_ARB
:
743 if (ctx
->Multisample
.SampleCoverage
== state
)
745 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
746 ctx
->Multisample
.SampleCoverage
= state
;
748 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
749 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
751 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
752 ctx
->Multisample
.SampleCoverageInvert
= state
;
755 /* GL_IBM_rasterpos_clip */
756 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
757 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
758 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
760 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
761 ctx
->Transform
.RasterPositionUnclipped
= state
;
764 /* GL_NV_point_sprite */
765 case GL_POINT_SPRITE_NV
:
766 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
767 if (ctx
->Point
.PointSprite
== state
)
769 FLUSH_VERTICES(ctx
, _NEW_POINT
);
770 ctx
->Point
.PointSprite
= state
;
773 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
774 case GL_VERTEX_PROGRAM_ARB
:
775 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
776 if (ctx
->VertexProgram
.Enabled
== state
)
778 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
779 ctx
->VertexProgram
.Enabled
= state
;
781 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
782 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
783 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
785 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
786 ctx
->VertexProgram
.PointSizeEnabled
= state
;
788 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
789 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
790 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
792 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
793 ctx
->VertexProgram
.TwoSideEnabled
= state
;
796 #if FEATURE_NV_vertex_program
797 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
798 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
799 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
800 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
801 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
802 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
803 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
804 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
805 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
806 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
807 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
808 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
809 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
810 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
811 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
812 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
813 CHECK_EXTENSION(NV_vertex_program
, cap
);
815 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
816 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
817 ctx
->Eval
.Map1Attrib
[map
] = state
;
820 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
821 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
822 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
823 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
824 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
825 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
826 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
827 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
828 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
829 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
830 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
831 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
832 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
833 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
834 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
835 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
836 CHECK_EXTENSION(NV_vertex_program
, cap
);
838 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
839 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
840 ctx
->Eval
.Map2Attrib
[map
] = state
;
843 #endif /* FEATURE_NV_vertex_program */
845 #if FEATURE_NV_fragment_program
846 case GL_FRAGMENT_PROGRAM_NV
:
847 CHECK_EXTENSION(NV_fragment_program
, cap
);
848 if (ctx
->FragmentProgram
.Enabled
== state
)
850 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
851 ctx
->FragmentProgram
.Enabled
= state
;
853 #endif /* FEATURE_NV_fragment_program */
855 /* GL_NV_texture_rectangle */
856 case GL_TEXTURE_RECTANGLE_NV
:
857 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
858 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
863 /* GL_EXT_stencil_two_side */
864 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
865 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
866 if (ctx
->Stencil
.TestTwoSide
== state
)
868 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
869 ctx
->Stencil
.TestTwoSide
= state
;
871 ctx
->Stencil
._BackFace
= 2;
872 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
874 ctx
->Stencil
._BackFace
= 1;
875 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
879 #if FEATURE_ARB_fragment_program
880 case GL_FRAGMENT_PROGRAM_ARB
:
881 CHECK_EXTENSION(ARB_fragment_program
, cap
);
882 if (ctx
->FragmentProgram
.Enabled
== state
)
884 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
885 ctx
->FragmentProgram
.Enabled
= state
;
887 #endif /* FEATURE_ARB_fragment_program */
889 /* GL_EXT_depth_bounds_test */
890 case GL_DEPTH_BOUNDS_TEST_EXT
:
891 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
892 if (ctx
->Depth
.BoundsTest
== state
)
894 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
895 ctx
->Depth
.BoundsTest
= state
;
899 if (ctx
->Transform
.DepthClamp
== state
)
901 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
902 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
903 ctx
->Transform
.DepthClamp
= state
;
906 #if FEATURE_ATI_fragment_shader
907 case GL_FRAGMENT_SHADER_ATI
:
908 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
909 if (ctx
->ATIFragmentShader
.Enabled
== state
)
911 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
912 ctx
->ATIFragmentShader
.Enabled
= state
;
916 /* GL_MESA_texture_array */
917 case GL_TEXTURE_1D_ARRAY_EXT
:
918 CHECK_EXTENSION(MESA_texture_array
, cap
);
919 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
924 case GL_TEXTURE_2D_ARRAY_EXT
:
925 CHECK_EXTENSION(MESA_texture_array
, cap
);
926 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
931 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
932 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
933 ctx
->Texture
.CubeMapSeamless
= state
;
936 #if FEATURE_EXT_transform_feedback
937 case GL_RASTERIZER_DISCARD
:
938 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
939 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
940 ctx
->TransformFeedback
.RasterDiscard
= state
;
941 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
946 /* GL 3.1 primitive restart. Note: this enum is different from
947 * GL_PRIMITIVE_RESTART_NV (which is client state).
949 case GL_PRIMITIVE_RESTART
:
950 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
951 goto invalid_enum_error
;
953 if (ctx
->Array
.PrimitiveRestart
!= state
) {
954 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
955 ctx
->Array
.PrimitiveRestart
= state
;
959 /* GL3.0 - GL_framebuffer_sRGB */
960 case GL_FRAMEBUFFER_SRGB_EXT
:
961 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
962 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
963 ctx
->Color
.sRGBEnabled
= state
;
967 goto invalid_enum_error
;
970 if (ctx
->Driver
.Enable
) {
971 ctx
->Driver
.Enable( ctx
, cap
, state
);
977 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
978 state
? "Enable" : "Disable", cap
);
983 * Enable GL capability. Called by glEnable()
984 * \param cap state to enable.
987 _mesa_Enable( GLenum cap
)
989 GET_CURRENT_CONTEXT(ctx
);
990 ASSERT_OUTSIDE_BEGIN_END(ctx
);
992 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
997 * Disable GL capability. Called by glDisable()
998 * \param cap state to disable.
1001 _mesa_Disable( GLenum cap
)
1003 GET_CURRENT_CONTEXT(ctx
);
1004 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1006 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1012 * Enable/disable an indexed state var.
1015 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1017 ASSERT(state
== 0 || state
== 1);
1020 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1021 goto invalid_enum_error
;
1023 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1024 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1025 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1028 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1029 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1031 ctx
->Color
.BlendEnabled
|= (1 << index
);
1033 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1037 goto invalid_enum_error
;
1042 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1043 state
? "glEnablei" : "glDisablei",
1044 _mesa_lookup_enum_by_nr(cap
));
1049 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1051 GET_CURRENT_CONTEXT(ctx
);
1052 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1053 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1058 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1060 GET_CURRENT_CONTEXT(ctx
);
1061 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1062 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1066 GLboolean GLAPIENTRY
1067 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1069 GET_CURRENT_CONTEXT(ctx
);
1072 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1073 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1077 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1079 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1080 _mesa_lookup_enum_by_nr(cap
));
1088 #undef CHECK_EXTENSION
1089 #define CHECK_EXTENSION(EXTNAME) \
1090 if (!ctx->Extensions.EXTNAME) { \
1091 goto invalid_enum_error; \
1094 #undef CHECK_EXTENSION2
1095 #define CHECK_EXTENSION2(EXT1, EXT2) \
1096 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1097 goto invalid_enum_error; \
1102 * Helper function to determine whether a texture target is enabled.
1105 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1107 const struct gl_texture_unit
*const texUnit
=
1108 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1109 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1114 * Return simple enable/disable state.
1116 * \param cap state variable to query.
1118 * Returns the state of the specified capability from the current GL context.
1119 * For the capabilities associated with extensions verifies that those
1120 * extensions are effectively present before reporting.
1122 GLboolean GLAPIENTRY
1123 _mesa_IsEnabled( GLenum cap
)
1125 GET_CURRENT_CONTEXT(ctx
);
1128 return ctx
->Color
.AlphaEnabled
;
1129 case GL_AUTO_NORMAL
:
1130 return ctx
->Eval
.AutoNormal
;
1132 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1133 case GL_CLIP_PLANE0
:
1134 case GL_CLIP_PLANE1
:
1135 case GL_CLIP_PLANE2
:
1136 case GL_CLIP_PLANE3
:
1137 case GL_CLIP_PLANE4
:
1138 case GL_CLIP_PLANE5
:
1139 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1140 case GL_COLOR_MATERIAL
:
1141 return ctx
->Light
.ColorMaterialEnabled
;
1143 return ctx
->Polygon
.CullFlag
;
1145 return ctx
->Depth
.Test
;
1147 return ctx
->Color
.DitherFlag
;
1149 return ctx
->Fog
.Enabled
;
1151 return ctx
->Light
.Enabled
;
1160 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1161 case GL_LINE_SMOOTH
:
1162 return ctx
->Line
.SmoothFlag
;
1163 case GL_LINE_STIPPLE
:
1164 return ctx
->Line
.StippleFlag
;
1165 case GL_INDEX_LOGIC_OP
:
1166 return ctx
->Color
.IndexLogicOpEnabled
;
1167 case GL_COLOR_LOGIC_OP
:
1168 return ctx
->Color
.ColorLogicOpEnabled
;
1169 case GL_MAP1_COLOR_4
:
1170 return ctx
->Eval
.Map1Color4
;
1172 return ctx
->Eval
.Map1Index
;
1173 case GL_MAP1_NORMAL
:
1174 return ctx
->Eval
.Map1Normal
;
1175 case GL_MAP1_TEXTURE_COORD_1
:
1176 return ctx
->Eval
.Map1TextureCoord1
;
1177 case GL_MAP1_TEXTURE_COORD_2
:
1178 return ctx
->Eval
.Map1TextureCoord2
;
1179 case GL_MAP1_TEXTURE_COORD_3
:
1180 return ctx
->Eval
.Map1TextureCoord3
;
1181 case GL_MAP1_TEXTURE_COORD_4
:
1182 return ctx
->Eval
.Map1TextureCoord4
;
1183 case GL_MAP1_VERTEX_3
:
1184 return ctx
->Eval
.Map1Vertex3
;
1185 case GL_MAP1_VERTEX_4
:
1186 return ctx
->Eval
.Map1Vertex4
;
1187 case GL_MAP2_COLOR_4
:
1188 return ctx
->Eval
.Map2Color4
;
1190 return ctx
->Eval
.Map2Index
;
1191 case GL_MAP2_NORMAL
:
1192 return ctx
->Eval
.Map2Normal
;
1193 case GL_MAP2_TEXTURE_COORD_1
:
1194 return ctx
->Eval
.Map2TextureCoord1
;
1195 case GL_MAP2_TEXTURE_COORD_2
:
1196 return ctx
->Eval
.Map2TextureCoord2
;
1197 case GL_MAP2_TEXTURE_COORD_3
:
1198 return ctx
->Eval
.Map2TextureCoord3
;
1199 case GL_MAP2_TEXTURE_COORD_4
:
1200 return ctx
->Eval
.Map2TextureCoord4
;
1201 case GL_MAP2_VERTEX_3
:
1202 return ctx
->Eval
.Map2Vertex3
;
1203 case GL_MAP2_VERTEX_4
:
1204 return ctx
->Eval
.Map2Vertex4
;
1206 return ctx
->Transform
.Normalize
;
1207 case GL_POINT_SMOOTH
:
1208 return ctx
->Point
.SmoothFlag
;
1209 case GL_POLYGON_SMOOTH
:
1210 return ctx
->Polygon
.SmoothFlag
;
1211 case GL_POLYGON_STIPPLE
:
1212 return ctx
->Polygon
.StippleFlag
;
1213 case GL_POLYGON_OFFSET_POINT
:
1214 return ctx
->Polygon
.OffsetPoint
;
1215 case GL_POLYGON_OFFSET_LINE
:
1216 return ctx
->Polygon
.OffsetLine
;
1217 case GL_POLYGON_OFFSET_FILL
:
1218 /*case GL_POLYGON_OFFSET_EXT:*/
1219 return ctx
->Polygon
.OffsetFill
;
1220 case GL_RESCALE_NORMAL_EXT
:
1221 return ctx
->Transform
.RescaleNormals
;
1222 case GL_SCISSOR_TEST
:
1223 return ctx
->Scissor
.Enabled
;
1224 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1225 return ctx
->Texture
.SharedPalette
;
1226 case GL_STENCIL_TEST
:
1227 return ctx
->Stencil
.Enabled
;
1229 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1231 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1233 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1234 case GL_TEXTURE_GEN_Q
:
1236 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1238 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1242 case GL_TEXTURE_GEN_R
:
1244 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1246 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1250 case GL_TEXTURE_GEN_S
:
1252 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1254 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1258 case GL_TEXTURE_GEN_T
:
1260 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1262 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1267 case GL_TEXTURE_GEN_STR_OES
:
1269 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1271 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1279 case GL_VERTEX_ARRAY
:
1280 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1281 case GL_NORMAL_ARRAY
:
1282 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1283 case GL_COLOR_ARRAY
:
1284 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1285 case GL_INDEX_ARRAY
:
1286 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1287 case GL_TEXTURE_COORD_ARRAY
:
1288 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1289 case GL_EDGE_FLAG_ARRAY
:
1290 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1291 case GL_FOG_COORDINATE_ARRAY_EXT
:
1292 CHECK_EXTENSION(EXT_fog_coord
);
1293 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1294 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1295 CHECK_EXTENSION(EXT_secondary_color
);
1296 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1297 #if FEATURE_point_size_array
1298 case GL_POINT_SIZE_ARRAY_OES
:
1299 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1302 /* GL_ARB_texture_cube_map */
1303 case GL_TEXTURE_CUBE_MAP_ARB
:
1304 CHECK_EXTENSION(ARB_texture_cube_map
);
1305 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1307 /* GL_EXT_secondary_color */
1308 case GL_COLOR_SUM_EXT
:
1309 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1310 return ctx
->Fog
.ColorSumEnabled
;
1312 /* GL_ARB_multisample */
1313 case GL_MULTISAMPLE_ARB
:
1314 return ctx
->Multisample
.Enabled
;
1315 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1316 return ctx
->Multisample
.SampleAlphaToCoverage
;
1317 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1318 return ctx
->Multisample
.SampleAlphaToOne
;
1319 case GL_SAMPLE_COVERAGE_ARB
:
1320 return ctx
->Multisample
.SampleCoverage
;
1321 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1322 return ctx
->Multisample
.SampleCoverageInvert
;
1324 /* GL_IBM_rasterpos_clip */
1325 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1326 CHECK_EXTENSION(IBM_rasterpos_clip
);
1327 return ctx
->Transform
.RasterPositionUnclipped
;
1329 /* GL_NV_point_sprite */
1330 case GL_POINT_SPRITE_NV
:
1331 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1332 return ctx
->Point
.PointSprite
;
1334 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1335 case GL_VERTEX_PROGRAM_ARB
:
1336 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1337 return ctx
->VertexProgram
.Enabled
;
1338 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1339 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1340 return ctx
->VertexProgram
.PointSizeEnabled
;
1341 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1342 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1343 return ctx
->VertexProgram
.TwoSideEnabled
;
1345 #if FEATURE_NV_vertex_program
1346 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1347 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1348 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1349 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1350 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1351 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1352 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1353 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1354 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1355 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1356 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1357 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1358 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1359 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1360 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1361 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1362 CHECK_EXTENSION(NV_vertex_program
);
1364 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1365 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1366 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1368 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1369 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1370 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1371 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1372 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1373 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1374 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1375 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1376 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1377 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1378 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1379 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1380 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1381 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1382 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1383 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1384 CHECK_EXTENSION(NV_vertex_program
);
1386 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1387 return ctx
->Eval
.Map1Attrib
[map
];
1389 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1390 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1391 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1392 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1393 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1394 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1395 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1396 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1397 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1398 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1399 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1400 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1401 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1402 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1403 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1404 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1405 CHECK_EXTENSION(NV_vertex_program
);
1407 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1408 return ctx
->Eval
.Map2Attrib
[map
];
1410 #endif /* FEATURE_NV_vertex_program */
1412 #if FEATURE_NV_fragment_program
1413 case GL_FRAGMENT_PROGRAM_NV
:
1414 CHECK_EXTENSION(NV_fragment_program
);
1415 return ctx
->FragmentProgram
.Enabled
;
1416 #endif /* FEATURE_NV_fragment_program */
1418 /* GL_NV_texture_rectangle */
1419 case GL_TEXTURE_RECTANGLE_NV
:
1420 CHECK_EXTENSION(NV_texture_rectangle
);
1421 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1423 /* GL_EXT_stencil_two_side */
1424 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1425 CHECK_EXTENSION(EXT_stencil_two_side
);
1426 return ctx
->Stencil
.TestTwoSide
;
1428 #if FEATURE_ARB_fragment_program
1429 case GL_FRAGMENT_PROGRAM_ARB
:
1430 return ctx
->FragmentProgram
.Enabled
;
1431 #endif /* FEATURE_ARB_fragment_program */
1433 /* GL_EXT_depth_bounds_test */
1434 case GL_DEPTH_BOUNDS_TEST_EXT
:
1435 CHECK_EXTENSION(EXT_depth_bounds_test
);
1436 return ctx
->Depth
.BoundsTest
;
1438 /* GL_ARB_depth_clamp */
1439 case GL_DEPTH_CLAMP
:
1440 CHECK_EXTENSION(ARB_depth_clamp
);
1441 return ctx
->Transform
.DepthClamp
;
1443 #if FEATURE_ATI_fragment_shader
1444 case GL_FRAGMENT_SHADER_ATI
:
1445 CHECK_EXTENSION(ATI_fragment_shader
);
1446 return ctx
->ATIFragmentShader
.Enabled
;
1447 #endif /* FEATURE_ATI_fragment_shader */
1449 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1450 CHECK_EXTENSION(ARB_seamless_cube_map
);
1451 return ctx
->Texture
.CubeMapSeamless
;
1453 #if FEATURE_EXT_transform_feedback
1454 case GL_RASTERIZER_DISCARD
:
1455 CHECK_EXTENSION(EXT_transform_feedback
);
1456 return ctx
->TransformFeedback
.RasterDiscard
;
1459 /* GL_NV_primitive_restart */
1460 case GL_PRIMITIVE_RESTART_NV
:
1461 if (!ctx
->Extensions
.NV_primitive_restart
) {
1462 goto invalid_enum_error
;
1464 return ctx
->Array
.PrimitiveRestart
;
1466 /* GL 3.1 primitive restart */
1467 case GL_PRIMITIVE_RESTART
:
1468 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1469 goto invalid_enum_error
;
1471 return ctx
->Array
.PrimitiveRestart
;
1473 /* GL3.0 - GL_framebuffer_sRGB */
1474 case GL_FRAMEBUFFER_SRGB_EXT
:
1475 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1476 return ctx
->Color
.sRGBEnabled
;
1479 goto invalid_enum_error
;
1485 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);