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_PLANE0
;
309 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
310 == ((GLuint
) state
<< p
))
313 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
316 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
317 _mesa_update_clip_plane(ctx
, p
);
320 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
325 case GL_COLOR_MATERIAL
:
326 if (ctx
->Light
.ColorMaterialEnabled
== state
)
328 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
329 FLUSH_CURRENT(ctx
, 0);
330 ctx
->Light
.ColorMaterialEnabled
= state
;
332 _mesa_update_color_material( ctx
,
333 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
337 if (ctx
->Polygon
.CullFlag
== state
)
339 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
340 ctx
->Polygon
.CullFlag
= state
;
343 if (ctx
->Depth
.Test
== state
)
345 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
346 ctx
->Depth
.Test
= state
;
349 if (ctx
->Color
.DitherFlag
== state
)
351 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
352 ctx
->Color
.DitherFlag
= state
;
355 if (ctx
->Fog
.Enabled
== state
)
357 FLUSH_VERTICES(ctx
, _NEW_FOG
);
358 ctx
->Fog
.Enabled
= state
;
368 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
370 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
371 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
373 insert_at_tail(&ctx
->Light
.EnabledList
,
374 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
377 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
381 if (ctx
->Light
.Enabled
== state
)
383 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
384 ctx
->Light
.Enabled
= state
;
385 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
386 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
388 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
391 if (ctx
->Line
.SmoothFlag
== state
)
393 FLUSH_VERTICES(ctx
, _NEW_LINE
);
394 ctx
->Line
.SmoothFlag
= state
;
395 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
397 case GL_LINE_STIPPLE
:
398 if (ctx
->Line
.StippleFlag
== state
)
400 FLUSH_VERTICES(ctx
, _NEW_LINE
);
401 ctx
->Line
.StippleFlag
= state
;
402 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
404 case GL_INDEX_LOGIC_OP
:
405 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
407 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
408 ctx
->Color
.IndexLogicOpEnabled
= state
;
410 case GL_COLOR_LOGIC_OP
:
411 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
413 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
414 ctx
->Color
.ColorLogicOpEnabled
= state
;
416 case GL_MAP1_COLOR_4
:
417 if (ctx
->Eval
.Map1Color4
== state
)
419 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
420 ctx
->Eval
.Map1Color4
= state
;
423 if (ctx
->Eval
.Map1Index
== state
)
425 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
426 ctx
->Eval
.Map1Index
= state
;
429 if (ctx
->Eval
.Map1Normal
== state
)
431 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
432 ctx
->Eval
.Map1Normal
= state
;
434 case GL_MAP1_TEXTURE_COORD_1
:
435 if (ctx
->Eval
.Map1TextureCoord1
== state
)
437 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
438 ctx
->Eval
.Map1TextureCoord1
= state
;
440 case GL_MAP1_TEXTURE_COORD_2
:
441 if (ctx
->Eval
.Map1TextureCoord2
== state
)
443 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
444 ctx
->Eval
.Map1TextureCoord2
= state
;
446 case GL_MAP1_TEXTURE_COORD_3
:
447 if (ctx
->Eval
.Map1TextureCoord3
== state
)
449 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
450 ctx
->Eval
.Map1TextureCoord3
= state
;
452 case GL_MAP1_TEXTURE_COORD_4
:
453 if (ctx
->Eval
.Map1TextureCoord4
== state
)
455 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
456 ctx
->Eval
.Map1TextureCoord4
= state
;
458 case GL_MAP1_VERTEX_3
:
459 if (ctx
->Eval
.Map1Vertex3
== state
)
461 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
462 ctx
->Eval
.Map1Vertex3
= state
;
464 case GL_MAP1_VERTEX_4
:
465 if (ctx
->Eval
.Map1Vertex4
== state
)
467 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
468 ctx
->Eval
.Map1Vertex4
= state
;
470 case GL_MAP2_COLOR_4
:
471 if (ctx
->Eval
.Map2Color4
== state
)
473 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
474 ctx
->Eval
.Map2Color4
= state
;
477 if (ctx
->Eval
.Map2Index
== state
)
479 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
480 ctx
->Eval
.Map2Index
= state
;
483 if (ctx
->Eval
.Map2Normal
== state
)
485 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
486 ctx
->Eval
.Map2Normal
= state
;
488 case GL_MAP2_TEXTURE_COORD_1
:
489 if (ctx
->Eval
.Map2TextureCoord1
== state
)
491 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
492 ctx
->Eval
.Map2TextureCoord1
= state
;
494 case GL_MAP2_TEXTURE_COORD_2
:
495 if (ctx
->Eval
.Map2TextureCoord2
== state
)
497 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
498 ctx
->Eval
.Map2TextureCoord2
= state
;
500 case GL_MAP2_TEXTURE_COORD_3
:
501 if (ctx
->Eval
.Map2TextureCoord3
== state
)
503 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
504 ctx
->Eval
.Map2TextureCoord3
= state
;
506 case GL_MAP2_TEXTURE_COORD_4
:
507 if (ctx
->Eval
.Map2TextureCoord4
== state
)
509 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
510 ctx
->Eval
.Map2TextureCoord4
= state
;
512 case GL_MAP2_VERTEX_3
:
513 if (ctx
->Eval
.Map2Vertex3
== state
)
515 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
516 ctx
->Eval
.Map2Vertex3
= state
;
518 case GL_MAP2_VERTEX_4
:
519 if (ctx
->Eval
.Map2Vertex4
== state
)
521 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
522 ctx
->Eval
.Map2Vertex4
= state
;
525 if (ctx
->Transform
.Normalize
== state
)
527 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
528 ctx
->Transform
.Normalize
= state
;
530 case GL_POINT_SMOOTH
:
531 if (ctx
->Point
.SmoothFlag
== state
)
533 FLUSH_VERTICES(ctx
, _NEW_POINT
);
534 ctx
->Point
.SmoothFlag
= state
;
535 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
537 case GL_POLYGON_SMOOTH
:
538 if (ctx
->Polygon
.SmoothFlag
== state
)
540 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
541 ctx
->Polygon
.SmoothFlag
= state
;
542 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
544 case GL_POLYGON_STIPPLE
:
545 if (ctx
->Polygon
.StippleFlag
== state
)
547 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
548 ctx
->Polygon
.StippleFlag
= state
;
549 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
551 case GL_POLYGON_OFFSET_POINT
:
552 if (ctx
->Polygon
.OffsetPoint
== state
)
554 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
555 ctx
->Polygon
.OffsetPoint
= state
;
557 case GL_POLYGON_OFFSET_LINE
:
558 if (ctx
->Polygon
.OffsetLine
== state
)
560 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
561 ctx
->Polygon
.OffsetLine
= state
;
563 case GL_POLYGON_OFFSET_FILL
:
564 if (ctx
->Polygon
.OffsetFill
== state
)
566 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
567 ctx
->Polygon
.OffsetFill
= state
;
569 case GL_RESCALE_NORMAL_EXT
:
570 if (ctx
->Transform
.RescaleNormals
== state
)
572 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
573 ctx
->Transform
.RescaleNormals
= state
;
575 case GL_SCISSOR_TEST
:
576 if (ctx
->Scissor
.Enabled
== state
)
578 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
579 ctx
->Scissor
.Enabled
= state
;
581 case GL_STENCIL_TEST
:
582 if (ctx
->Stencil
.Enabled
== state
)
584 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
585 ctx
->Stencil
.Enabled
= state
;
588 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
593 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
598 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
602 case GL_TEXTURE_GEN_S
:
603 case GL_TEXTURE_GEN_T
:
604 case GL_TEXTURE_GEN_R
:
605 case GL_TEXTURE_GEN_Q
:
607 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
609 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
610 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
612 newenabled
|= coordBit
;
613 if (texUnit
->TexGenEnabled
== newenabled
)
615 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
616 texUnit
->TexGenEnabled
= newenabled
;
622 case GL_TEXTURE_GEN_STR_OES
:
623 /* disable S, T, and R at the same time */
625 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
628 texUnit
->TexGenEnabled
& ~STR_BITS
;
630 newenabled
|= STR_BITS
;
631 if (texUnit
->TexGenEnabled
== newenabled
)
633 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
634 texUnit
->TexGenEnabled
= newenabled
;
640 /* client-side state */
641 case GL_VERTEX_ARRAY
:
642 case GL_NORMAL_ARRAY
:
645 case GL_TEXTURE_COORD_ARRAY
:
646 case GL_EDGE_FLAG_ARRAY
:
647 case GL_FOG_COORDINATE_ARRAY_EXT
:
648 case GL_SECONDARY_COLOR_ARRAY_EXT
:
649 case GL_POINT_SIZE_ARRAY_OES
:
650 client_state( ctx
, cap
, state
);
653 /* GL_ARB_texture_cube_map */
654 case GL_TEXTURE_CUBE_MAP_ARB
:
655 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
656 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
661 /* GL_EXT_secondary_color */
662 case GL_COLOR_SUM_EXT
:
663 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
664 if (ctx
->Fog
.ColorSumEnabled
== state
)
666 FLUSH_VERTICES(ctx
, _NEW_FOG
);
667 ctx
->Fog
.ColorSumEnabled
= state
;
670 /* GL_ARB_multisample */
671 case GL_MULTISAMPLE_ARB
:
672 if (ctx
->Multisample
.Enabled
== state
)
674 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
675 ctx
->Multisample
.Enabled
= state
;
677 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
678 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
680 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
681 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
683 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
684 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
686 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
687 ctx
->Multisample
.SampleAlphaToOne
= state
;
689 case GL_SAMPLE_COVERAGE_ARB
:
690 if (ctx
->Multisample
.SampleCoverage
== state
)
692 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
693 ctx
->Multisample
.SampleCoverage
= state
;
695 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
696 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
698 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
699 ctx
->Multisample
.SampleCoverageInvert
= state
;
702 /* GL_IBM_rasterpos_clip */
703 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
704 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
705 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
707 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
708 ctx
->Transform
.RasterPositionUnclipped
= state
;
711 /* GL_NV_point_sprite */
712 case GL_POINT_SPRITE_NV
:
713 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
714 if (ctx
->Point
.PointSprite
== state
)
716 FLUSH_VERTICES(ctx
, _NEW_POINT
);
717 ctx
->Point
.PointSprite
= state
;
720 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
721 case GL_VERTEX_PROGRAM_ARB
:
722 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
723 if (ctx
->VertexProgram
.Enabled
== state
)
725 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
726 ctx
->VertexProgram
.Enabled
= state
;
728 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
729 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
730 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
732 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
733 ctx
->VertexProgram
.PointSizeEnabled
= state
;
735 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
736 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
737 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
739 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
740 ctx
->VertexProgram
.TwoSideEnabled
= state
;
743 #if FEATURE_NV_vertex_program
744 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
745 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
746 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
747 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
748 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
749 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
750 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
751 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
752 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
753 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
754 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
755 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
756 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
757 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
758 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
759 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
760 CHECK_EXTENSION(NV_vertex_program
, cap
);
762 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
763 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
764 ctx
->Eval
.Map1Attrib
[map
] = state
;
767 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
768 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
769 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
770 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
771 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
772 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
773 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
774 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
775 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
776 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
777 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
778 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
779 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
780 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
781 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
782 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
783 CHECK_EXTENSION(NV_vertex_program
, cap
);
785 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
786 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
787 ctx
->Eval
.Map2Attrib
[map
] = state
;
790 #endif /* FEATURE_NV_vertex_program */
792 #if FEATURE_NV_fragment_program
793 case GL_FRAGMENT_PROGRAM_NV
:
794 CHECK_EXTENSION(NV_fragment_program
, cap
);
795 if (ctx
->FragmentProgram
.Enabled
== state
)
797 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
798 ctx
->FragmentProgram
.Enabled
= state
;
800 #endif /* FEATURE_NV_fragment_program */
802 /* GL_NV_texture_rectangle */
803 case GL_TEXTURE_RECTANGLE_NV
:
804 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
805 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
810 /* GL_EXT_stencil_two_side */
811 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
812 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
813 if (ctx
->Stencil
.TestTwoSide
== state
)
815 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
816 ctx
->Stencil
.TestTwoSide
= state
;
818 ctx
->Stencil
._BackFace
= 2;
819 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
821 ctx
->Stencil
._BackFace
= 1;
822 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
826 #if FEATURE_ARB_fragment_program
827 case GL_FRAGMENT_PROGRAM_ARB
:
828 CHECK_EXTENSION(ARB_fragment_program
, cap
);
829 if (ctx
->FragmentProgram
.Enabled
== state
)
831 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
832 ctx
->FragmentProgram
.Enabled
= state
;
834 #endif /* FEATURE_ARB_fragment_program */
836 /* GL_EXT_depth_bounds_test */
837 case GL_DEPTH_BOUNDS_TEST_EXT
:
838 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
839 if (ctx
->Depth
.BoundsTest
== state
)
841 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
842 ctx
->Depth
.BoundsTest
= state
;
846 if (ctx
->Transform
.DepthClamp
== state
)
848 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
849 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
850 ctx
->Transform
.DepthClamp
= state
;
853 #if FEATURE_ATI_fragment_shader
854 case GL_FRAGMENT_SHADER_ATI
:
855 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
856 if (ctx
->ATIFragmentShader
.Enabled
== state
)
858 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
859 ctx
->ATIFragmentShader
.Enabled
= state
;
863 /* GL_MESA_texture_array */
864 case GL_TEXTURE_1D_ARRAY_EXT
:
865 CHECK_EXTENSION(MESA_texture_array
, cap
);
866 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
871 case GL_TEXTURE_2D_ARRAY_EXT
:
872 CHECK_EXTENSION(MESA_texture_array
, cap
);
873 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
878 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
879 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
880 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
881 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
882 ctx
->Texture
.CubeMapSeamless
= state
;
886 #if FEATURE_EXT_transform_feedback
887 case GL_RASTERIZER_DISCARD
:
888 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
889 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
890 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
891 ctx
->TransformFeedback
.RasterDiscard
= state
;
896 /* GL 3.1 primitive restart. Note: this enum is different from
897 * GL_PRIMITIVE_RESTART_NV (which is client state).
899 case GL_PRIMITIVE_RESTART
:
900 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
901 goto invalid_enum_error
;
903 if (ctx
->Array
.PrimitiveRestart
!= state
) {
904 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
905 ctx
->Array
.PrimitiveRestart
= state
;
909 /* GL3.0 - GL_framebuffer_sRGB */
910 case GL_FRAMEBUFFER_SRGB_EXT
:
911 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
912 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
913 ctx
->Color
.sRGBEnabled
= state
;
917 goto invalid_enum_error
;
920 if (ctx
->Driver
.Enable
) {
921 ctx
->Driver
.Enable( ctx
, cap
, state
);
927 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
928 state
? "Enable" : "Disable", cap
);
933 * Enable GL capability. Called by glEnable()
934 * \param cap state to enable.
937 _mesa_Enable( GLenum cap
)
939 GET_CURRENT_CONTEXT(ctx
);
940 ASSERT_OUTSIDE_BEGIN_END(ctx
);
942 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
947 * Disable GL capability. Called by glDisable()
948 * \param cap state to disable.
951 _mesa_Disable( GLenum cap
)
953 GET_CURRENT_CONTEXT(ctx
);
954 ASSERT_OUTSIDE_BEGIN_END(ctx
);
956 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
962 * Enable/disable an indexed state var.
965 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
966 GLuint index
, GLboolean state
)
968 ASSERT(state
== 0 || state
== 1);
971 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
972 goto invalid_enum_error
;
974 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
975 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
976 state
? "glEnableIndexed" : "glDisableIndexed", index
);
979 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
980 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
982 ctx
->Color
.BlendEnabled
|= (1 << index
);
984 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
988 goto invalid_enum_error
;
993 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
994 state
? "glEnablei" : "glDisablei",
995 _mesa_lookup_enum_by_nr(cap
));
1000 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1002 GET_CURRENT_CONTEXT(ctx
);
1003 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1004 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1009 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1011 GET_CURRENT_CONTEXT(ctx
);
1012 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1013 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1017 GLboolean GLAPIENTRY
1018 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1020 GET_CURRENT_CONTEXT(ctx
);
1021 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1024 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1025 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1029 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1031 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1032 _mesa_lookup_enum_by_nr(cap
));
1040 #undef CHECK_EXTENSION
1041 #define CHECK_EXTENSION(EXTNAME) \
1042 if (!ctx->Extensions.EXTNAME) { \
1043 goto invalid_enum_error; \
1046 #undef CHECK_EXTENSION2
1047 #define CHECK_EXTENSION2(EXT1, EXT2) \
1048 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1049 goto invalid_enum_error; \
1054 * Helper function to determine whether a texture target is enabled.
1057 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1059 const struct gl_texture_unit
*const texUnit
=
1060 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1061 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1066 * Return simple enable/disable state.
1068 * \param cap state variable to query.
1070 * Returns the state of the specified capability from the current GL context.
1071 * For the capabilities associated with extensions verifies that those
1072 * extensions are effectively present before reporting.
1074 GLboolean GLAPIENTRY
1075 _mesa_IsEnabled( GLenum cap
)
1077 GET_CURRENT_CONTEXT(ctx
);
1078 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1082 return ctx
->Color
.AlphaEnabled
;
1083 case GL_AUTO_NORMAL
:
1084 return ctx
->Eval
.AutoNormal
;
1086 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1087 case GL_CLIP_PLANE0
:
1088 case GL_CLIP_PLANE1
:
1089 case GL_CLIP_PLANE2
:
1090 case GL_CLIP_PLANE3
:
1091 case GL_CLIP_PLANE4
:
1092 case GL_CLIP_PLANE5
:
1093 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1094 case GL_COLOR_MATERIAL
:
1095 return ctx
->Light
.ColorMaterialEnabled
;
1097 return ctx
->Polygon
.CullFlag
;
1099 return ctx
->Depth
.Test
;
1101 return ctx
->Color
.DitherFlag
;
1103 return ctx
->Fog
.Enabled
;
1105 return ctx
->Light
.Enabled
;
1114 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1115 case GL_LINE_SMOOTH
:
1116 return ctx
->Line
.SmoothFlag
;
1117 case GL_LINE_STIPPLE
:
1118 return ctx
->Line
.StippleFlag
;
1119 case GL_INDEX_LOGIC_OP
:
1120 return ctx
->Color
.IndexLogicOpEnabled
;
1121 case GL_COLOR_LOGIC_OP
:
1122 return ctx
->Color
.ColorLogicOpEnabled
;
1123 case GL_MAP1_COLOR_4
:
1124 return ctx
->Eval
.Map1Color4
;
1126 return ctx
->Eval
.Map1Index
;
1127 case GL_MAP1_NORMAL
:
1128 return ctx
->Eval
.Map1Normal
;
1129 case GL_MAP1_TEXTURE_COORD_1
:
1130 return ctx
->Eval
.Map1TextureCoord1
;
1131 case GL_MAP1_TEXTURE_COORD_2
:
1132 return ctx
->Eval
.Map1TextureCoord2
;
1133 case GL_MAP1_TEXTURE_COORD_3
:
1134 return ctx
->Eval
.Map1TextureCoord3
;
1135 case GL_MAP1_TEXTURE_COORD_4
:
1136 return ctx
->Eval
.Map1TextureCoord4
;
1137 case GL_MAP1_VERTEX_3
:
1138 return ctx
->Eval
.Map1Vertex3
;
1139 case GL_MAP1_VERTEX_4
:
1140 return ctx
->Eval
.Map1Vertex4
;
1141 case GL_MAP2_COLOR_4
:
1142 return ctx
->Eval
.Map2Color4
;
1144 return ctx
->Eval
.Map2Index
;
1145 case GL_MAP2_NORMAL
:
1146 return ctx
->Eval
.Map2Normal
;
1147 case GL_MAP2_TEXTURE_COORD_1
:
1148 return ctx
->Eval
.Map2TextureCoord1
;
1149 case GL_MAP2_TEXTURE_COORD_2
:
1150 return ctx
->Eval
.Map2TextureCoord2
;
1151 case GL_MAP2_TEXTURE_COORD_3
:
1152 return ctx
->Eval
.Map2TextureCoord3
;
1153 case GL_MAP2_TEXTURE_COORD_4
:
1154 return ctx
->Eval
.Map2TextureCoord4
;
1155 case GL_MAP2_VERTEX_3
:
1156 return ctx
->Eval
.Map2Vertex3
;
1157 case GL_MAP2_VERTEX_4
:
1158 return ctx
->Eval
.Map2Vertex4
;
1160 return ctx
->Transform
.Normalize
;
1161 case GL_POINT_SMOOTH
:
1162 return ctx
->Point
.SmoothFlag
;
1163 case GL_POLYGON_SMOOTH
:
1164 return ctx
->Polygon
.SmoothFlag
;
1165 case GL_POLYGON_STIPPLE
:
1166 return ctx
->Polygon
.StippleFlag
;
1167 case GL_POLYGON_OFFSET_POINT
:
1168 return ctx
->Polygon
.OffsetPoint
;
1169 case GL_POLYGON_OFFSET_LINE
:
1170 return ctx
->Polygon
.OffsetLine
;
1171 case GL_POLYGON_OFFSET_FILL
:
1172 return ctx
->Polygon
.OffsetFill
;
1173 case GL_RESCALE_NORMAL_EXT
:
1174 return ctx
->Transform
.RescaleNormals
;
1175 case GL_SCISSOR_TEST
:
1176 return ctx
->Scissor
.Enabled
;
1177 case GL_STENCIL_TEST
:
1178 return ctx
->Stencil
.Enabled
;
1180 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1182 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1184 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1185 case GL_TEXTURE_GEN_S
:
1186 case GL_TEXTURE_GEN_T
:
1187 case GL_TEXTURE_GEN_R
:
1188 case GL_TEXTURE_GEN_Q
:
1190 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1192 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1193 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1198 case GL_TEXTURE_GEN_STR_OES
:
1200 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1202 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1203 ? GL_TRUE
: GL_FALSE
;
1208 /* client-side state */
1209 case GL_VERTEX_ARRAY
:
1210 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1211 case GL_NORMAL_ARRAY
:
1212 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1213 case GL_COLOR_ARRAY
:
1214 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1215 case GL_INDEX_ARRAY
:
1216 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1217 case GL_TEXTURE_COORD_ARRAY
:
1218 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
]
1220 case GL_EDGE_FLAG_ARRAY
:
1221 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1222 case GL_FOG_COORDINATE_ARRAY_EXT
:
1223 CHECK_EXTENSION(EXT_fog_coord
);
1224 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1225 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1226 CHECK_EXTENSION(EXT_secondary_color
);
1227 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1228 #if FEATURE_point_size_array
1229 case GL_POINT_SIZE_ARRAY_OES
:
1230 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1233 /* GL_ARB_texture_cube_map */
1234 case GL_TEXTURE_CUBE_MAP_ARB
:
1235 CHECK_EXTENSION(ARB_texture_cube_map
);
1236 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1238 /* GL_EXT_secondary_color */
1239 case GL_COLOR_SUM_EXT
:
1240 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1241 return ctx
->Fog
.ColorSumEnabled
;
1243 /* GL_ARB_multisample */
1244 case GL_MULTISAMPLE_ARB
:
1245 return ctx
->Multisample
.Enabled
;
1246 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1247 return ctx
->Multisample
.SampleAlphaToCoverage
;
1248 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1249 return ctx
->Multisample
.SampleAlphaToOne
;
1250 case GL_SAMPLE_COVERAGE_ARB
:
1251 return ctx
->Multisample
.SampleCoverage
;
1252 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1253 return ctx
->Multisample
.SampleCoverageInvert
;
1255 /* GL_IBM_rasterpos_clip */
1256 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1257 CHECK_EXTENSION(IBM_rasterpos_clip
);
1258 return ctx
->Transform
.RasterPositionUnclipped
;
1260 /* GL_NV_point_sprite */
1261 case GL_POINT_SPRITE_NV
:
1262 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1263 return ctx
->Point
.PointSprite
;
1265 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1266 case GL_VERTEX_PROGRAM_ARB
:
1267 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1268 return ctx
->VertexProgram
.Enabled
;
1269 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1270 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1271 return ctx
->VertexProgram
.PointSizeEnabled
;
1272 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1273 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1274 return ctx
->VertexProgram
.TwoSideEnabled
;
1276 #if FEATURE_NV_vertex_program
1277 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1278 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1279 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1280 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1281 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1282 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1283 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1284 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1285 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1286 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1287 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1288 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1289 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1290 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1291 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1292 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1293 CHECK_EXTENSION(NV_vertex_program
);
1295 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1296 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1297 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1299 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1300 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1301 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1302 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1303 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1304 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1305 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1306 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1307 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1308 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1309 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1310 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1311 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1312 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1313 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1314 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1315 CHECK_EXTENSION(NV_vertex_program
);
1317 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1318 return ctx
->Eval
.Map1Attrib
[map
];
1320 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1321 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1322 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1323 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1324 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1325 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1326 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1327 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1328 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1329 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1330 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1331 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1332 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1333 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1334 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1335 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1336 CHECK_EXTENSION(NV_vertex_program
);
1338 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1339 return ctx
->Eval
.Map2Attrib
[map
];
1341 #endif /* FEATURE_NV_vertex_program */
1343 #if FEATURE_NV_fragment_program
1344 case GL_FRAGMENT_PROGRAM_NV
:
1345 CHECK_EXTENSION(NV_fragment_program
);
1346 return ctx
->FragmentProgram
.Enabled
;
1347 #endif /* FEATURE_NV_fragment_program */
1349 /* GL_NV_texture_rectangle */
1350 case GL_TEXTURE_RECTANGLE_NV
:
1351 CHECK_EXTENSION(NV_texture_rectangle
);
1352 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1354 /* GL_EXT_stencil_two_side */
1355 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1356 CHECK_EXTENSION(EXT_stencil_two_side
);
1357 return ctx
->Stencil
.TestTwoSide
;
1359 #if FEATURE_ARB_fragment_program
1360 case GL_FRAGMENT_PROGRAM_ARB
:
1361 return ctx
->FragmentProgram
.Enabled
;
1362 #endif /* FEATURE_ARB_fragment_program */
1364 /* GL_EXT_depth_bounds_test */
1365 case GL_DEPTH_BOUNDS_TEST_EXT
:
1366 CHECK_EXTENSION(EXT_depth_bounds_test
);
1367 return ctx
->Depth
.BoundsTest
;
1369 /* GL_ARB_depth_clamp */
1370 case GL_DEPTH_CLAMP
:
1371 CHECK_EXTENSION(ARB_depth_clamp
);
1372 return ctx
->Transform
.DepthClamp
;
1374 #if FEATURE_ATI_fragment_shader
1375 case GL_FRAGMENT_SHADER_ATI
:
1376 CHECK_EXTENSION(ATI_fragment_shader
);
1377 return ctx
->ATIFragmentShader
.Enabled
;
1378 #endif /* FEATURE_ATI_fragment_shader */
1380 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1381 CHECK_EXTENSION(ARB_seamless_cube_map
);
1382 return ctx
->Texture
.CubeMapSeamless
;
1384 #if FEATURE_EXT_transform_feedback
1385 case GL_RASTERIZER_DISCARD
:
1386 CHECK_EXTENSION(EXT_transform_feedback
);
1387 return ctx
->TransformFeedback
.RasterDiscard
;
1390 /* GL_NV_primitive_restart */
1391 case GL_PRIMITIVE_RESTART_NV
:
1392 if (!ctx
->Extensions
.NV_primitive_restart
) {
1393 goto invalid_enum_error
;
1395 return ctx
->Array
.PrimitiveRestart
;
1397 /* GL 3.1 primitive restart */
1398 case GL_PRIMITIVE_RESTART
:
1399 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1400 goto invalid_enum_error
;
1402 return ctx
->Array
.PrimitiveRestart
;
1404 /* GL3.0 - GL_framebuffer_sRGB */
1405 case GL_FRAMEBUFFER_SRGB_EXT
:
1406 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1407 return ctx
->Color
.sRGBEnabled
;
1410 goto invalid_enum_error
;
1416 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);