3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * 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
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
66 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
67 flag
= VERT_BIT_NORMAL
;
70 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
71 flag
= VERT_BIT_COLOR0
;
74 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
75 flag
= VERT_BIT_COLOR_INDEX
;
77 case GL_TEXTURE_COORD_ARRAY
:
78 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
79 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
81 case GL_EDGE_FLAG_ARRAY
:
82 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
83 flag
= VERT_BIT_EDGEFLAG
;
85 case GL_FOG_COORDINATE_ARRAY_EXT
:
86 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
89 case GL_SECONDARY_COLOR_ARRAY_EXT
:
90 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
91 flag
= VERT_BIT_COLOR1
;
94 #if FEATURE_point_size_array
95 case GL_POINT_SIZE_ARRAY_OES
:
96 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
97 flag
= VERT_BIT_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(VERT_ATTRIB_GENERIC(n
) < Elements(arrayObj
->VertexAttrib
));
122 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(n
)].Enabled
;
123 flag
= VERT_BIT_GENERIC(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
);
146 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
151 arrayObj
->_Enabled
|= flag
;
153 arrayObj
->_Enabled
&= ~flag
;
155 arrayObj
->NewArrays
|= flag
;
157 if (ctx
->Driver
.Enable
) {
158 ctx
->Driver
.Enable( ctx
, cap
, state
);
164 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
165 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(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 and return NULL if the active
218 * texture unit is higher than the number of supported coordinate units.
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
=
291 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
292 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
293 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
294 ctx
->Color
.BlendEnabled
= newEnabled
;
299 case GL_CLIP_DISTANCE0
:
300 case GL_CLIP_DISTANCE1
:
301 case GL_CLIP_DISTANCE2
:
302 case GL_CLIP_DISTANCE3
:
303 case GL_CLIP_DISTANCE4
:
304 case GL_CLIP_DISTANCE5
:
305 case GL_CLIP_DISTANCE6
:
306 case GL_CLIP_DISTANCE7
:
308 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
310 if (p
>= ctx
->Const
.MaxClipPlanes
)
311 goto invalid_enum_error
;
313 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
314 == ((GLuint
) state
<< p
))
317 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
320 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
321 _mesa_update_clip_plane(ctx
, p
);
324 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
329 case GL_COLOR_MATERIAL
:
330 if (ctx
->Light
.ColorMaterialEnabled
== state
)
332 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
333 FLUSH_CURRENT(ctx
, 0);
334 ctx
->Light
.ColorMaterialEnabled
= state
;
336 _mesa_update_color_material( ctx
,
337 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
341 if (ctx
->Polygon
.CullFlag
== state
)
343 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
344 ctx
->Polygon
.CullFlag
= state
;
347 if (ctx
->Depth
.Test
== state
)
349 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
350 ctx
->Depth
.Test
= state
;
352 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
353 ctx
->Debug
.SyncOutput
= state
;
356 if (ctx
->Color
.DitherFlag
== state
)
358 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
359 ctx
->Color
.DitherFlag
= state
;
362 if (ctx
->Fog
.Enabled
== state
)
364 FLUSH_VERTICES(ctx
, _NEW_FOG
);
365 ctx
->Fog
.Enabled
= state
;
375 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
377 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
378 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
380 insert_at_tail(&ctx
->Light
.EnabledList
,
381 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
384 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
388 if (ctx
->Light
.Enabled
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
391 ctx
->Light
.Enabled
= state
;
392 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
393 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
395 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
398 if (ctx
->Line
.SmoothFlag
== state
)
400 FLUSH_VERTICES(ctx
, _NEW_LINE
);
401 ctx
->Line
.SmoothFlag
= state
;
402 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
404 case GL_LINE_STIPPLE
:
405 if (ctx
->Line
.StippleFlag
== state
)
407 FLUSH_VERTICES(ctx
, _NEW_LINE
);
408 ctx
->Line
.StippleFlag
= state
;
409 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
411 case GL_INDEX_LOGIC_OP
:
412 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
415 ctx
->Color
.IndexLogicOpEnabled
= state
;
417 case GL_COLOR_LOGIC_OP
:
418 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
421 ctx
->Color
.ColorLogicOpEnabled
= state
;
423 case GL_MAP1_COLOR_4
:
424 if (ctx
->Eval
.Map1Color4
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
427 ctx
->Eval
.Map1Color4
= state
;
430 if (ctx
->Eval
.Map1Index
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
433 ctx
->Eval
.Map1Index
= state
;
436 if (ctx
->Eval
.Map1Normal
== state
)
438 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
439 ctx
->Eval
.Map1Normal
= state
;
441 case GL_MAP1_TEXTURE_COORD_1
:
442 if (ctx
->Eval
.Map1TextureCoord1
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
445 ctx
->Eval
.Map1TextureCoord1
= state
;
447 case GL_MAP1_TEXTURE_COORD_2
:
448 if (ctx
->Eval
.Map1TextureCoord2
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
451 ctx
->Eval
.Map1TextureCoord2
= state
;
453 case GL_MAP1_TEXTURE_COORD_3
:
454 if (ctx
->Eval
.Map1TextureCoord3
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 ctx
->Eval
.Map1TextureCoord3
= state
;
459 case GL_MAP1_TEXTURE_COORD_4
:
460 if (ctx
->Eval
.Map1TextureCoord4
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map1TextureCoord4
= state
;
465 case GL_MAP1_VERTEX_3
:
466 if (ctx
->Eval
.Map1Vertex3
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map1Vertex3
= state
;
471 case GL_MAP1_VERTEX_4
:
472 if (ctx
->Eval
.Map1Vertex4
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map1Vertex4
= state
;
477 case GL_MAP2_COLOR_4
:
478 if (ctx
->Eval
.Map2Color4
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map2Color4
= state
;
484 if (ctx
->Eval
.Map2Index
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
487 ctx
->Eval
.Map2Index
= state
;
490 if (ctx
->Eval
.Map2Normal
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
493 ctx
->Eval
.Map2Normal
= state
;
495 case GL_MAP2_TEXTURE_COORD_1
:
496 if (ctx
->Eval
.Map2TextureCoord1
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map2TextureCoord1
= state
;
501 case GL_MAP2_TEXTURE_COORD_2
:
502 if (ctx
->Eval
.Map2TextureCoord2
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
505 ctx
->Eval
.Map2TextureCoord2
= state
;
507 case GL_MAP2_TEXTURE_COORD_3
:
508 if (ctx
->Eval
.Map2TextureCoord3
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
511 ctx
->Eval
.Map2TextureCoord3
= state
;
513 case GL_MAP2_TEXTURE_COORD_4
:
514 if (ctx
->Eval
.Map2TextureCoord4
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
517 ctx
->Eval
.Map2TextureCoord4
= state
;
519 case GL_MAP2_VERTEX_3
:
520 if (ctx
->Eval
.Map2Vertex3
== state
)
522 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
523 ctx
->Eval
.Map2Vertex3
= state
;
525 case GL_MAP2_VERTEX_4
:
526 if (ctx
->Eval
.Map2Vertex4
== state
)
528 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
529 ctx
->Eval
.Map2Vertex4
= state
;
532 if (ctx
->Transform
.Normalize
== state
)
534 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
535 ctx
->Transform
.Normalize
= state
;
537 case GL_POINT_SMOOTH
:
538 if (ctx
->Point
.SmoothFlag
== state
)
540 FLUSH_VERTICES(ctx
, _NEW_POINT
);
541 ctx
->Point
.SmoothFlag
= state
;
542 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
544 case GL_POLYGON_SMOOTH
:
545 if (ctx
->Polygon
.SmoothFlag
== state
)
547 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
548 ctx
->Polygon
.SmoothFlag
= state
;
549 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
551 case GL_POLYGON_STIPPLE
:
552 if (ctx
->Polygon
.StippleFlag
== state
)
554 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
555 ctx
->Polygon
.StippleFlag
= state
;
556 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
558 case GL_POLYGON_OFFSET_POINT
:
559 if (ctx
->Polygon
.OffsetPoint
== state
)
561 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
562 ctx
->Polygon
.OffsetPoint
= state
;
564 case GL_POLYGON_OFFSET_LINE
:
565 if (ctx
->Polygon
.OffsetLine
== state
)
567 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
568 ctx
->Polygon
.OffsetLine
= state
;
570 case GL_POLYGON_OFFSET_FILL
:
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_STENCIL_TEST
:
589 if (ctx
->Stencil
.Enabled
== state
)
591 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
592 ctx
->Stencil
.Enabled
= state
;
595 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
600 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
605 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
609 case GL_TEXTURE_GEN_S
:
610 case GL_TEXTURE_GEN_T
:
611 case GL_TEXTURE_GEN_R
:
612 case GL_TEXTURE_GEN_Q
:
614 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
616 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
617 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
619 newenabled
|= coordBit
;
620 if (texUnit
->TexGenEnabled
== newenabled
)
622 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
623 texUnit
->TexGenEnabled
= newenabled
;
629 case GL_TEXTURE_GEN_STR_OES
:
630 /* disable S, T, and R at the same time */
632 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
635 texUnit
->TexGenEnabled
& ~STR_BITS
;
637 newenabled
|= STR_BITS
;
638 if (texUnit
->TexGenEnabled
== newenabled
)
640 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
641 texUnit
->TexGenEnabled
= newenabled
;
647 /* client-side state */
648 case GL_VERTEX_ARRAY
:
649 case GL_NORMAL_ARRAY
:
652 case GL_TEXTURE_COORD_ARRAY
:
653 case GL_EDGE_FLAG_ARRAY
:
654 case GL_FOG_COORDINATE_ARRAY_EXT
:
655 case GL_SECONDARY_COLOR_ARRAY_EXT
:
656 case GL_POINT_SIZE_ARRAY_OES
:
657 client_state( ctx
, cap
, state
);
660 /* GL_ARB_texture_cube_map */
661 case GL_TEXTURE_CUBE_MAP_ARB
:
662 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
663 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
668 /* GL_EXT_secondary_color */
669 case GL_COLOR_SUM_EXT
:
670 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
671 if (ctx
->Fog
.ColorSumEnabled
== state
)
673 FLUSH_VERTICES(ctx
, _NEW_FOG
);
674 ctx
->Fog
.ColorSumEnabled
= state
;
677 /* GL_ARB_multisample */
678 case GL_MULTISAMPLE_ARB
:
679 if (ctx
->Multisample
.Enabled
== state
)
681 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
682 ctx
->Multisample
.Enabled
= state
;
684 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
685 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
687 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
688 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
690 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
691 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
693 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
694 ctx
->Multisample
.SampleAlphaToOne
= state
;
696 case GL_SAMPLE_COVERAGE_ARB
:
697 if (ctx
->Multisample
.SampleCoverage
== state
)
699 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
700 ctx
->Multisample
.SampleCoverage
= state
;
702 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
703 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
705 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
706 ctx
->Multisample
.SampleCoverageInvert
= state
;
709 /* GL_IBM_rasterpos_clip */
710 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
711 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
712 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
714 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
715 ctx
->Transform
.RasterPositionUnclipped
= state
;
718 /* GL_NV_point_sprite */
719 case GL_POINT_SPRITE_NV
:
720 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
721 if (ctx
->Point
.PointSprite
== state
)
723 FLUSH_VERTICES(ctx
, _NEW_POINT
);
724 ctx
->Point
.PointSprite
= state
;
727 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
728 case GL_VERTEX_PROGRAM_ARB
:
729 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
730 if (ctx
->VertexProgram
.Enabled
== state
)
732 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
733 ctx
->VertexProgram
.Enabled
= state
;
735 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
736 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
737 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
739 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
740 ctx
->VertexProgram
.PointSizeEnabled
= state
;
742 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
743 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
744 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
746 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
747 ctx
->VertexProgram
.TwoSideEnabled
= state
;
750 #if FEATURE_NV_vertex_program
751 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
752 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
753 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
754 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
755 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
756 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
757 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
758 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
759 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
760 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
761 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
762 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
763 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
764 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
765 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
766 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
767 CHECK_EXTENSION(NV_vertex_program
, cap
);
769 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
770 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
771 ctx
->Eval
.Map1Attrib
[map
] = state
;
774 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
775 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
776 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
777 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
778 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
779 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
780 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
781 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
782 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
783 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
784 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
785 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
786 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
787 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
788 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
789 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
790 CHECK_EXTENSION(NV_vertex_program
, cap
);
792 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
793 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
794 ctx
->Eval
.Map2Attrib
[map
] = state
;
797 #endif /* FEATURE_NV_vertex_program */
799 #if FEATURE_NV_fragment_program
800 case GL_FRAGMENT_PROGRAM_NV
:
801 CHECK_EXTENSION(NV_fragment_program
, cap
);
802 if (ctx
->FragmentProgram
.Enabled
== state
)
804 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
805 ctx
->FragmentProgram
.Enabled
= state
;
807 #endif /* FEATURE_NV_fragment_program */
809 /* GL_NV_texture_rectangle */
810 case GL_TEXTURE_RECTANGLE_NV
:
811 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
812 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
817 /* GL_EXT_stencil_two_side */
818 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
819 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
820 if (ctx
->Stencil
.TestTwoSide
== state
)
822 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
823 ctx
->Stencil
.TestTwoSide
= state
;
825 ctx
->Stencil
._BackFace
= 2;
827 ctx
->Stencil
._BackFace
= 1;
831 #if FEATURE_ARB_fragment_program
832 case GL_FRAGMENT_PROGRAM_ARB
:
833 CHECK_EXTENSION(ARB_fragment_program
, cap
);
834 if (ctx
->FragmentProgram
.Enabled
== state
)
836 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
837 ctx
->FragmentProgram
.Enabled
= state
;
839 #endif /* FEATURE_ARB_fragment_program */
841 /* GL_EXT_depth_bounds_test */
842 case GL_DEPTH_BOUNDS_TEST_EXT
:
843 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
844 if (ctx
->Depth
.BoundsTest
== state
)
846 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
847 ctx
->Depth
.BoundsTest
= state
;
851 if (ctx
->Transform
.DepthClamp
== state
)
853 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
854 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
855 ctx
->Transform
.DepthClamp
= state
;
858 #if FEATURE_ATI_fragment_shader
859 case GL_FRAGMENT_SHADER_ATI
:
860 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
861 if (ctx
->ATIFragmentShader
.Enabled
== state
)
863 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
864 ctx
->ATIFragmentShader
.Enabled
= state
;
868 /* GL_MESA_texture_array */
869 case GL_TEXTURE_1D_ARRAY_EXT
:
870 CHECK_EXTENSION(MESA_texture_array
, cap
);
871 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
876 case GL_TEXTURE_2D_ARRAY_EXT
:
877 CHECK_EXTENSION(MESA_texture_array
, cap
);
878 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
883 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
884 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
885 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
886 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
887 ctx
->Texture
.CubeMapSeamless
= state
;
891 #if FEATURE_EXT_transform_feedback
892 case GL_RASTERIZER_DISCARD
:
893 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
894 if (ctx
->RasterDiscard
!= state
) {
895 FLUSH_VERTICES(ctx
, _NEW_RASTERIZER_DISCARD
);
896 ctx
->RasterDiscard
= state
;
901 /* GL 3.1 primitive restart. Note: this enum is different from
902 * GL_PRIMITIVE_RESTART_NV (which is client state).
904 case GL_PRIMITIVE_RESTART
:
905 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
906 goto invalid_enum_error
;
908 if (ctx
->Array
.PrimitiveRestart
!= state
) {
909 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
910 ctx
->Array
.PrimitiveRestart
= state
;
914 /* GL3.0 - GL_framebuffer_sRGB */
915 case GL_FRAMEBUFFER_SRGB_EXT
:
916 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
917 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
918 ctx
->Color
.sRGBEnabled
= state
;
921 /* GL_OES_EGL_image_external */
922 case GL_TEXTURE_EXTERNAL_OES
:
923 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
924 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
930 goto invalid_enum_error
;
933 if (ctx
->Driver
.Enable
) {
934 ctx
->Driver
.Enable( ctx
, cap
, state
);
940 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
941 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
946 * Enable GL capability. Called by glEnable()
947 * \param cap state to enable.
950 _mesa_Enable( GLenum cap
)
952 GET_CURRENT_CONTEXT(ctx
);
953 ASSERT_OUTSIDE_BEGIN_END(ctx
);
955 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
960 * Disable GL capability. Called by glDisable()
961 * \param cap state to disable.
964 _mesa_Disable( GLenum cap
)
966 GET_CURRENT_CONTEXT(ctx
);
967 ASSERT_OUTSIDE_BEGIN_END(ctx
);
969 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
975 * Enable/disable an indexed state var.
978 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
979 GLuint index
, GLboolean state
)
981 ASSERT(state
== 0 || state
== 1);
984 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
985 goto invalid_enum_error
;
987 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
988 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
989 state
? "glEnableIndexed" : "glDisableIndexed", index
);
992 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
993 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
995 ctx
->Color
.BlendEnabled
|= (1 << index
);
997 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1001 goto invalid_enum_error
;
1006 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1007 state
? "glEnablei" : "glDisablei",
1008 _mesa_lookup_enum_by_nr(cap
));
1013 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1015 GET_CURRENT_CONTEXT(ctx
);
1016 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1017 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1022 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1024 GET_CURRENT_CONTEXT(ctx
);
1025 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1026 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1030 GLboolean GLAPIENTRY
1031 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1033 GET_CURRENT_CONTEXT(ctx
);
1034 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1037 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1038 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1042 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1044 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1045 _mesa_lookup_enum_by_nr(cap
));
1053 #undef CHECK_EXTENSION
1054 #define CHECK_EXTENSION(EXTNAME) \
1055 if (!ctx->Extensions.EXTNAME) { \
1056 goto invalid_enum_error; \
1059 #undef CHECK_EXTENSION2
1060 #define CHECK_EXTENSION2(EXT1, EXT2) \
1061 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1062 goto invalid_enum_error; \
1067 * Helper function to determine whether a texture target is enabled.
1070 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1072 const struct gl_texture_unit
*const texUnit
=
1073 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1074 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1079 * Return simple enable/disable state.
1081 * \param cap state variable to query.
1083 * Returns the state of the specified capability from the current GL context.
1084 * For the capabilities associated with extensions verifies that those
1085 * extensions are effectively present before reporting.
1087 GLboolean GLAPIENTRY
1088 _mesa_IsEnabled( GLenum cap
)
1090 GET_CURRENT_CONTEXT(ctx
);
1091 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1095 return ctx
->Color
.AlphaEnabled
;
1096 case GL_AUTO_NORMAL
:
1097 return ctx
->Eval
.AutoNormal
;
1099 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1100 case GL_CLIP_DISTANCE0
:
1101 case GL_CLIP_DISTANCE1
:
1102 case GL_CLIP_DISTANCE2
:
1103 case GL_CLIP_DISTANCE3
:
1104 case GL_CLIP_DISTANCE4
:
1105 case GL_CLIP_DISTANCE5
:
1106 case GL_CLIP_DISTANCE6
:
1107 case GL_CLIP_DISTANCE7
: {
1108 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1110 if (p
>= ctx
->Const
.MaxClipPlanes
)
1111 goto invalid_enum_error
;
1113 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1115 case GL_COLOR_MATERIAL
:
1116 return ctx
->Light
.ColorMaterialEnabled
;
1118 return ctx
->Polygon
.CullFlag
;
1119 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1120 return ctx
->Debug
.SyncOutput
;
1122 return ctx
->Depth
.Test
;
1124 return ctx
->Color
.DitherFlag
;
1126 return ctx
->Fog
.Enabled
;
1128 return ctx
->Light
.Enabled
;
1137 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1138 case GL_LINE_SMOOTH
:
1139 return ctx
->Line
.SmoothFlag
;
1140 case GL_LINE_STIPPLE
:
1141 return ctx
->Line
.StippleFlag
;
1142 case GL_INDEX_LOGIC_OP
:
1143 return ctx
->Color
.IndexLogicOpEnabled
;
1144 case GL_COLOR_LOGIC_OP
:
1145 return ctx
->Color
.ColorLogicOpEnabled
;
1146 case GL_MAP1_COLOR_4
:
1147 return ctx
->Eval
.Map1Color4
;
1149 return ctx
->Eval
.Map1Index
;
1150 case GL_MAP1_NORMAL
:
1151 return ctx
->Eval
.Map1Normal
;
1152 case GL_MAP1_TEXTURE_COORD_1
:
1153 return ctx
->Eval
.Map1TextureCoord1
;
1154 case GL_MAP1_TEXTURE_COORD_2
:
1155 return ctx
->Eval
.Map1TextureCoord2
;
1156 case GL_MAP1_TEXTURE_COORD_3
:
1157 return ctx
->Eval
.Map1TextureCoord3
;
1158 case GL_MAP1_TEXTURE_COORD_4
:
1159 return ctx
->Eval
.Map1TextureCoord4
;
1160 case GL_MAP1_VERTEX_3
:
1161 return ctx
->Eval
.Map1Vertex3
;
1162 case GL_MAP1_VERTEX_4
:
1163 return ctx
->Eval
.Map1Vertex4
;
1164 case GL_MAP2_COLOR_4
:
1165 return ctx
->Eval
.Map2Color4
;
1167 return ctx
->Eval
.Map2Index
;
1168 case GL_MAP2_NORMAL
:
1169 return ctx
->Eval
.Map2Normal
;
1170 case GL_MAP2_TEXTURE_COORD_1
:
1171 return ctx
->Eval
.Map2TextureCoord1
;
1172 case GL_MAP2_TEXTURE_COORD_2
:
1173 return ctx
->Eval
.Map2TextureCoord2
;
1174 case GL_MAP2_TEXTURE_COORD_3
:
1175 return ctx
->Eval
.Map2TextureCoord3
;
1176 case GL_MAP2_TEXTURE_COORD_4
:
1177 return ctx
->Eval
.Map2TextureCoord4
;
1178 case GL_MAP2_VERTEX_3
:
1179 return ctx
->Eval
.Map2Vertex3
;
1180 case GL_MAP2_VERTEX_4
:
1181 return ctx
->Eval
.Map2Vertex4
;
1183 return ctx
->Transform
.Normalize
;
1184 case GL_POINT_SMOOTH
:
1185 return ctx
->Point
.SmoothFlag
;
1186 case GL_POLYGON_SMOOTH
:
1187 return ctx
->Polygon
.SmoothFlag
;
1188 case GL_POLYGON_STIPPLE
:
1189 return ctx
->Polygon
.StippleFlag
;
1190 case GL_POLYGON_OFFSET_POINT
:
1191 return ctx
->Polygon
.OffsetPoint
;
1192 case GL_POLYGON_OFFSET_LINE
:
1193 return ctx
->Polygon
.OffsetLine
;
1194 case GL_POLYGON_OFFSET_FILL
:
1195 return ctx
->Polygon
.OffsetFill
;
1196 case GL_RESCALE_NORMAL_EXT
:
1197 return ctx
->Transform
.RescaleNormals
;
1198 case GL_SCISSOR_TEST
:
1199 return ctx
->Scissor
.Enabled
;
1200 case GL_STENCIL_TEST
:
1201 return ctx
->Stencil
.Enabled
;
1203 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1205 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1207 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1208 case GL_TEXTURE_GEN_S
:
1209 case GL_TEXTURE_GEN_T
:
1210 case GL_TEXTURE_GEN_R
:
1211 case GL_TEXTURE_GEN_Q
:
1213 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1215 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1216 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1221 case GL_TEXTURE_GEN_STR_OES
:
1223 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1225 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1226 ? GL_TRUE
: GL_FALSE
;
1231 /* client-side state */
1232 case GL_VERTEX_ARRAY
:
1233 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
!= 0);
1234 case GL_NORMAL_ARRAY
:
1235 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1236 case GL_COLOR_ARRAY
:
1237 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
!= 0);
1238 case GL_INDEX_ARRAY
:
1239 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1240 case GL_TEXTURE_COORD_ARRAY
:
1241 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1243 case GL_EDGE_FLAG_ARRAY
:
1244 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1245 case GL_FOG_COORDINATE_ARRAY_EXT
:
1246 CHECK_EXTENSION(EXT_fog_coord
);
1247 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1248 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1249 CHECK_EXTENSION(EXT_secondary_color
);
1250 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1251 #if FEATURE_point_size_array
1252 case GL_POINT_SIZE_ARRAY_OES
:
1253 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1256 /* GL_ARB_texture_cube_map */
1257 case GL_TEXTURE_CUBE_MAP_ARB
:
1258 CHECK_EXTENSION(ARB_texture_cube_map
);
1259 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1261 /* GL_EXT_secondary_color */
1262 case GL_COLOR_SUM_EXT
:
1263 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1264 return ctx
->Fog
.ColorSumEnabled
;
1266 /* GL_ARB_multisample */
1267 case GL_MULTISAMPLE_ARB
:
1268 return ctx
->Multisample
.Enabled
;
1269 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1270 return ctx
->Multisample
.SampleAlphaToCoverage
;
1271 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1272 return ctx
->Multisample
.SampleAlphaToOne
;
1273 case GL_SAMPLE_COVERAGE_ARB
:
1274 return ctx
->Multisample
.SampleCoverage
;
1275 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1276 return ctx
->Multisample
.SampleCoverageInvert
;
1278 /* GL_IBM_rasterpos_clip */
1279 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1280 CHECK_EXTENSION(IBM_rasterpos_clip
);
1281 return ctx
->Transform
.RasterPositionUnclipped
;
1283 /* GL_NV_point_sprite */
1284 case GL_POINT_SPRITE_NV
:
1285 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1286 return ctx
->Point
.PointSprite
;
1288 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1289 case GL_VERTEX_PROGRAM_ARB
:
1290 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1291 return ctx
->VertexProgram
.Enabled
;
1292 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1293 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1294 return ctx
->VertexProgram
.PointSizeEnabled
;
1295 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1296 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1297 return ctx
->VertexProgram
.TwoSideEnabled
;
1299 #if FEATURE_NV_vertex_program
1300 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1301 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1302 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1303 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1304 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1305 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1306 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1307 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1308 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1309 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1310 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1311 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1312 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1313 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1314 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1315 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1316 CHECK_EXTENSION(NV_vertex_program
);
1318 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1319 ASSERT(VERT_ATTRIB_GENERIC(n
) < Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1320 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(n
)].Enabled
!= 0);
1322 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1323 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1324 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1325 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1326 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1327 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1328 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1329 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1330 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1331 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1332 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1333 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1334 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1335 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1336 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1337 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1338 CHECK_EXTENSION(NV_vertex_program
);
1340 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1341 return ctx
->Eval
.Map1Attrib
[map
];
1343 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1344 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1345 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1346 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1347 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1348 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1349 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1350 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1351 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1352 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1353 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1354 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1355 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1356 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1357 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1358 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1359 CHECK_EXTENSION(NV_vertex_program
);
1361 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1362 return ctx
->Eval
.Map2Attrib
[map
];
1364 #endif /* FEATURE_NV_vertex_program */
1366 #if FEATURE_NV_fragment_program
1367 case GL_FRAGMENT_PROGRAM_NV
:
1368 CHECK_EXTENSION(NV_fragment_program
);
1369 return ctx
->FragmentProgram
.Enabled
;
1370 #endif /* FEATURE_NV_fragment_program */
1372 /* GL_NV_texture_rectangle */
1373 case GL_TEXTURE_RECTANGLE_NV
:
1374 CHECK_EXTENSION(NV_texture_rectangle
);
1375 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1377 /* GL_EXT_stencil_two_side */
1378 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1379 CHECK_EXTENSION(EXT_stencil_two_side
);
1380 return ctx
->Stencil
.TestTwoSide
;
1382 #if FEATURE_ARB_fragment_program
1383 case GL_FRAGMENT_PROGRAM_ARB
:
1384 return ctx
->FragmentProgram
.Enabled
;
1385 #endif /* FEATURE_ARB_fragment_program */
1387 /* GL_EXT_depth_bounds_test */
1388 case GL_DEPTH_BOUNDS_TEST_EXT
:
1389 CHECK_EXTENSION(EXT_depth_bounds_test
);
1390 return ctx
->Depth
.BoundsTest
;
1392 /* GL_ARB_depth_clamp */
1393 case GL_DEPTH_CLAMP
:
1394 CHECK_EXTENSION(ARB_depth_clamp
);
1395 return ctx
->Transform
.DepthClamp
;
1397 #if FEATURE_ATI_fragment_shader
1398 case GL_FRAGMENT_SHADER_ATI
:
1399 CHECK_EXTENSION(ATI_fragment_shader
);
1400 return ctx
->ATIFragmentShader
.Enabled
;
1401 #endif /* FEATURE_ATI_fragment_shader */
1403 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1404 CHECK_EXTENSION(ARB_seamless_cube_map
);
1405 return ctx
->Texture
.CubeMapSeamless
;
1407 #if FEATURE_EXT_transform_feedback
1408 case GL_RASTERIZER_DISCARD
:
1409 CHECK_EXTENSION(EXT_transform_feedback
);
1410 return ctx
->RasterDiscard
;
1413 /* GL_NV_primitive_restart */
1414 case GL_PRIMITIVE_RESTART_NV
:
1415 if (!ctx
->Extensions
.NV_primitive_restart
) {
1416 goto invalid_enum_error
;
1418 return ctx
->Array
.PrimitiveRestart
;
1420 /* GL 3.1 primitive restart */
1421 case GL_PRIMITIVE_RESTART
:
1422 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1423 goto invalid_enum_error
;
1425 return ctx
->Array
.PrimitiveRestart
;
1427 /* GL3.0 - GL_framebuffer_sRGB */
1428 case GL_FRAMEBUFFER_SRGB_EXT
:
1429 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1430 return ctx
->Color
.sRGBEnabled
;
1432 /* GL_OES_EGL_image_external */
1433 case GL_TEXTURE_EXTERNAL_OES
:
1434 CHECK_EXTENSION(OES_EGL_image_external
);
1435 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1438 goto invalid_enum_error
;
1444 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1445 _mesa_lookup_enum_by_nr(cap
));