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_SGI_texture_color_table */
707 case GL_TEXTURE_COLOR_TABLE_SGI
:
708 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
709 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
711 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
712 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
715 /* GL_ARB_texture_cube_map */
716 case GL_TEXTURE_CUBE_MAP_ARB
:
717 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
718 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
723 /* GL_EXT_secondary_color */
724 case GL_COLOR_SUM_EXT
:
725 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
726 if (ctx
->Fog
.ColorSumEnabled
== state
)
728 FLUSH_VERTICES(ctx
, _NEW_FOG
);
729 ctx
->Fog
.ColorSumEnabled
= state
;
732 /* GL_ARB_multisample */
733 case GL_MULTISAMPLE_ARB
:
734 if (ctx
->Multisample
.Enabled
== state
)
736 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
737 ctx
->Multisample
.Enabled
= state
;
739 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
740 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
743 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
745 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
746 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
748 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
749 ctx
->Multisample
.SampleAlphaToOne
= state
;
751 case GL_SAMPLE_COVERAGE_ARB
:
752 if (ctx
->Multisample
.SampleCoverage
== state
)
754 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
755 ctx
->Multisample
.SampleCoverage
= state
;
757 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
758 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
760 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
761 ctx
->Multisample
.SampleCoverageInvert
= state
;
764 /* GL_IBM_rasterpos_clip */
765 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
766 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
767 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
769 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
770 ctx
->Transform
.RasterPositionUnclipped
= state
;
773 /* GL_NV_point_sprite */
774 case GL_POINT_SPRITE_NV
:
775 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
776 if (ctx
->Point
.PointSprite
== state
)
778 FLUSH_VERTICES(ctx
, _NEW_POINT
);
779 ctx
->Point
.PointSprite
= state
;
782 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
783 case GL_VERTEX_PROGRAM_ARB
:
784 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
785 if (ctx
->VertexProgram
.Enabled
== state
)
787 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
788 ctx
->VertexProgram
.Enabled
= state
;
790 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
791 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
792 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
794 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
795 ctx
->VertexProgram
.PointSizeEnabled
= state
;
797 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
798 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
799 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
801 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
802 ctx
->VertexProgram
.TwoSideEnabled
= state
;
805 #if FEATURE_NV_vertex_program
806 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
807 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
808 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
809 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
810 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
811 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
812 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
813 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
814 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
815 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
816 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
817 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
818 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
819 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
820 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
821 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
822 CHECK_EXTENSION(NV_vertex_program
, cap
);
824 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
825 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
826 ctx
->Eval
.Map1Attrib
[map
] = state
;
829 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
830 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
831 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
832 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
833 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
834 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
835 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
836 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
837 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
838 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
839 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
840 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
841 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
842 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
843 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
844 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
845 CHECK_EXTENSION(NV_vertex_program
, cap
);
847 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
848 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
849 ctx
->Eval
.Map2Attrib
[map
] = state
;
852 #endif /* FEATURE_NV_vertex_program */
854 #if FEATURE_NV_fragment_program
855 case GL_FRAGMENT_PROGRAM_NV
:
856 CHECK_EXTENSION(NV_fragment_program
, cap
);
857 if (ctx
->FragmentProgram
.Enabled
== state
)
859 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
860 ctx
->FragmentProgram
.Enabled
= state
;
862 #endif /* FEATURE_NV_fragment_program */
864 /* GL_NV_texture_rectangle */
865 case GL_TEXTURE_RECTANGLE_NV
:
866 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
867 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
872 /* GL_EXT_stencil_two_side */
873 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
874 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
875 if (ctx
->Stencil
.TestTwoSide
== state
)
877 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
878 ctx
->Stencil
.TestTwoSide
= state
;
880 ctx
->Stencil
._BackFace
= 2;
881 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
883 ctx
->Stencil
._BackFace
= 1;
884 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
888 #if FEATURE_ARB_fragment_program
889 case GL_FRAGMENT_PROGRAM_ARB
:
890 CHECK_EXTENSION(ARB_fragment_program
, cap
);
891 if (ctx
->FragmentProgram
.Enabled
== state
)
893 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
894 ctx
->FragmentProgram
.Enabled
= state
;
896 #endif /* FEATURE_ARB_fragment_program */
898 /* GL_EXT_depth_bounds_test */
899 case GL_DEPTH_BOUNDS_TEST_EXT
:
900 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
901 if (ctx
->Depth
.BoundsTest
== state
)
903 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
904 ctx
->Depth
.BoundsTest
= state
;
908 if (ctx
->Transform
.DepthClamp
== state
)
910 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
911 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
912 ctx
->Transform
.DepthClamp
= state
;
915 #if FEATURE_ATI_fragment_shader
916 case GL_FRAGMENT_SHADER_ATI
:
917 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
918 if (ctx
->ATIFragmentShader
.Enabled
== state
)
920 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
921 ctx
->ATIFragmentShader
.Enabled
= state
;
925 /* GL_MESA_texture_array */
926 case GL_TEXTURE_1D_ARRAY_EXT
:
927 CHECK_EXTENSION(MESA_texture_array
, cap
);
928 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
933 case GL_TEXTURE_2D_ARRAY_EXT
:
934 CHECK_EXTENSION(MESA_texture_array
, cap
);
935 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
940 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
941 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
942 ctx
->Texture
.CubeMapSeamless
= state
;
945 #if FEATURE_EXT_transform_feedback
946 case GL_RASTERIZER_DISCARD
:
947 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
948 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
949 ctx
->TransformFeedback
.RasterDiscard
= state
;
950 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
955 /* GL 3.1 primitive restart. Note: this enum is different from
956 * GL_PRIMITIVE_RESTART_NV (which is client state).
958 case GL_PRIMITIVE_RESTART
:
959 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
960 goto invalid_enum_error
;
962 if (ctx
->Array
.PrimitiveRestart
!= state
) {
963 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
964 ctx
->Array
.PrimitiveRestart
= state
;
968 /* GL3.0 - GL_framebuffer_sRGB */
969 case GL_FRAMEBUFFER_SRGB_EXT
:
970 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
971 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
972 ctx
->Color
.sRGBEnabled
= state
;
976 goto invalid_enum_error
;
979 if (ctx
->Driver
.Enable
) {
980 ctx
->Driver
.Enable( ctx
, cap
, state
);
986 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
987 state
? "Enable" : "Disable", cap
);
992 * Enable GL capability. Called by glEnable()
993 * \param cap state to enable.
996 _mesa_Enable( GLenum cap
)
998 GET_CURRENT_CONTEXT(ctx
);
999 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1001 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1006 * Disable GL capability. Called by glDisable()
1007 * \param cap state to disable.
1010 _mesa_Disable( GLenum cap
)
1012 GET_CURRENT_CONTEXT(ctx
);
1013 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1015 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1021 * Enable/disable an indexed state var.
1024 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1026 ASSERT(state
== 0 || state
== 1);
1029 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1030 goto invalid_enum_error
;
1032 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1033 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1034 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1037 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1038 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1040 ctx
->Color
.BlendEnabled
|= (1 << index
);
1042 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1046 goto invalid_enum_error
;
1051 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1052 state
? "glEnablei" : "glDisablei",
1053 _mesa_lookup_enum_by_nr(cap
));
1058 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1060 GET_CURRENT_CONTEXT(ctx
);
1061 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1062 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1067 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1069 GET_CURRENT_CONTEXT(ctx
);
1070 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1071 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1075 GLboolean GLAPIENTRY
1076 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1078 GET_CURRENT_CONTEXT(ctx
);
1081 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1082 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1086 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1088 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1089 _mesa_lookup_enum_by_nr(cap
));
1097 #undef CHECK_EXTENSION
1098 #define CHECK_EXTENSION(EXTNAME) \
1099 if (!ctx->Extensions.EXTNAME) { \
1100 goto invalid_enum_error; \
1103 #undef CHECK_EXTENSION2
1104 #define CHECK_EXTENSION2(EXT1, EXT2) \
1105 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1106 goto invalid_enum_error; \
1111 * Helper function to determine whether a texture target is enabled.
1114 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1116 const struct gl_texture_unit
*const texUnit
=
1117 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1118 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1123 * Return simple enable/disable state.
1125 * \param cap state variable to query.
1127 * Returns the state of the specified capability from the current GL context.
1128 * For the capabilities associated with extensions verifies that those
1129 * extensions are effectively present before reporting.
1131 GLboolean GLAPIENTRY
1132 _mesa_IsEnabled( GLenum cap
)
1134 GET_CURRENT_CONTEXT(ctx
);
1137 return ctx
->Color
.AlphaEnabled
;
1138 case GL_AUTO_NORMAL
:
1139 return ctx
->Eval
.AutoNormal
;
1141 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1142 case GL_CLIP_PLANE0
:
1143 case GL_CLIP_PLANE1
:
1144 case GL_CLIP_PLANE2
:
1145 case GL_CLIP_PLANE3
:
1146 case GL_CLIP_PLANE4
:
1147 case GL_CLIP_PLANE5
:
1148 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1149 case GL_COLOR_MATERIAL
:
1150 return ctx
->Light
.ColorMaterialEnabled
;
1152 return ctx
->Polygon
.CullFlag
;
1154 return ctx
->Depth
.Test
;
1156 return ctx
->Color
.DitherFlag
;
1158 return ctx
->Fog
.Enabled
;
1160 return ctx
->Light
.Enabled
;
1169 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1170 case GL_LINE_SMOOTH
:
1171 return ctx
->Line
.SmoothFlag
;
1172 case GL_LINE_STIPPLE
:
1173 return ctx
->Line
.StippleFlag
;
1174 case GL_INDEX_LOGIC_OP
:
1175 return ctx
->Color
.IndexLogicOpEnabled
;
1176 case GL_COLOR_LOGIC_OP
:
1177 return ctx
->Color
.ColorLogicOpEnabled
;
1178 case GL_MAP1_COLOR_4
:
1179 return ctx
->Eval
.Map1Color4
;
1181 return ctx
->Eval
.Map1Index
;
1182 case GL_MAP1_NORMAL
:
1183 return ctx
->Eval
.Map1Normal
;
1184 case GL_MAP1_TEXTURE_COORD_1
:
1185 return ctx
->Eval
.Map1TextureCoord1
;
1186 case GL_MAP1_TEXTURE_COORD_2
:
1187 return ctx
->Eval
.Map1TextureCoord2
;
1188 case GL_MAP1_TEXTURE_COORD_3
:
1189 return ctx
->Eval
.Map1TextureCoord3
;
1190 case GL_MAP1_TEXTURE_COORD_4
:
1191 return ctx
->Eval
.Map1TextureCoord4
;
1192 case GL_MAP1_VERTEX_3
:
1193 return ctx
->Eval
.Map1Vertex3
;
1194 case GL_MAP1_VERTEX_4
:
1195 return ctx
->Eval
.Map1Vertex4
;
1196 case GL_MAP2_COLOR_4
:
1197 return ctx
->Eval
.Map2Color4
;
1199 return ctx
->Eval
.Map2Index
;
1200 case GL_MAP2_NORMAL
:
1201 return ctx
->Eval
.Map2Normal
;
1202 case GL_MAP2_TEXTURE_COORD_1
:
1203 return ctx
->Eval
.Map2TextureCoord1
;
1204 case GL_MAP2_TEXTURE_COORD_2
:
1205 return ctx
->Eval
.Map2TextureCoord2
;
1206 case GL_MAP2_TEXTURE_COORD_3
:
1207 return ctx
->Eval
.Map2TextureCoord3
;
1208 case GL_MAP2_TEXTURE_COORD_4
:
1209 return ctx
->Eval
.Map2TextureCoord4
;
1210 case GL_MAP2_VERTEX_3
:
1211 return ctx
->Eval
.Map2Vertex3
;
1212 case GL_MAP2_VERTEX_4
:
1213 return ctx
->Eval
.Map2Vertex4
;
1215 return ctx
->Transform
.Normalize
;
1216 case GL_POINT_SMOOTH
:
1217 return ctx
->Point
.SmoothFlag
;
1218 case GL_POLYGON_SMOOTH
:
1219 return ctx
->Polygon
.SmoothFlag
;
1220 case GL_POLYGON_STIPPLE
:
1221 return ctx
->Polygon
.StippleFlag
;
1222 case GL_POLYGON_OFFSET_POINT
:
1223 return ctx
->Polygon
.OffsetPoint
;
1224 case GL_POLYGON_OFFSET_LINE
:
1225 return ctx
->Polygon
.OffsetLine
;
1226 case GL_POLYGON_OFFSET_FILL
:
1227 /*case GL_POLYGON_OFFSET_EXT:*/
1228 return ctx
->Polygon
.OffsetFill
;
1229 case GL_RESCALE_NORMAL_EXT
:
1230 return ctx
->Transform
.RescaleNormals
;
1231 case GL_SCISSOR_TEST
:
1232 return ctx
->Scissor
.Enabled
;
1233 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1234 return ctx
->Texture
.SharedPalette
;
1235 case GL_STENCIL_TEST
:
1236 return ctx
->Stencil
.Enabled
;
1238 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1240 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1242 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1243 case GL_TEXTURE_GEN_Q
:
1245 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1247 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1251 case GL_TEXTURE_GEN_R
:
1253 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1255 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1259 case GL_TEXTURE_GEN_S
:
1261 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1263 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1267 case GL_TEXTURE_GEN_T
:
1269 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1271 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1276 case GL_TEXTURE_GEN_STR_OES
:
1278 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1280 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1288 case GL_VERTEX_ARRAY
:
1289 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1290 case GL_NORMAL_ARRAY
:
1291 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1292 case GL_COLOR_ARRAY
:
1293 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1294 case GL_INDEX_ARRAY
:
1295 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1296 case GL_TEXTURE_COORD_ARRAY
:
1297 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1298 case GL_EDGE_FLAG_ARRAY
:
1299 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1300 case GL_FOG_COORDINATE_ARRAY_EXT
:
1301 CHECK_EXTENSION(EXT_fog_coord
);
1302 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1303 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1304 CHECK_EXTENSION(EXT_secondary_color
);
1305 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1306 #if FEATURE_point_size_array
1307 case GL_POINT_SIZE_ARRAY_OES
:
1308 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1311 /* GL_SGI_texture_color_table */
1312 case GL_TEXTURE_COLOR_TABLE_SGI
:
1313 CHECK_EXTENSION(SGI_texture_color_table
);
1314 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1316 /* GL_ARB_texture_cube_map */
1317 case GL_TEXTURE_CUBE_MAP_ARB
:
1318 CHECK_EXTENSION(ARB_texture_cube_map
);
1319 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1321 /* GL_EXT_secondary_color */
1322 case GL_COLOR_SUM_EXT
:
1323 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1324 return ctx
->Fog
.ColorSumEnabled
;
1326 /* GL_ARB_multisample */
1327 case GL_MULTISAMPLE_ARB
:
1328 return ctx
->Multisample
.Enabled
;
1329 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1330 return ctx
->Multisample
.SampleAlphaToCoverage
;
1331 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1332 return ctx
->Multisample
.SampleAlphaToOne
;
1333 case GL_SAMPLE_COVERAGE_ARB
:
1334 return ctx
->Multisample
.SampleCoverage
;
1335 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1336 return ctx
->Multisample
.SampleCoverageInvert
;
1338 /* GL_IBM_rasterpos_clip */
1339 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1340 CHECK_EXTENSION(IBM_rasterpos_clip
);
1341 return ctx
->Transform
.RasterPositionUnclipped
;
1343 /* GL_NV_point_sprite */
1344 case GL_POINT_SPRITE_NV
:
1345 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1346 return ctx
->Point
.PointSprite
;
1348 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1349 case GL_VERTEX_PROGRAM_ARB
:
1350 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1351 return ctx
->VertexProgram
.Enabled
;
1352 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1353 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1354 return ctx
->VertexProgram
.PointSizeEnabled
;
1355 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1356 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1357 return ctx
->VertexProgram
.TwoSideEnabled
;
1359 #if FEATURE_NV_vertex_program
1360 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1361 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1362 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1363 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1364 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1365 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1366 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1367 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1368 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1369 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1370 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1371 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1372 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1373 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1374 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1375 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1376 CHECK_EXTENSION(NV_vertex_program
);
1378 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1379 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1380 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1382 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1383 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1384 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1385 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1386 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1387 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1388 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1389 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1390 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1391 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1392 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1393 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1394 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1395 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1396 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1397 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1398 CHECK_EXTENSION(NV_vertex_program
);
1400 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1401 return ctx
->Eval
.Map1Attrib
[map
];
1403 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1404 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1405 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1406 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1407 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1408 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1409 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1410 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1411 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1412 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1413 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1414 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1415 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1416 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1417 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1418 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1419 CHECK_EXTENSION(NV_vertex_program
);
1421 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1422 return ctx
->Eval
.Map2Attrib
[map
];
1424 #endif /* FEATURE_NV_vertex_program */
1426 #if FEATURE_NV_fragment_program
1427 case GL_FRAGMENT_PROGRAM_NV
:
1428 CHECK_EXTENSION(NV_fragment_program
);
1429 return ctx
->FragmentProgram
.Enabled
;
1430 #endif /* FEATURE_NV_fragment_program */
1432 /* GL_NV_texture_rectangle */
1433 case GL_TEXTURE_RECTANGLE_NV
:
1434 CHECK_EXTENSION(NV_texture_rectangle
);
1435 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1437 /* GL_EXT_stencil_two_side */
1438 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1439 CHECK_EXTENSION(EXT_stencil_two_side
);
1440 return ctx
->Stencil
.TestTwoSide
;
1442 #if FEATURE_ARB_fragment_program
1443 case GL_FRAGMENT_PROGRAM_ARB
:
1444 return ctx
->FragmentProgram
.Enabled
;
1445 #endif /* FEATURE_ARB_fragment_program */
1447 /* GL_EXT_depth_bounds_test */
1448 case GL_DEPTH_BOUNDS_TEST_EXT
:
1449 CHECK_EXTENSION(EXT_depth_bounds_test
);
1450 return ctx
->Depth
.BoundsTest
;
1452 /* GL_ARB_depth_clamp */
1453 case GL_DEPTH_CLAMP
:
1454 CHECK_EXTENSION(ARB_depth_clamp
);
1455 return ctx
->Transform
.DepthClamp
;
1457 #if FEATURE_ATI_fragment_shader
1458 case GL_FRAGMENT_SHADER_ATI
:
1459 CHECK_EXTENSION(ATI_fragment_shader
);
1460 return ctx
->ATIFragmentShader
.Enabled
;
1461 #endif /* FEATURE_ATI_fragment_shader */
1463 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1464 CHECK_EXTENSION(ARB_seamless_cube_map
);
1465 return ctx
->Texture
.CubeMapSeamless
;
1467 #if FEATURE_EXT_transform_feedback
1468 case GL_RASTERIZER_DISCARD
:
1469 CHECK_EXTENSION(EXT_transform_feedback
);
1470 return ctx
->TransformFeedback
.RasterDiscard
;
1473 /* GL_NV_primitive_restart */
1474 case GL_PRIMITIVE_RESTART_NV
:
1475 if (!ctx
->Extensions
.NV_primitive_restart
) {
1476 goto invalid_enum_error
;
1478 return ctx
->Array
.PrimitiveRestart
;
1480 /* GL 3.1 primitive restart */
1481 case GL_PRIMITIVE_RESTART
:
1482 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1483 goto invalid_enum_error
;
1485 return ctx
->Array
.PrimitiveRestart
;
1487 /* GL3.0 - GL_framebuffer_sRGB */
1488 case GL_FRAMEBUFFER_SRGB_EXT
:
1489 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1490 return ctx
->Color
.sRGBEnabled
;
1493 goto invalid_enum_error
;
1499 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);