3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 #include "simple_list.h"
37 #include "mfeatures.h"
40 #include "api_arrayelt.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
52 * Helper to enable/disable client-side state.
55 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
57 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
63 var
= &arrayObj
->Vertex
.Enabled
;
64 flag
= _NEW_ARRAY_VERTEX
;
67 var
= &arrayObj
->Normal
.Enabled
;
68 flag
= _NEW_ARRAY_NORMAL
;
71 var
= &arrayObj
->Color
.Enabled
;
72 flag
= _NEW_ARRAY_COLOR0
;
75 var
= &arrayObj
->Index
.Enabled
;
76 flag
= _NEW_ARRAY_INDEX
;
78 case GL_TEXTURE_COORD_ARRAY
:
79 var
= &arrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
80 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
82 case GL_EDGE_FLAG_ARRAY
:
83 var
= &arrayObj
->EdgeFlag
.Enabled
;
84 flag
= _NEW_ARRAY_EDGEFLAG
;
86 case GL_FOG_COORDINATE_ARRAY_EXT
:
87 var
= &arrayObj
->FogCoord
.Enabled
;
88 flag
= _NEW_ARRAY_FOGCOORD
;
90 case GL_SECONDARY_COLOR_ARRAY_EXT
:
91 var
= &arrayObj
->SecondaryColor
.Enabled
;
92 flag
= _NEW_ARRAY_COLOR1
;
95 #if FEATURE_point_size_array
96 case GL_POINT_SIZE_ARRAY_OES
:
97 var
= &arrayObj
->PointSize
.Enabled
;
98 flag
= _NEW_ARRAY_POINT_SIZE
;
102 #if FEATURE_NV_vertex_program
103 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
118 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
119 CHECK_EXTENSION(NV_vertex_program
, cap
);
121 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
122 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
123 var
= &arrayObj
->VertexAttrib
[n
].Enabled
;
124 flag
= _NEW_ARRAY_ATTRIB(n
);
127 #endif /* FEATURE_NV_vertex_program */
129 /* GL_NV_primitive_restart */
130 case GL_PRIMITIVE_RESTART_NV
:
131 if (!ctx
->Extensions
.NV_primitive_restart
) {
132 goto invalid_enum_error
;
134 var
= &ctx
->Array
.PrimitiveRestart
;
139 goto invalid_enum_error
;
145 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
146 ctx
->Array
.NewState
|= flag
;
148 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
153 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
155 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
157 if (ctx
->Driver
.Enable
) {
158 ctx
->Driver
.Enable( ctx
, cap
, state
);
164 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(0x%x)",
165 state
? "Enable" : "Disable", cap
);
170 * Enable GL capability.
171 * \param cap state to enable/disable.
173 * Get's the current context, assures that we're outside glBegin()/glEnd() and
174 * calls client_state().
177 _mesa_EnableClientState( GLenum cap
)
179 GET_CURRENT_CONTEXT(ctx
);
180 ASSERT_OUTSIDE_BEGIN_END(ctx
);
181 client_state( ctx
, cap
, GL_TRUE
);
186 * Disable GL capability.
187 * \param cap state to enable/disable.
189 * Get's the current context, assures that we're outside glBegin()/glEnd() and
190 * calls client_state().
193 _mesa_DisableClientState( GLenum cap
)
195 GET_CURRENT_CONTEXT(ctx
);
196 ASSERT_OUTSIDE_BEGIN_END(ctx
);
197 client_state( ctx
, cap
, GL_FALSE
);
201 #undef CHECK_EXTENSION
202 #define CHECK_EXTENSION(EXTNAME, CAP) \
203 if (!ctx->Extensions.EXTNAME) { \
204 goto invalid_enum_error; \
207 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
208 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
209 goto invalid_enum_error; \
215 * Return pointer to current texture unit for setting/getting coordinate
217 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
218 * higher than the number of supported coordinate units. And we'll return NULL.
220 static struct gl_texture_unit
*
221 get_texcoord_unit(struct gl_context
*ctx
)
223 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
224 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
228 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
234 * Helper function to enable or disable a texture target.
235 * \param bit one of the TEXTURE_x_BIT values
236 * \return GL_TRUE if state is changing or GL_FALSE if no change
239 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
241 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
242 const GLbitfield newenabled
= state
243 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
245 if (texUnit
->Enabled
== newenabled
)
248 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
249 texUnit
->Enabled
= newenabled
;
255 * Helper function to enable or disable state.
257 * \param ctx GL context.
258 * \param cap the state to enable/disable
259 * \param state whether to enable or disable the specified capability.
261 * Updates the current context and flushes the vertices as needed. For
262 * capabilities associated with extensions it verifies that those extensions
263 * are effectivly present before updating. Notifies the driver via
264 * dd_function_table::Enable.
267 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
269 if (MESA_VERBOSE
& VERBOSE_API
)
270 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
271 state
? "glEnable" : "glDisable",
272 _mesa_lookup_enum_by_nr(cap
),
277 if (ctx
->Color
.AlphaEnabled
== state
)
279 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
280 ctx
->Color
.AlphaEnabled
= state
;
283 if (ctx
->Eval
.AutoNormal
== state
)
285 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
286 ctx
->Eval
.AutoNormal
= state
;
290 GLbitfield newEnabled
= state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
291 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
292 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
293 ctx
->Color
.BlendEnabled
= newEnabled
;
305 const GLuint p
= cap
- GL_CLIP_PLANE0
;
307 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
310 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
313 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
314 _mesa_update_clip_plane(ctx
, p
);
317 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
322 case GL_COLOR_MATERIAL
:
323 if (ctx
->Light
.ColorMaterialEnabled
== state
)
325 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
326 FLUSH_CURRENT(ctx
, 0);
327 ctx
->Light
.ColorMaterialEnabled
= state
;
329 _mesa_update_color_material( ctx
,
330 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
334 if (ctx
->Polygon
.CullFlag
== state
)
336 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
337 ctx
->Polygon
.CullFlag
= state
;
340 if (ctx
->Depth
.Test
== state
)
342 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
343 ctx
->Depth
.Test
= state
;
346 if (ctx
->Color
.DitherFlag
== state
)
348 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
349 ctx
->Color
.DitherFlag
= state
;
352 if (ctx
->Fog
.Enabled
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_FOG
);
355 ctx
->Fog
.Enabled
= state
;
365 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
367 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
368 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
370 insert_at_tail(&ctx
->Light
.EnabledList
,
371 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
374 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
378 if (ctx
->Light
.Enabled
== state
)
380 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
381 ctx
->Light
.Enabled
= state
;
382 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
383 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
385 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
388 if (ctx
->Line
.SmoothFlag
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_LINE
);
391 ctx
->Line
.SmoothFlag
= state
;
392 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
394 case GL_LINE_STIPPLE
:
395 if (ctx
->Line
.StippleFlag
== state
)
397 FLUSH_VERTICES(ctx
, _NEW_LINE
);
398 ctx
->Line
.StippleFlag
= state
;
399 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
401 case GL_INDEX_LOGIC_OP
:
402 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
404 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
405 ctx
->Color
.IndexLogicOpEnabled
= state
;
407 case GL_COLOR_LOGIC_OP
:
408 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
410 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
411 ctx
->Color
.ColorLogicOpEnabled
= state
;
413 case GL_MAP1_COLOR_4
:
414 if (ctx
->Eval
.Map1Color4
== state
)
416 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
417 ctx
->Eval
.Map1Color4
= state
;
420 if (ctx
->Eval
.Map1Index
== state
)
422 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
423 ctx
->Eval
.Map1Index
= state
;
426 if (ctx
->Eval
.Map1Normal
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
429 ctx
->Eval
.Map1Normal
= state
;
431 case GL_MAP1_TEXTURE_COORD_1
:
432 if (ctx
->Eval
.Map1TextureCoord1
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
435 ctx
->Eval
.Map1TextureCoord1
= state
;
437 case GL_MAP1_TEXTURE_COORD_2
:
438 if (ctx
->Eval
.Map1TextureCoord2
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
441 ctx
->Eval
.Map1TextureCoord2
= state
;
443 case GL_MAP1_TEXTURE_COORD_3
:
444 if (ctx
->Eval
.Map1TextureCoord3
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
447 ctx
->Eval
.Map1TextureCoord3
= state
;
449 case GL_MAP1_TEXTURE_COORD_4
:
450 if (ctx
->Eval
.Map1TextureCoord4
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map1TextureCoord4
= state
;
455 case GL_MAP1_VERTEX_3
:
456 if (ctx
->Eval
.Map1Vertex3
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map1Vertex3
= state
;
461 case GL_MAP1_VERTEX_4
:
462 if (ctx
->Eval
.Map1Vertex4
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map1Vertex4
= state
;
467 case GL_MAP2_COLOR_4
:
468 if (ctx
->Eval
.Map2Color4
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map2Color4
= state
;
474 if (ctx
->Eval
.Map2Index
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map2Index
= state
;
480 if (ctx
->Eval
.Map2Normal
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map2Normal
= state
;
485 case GL_MAP2_TEXTURE_COORD_1
:
486 if (ctx
->Eval
.Map2TextureCoord1
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map2TextureCoord1
= state
;
491 case GL_MAP2_TEXTURE_COORD_2
:
492 if (ctx
->Eval
.Map2TextureCoord2
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map2TextureCoord2
= state
;
497 case GL_MAP2_TEXTURE_COORD_3
:
498 if (ctx
->Eval
.Map2TextureCoord3
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
501 ctx
->Eval
.Map2TextureCoord3
= state
;
503 case GL_MAP2_TEXTURE_COORD_4
:
504 if (ctx
->Eval
.Map2TextureCoord4
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map2TextureCoord4
= state
;
509 case GL_MAP2_VERTEX_3
:
510 if (ctx
->Eval
.Map2Vertex3
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map2Vertex3
= state
;
515 case GL_MAP2_VERTEX_4
:
516 if (ctx
->Eval
.Map2Vertex4
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map2Vertex4
= state
;
522 if (ctx
->Transform
.Normalize
== state
)
524 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
525 ctx
->Transform
.Normalize
= state
;
527 case GL_POINT_SMOOTH
:
528 if (ctx
->Point
.SmoothFlag
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_POINT
);
531 ctx
->Point
.SmoothFlag
= state
;
532 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
534 case GL_POLYGON_SMOOTH
:
535 if (ctx
->Polygon
.SmoothFlag
== state
)
537 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
538 ctx
->Polygon
.SmoothFlag
= state
;
539 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
541 case GL_POLYGON_STIPPLE
:
542 if (ctx
->Polygon
.StippleFlag
== state
)
544 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
545 ctx
->Polygon
.StippleFlag
= state
;
546 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
548 case GL_POLYGON_OFFSET_POINT
:
549 if (ctx
->Polygon
.OffsetPoint
== state
)
551 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
552 ctx
->Polygon
.OffsetPoint
= state
;
554 case GL_POLYGON_OFFSET_LINE
:
555 if (ctx
->Polygon
.OffsetLine
== state
)
557 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
558 ctx
->Polygon
.OffsetLine
= state
;
560 case GL_POLYGON_OFFSET_FILL
:
561 /*case GL_POLYGON_OFFSET_EXT:*/
562 if (ctx
->Polygon
.OffsetFill
== state
)
564 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
565 ctx
->Polygon
.OffsetFill
= state
;
567 case GL_RESCALE_NORMAL_EXT
:
568 if (ctx
->Transform
.RescaleNormals
== state
)
570 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
571 ctx
->Transform
.RescaleNormals
= state
;
573 case GL_SCISSOR_TEST
:
574 if (ctx
->Scissor
.Enabled
== state
)
576 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
577 ctx
->Scissor
.Enabled
= state
;
579 case GL_SHARED_TEXTURE_PALETTE_EXT
:
580 if (ctx
->Texture
.SharedPalette
== state
)
582 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
583 ctx
->Texture
.SharedPalette
= state
;
585 case GL_STENCIL_TEST
:
586 if (ctx
->Stencil
.Enabled
== state
)
588 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
589 ctx
->Stencil
.Enabled
= state
;
592 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
597 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
602 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
606 case GL_TEXTURE_GEN_Q
:
608 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
610 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
613 if (texUnit
->TexGenEnabled
== newenabled
)
615 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
616 texUnit
->TexGenEnabled
= newenabled
;
620 case GL_TEXTURE_GEN_R
:
622 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
624 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
627 if (texUnit
->TexGenEnabled
== newenabled
)
629 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
630 texUnit
->TexGenEnabled
= newenabled
;
634 case GL_TEXTURE_GEN_S
:
636 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
638 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
641 if (texUnit
->TexGenEnabled
== newenabled
)
643 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
644 texUnit
->TexGenEnabled
= newenabled
;
648 case GL_TEXTURE_GEN_T
:
650 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
652 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
655 if (texUnit
->TexGenEnabled
== newenabled
)
657 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
658 texUnit
->TexGenEnabled
= newenabled
;
664 case GL_TEXTURE_GEN_STR_OES
:
665 /* disable S, T, and R at the same time */
667 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
670 texUnit
->TexGenEnabled
& ~STR_BITS
;
672 newenabled
|= STR_BITS
;
673 if (texUnit
->TexGenEnabled
== newenabled
)
675 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
676 texUnit
->TexGenEnabled
= newenabled
;
685 case GL_VERTEX_ARRAY
:
686 case GL_NORMAL_ARRAY
:
689 case GL_TEXTURE_COORD_ARRAY
:
690 case GL_EDGE_FLAG_ARRAY
:
691 case GL_FOG_COORDINATE_ARRAY_EXT
:
692 case GL_SECONDARY_COLOR_ARRAY_EXT
:
693 case GL_POINT_SIZE_ARRAY_OES
:
694 client_state( ctx
, cap
, state
);
697 /* GL_ARB_texture_cube_map */
698 case GL_TEXTURE_CUBE_MAP_ARB
:
699 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
700 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
705 /* GL_EXT_secondary_color */
706 case GL_COLOR_SUM_EXT
:
707 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
708 if (ctx
->Fog
.ColorSumEnabled
== state
)
710 FLUSH_VERTICES(ctx
, _NEW_FOG
);
711 ctx
->Fog
.ColorSumEnabled
= state
;
714 /* GL_ARB_multisample */
715 case GL_MULTISAMPLE_ARB
:
716 if (ctx
->Multisample
.Enabled
== state
)
718 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
719 ctx
->Multisample
.Enabled
= state
;
721 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
722 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
724 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
725 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
727 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
728 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
730 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
731 ctx
->Multisample
.SampleAlphaToOne
= state
;
733 case GL_SAMPLE_COVERAGE_ARB
:
734 if (ctx
->Multisample
.SampleCoverage
== state
)
736 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
737 ctx
->Multisample
.SampleCoverage
= state
;
739 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
740 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
743 ctx
->Multisample
.SampleCoverageInvert
= state
;
746 /* GL_IBM_rasterpos_clip */
747 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
748 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
749 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
751 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
752 ctx
->Transform
.RasterPositionUnclipped
= state
;
755 /* GL_NV_point_sprite */
756 case GL_POINT_SPRITE_NV
:
757 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
758 if (ctx
->Point
.PointSprite
== state
)
760 FLUSH_VERTICES(ctx
, _NEW_POINT
);
761 ctx
->Point
.PointSprite
= state
;
764 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
765 case GL_VERTEX_PROGRAM_ARB
:
766 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
767 if (ctx
->VertexProgram
.Enabled
== state
)
769 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
770 ctx
->VertexProgram
.Enabled
= state
;
772 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
773 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
774 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
776 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
777 ctx
->VertexProgram
.PointSizeEnabled
= state
;
779 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
780 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
781 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
783 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
784 ctx
->VertexProgram
.TwoSideEnabled
= state
;
787 #if FEATURE_NV_vertex_program
788 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
789 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
790 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
791 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
792 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
793 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
794 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
795 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
796 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
797 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
798 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
799 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
800 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
801 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
802 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
803 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
804 CHECK_EXTENSION(NV_vertex_program
, cap
);
806 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
807 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
808 ctx
->Eval
.Map1Attrib
[map
] = state
;
811 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
812 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
813 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
814 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
815 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
816 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
817 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
818 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
819 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
820 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
821 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
822 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
823 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
824 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
825 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
826 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
827 CHECK_EXTENSION(NV_vertex_program
, cap
);
829 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
830 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
831 ctx
->Eval
.Map2Attrib
[map
] = state
;
834 #endif /* FEATURE_NV_vertex_program */
836 #if FEATURE_NV_fragment_program
837 case GL_FRAGMENT_PROGRAM_NV
:
838 CHECK_EXTENSION(NV_fragment_program
, cap
);
839 if (ctx
->FragmentProgram
.Enabled
== state
)
841 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
842 ctx
->FragmentProgram
.Enabled
= state
;
844 #endif /* FEATURE_NV_fragment_program */
846 /* GL_NV_texture_rectangle */
847 case GL_TEXTURE_RECTANGLE_NV
:
848 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
849 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
854 /* GL_EXT_stencil_two_side */
855 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
856 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
857 if (ctx
->Stencil
.TestTwoSide
== state
)
859 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
860 ctx
->Stencil
.TestTwoSide
= state
;
862 ctx
->Stencil
._BackFace
= 2;
863 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
865 ctx
->Stencil
._BackFace
= 1;
866 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
870 #if FEATURE_ARB_fragment_program
871 case GL_FRAGMENT_PROGRAM_ARB
:
872 CHECK_EXTENSION(ARB_fragment_program
, cap
);
873 if (ctx
->FragmentProgram
.Enabled
== state
)
875 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
876 ctx
->FragmentProgram
.Enabled
= state
;
878 #endif /* FEATURE_ARB_fragment_program */
880 /* GL_EXT_depth_bounds_test */
881 case GL_DEPTH_BOUNDS_TEST_EXT
:
882 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
883 if (ctx
->Depth
.BoundsTest
== state
)
885 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
886 ctx
->Depth
.BoundsTest
= state
;
890 if (ctx
->Transform
.DepthClamp
== state
)
892 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
893 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
894 ctx
->Transform
.DepthClamp
= state
;
897 #if FEATURE_ATI_fragment_shader
898 case GL_FRAGMENT_SHADER_ATI
:
899 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
900 if (ctx
->ATIFragmentShader
.Enabled
== state
)
902 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
903 ctx
->ATIFragmentShader
.Enabled
= state
;
907 /* GL_MESA_texture_array */
908 case GL_TEXTURE_1D_ARRAY_EXT
:
909 CHECK_EXTENSION(MESA_texture_array
, cap
);
910 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
915 case GL_TEXTURE_2D_ARRAY_EXT
:
916 CHECK_EXTENSION(MESA_texture_array
, cap
);
917 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
922 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
923 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
924 ctx
->Texture
.CubeMapSeamless
= state
;
927 #if FEATURE_EXT_transform_feedback
928 case GL_RASTERIZER_DISCARD
:
929 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
930 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
931 ctx
->TransformFeedback
.RasterDiscard
= state
;
932 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
937 /* GL 3.1 primitive restart. Note: this enum is different from
938 * GL_PRIMITIVE_RESTART_NV (which is client state).
940 case GL_PRIMITIVE_RESTART
:
941 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
942 goto invalid_enum_error
;
944 if (ctx
->Array
.PrimitiveRestart
!= state
) {
945 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
946 ctx
->Array
.PrimitiveRestart
= state
;
950 /* GL3.0 - GL_framebuffer_sRGB */
951 case GL_FRAMEBUFFER_SRGB_EXT
:
952 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
953 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
954 ctx
->Color
.sRGBEnabled
= state
;
958 goto invalid_enum_error
;
961 if (ctx
->Driver
.Enable
) {
962 ctx
->Driver
.Enable( ctx
, cap
, state
);
968 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
969 state
? "Enable" : "Disable", cap
);
974 * Enable GL capability. Called by glEnable()
975 * \param cap state to enable.
978 _mesa_Enable( GLenum cap
)
980 GET_CURRENT_CONTEXT(ctx
);
981 ASSERT_OUTSIDE_BEGIN_END(ctx
);
983 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
988 * Disable GL capability. Called by glDisable()
989 * \param cap state to disable.
992 _mesa_Disable( GLenum cap
)
994 GET_CURRENT_CONTEXT(ctx
);
995 ASSERT_OUTSIDE_BEGIN_END(ctx
);
997 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1003 * Enable/disable an indexed state var.
1006 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1008 ASSERT(state
== 0 || state
== 1);
1011 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1012 goto invalid_enum_error
;
1014 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1015 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1016 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1019 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1020 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1022 ctx
->Color
.BlendEnabled
|= (1 << index
);
1024 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1028 goto invalid_enum_error
;
1033 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1034 state
? "glEnablei" : "glDisablei",
1035 _mesa_lookup_enum_by_nr(cap
));
1040 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1042 GET_CURRENT_CONTEXT(ctx
);
1043 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1044 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1049 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1051 GET_CURRENT_CONTEXT(ctx
);
1052 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1053 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1057 GLboolean GLAPIENTRY
1058 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1060 GET_CURRENT_CONTEXT(ctx
);
1063 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1064 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1068 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1070 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1071 _mesa_lookup_enum_by_nr(cap
));
1079 #undef CHECK_EXTENSION
1080 #define CHECK_EXTENSION(EXTNAME) \
1081 if (!ctx->Extensions.EXTNAME) { \
1082 goto invalid_enum_error; \
1085 #undef CHECK_EXTENSION2
1086 #define CHECK_EXTENSION2(EXT1, EXT2) \
1087 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1088 goto invalid_enum_error; \
1093 * Helper function to determine whether a texture target is enabled.
1096 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1098 const struct gl_texture_unit
*const texUnit
=
1099 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1100 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1105 * Return simple enable/disable state.
1107 * \param cap state variable to query.
1109 * Returns the state of the specified capability from the current GL context.
1110 * For the capabilities associated with extensions verifies that those
1111 * extensions are effectively present before reporting.
1113 GLboolean GLAPIENTRY
1114 _mesa_IsEnabled( GLenum cap
)
1116 GET_CURRENT_CONTEXT(ctx
);
1119 return ctx
->Color
.AlphaEnabled
;
1120 case GL_AUTO_NORMAL
:
1121 return ctx
->Eval
.AutoNormal
;
1123 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1124 case GL_CLIP_PLANE0
:
1125 case GL_CLIP_PLANE1
:
1126 case GL_CLIP_PLANE2
:
1127 case GL_CLIP_PLANE3
:
1128 case GL_CLIP_PLANE4
:
1129 case GL_CLIP_PLANE5
:
1130 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1131 case GL_COLOR_MATERIAL
:
1132 return ctx
->Light
.ColorMaterialEnabled
;
1134 return ctx
->Polygon
.CullFlag
;
1136 return ctx
->Depth
.Test
;
1138 return ctx
->Color
.DitherFlag
;
1140 return ctx
->Fog
.Enabled
;
1142 return ctx
->Light
.Enabled
;
1151 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1152 case GL_LINE_SMOOTH
:
1153 return ctx
->Line
.SmoothFlag
;
1154 case GL_LINE_STIPPLE
:
1155 return ctx
->Line
.StippleFlag
;
1156 case GL_INDEX_LOGIC_OP
:
1157 return ctx
->Color
.IndexLogicOpEnabled
;
1158 case GL_COLOR_LOGIC_OP
:
1159 return ctx
->Color
.ColorLogicOpEnabled
;
1160 case GL_MAP1_COLOR_4
:
1161 return ctx
->Eval
.Map1Color4
;
1163 return ctx
->Eval
.Map1Index
;
1164 case GL_MAP1_NORMAL
:
1165 return ctx
->Eval
.Map1Normal
;
1166 case GL_MAP1_TEXTURE_COORD_1
:
1167 return ctx
->Eval
.Map1TextureCoord1
;
1168 case GL_MAP1_TEXTURE_COORD_2
:
1169 return ctx
->Eval
.Map1TextureCoord2
;
1170 case GL_MAP1_TEXTURE_COORD_3
:
1171 return ctx
->Eval
.Map1TextureCoord3
;
1172 case GL_MAP1_TEXTURE_COORD_4
:
1173 return ctx
->Eval
.Map1TextureCoord4
;
1174 case GL_MAP1_VERTEX_3
:
1175 return ctx
->Eval
.Map1Vertex3
;
1176 case GL_MAP1_VERTEX_4
:
1177 return ctx
->Eval
.Map1Vertex4
;
1178 case GL_MAP2_COLOR_4
:
1179 return ctx
->Eval
.Map2Color4
;
1181 return ctx
->Eval
.Map2Index
;
1182 case GL_MAP2_NORMAL
:
1183 return ctx
->Eval
.Map2Normal
;
1184 case GL_MAP2_TEXTURE_COORD_1
:
1185 return ctx
->Eval
.Map2TextureCoord1
;
1186 case GL_MAP2_TEXTURE_COORD_2
:
1187 return ctx
->Eval
.Map2TextureCoord2
;
1188 case GL_MAP2_TEXTURE_COORD_3
:
1189 return ctx
->Eval
.Map2TextureCoord3
;
1190 case GL_MAP2_TEXTURE_COORD_4
:
1191 return ctx
->Eval
.Map2TextureCoord4
;
1192 case GL_MAP2_VERTEX_3
:
1193 return ctx
->Eval
.Map2Vertex3
;
1194 case GL_MAP2_VERTEX_4
:
1195 return ctx
->Eval
.Map2Vertex4
;
1197 return ctx
->Transform
.Normalize
;
1198 case GL_POINT_SMOOTH
:
1199 return ctx
->Point
.SmoothFlag
;
1200 case GL_POLYGON_SMOOTH
:
1201 return ctx
->Polygon
.SmoothFlag
;
1202 case GL_POLYGON_STIPPLE
:
1203 return ctx
->Polygon
.StippleFlag
;
1204 case GL_POLYGON_OFFSET_POINT
:
1205 return ctx
->Polygon
.OffsetPoint
;
1206 case GL_POLYGON_OFFSET_LINE
:
1207 return ctx
->Polygon
.OffsetLine
;
1208 case GL_POLYGON_OFFSET_FILL
:
1209 /*case GL_POLYGON_OFFSET_EXT:*/
1210 return ctx
->Polygon
.OffsetFill
;
1211 case GL_RESCALE_NORMAL_EXT
:
1212 return ctx
->Transform
.RescaleNormals
;
1213 case GL_SCISSOR_TEST
:
1214 return ctx
->Scissor
.Enabled
;
1215 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1216 return ctx
->Texture
.SharedPalette
;
1217 case GL_STENCIL_TEST
:
1218 return ctx
->Stencil
.Enabled
;
1220 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1222 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1224 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1225 case GL_TEXTURE_GEN_Q
:
1227 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1229 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1233 case GL_TEXTURE_GEN_R
:
1235 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1237 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1241 case GL_TEXTURE_GEN_S
:
1243 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1245 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1249 case GL_TEXTURE_GEN_T
:
1251 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1253 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1258 case GL_TEXTURE_GEN_STR_OES
:
1260 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1262 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1270 case GL_VERTEX_ARRAY
:
1271 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1272 case GL_NORMAL_ARRAY
:
1273 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1274 case GL_COLOR_ARRAY
:
1275 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1276 case GL_INDEX_ARRAY
:
1277 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1278 case GL_TEXTURE_COORD_ARRAY
:
1279 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1280 case GL_EDGE_FLAG_ARRAY
:
1281 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1282 case GL_FOG_COORDINATE_ARRAY_EXT
:
1283 CHECK_EXTENSION(EXT_fog_coord
);
1284 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1285 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1286 CHECK_EXTENSION(EXT_secondary_color
);
1287 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1288 #if FEATURE_point_size_array
1289 case GL_POINT_SIZE_ARRAY_OES
:
1290 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1293 /* GL_ARB_texture_cube_map */
1294 case GL_TEXTURE_CUBE_MAP_ARB
:
1295 CHECK_EXTENSION(ARB_texture_cube_map
);
1296 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1298 /* GL_EXT_secondary_color */
1299 case GL_COLOR_SUM_EXT
:
1300 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1301 return ctx
->Fog
.ColorSumEnabled
;
1303 /* GL_ARB_multisample */
1304 case GL_MULTISAMPLE_ARB
:
1305 return ctx
->Multisample
.Enabled
;
1306 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1307 return ctx
->Multisample
.SampleAlphaToCoverage
;
1308 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1309 return ctx
->Multisample
.SampleAlphaToOne
;
1310 case GL_SAMPLE_COVERAGE_ARB
:
1311 return ctx
->Multisample
.SampleCoverage
;
1312 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1313 return ctx
->Multisample
.SampleCoverageInvert
;
1315 /* GL_IBM_rasterpos_clip */
1316 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1317 CHECK_EXTENSION(IBM_rasterpos_clip
);
1318 return ctx
->Transform
.RasterPositionUnclipped
;
1320 /* GL_NV_point_sprite */
1321 case GL_POINT_SPRITE_NV
:
1322 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1323 return ctx
->Point
.PointSprite
;
1325 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1326 case GL_VERTEX_PROGRAM_ARB
:
1327 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1328 return ctx
->VertexProgram
.Enabled
;
1329 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1330 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1331 return ctx
->VertexProgram
.PointSizeEnabled
;
1332 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1333 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1334 return ctx
->VertexProgram
.TwoSideEnabled
;
1336 #if FEATURE_NV_vertex_program
1337 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1338 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1339 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1340 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1341 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1342 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1343 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1344 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1345 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1346 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1347 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1348 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1349 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1350 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1351 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1352 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1353 CHECK_EXTENSION(NV_vertex_program
);
1355 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1356 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1357 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1359 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1360 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1361 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1362 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1363 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1364 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1365 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1366 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1367 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1368 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1369 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1370 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1371 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1372 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1373 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1374 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1375 CHECK_EXTENSION(NV_vertex_program
);
1377 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1378 return ctx
->Eval
.Map1Attrib
[map
];
1380 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1381 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1382 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1383 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1384 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1385 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1386 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1387 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1388 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1389 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1390 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1391 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1392 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1393 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1394 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1395 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1396 CHECK_EXTENSION(NV_vertex_program
);
1398 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1399 return ctx
->Eval
.Map2Attrib
[map
];
1401 #endif /* FEATURE_NV_vertex_program */
1403 #if FEATURE_NV_fragment_program
1404 case GL_FRAGMENT_PROGRAM_NV
:
1405 CHECK_EXTENSION(NV_fragment_program
);
1406 return ctx
->FragmentProgram
.Enabled
;
1407 #endif /* FEATURE_NV_fragment_program */
1409 /* GL_NV_texture_rectangle */
1410 case GL_TEXTURE_RECTANGLE_NV
:
1411 CHECK_EXTENSION(NV_texture_rectangle
);
1412 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1414 /* GL_EXT_stencil_two_side */
1415 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1416 CHECK_EXTENSION(EXT_stencil_two_side
);
1417 return ctx
->Stencil
.TestTwoSide
;
1419 #if FEATURE_ARB_fragment_program
1420 case GL_FRAGMENT_PROGRAM_ARB
:
1421 return ctx
->FragmentProgram
.Enabled
;
1422 #endif /* FEATURE_ARB_fragment_program */
1424 /* GL_EXT_depth_bounds_test */
1425 case GL_DEPTH_BOUNDS_TEST_EXT
:
1426 CHECK_EXTENSION(EXT_depth_bounds_test
);
1427 return ctx
->Depth
.BoundsTest
;
1429 /* GL_ARB_depth_clamp */
1430 case GL_DEPTH_CLAMP
:
1431 CHECK_EXTENSION(ARB_depth_clamp
);
1432 return ctx
->Transform
.DepthClamp
;
1434 #if FEATURE_ATI_fragment_shader
1435 case GL_FRAGMENT_SHADER_ATI
:
1436 CHECK_EXTENSION(ATI_fragment_shader
);
1437 return ctx
->ATIFragmentShader
.Enabled
;
1438 #endif /* FEATURE_ATI_fragment_shader */
1440 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1441 CHECK_EXTENSION(ARB_seamless_cube_map
);
1442 return ctx
->Texture
.CubeMapSeamless
;
1444 #if FEATURE_EXT_transform_feedback
1445 case GL_RASTERIZER_DISCARD
:
1446 CHECK_EXTENSION(EXT_transform_feedback
);
1447 return ctx
->TransformFeedback
.RasterDiscard
;
1450 /* GL_NV_primitive_restart */
1451 case GL_PRIMITIVE_RESTART_NV
:
1452 if (!ctx
->Extensions
.NV_primitive_restart
) {
1453 goto invalid_enum_error
;
1455 return ctx
->Array
.PrimitiveRestart
;
1457 /* GL 3.1 primitive restart */
1458 case GL_PRIMITIVE_RESTART
:
1459 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1460 goto invalid_enum_error
;
1462 return ctx
->Array
.PrimitiveRestart
;
1464 /* GL3.0 - GL_framebuffer_sRGB */
1465 case GL_FRAMEBUFFER_SRGB_EXT
:
1466 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1467 return ctx
->Color
.sRGBEnabled
;
1470 goto invalid_enum_error
;
1476 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);