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
->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 and return NULL if the active
217 * texture unit is higher than the number of supported coordinate units.
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
=
290 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
291 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
292 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
293 ctx
->Color
.BlendEnabled
= newEnabled
;
298 case GL_CLIP_DISTANCE0
:
299 case GL_CLIP_DISTANCE1
:
300 case GL_CLIP_DISTANCE2
:
301 case GL_CLIP_DISTANCE3
:
302 case GL_CLIP_DISTANCE4
:
303 case GL_CLIP_DISTANCE5
:
304 case GL_CLIP_DISTANCE6
:
305 case GL_CLIP_DISTANCE7
:
307 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
309 if (p
>= ctx
->Const
.MaxClipPlanes
)
310 goto invalid_enum_error
;
312 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
313 == ((GLuint
) state
<< p
))
316 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
319 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
320 _mesa_update_clip_plane(ctx
, p
);
323 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
328 case GL_COLOR_MATERIAL
:
329 if (ctx
->Light
.ColorMaterialEnabled
== state
)
331 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
332 FLUSH_CURRENT(ctx
, 0);
333 ctx
->Light
.ColorMaterialEnabled
= state
;
335 _mesa_update_color_material( ctx
,
336 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
340 if (ctx
->Polygon
.CullFlag
== state
)
342 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
343 ctx
->Polygon
.CullFlag
= state
;
346 if (ctx
->Depth
.Test
== state
)
348 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
349 ctx
->Depth
.Test
= state
;
352 if (ctx
->Color
.DitherFlag
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
355 ctx
->Color
.DitherFlag
= state
;
358 if (ctx
->Fog
.Enabled
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_FOG
);
361 ctx
->Fog
.Enabled
= state
;
371 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
373 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
374 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
376 insert_at_tail(&ctx
->Light
.EnabledList
,
377 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
380 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
384 if (ctx
->Light
.Enabled
== state
)
386 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
387 ctx
->Light
.Enabled
= state
;
388 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
389 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
391 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
394 if (ctx
->Line
.SmoothFlag
== state
)
396 FLUSH_VERTICES(ctx
, _NEW_LINE
);
397 ctx
->Line
.SmoothFlag
= state
;
398 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
400 case GL_LINE_STIPPLE
:
401 if (ctx
->Line
.StippleFlag
== state
)
403 FLUSH_VERTICES(ctx
, _NEW_LINE
);
404 ctx
->Line
.StippleFlag
= state
;
405 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
407 case GL_INDEX_LOGIC_OP
:
408 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
410 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
411 ctx
->Color
.IndexLogicOpEnabled
= state
;
413 case GL_COLOR_LOGIC_OP
:
414 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
416 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
417 ctx
->Color
.ColorLogicOpEnabled
= state
;
419 case GL_MAP1_COLOR_4
:
420 if (ctx
->Eval
.Map1Color4
== state
)
422 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
423 ctx
->Eval
.Map1Color4
= state
;
426 if (ctx
->Eval
.Map1Index
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
429 ctx
->Eval
.Map1Index
= state
;
432 if (ctx
->Eval
.Map1Normal
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
435 ctx
->Eval
.Map1Normal
= state
;
437 case GL_MAP1_TEXTURE_COORD_1
:
438 if (ctx
->Eval
.Map1TextureCoord1
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
441 ctx
->Eval
.Map1TextureCoord1
= state
;
443 case GL_MAP1_TEXTURE_COORD_2
:
444 if (ctx
->Eval
.Map1TextureCoord2
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
447 ctx
->Eval
.Map1TextureCoord2
= state
;
449 case GL_MAP1_TEXTURE_COORD_3
:
450 if (ctx
->Eval
.Map1TextureCoord3
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map1TextureCoord3
= state
;
455 case GL_MAP1_TEXTURE_COORD_4
:
456 if (ctx
->Eval
.Map1TextureCoord4
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map1TextureCoord4
= state
;
461 case GL_MAP1_VERTEX_3
:
462 if (ctx
->Eval
.Map1Vertex3
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map1Vertex3
= state
;
467 case GL_MAP1_VERTEX_4
:
468 if (ctx
->Eval
.Map1Vertex4
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map1Vertex4
= state
;
473 case GL_MAP2_COLOR_4
:
474 if (ctx
->Eval
.Map2Color4
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map2Color4
= state
;
480 if (ctx
->Eval
.Map2Index
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map2Index
= state
;
486 if (ctx
->Eval
.Map2Normal
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map2Normal
= state
;
491 case GL_MAP2_TEXTURE_COORD_1
:
492 if (ctx
->Eval
.Map2TextureCoord1
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map2TextureCoord1
= state
;
497 case GL_MAP2_TEXTURE_COORD_2
:
498 if (ctx
->Eval
.Map2TextureCoord2
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
501 ctx
->Eval
.Map2TextureCoord2
= state
;
503 case GL_MAP2_TEXTURE_COORD_3
:
504 if (ctx
->Eval
.Map2TextureCoord3
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map2TextureCoord3
= state
;
509 case GL_MAP2_TEXTURE_COORD_4
:
510 if (ctx
->Eval
.Map2TextureCoord4
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map2TextureCoord4
= state
;
515 case GL_MAP2_VERTEX_3
:
516 if (ctx
->Eval
.Map2Vertex3
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map2Vertex3
= state
;
521 case GL_MAP2_VERTEX_4
:
522 if (ctx
->Eval
.Map2Vertex4
== state
)
524 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
525 ctx
->Eval
.Map2Vertex4
= state
;
528 if (ctx
->Transform
.Normalize
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
531 ctx
->Transform
.Normalize
= state
;
533 case GL_POINT_SMOOTH
:
534 if (ctx
->Point
.SmoothFlag
== state
)
536 FLUSH_VERTICES(ctx
, _NEW_POINT
);
537 ctx
->Point
.SmoothFlag
= state
;
538 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
540 case GL_POLYGON_SMOOTH
:
541 if (ctx
->Polygon
.SmoothFlag
== state
)
543 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
544 ctx
->Polygon
.SmoothFlag
= state
;
545 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
547 case GL_POLYGON_STIPPLE
:
548 if (ctx
->Polygon
.StippleFlag
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
551 ctx
->Polygon
.StippleFlag
= state
;
552 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
554 case GL_POLYGON_OFFSET_POINT
:
555 if (ctx
->Polygon
.OffsetPoint
== state
)
557 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
558 ctx
->Polygon
.OffsetPoint
= state
;
560 case GL_POLYGON_OFFSET_LINE
:
561 if (ctx
->Polygon
.OffsetLine
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
564 ctx
->Polygon
.OffsetLine
= state
;
566 case GL_POLYGON_OFFSET_FILL
:
567 if (ctx
->Polygon
.OffsetFill
== state
)
569 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
570 ctx
->Polygon
.OffsetFill
= state
;
572 case GL_RESCALE_NORMAL_EXT
:
573 if (ctx
->Transform
.RescaleNormals
== state
)
575 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
576 ctx
->Transform
.RescaleNormals
= state
;
578 case GL_SCISSOR_TEST
:
579 if (ctx
->Scissor
.Enabled
== state
)
581 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
582 ctx
->Scissor
.Enabled
= state
;
584 case GL_STENCIL_TEST
:
585 if (ctx
->Stencil
.Enabled
== state
)
587 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
588 ctx
->Stencil
.Enabled
= state
;
591 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
596 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
601 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
605 case GL_TEXTURE_GEN_S
:
606 case GL_TEXTURE_GEN_T
:
607 case GL_TEXTURE_GEN_R
:
608 case GL_TEXTURE_GEN_Q
:
610 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
612 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
613 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
615 newenabled
|= coordBit
;
616 if (texUnit
->TexGenEnabled
== newenabled
)
618 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
619 texUnit
->TexGenEnabled
= newenabled
;
625 case GL_TEXTURE_GEN_STR_OES
:
626 /* disable S, T, and R at the same time */
628 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
631 texUnit
->TexGenEnabled
& ~STR_BITS
;
633 newenabled
|= STR_BITS
;
634 if (texUnit
->TexGenEnabled
== newenabled
)
636 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
637 texUnit
->TexGenEnabled
= newenabled
;
643 /* client-side state */
644 case GL_VERTEX_ARRAY
:
645 case GL_NORMAL_ARRAY
:
648 case GL_TEXTURE_COORD_ARRAY
:
649 case GL_EDGE_FLAG_ARRAY
:
650 case GL_FOG_COORDINATE_ARRAY_EXT
:
651 case GL_SECONDARY_COLOR_ARRAY_EXT
:
652 case GL_POINT_SIZE_ARRAY_OES
:
653 client_state( ctx
, cap
, state
);
656 /* GL_ARB_texture_cube_map */
657 case GL_TEXTURE_CUBE_MAP_ARB
:
658 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
659 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
664 /* GL_EXT_secondary_color */
665 case GL_COLOR_SUM_EXT
:
666 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
667 if (ctx
->Fog
.ColorSumEnabled
== state
)
669 FLUSH_VERTICES(ctx
, _NEW_FOG
);
670 ctx
->Fog
.ColorSumEnabled
= state
;
673 /* GL_ARB_multisample */
674 case GL_MULTISAMPLE_ARB
:
675 if (ctx
->Multisample
.Enabled
== state
)
677 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
678 ctx
->Multisample
.Enabled
= state
;
680 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
681 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
683 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
684 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
686 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
687 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
689 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
690 ctx
->Multisample
.SampleAlphaToOne
= state
;
692 case GL_SAMPLE_COVERAGE_ARB
:
693 if (ctx
->Multisample
.SampleCoverage
== state
)
695 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
696 ctx
->Multisample
.SampleCoverage
= state
;
698 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
699 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
701 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
702 ctx
->Multisample
.SampleCoverageInvert
= state
;
705 /* GL_IBM_rasterpos_clip */
706 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
707 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
708 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
710 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
711 ctx
->Transform
.RasterPositionUnclipped
= state
;
714 /* GL_NV_point_sprite */
715 case GL_POINT_SPRITE_NV
:
716 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
717 if (ctx
->Point
.PointSprite
== state
)
719 FLUSH_VERTICES(ctx
, _NEW_POINT
);
720 ctx
->Point
.PointSprite
= state
;
723 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
724 case GL_VERTEX_PROGRAM_ARB
:
725 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
726 if (ctx
->VertexProgram
.Enabled
== state
)
728 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
729 ctx
->VertexProgram
.Enabled
= state
;
731 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
732 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
733 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
735 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
736 ctx
->VertexProgram
.PointSizeEnabled
= state
;
738 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
739 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
740 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
743 ctx
->VertexProgram
.TwoSideEnabled
= state
;
746 #if FEATURE_NV_vertex_program
747 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
748 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
749 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
750 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
751 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
752 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
753 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
754 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
755 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
756 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
757 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
758 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
759 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
760 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
761 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
762 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
763 CHECK_EXTENSION(NV_vertex_program
, cap
);
765 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
766 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
767 ctx
->Eval
.Map1Attrib
[map
] = state
;
770 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
771 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
772 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
773 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
774 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
775 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
776 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
777 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
778 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
779 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
780 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
781 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
782 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
783 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
784 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
785 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
786 CHECK_EXTENSION(NV_vertex_program
, cap
);
788 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
789 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
790 ctx
->Eval
.Map2Attrib
[map
] = state
;
793 #endif /* FEATURE_NV_vertex_program */
795 #if FEATURE_NV_fragment_program
796 case GL_FRAGMENT_PROGRAM_NV
:
797 CHECK_EXTENSION(NV_fragment_program
, cap
);
798 if (ctx
->FragmentProgram
.Enabled
== state
)
800 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
801 ctx
->FragmentProgram
.Enabled
= state
;
803 #endif /* FEATURE_NV_fragment_program */
805 /* GL_NV_texture_rectangle */
806 case GL_TEXTURE_RECTANGLE_NV
:
807 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
808 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
813 /* GL_EXT_stencil_two_side */
814 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
815 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
816 if (ctx
->Stencil
.TestTwoSide
== state
)
818 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
819 ctx
->Stencil
.TestTwoSide
= state
;
821 ctx
->Stencil
._BackFace
= 2;
822 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
824 ctx
->Stencil
._BackFace
= 1;
825 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
829 #if FEATURE_ARB_fragment_program
830 case GL_FRAGMENT_PROGRAM_ARB
:
831 CHECK_EXTENSION(ARB_fragment_program
, cap
);
832 if (ctx
->FragmentProgram
.Enabled
== state
)
834 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
835 ctx
->FragmentProgram
.Enabled
= state
;
837 #endif /* FEATURE_ARB_fragment_program */
839 /* GL_EXT_depth_bounds_test */
840 case GL_DEPTH_BOUNDS_TEST_EXT
:
841 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
842 if (ctx
->Depth
.BoundsTest
== state
)
844 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
845 ctx
->Depth
.BoundsTest
= state
;
849 if (ctx
->Transform
.DepthClamp
== state
)
851 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
852 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
853 ctx
->Transform
.DepthClamp
= state
;
856 #if FEATURE_ATI_fragment_shader
857 case GL_FRAGMENT_SHADER_ATI
:
858 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
859 if (ctx
->ATIFragmentShader
.Enabled
== state
)
861 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
862 ctx
->ATIFragmentShader
.Enabled
= state
;
866 /* GL_MESA_texture_array */
867 case GL_TEXTURE_1D_ARRAY_EXT
:
868 CHECK_EXTENSION(MESA_texture_array
, cap
);
869 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
874 case GL_TEXTURE_2D_ARRAY_EXT
:
875 CHECK_EXTENSION(MESA_texture_array
, cap
);
876 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
881 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
882 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
883 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
884 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
885 ctx
->Texture
.CubeMapSeamless
= state
;
889 #if FEATURE_EXT_transform_feedback
890 case GL_RASTERIZER_DISCARD
:
891 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
892 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
893 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
894 ctx
->TransformFeedback
.RasterDiscard
= state
;
899 /* GL 3.1 primitive restart. Note: this enum is different from
900 * GL_PRIMITIVE_RESTART_NV (which is client state).
902 case GL_PRIMITIVE_RESTART
:
903 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
904 goto invalid_enum_error
;
906 if (ctx
->Array
.PrimitiveRestart
!= state
) {
907 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
908 ctx
->Array
.PrimitiveRestart
= state
;
912 /* GL3.0 - GL_framebuffer_sRGB */
913 case GL_FRAMEBUFFER_SRGB_EXT
:
914 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
915 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
916 ctx
->Color
.sRGBEnabled
= state
;
920 goto invalid_enum_error
;
923 if (ctx
->Driver
.Enable
) {
924 ctx
->Driver
.Enable( ctx
, cap
, state
);
930 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
931 state
? "Enable" : "Disable", cap
);
936 * Enable GL capability. Called by glEnable()
937 * \param cap state to enable.
940 _mesa_Enable( GLenum cap
)
942 GET_CURRENT_CONTEXT(ctx
);
943 ASSERT_OUTSIDE_BEGIN_END(ctx
);
945 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
950 * Disable GL capability. Called by glDisable()
951 * \param cap state to disable.
954 _mesa_Disable( GLenum cap
)
956 GET_CURRENT_CONTEXT(ctx
);
957 ASSERT_OUTSIDE_BEGIN_END(ctx
);
959 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
965 * Enable/disable an indexed state var.
968 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
969 GLuint index
, GLboolean state
)
971 ASSERT(state
== 0 || state
== 1);
974 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
975 goto invalid_enum_error
;
977 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
978 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
979 state
? "glEnableIndexed" : "glDisableIndexed", index
);
982 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
983 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
985 ctx
->Color
.BlendEnabled
|= (1 << index
);
987 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
991 goto invalid_enum_error
;
996 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
997 state
? "glEnablei" : "glDisablei",
998 _mesa_lookup_enum_by_nr(cap
));
1003 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1005 GET_CURRENT_CONTEXT(ctx
);
1006 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1007 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1012 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1014 GET_CURRENT_CONTEXT(ctx
);
1015 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1016 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1020 GLboolean GLAPIENTRY
1021 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1023 GET_CURRENT_CONTEXT(ctx
);
1024 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1027 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1028 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1032 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1034 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1035 _mesa_lookup_enum_by_nr(cap
));
1043 #undef CHECK_EXTENSION
1044 #define CHECK_EXTENSION(EXTNAME) \
1045 if (!ctx->Extensions.EXTNAME) { \
1046 goto invalid_enum_error; \
1049 #undef CHECK_EXTENSION2
1050 #define CHECK_EXTENSION2(EXT1, EXT2) \
1051 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1052 goto invalid_enum_error; \
1057 * Helper function to determine whether a texture target is enabled.
1060 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1062 const struct gl_texture_unit
*const texUnit
=
1063 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1064 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1069 * Return simple enable/disable state.
1071 * \param cap state variable to query.
1073 * Returns the state of the specified capability from the current GL context.
1074 * For the capabilities associated with extensions verifies that those
1075 * extensions are effectively present before reporting.
1077 GLboolean GLAPIENTRY
1078 _mesa_IsEnabled( GLenum cap
)
1080 GET_CURRENT_CONTEXT(ctx
);
1081 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1085 return ctx
->Color
.AlphaEnabled
;
1086 case GL_AUTO_NORMAL
:
1087 return ctx
->Eval
.AutoNormal
;
1089 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1090 case GL_CLIP_DISTANCE0
:
1091 case GL_CLIP_DISTANCE1
:
1092 case GL_CLIP_DISTANCE2
:
1093 case GL_CLIP_DISTANCE3
:
1094 case GL_CLIP_DISTANCE4
:
1095 case GL_CLIP_DISTANCE5
:
1096 case GL_CLIP_DISTANCE6
:
1097 case GL_CLIP_DISTANCE7
: {
1098 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1100 if (p
>= ctx
->Const
.MaxClipPlanes
)
1101 goto invalid_enum_error
;
1103 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1105 case GL_COLOR_MATERIAL
:
1106 return ctx
->Light
.ColorMaterialEnabled
;
1108 return ctx
->Polygon
.CullFlag
;
1110 return ctx
->Depth
.Test
;
1112 return ctx
->Color
.DitherFlag
;
1114 return ctx
->Fog
.Enabled
;
1116 return ctx
->Light
.Enabled
;
1125 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1126 case GL_LINE_SMOOTH
:
1127 return ctx
->Line
.SmoothFlag
;
1128 case GL_LINE_STIPPLE
:
1129 return ctx
->Line
.StippleFlag
;
1130 case GL_INDEX_LOGIC_OP
:
1131 return ctx
->Color
.IndexLogicOpEnabled
;
1132 case GL_COLOR_LOGIC_OP
:
1133 return ctx
->Color
.ColorLogicOpEnabled
;
1134 case GL_MAP1_COLOR_4
:
1135 return ctx
->Eval
.Map1Color4
;
1137 return ctx
->Eval
.Map1Index
;
1138 case GL_MAP1_NORMAL
:
1139 return ctx
->Eval
.Map1Normal
;
1140 case GL_MAP1_TEXTURE_COORD_1
:
1141 return ctx
->Eval
.Map1TextureCoord1
;
1142 case GL_MAP1_TEXTURE_COORD_2
:
1143 return ctx
->Eval
.Map1TextureCoord2
;
1144 case GL_MAP1_TEXTURE_COORD_3
:
1145 return ctx
->Eval
.Map1TextureCoord3
;
1146 case GL_MAP1_TEXTURE_COORD_4
:
1147 return ctx
->Eval
.Map1TextureCoord4
;
1148 case GL_MAP1_VERTEX_3
:
1149 return ctx
->Eval
.Map1Vertex3
;
1150 case GL_MAP1_VERTEX_4
:
1151 return ctx
->Eval
.Map1Vertex4
;
1152 case GL_MAP2_COLOR_4
:
1153 return ctx
->Eval
.Map2Color4
;
1155 return ctx
->Eval
.Map2Index
;
1156 case GL_MAP2_NORMAL
:
1157 return ctx
->Eval
.Map2Normal
;
1158 case GL_MAP2_TEXTURE_COORD_1
:
1159 return ctx
->Eval
.Map2TextureCoord1
;
1160 case GL_MAP2_TEXTURE_COORD_2
:
1161 return ctx
->Eval
.Map2TextureCoord2
;
1162 case GL_MAP2_TEXTURE_COORD_3
:
1163 return ctx
->Eval
.Map2TextureCoord3
;
1164 case GL_MAP2_TEXTURE_COORD_4
:
1165 return ctx
->Eval
.Map2TextureCoord4
;
1166 case GL_MAP2_VERTEX_3
:
1167 return ctx
->Eval
.Map2Vertex3
;
1168 case GL_MAP2_VERTEX_4
:
1169 return ctx
->Eval
.Map2Vertex4
;
1171 return ctx
->Transform
.Normalize
;
1172 case GL_POINT_SMOOTH
:
1173 return ctx
->Point
.SmoothFlag
;
1174 case GL_POLYGON_SMOOTH
:
1175 return ctx
->Polygon
.SmoothFlag
;
1176 case GL_POLYGON_STIPPLE
:
1177 return ctx
->Polygon
.StippleFlag
;
1178 case GL_POLYGON_OFFSET_POINT
:
1179 return ctx
->Polygon
.OffsetPoint
;
1180 case GL_POLYGON_OFFSET_LINE
:
1181 return ctx
->Polygon
.OffsetLine
;
1182 case GL_POLYGON_OFFSET_FILL
:
1183 return ctx
->Polygon
.OffsetFill
;
1184 case GL_RESCALE_NORMAL_EXT
:
1185 return ctx
->Transform
.RescaleNormals
;
1186 case GL_SCISSOR_TEST
:
1187 return ctx
->Scissor
.Enabled
;
1188 case GL_STENCIL_TEST
:
1189 return ctx
->Stencil
.Enabled
;
1191 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1193 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1195 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1196 case GL_TEXTURE_GEN_S
:
1197 case GL_TEXTURE_GEN_T
:
1198 case GL_TEXTURE_GEN_R
:
1199 case GL_TEXTURE_GEN_Q
:
1201 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1203 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1204 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1209 case GL_TEXTURE_GEN_STR_OES
:
1211 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1213 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1214 ? GL_TRUE
: GL_FALSE
;
1219 /* client-side state */
1220 case GL_VERTEX_ARRAY
:
1221 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1222 case GL_NORMAL_ARRAY
:
1223 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1224 case GL_COLOR_ARRAY
:
1225 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1226 case GL_INDEX_ARRAY
:
1227 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1228 case GL_TEXTURE_COORD_ARRAY
:
1229 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
]
1231 case GL_EDGE_FLAG_ARRAY
:
1232 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1233 case GL_FOG_COORDINATE_ARRAY_EXT
:
1234 CHECK_EXTENSION(EXT_fog_coord
);
1235 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1236 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1237 CHECK_EXTENSION(EXT_secondary_color
);
1238 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1239 #if FEATURE_point_size_array
1240 case GL_POINT_SIZE_ARRAY_OES
:
1241 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1244 /* GL_ARB_texture_cube_map */
1245 case GL_TEXTURE_CUBE_MAP_ARB
:
1246 CHECK_EXTENSION(ARB_texture_cube_map
);
1247 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1249 /* GL_EXT_secondary_color */
1250 case GL_COLOR_SUM_EXT
:
1251 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1252 return ctx
->Fog
.ColorSumEnabled
;
1254 /* GL_ARB_multisample */
1255 case GL_MULTISAMPLE_ARB
:
1256 return ctx
->Multisample
.Enabled
;
1257 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1258 return ctx
->Multisample
.SampleAlphaToCoverage
;
1259 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1260 return ctx
->Multisample
.SampleAlphaToOne
;
1261 case GL_SAMPLE_COVERAGE_ARB
:
1262 return ctx
->Multisample
.SampleCoverage
;
1263 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1264 return ctx
->Multisample
.SampleCoverageInvert
;
1266 /* GL_IBM_rasterpos_clip */
1267 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1268 CHECK_EXTENSION(IBM_rasterpos_clip
);
1269 return ctx
->Transform
.RasterPositionUnclipped
;
1271 /* GL_NV_point_sprite */
1272 case GL_POINT_SPRITE_NV
:
1273 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1274 return ctx
->Point
.PointSprite
;
1276 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1277 case GL_VERTEX_PROGRAM_ARB
:
1278 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1279 return ctx
->VertexProgram
.Enabled
;
1280 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1281 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1282 return ctx
->VertexProgram
.PointSizeEnabled
;
1283 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1284 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1285 return ctx
->VertexProgram
.TwoSideEnabled
;
1287 #if FEATURE_NV_vertex_program
1288 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1289 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1290 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1291 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1292 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1293 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1294 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1295 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1296 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1297 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1298 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1299 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1300 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1301 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1302 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1303 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1304 CHECK_EXTENSION(NV_vertex_program
);
1306 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1307 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1308 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1310 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1311 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1312 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1313 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1314 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1315 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1316 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1317 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1318 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1319 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1320 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1321 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1322 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1323 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1324 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1325 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1326 CHECK_EXTENSION(NV_vertex_program
);
1328 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1329 return ctx
->Eval
.Map1Attrib
[map
];
1331 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1332 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1333 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1334 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1335 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1336 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1337 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1338 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1339 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1340 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1341 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1342 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1343 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1344 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1345 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1346 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1347 CHECK_EXTENSION(NV_vertex_program
);
1349 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1350 return ctx
->Eval
.Map2Attrib
[map
];
1352 #endif /* FEATURE_NV_vertex_program */
1354 #if FEATURE_NV_fragment_program
1355 case GL_FRAGMENT_PROGRAM_NV
:
1356 CHECK_EXTENSION(NV_fragment_program
);
1357 return ctx
->FragmentProgram
.Enabled
;
1358 #endif /* FEATURE_NV_fragment_program */
1360 /* GL_NV_texture_rectangle */
1361 case GL_TEXTURE_RECTANGLE_NV
:
1362 CHECK_EXTENSION(NV_texture_rectangle
);
1363 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1365 /* GL_EXT_stencil_two_side */
1366 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1367 CHECK_EXTENSION(EXT_stencil_two_side
);
1368 return ctx
->Stencil
.TestTwoSide
;
1370 #if FEATURE_ARB_fragment_program
1371 case GL_FRAGMENT_PROGRAM_ARB
:
1372 return ctx
->FragmentProgram
.Enabled
;
1373 #endif /* FEATURE_ARB_fragment_program */
1375 /* GL_EXT_depth_bounds_test */
1376 case GL_DEPTH_BOUNDS_TEST_EXT
:
1377 CHECK_EXTENSION(EXT_depth_bounds_test
);
1378 return ctx
->Depth
.BoundsTest
;
1380 /* GL_ARB_depth_clamp */
1381 case GL_DEPTH_CLAMP
:
1382 CHECK_EXTENSION(ARB_depth_clamp
);
1383 return ctx
->Transform
.DepthClamp
;
1385 #if FEATURE_ATI_fragment_shader
1386 case GL_FRAGMENT_SHADER_ATI
:
1387 CHECK_EXTENSION(ATI_fragment_shader
);
1388 return ctx
->ATIFragmentShader
.Enabled
;
1389 #endif /* FEATURE_ATI_fragment_shader */
1391 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1392 CHECK_EXTENSION(ARB_seamless_cube_map
);
1393 return ctx
->Texture
.CubeMapSeamless
;
1395 #if FEATURE_EXT_transform_feedback
1396 case GL_RASTERIZER_DISCARD
:
1397 CHECK_EXTENSION(EXT_transform_feedback
);
1398 return ctx
->TransformFeedback
.RasterDiscard
;
1401 /* GL_NV_primitive_restart */
1402 case GL_PRIMITIVE_RESTART_NV
:
1403 if (!ctx
->Extensions
.NV_primitive_restart
) {
1404 goto invalid_enum_error
;
1406 return ctx
->Array
.PrimitiveRestart
;
1408 /* GL 3.1 primitive restart */
1409 case GL_PRIMITIVE_RESTART
:
1410 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1411 goto invalid_enum_error
;
1413 return ctx
->Array
.PrimitiveRestart
;
1415 /* GL3.0 - GL_framebuffer_sRGB */
1416 case GL_FRAMEBUFFER_SRGB_EXT
:
1417 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1418 return ctx
->Color
.sRGBEnabled
;
1421 goto invalid_enum_error
;
1427 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);