3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 #include "simple_list.h"
37 #include "mfeatures.h"
40 #include "api_arrayelt.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
52 * Helper to enable/disable client-side state.
55 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
57 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
63 var
= &arrayObj
->Vertex
.Enabled
;
64 flag
= _NEW_ARRAY_VERTEX
;
67 var
= &arrayObj
->Normal
.Enabled
;
68 flag
= _NEW_ARRAY_NORMAL
;
71 var
= &arrayObj
->Color
.Enabled
;
72 flag
= _NEW_ARRAY_COLOR0
;
75 var
= &arrayObj
->Index
.Enabled
;
76 flag
= _NEW_ARRAY_INDEX
;
78 case GL_TEXTURE_COORD_ARRAY
:
79 var
= &arrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
80 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
82 case GL_EDGE_FLAG_ARRAY
:
83 var
= &arrayObj
->EdgeFlag
.Enabled
;
84 flag
= _NEW_ARRAY_EDGEFLAG
;
86 case GL_FOG_COORDINATE_ARRAY_EXT
:
87 var
= &arrayObj
->FogCoord
.Enabled
;
88 flag
= _NEW_ARRAY_FOGCOORD
;
90 case GL_SECONDARY_COLOR_ARRAY_EXT
:
91 var
= &arrayObj
->SecondaryColor
.Enabled
;
92 flag
= _NEW_ARRAY_COLOR1
;
95 #if FEATURE_point_size_array
96 case GL_POINT_SIZE_ARRAY_OES
:
97 var
= &arrayObj
->PointSize
.Enabled
;
98 flag
= _NEW_ARRAY_POINT_SIZE
;
102 #if FEATURE_NV_vertex_program
103 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
118 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
119 CHECK_EXTENSION(NV_vertex_program
, cap
);
121 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
122 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
123 var
= &arrayObj
->VertexAttrib
[n
].Enabled
;
124 flag
= _NEW_ARRAY_ATTRIB(n
);
127 #endif /* FEATURE_NV_vertex_program */
129 /* GL_NV_primitive_restart */
130 case GL_PRIMITIVE_RESTART_NV
:
131 if (!ctx
->Extensions
.NV_primitive_restart
) {
132 goto invalid_enum_error
;
134 var
= &ctx
->Array
.PrimitiveRestart
;
139 goto invalid_enum_error
;
145 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
146 ctx
->Array
.NewState
|= flag
;
148 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
153 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
155 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
157 if (ctx
->Driver
.Enable
) {
158 ctx
->Driver
.Enable( ctx
, cap
, state
);
164 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(0x%x)",
165 state
? "Enable" : "Disable", cap
);
170 * Enable GL capability.
171 * \param cap state to enable/disable.
173 * Get's the current context, assures that we're outside glBegin()/glEnd() and
174 * calls client_state().
177 _mesa_EnableClientState( GLenum cap
)
179 GET_CURRENT_CONTEXT(ctx
);
180 ASSERT_OUTSIDE_BEGIN_END(ctx
);
181 client_state( ctx
, cap
, GL_TRUE
);
186 * Disable GL capability.
187 * \param cap state to enable/disable.
189 * Get's the current context, assures that we're outside glBegin()/glEnd() and
190 * calls client_state().
193 _mesa_DisableClientState( GLenum cap
)
195 GET_CURRENT_CONTEXT(ctx
);
196 ASSERT_OUTSIDE_BEGIN_END(ctx
);
197 client_state( ctx
, cap
, GL_FALSE
);
201 #undef CHECK_EXTENSION
202 #define CHECK_EXTENSION(EXTNAME, CAP) \
203 if (!ctx->Extensions.EXTNAME) { \
204 goto invalid_enum_error; \
207 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
208 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
209 goto invalid_enum_error; \
215 * Return pointer to current texture unit for setting/getting coordinate
217 * Note that we'll set GL_INVALID_OPERATION 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
;
306 const GLuint p
= cap
- GL_CLIP_PLANE0
;
308 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
309 == ((GLuint
) state
<< p
))
312 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
315 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
316 _mesa_update_clip_plane(ctx
, p
);
319 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
324 case GL_COLOR_MATERIAL
:
325 if (ctx
->Light
.ColorMaterialEnabled
== state
)
327 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
328 FLUSH_CURRENT(ctx
, 0);
329 ctx
->Light
.ColorMaterialEnabled
= state
;
331 _mesa_update_color_material( ctx
,
332 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
336 if (ctx
->Polygon
.CullFlag
== state
)
338 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
339 ctx
->Polygon
.CullFlag
= state
;
342 if (ctx
->Depth
.Test
== state
)
344 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
345 ctx
->Depth
.Test
= state
;
348 if (ctx
->Color
.DitherFlag
== state
)
350 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
351 ctx
->Color
.DitherFlag
= state
;
354 if (ctx
->Fog
.Enabled
== state
)
356 FLUSH_VERTICES(ctx
, _NEW_FOG
);
357 ctx
->Fog
.Enabled
= state
;
367 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
369 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
370 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
372 insert_at_tail(&ctx
->Light
.EnabledList
,
373 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
376 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
380 if (ctx
->Light
.Enabled
== state
)
382 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
383 ctx
->Light
.Enabled
= state
;
384 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
385 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
387 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
390 if (ctx
->Line
.SmoothFlag
== state
)
392 FLUSH_VERTICES(ctx
, _NEW_LINE
);
393 ctx
->Line
.SmoothFlag
= state
;
394 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
396 case GL_LINE_STIPPLE
:
397 if (ctx
->Line
.StippleFlag
== state
)
399 FLUSH_VERTICES(ctx
, _NEW_LINE
);
400 ctx
->Line
.StippleFlag
= state
;
401 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
403 case GL_INDEX_LOGIC_OP
:
404 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
406 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
407 ctx
->Color
.IndexLogicOpEnabled
= state
;
409 case GL_COLOR_LOGIC_OP
:
410 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
412 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
413 ctx
->Color
.ColorLogicOpEnabled
= state
;
415 case GL_MAP1_COLOR_4
:
416 if (ctx
->Eval
.Map1Color4
== state
)
418 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
419 ctx
->Eval
.Map1Color4
= state
;
422 if (ctx
->Eval
.Map1Index
== state
)
424 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
425 ctx
->Eval
.Map1Index
= state
;
428 if (ctx
->Eval
.Map1Normal
== state
)
430 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
431 ctx
->Eval
.Map1Normal
= state
;
433 case GL_MAP1_TEXTURE_COORD_1
:
434 if (ctx
->Eval
.Map1TextureCoord1
== state
)
436 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
437 ctx
->Eval
.Map1TextureCoord1
= state
;
439 case GL_MAP1_TEXTURE_COORD_2
:
440 if (ctx
->Eval
.Map1TextureCoord2
== state
)
442 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
443 ctx
->Eval
.Map1TextureCoord2
= state
;
445 case GL_MAP1_TEXTURE_COORD_3
:
446 if (ctx
->Eval
.Map1TextureCoord3
== state
)
448 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
449 ctx
->Eval
.Map1TextureCoord3
= state
;
451 case GL_MAP1_TEXTURE_COORD_4
:
452 if (ctx
->Eval
.Map1TextureCoord4
== state
)
454 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
455 ctx
->Eval
.Map1TextureCoord4
= state
;
457 case GL_MAP1_VERTEX_3
:
458 if (ctx
->Eval
.Map1Vertex3
== state
)
460 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
461 ctx
->Eval
.Map1Vertex3
= state
;
463 case GL_MAP1_VERTEX_4
:
464 if (ctx
->Eval
.Map1Vertex4
== state
)
466 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
467 ctx
->Eval
.Map1Vertex4
= state
;
469 case GL_MAP2_COLOR_4
:
470 if (ctx
->Eval
.Map2Color4
== state
)
472 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
473 ctx
->Eval
.Map2Color4
= state
;
476 if (ctx
->Eval
.Map2Index
== state
)
478 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
479 ctx
->Eval
.Map2Index
= state
;
482 if (ctx
->Eval
.Map2Normal
== state
)
484 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
485 ctx
->Eval
.Map2Normal
= state
;
487 case GL_MAP2_TEXTURE_COORD_1
:
488 if (ctx
->Eval
.Map2TextureCoord1
== state
)
490 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
491 ctx
->Eval
.Map2TextureCoord1
= state
;
493 case GL_MAP2_TEXTURE_COORD_2
:
494 if (ctx
->Eval
.Map2TextureCoord2
== state
)
496 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
497 ctx
->Eval
.Map2TextureCoord2
= state
;
499 case GL_MAP2_TEXTURE_COORD_3
:
500 if (ctx
->Eval
.Map2TextureCoord3
== state
)
502 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
503 ctx
->Eval
.Map2TextureCoord3
= state
;
505 case GL_MAP2_TEXTURE_COORD_4
:
506 if (ctx
->Eval
.Map2TextureCoord4
== state
)
508 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
509 ctx
->Eval
.Map2TextureCoord4
= state
;
511 case GL_MAP2_VERTEX_3
:
512 if (ctx
->Eval
.Map2Vertex3
== state
)
514 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
515 ctx
->Eval
.Map2Vertex3
= state
;
517 case GL_MAP2_VERTEX_4
:
518 if (ctx
->Eval
.Map2Vertex4
== state
)
520 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
521 ctx
->Eval
.Map2Vertex4
= state
;
524 if (ctx
->Transform
.Normalize
== state
)
526 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
527 ctx
->Transform
.Normalize
= state
;
529 case GL_POINT_SMOOTH
:
530 if (ctx
->Point
.SmoothFlag
== state
)
532 FLUSH_VERTICES(ctx
, _NEW_POINT
);
533 ctx
->Point
.SmoothFlag
= state
;
534 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
536 case GL_POLYGON_SMOOTH
:
537 if (ctx
->Polygon
.SmoothFlag
== state
)
539 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
540 ctx
->Polygon
.SmoothFlag
= state
;
541 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
543 case GL_POLYGON_STIPPLE
:
544 if (ctx
->Polygon
.StippleFlag
== state
)
546 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
547 ctx
->Polygon
.StippleFlag
= state
;
548 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
550 case GL_POLYGON_OFFSET_POINT
:
551 if (ctx
->Polygon
.OffsetPoint
== state
)
553 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
554 ctx
->Polygon
.OffsetPoint
= state
;
556 case GL_POLYGON_OFFSET_LINE
:
557 if (ctx
->Polygon
.OffsetLine
== state
)
559 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
560 ctx
->Polygon
.OffsetLine
= state
;
562 case GL_POLYGON_OFFSET_FILL
:
563 /*case GL_POLYGON_OFFSET_EXT:*/
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_SHARED_TEXTURE_PALETTE_EXT
:
582 if (ctx
->Texture
.SharedPalette
== state
)
584 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
585 ctx
->Texture
.SharedPalette
= state
;
587 case GL_STENCIL_TEST
:
588 if (ctx
->Stencil
.Enabled
== state
)
590 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
591 ctx
->Stencil
.Enabled
= state
;
594 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
599 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
604 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
608 case GL_TEXTURE_GEN_S
:
609 case GL_TEXTURE_GEN_T
:
610 case GL_TEXTURE_GEN_R
:
611 case GL_TEXTURE_GEN_Q
:
613 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
615 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
616 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
618 newenabled
|= coordBit
;
619 if (texUnit
->TexGenEnabled
== newenabled
)
621 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
622 texUnit
->TexGenEnabled
= newenabled
;
628 case GL_TEXTURE_GEN_STR_OES
:
629 /* disable S, T, and R at the same time */
631 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
634 texUnit
->TexGenEnabled
& ~STR_BITS
;
636 newenabled
|= STR_BITS
;
637 if (texUnit
->TexGenEnabled
== newenabled
)
639 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
640 texUnit
->TexGenEnabled
= newenabled
;
649 case GL_VERTEX_ARRAY
:
650 case GL_NORMAL_ARRAY
:
653 case GL_TEXTURE_COORD_ARRAY
:
654 case GL_EDGE_FLAG_ARRAY
:
655 case GL_FOG_COORDINATE_ARRAY_EXT
:
656 case GL_SECONDARY_COLOR_ARRAY_EXT
:
657 case GL_POINT_SIZE_ARRAY_OES
:
658 client_state( ctx
, cap
, state
);
661 /* GL_ARB_texture_cube_map */
662 case GL_TEXTURE_CUBE_MAP_ARB
:
663 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
664 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
669 /* GL_EXT_secondary_color */
670 case GL_COLOR_SUM_EXT
:
671 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
672 if (ctx
->Fog
.ColorSumEnabled
== state
)
674 FLUSH_VERTICES(ctx
, _NEW_FOG
);
675 ctx
->Fog
.ColorSumEnabled
= state
;
678 /* GL_ARB_multisample */
679 case GL_MULTISAMPLE_ARB
:
680 if (ctx
->Multisample
.Enabled
== state
)
682 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
683 ctx
->Multisample
.Enabled
= state
;
685 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
686 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
688 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
689 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
691 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
692 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
694 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
695 ctx
->Multisample
.SampleAlphaToOne
= state
;
697 case GL_SAMPLE_COVERAGE_ARB
:
698 if (ctx
->Multisample
.SampleCoverage
== state
)
700 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
701 ctx
->Multisample
.SampleCoverage
= state
;
703 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
704 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
706 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
707 ctx
->Multisample
.SampleCoverageInvert
= state
;
710 /* GL_IBM_rasterpos_clip */
711 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
712 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
713 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
715 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
716 ctx
->Transform
.RasterPositionUnclipped
= state
;
719 /* GL_NV_point_sprite */
720 case GL_POINT_SPRITE_NV
:
721 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
722 if (ctx
->Point
.PointSprite
== state
)
724 FLUSH_VERTICES(ctx
, _NEW_POINT
);
725 ctx
->Point
.PointSprite
= state
;
728 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
729 case GL_VERTEX_PROGRAM_ARB
:
730 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
731 if (ctx
->VertexProgram
.Enabled
== state
)
733 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
734 ctx
->VertexProgram
.Enabled
= state
;
736 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
737 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
738 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
740 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
741 ctx
->VertexProgram
.PointSizeEnabled
= state
;
743 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
744 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
745 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
747 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
748 ctx
->VertexProgram
.TwoSideEnabled
= state
;
751 #if FEATURE_NV_vertex_program
752 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
753 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
754 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
755 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
756 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
757 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
758 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
759 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
760 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
761 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
762 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
763 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
764 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
765 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
766 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
767 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
768 CHECK_EXTENSION(NV_vertex_program
, cap
);
770 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
771 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
772 ctx
->Eval
.Map1Attrib
[map
] = state
;
775 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
776 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
777 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
778 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
779 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
780 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
781 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
782 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
783 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
784 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
785 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
786 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
787 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
788 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
789 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
790 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
791 CHECK_EXTENSION(NV_vertex_program
, cap
);
793 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
794 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
795 ctx
->Eval
.Map2Attrib
[map
] = state
;
798 #endif /* FEATURE_NV_vertex_program */
800 #if FEATURE_NV_fragment_program
801 case GL_FRAGMENT_PROGRAM_NV
:
802 CHECK_EXTENSION(NV_fragment_program
, cap
);
803 if (ctx
->FragmentProgram
.Enabled
== state
)
805 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
806 ctx
->FragmentProgram
.Enabled
= state
;
808 #endif /* FEATURE_NV_fragment_program */
810 /* GL_NV_texture_rectangle */
811 case GL_TEXTURE_RECTANGLE_NV
:
812 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
813 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
818 /* GL_EXT_stencil_two_side */
819 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
820 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
821 if (ctx
->Stencil
.TestTwoSide
== state
)
823 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
824 ctx
->Stencil
.TestTwoSide
= state
;
826 ctx
->Stencil
._BackFace
= 2;
827 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
829 ctx
->Stencil
._BackFace
= 1;
830 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
834 #if FEATURE_ARB_fragment_program
835 case GL_FRAGMENT_PROGRAM_ARB
:
836 CHECK_EXTENSION(ARB_fragment_program
, cap
);
837 if (ctx
->FragmentProgram
.Enabled
== state
)
839 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
840 ctx
->FragmentProgram
.Enabled
= state
;
842 #endif /* FEATURE_ARB_fragment_program */
844 /* GL_EXT_depth_bounds_test */
845 case GL_DEPTH_BOUNDS_TEST_EXT
:
846 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
847 if (ctx
->Depth
.BoundsTest
== state
)
849 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
850 ctx
->Depth
.BoundsTest
= state
;
854 if (ctx
->Transform
.DepthClamp
== state
)
856 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
857 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
858 ctx
->Transform
.DepthClamp
= state
;
861 #if FEATURE_ATI_fragment_shader
862 case GL_FRAGMENT_SHADER_ATI
:
863 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
864 if (ctx
->ATIFragmentShader
.Enabled
== state
)
866 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
867 ctx
->ATIFragmentShader
.Enabled
= state
;
871 /* GL_MESA_texture_array */
872 case GL_TEXTURE_1D_ARRAY_EXT
:
873 CHECK_EXTENSION(MESA_texture_array
, cap
);
874 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
879 case GL_TEXTURE_2D_ARRAY_EXT
:
880 CHECK_EXTENSION(MESA_texture_array
, cap
);
881 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
886 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
887 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
888 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
->TransformFeedback
.RasterDiscard
!= state
) {
895 ctx
->TransformFeedback
.RasterDiscard
= state
;
896 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
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
;
922 goto invalid_enum_error
;
925 if (ctx
->Driver
.Enable
) {
926 ctx
->Driver
.Enable( ctx
, cap
, state
);
932 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
933 state
? "Enable" : "Disable", cap
);
938 * Enable GL capability. Called by glEnable()
939 * \param cap state to enable.
942 _mesa_Enable( GLenum cap
)
944 GET_CURRENT_CONTEXT(ctx
);
945 ASSERT_OUTSIDE_BEGIN_END(ctx
);
947 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
952 * Disable GL capability. Called by glDisable()
953 * \param cap state to disable.
956 _mesa_Disable( GLenum cap
)
958 GET_CURRENT_CONTEXT(ctx
);
959 ASSERT_OUTSIDE_BEGIN_END(ctx
);
961 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
967 * Enable/disable an indexed state var.
970 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
971 GLuint index
, GLboolean state
)
973 ASSERT(state
== 0 || state
== 1);
976 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
977 goto invalid_enum_error
;
979 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
980 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
981 state
? "glEnableIndexed" : "glDisableIndexed", index
);
984 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
985 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
987 ctx
->Color
.BlendEnabled
|= (1 << index
);
989 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
993 goto invalid_enum_error
;
998 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
999 state
? "glEnablei" : "glDisablei",
1000 _mesa_lookup_enum_by_nr(cap
));
1005 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1007 GET_CURRENT_CONTEXT(ctx
);
1008 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1009 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1014 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1016 GET_CURRENT_CONTEXT(ctx
);
1017 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1018 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1022 GLboolean GLAPIENTRY
1023 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1025 GET_CURRENT_CONTEXT(ctx
);
1028 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1029 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1033 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1035 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1036 _mesa_lookup_enum_by_nr(cap
));
1044 #undef CHECK_EXTENSION
1045 #define CHECK_EXTENSION(EXTNAME) \
1046 if (!ctx->Extensions.EXTNAME) { \
1047 goto invalid_enum_error; \
1050 #undef CHECK_EXTENSION2
1051 #define CHECK_EXTENSION2(EXT1, EXT2) \
1052 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1053 goto invalid_enum_error; \
1058 * Helper function to determine whether a texture target is enabled.
1061 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1063 const struct gl_texture_unit
*const texUnit
=
1064 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1065 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1070 * Return simple enable/disable state.
1072 * \param cap state variable to query.
1074 * Returns the state of the specified capability from the current GL context.
1075 * For the capabilities associated with extensions verifies that those
1076 * extensions are effectively present before reporting.
1078 GLboolean GLAPIENTRY
1079 _mesa_IsEnabled( GLenum cap
)
1081 GET_CURRENT_CONTEXT(ctx
);
1084 return ctx
->Color
.AlphaEnabled
;
1085 case GL_AUTO_NORMAL
:
1086 return ctx
->Eval
.AutoNormal
;
1088 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1089 case GL_CLIP_PLANE0
:
1090 case GL_CLIP_PLANE1
:
1091 case GL_CLIP_PLANE2
:
1092 case GL_CLIP_PLANE3
:
1093 case GL_CLIP_PLANE4
:
1094 case GL_CLIP_PLANE5
:
1095 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1096 case GL_COLOR_MATERIAL
:
1097 return ctx
->Light
.ColorMaterialEnabled
;
1099 return ctx
->Polygon
.CullFlag
;
1101 return ctx
->Depth
.Test
;
1103 return ctx
->Color
.DitherFlag
;
1105 return ctx
->Fog
.Enabled
;
1107 return ctx
->Light
.Enabled
;
1116 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1117 case GL_LINE_SMOOTH
:
1118 return ctx
->Line
.SmoothFlag
;
1119 case GL_LINE_STIPPLE
:
1120 return ctx
->Line
.StippleFlag
;
1121 case GL_INDEX_LOGIC_OP
:
1122 return ctx
->Color
.IndexLogicOpEnabled
;
1123 case GL_COLOR_LOGIC_OP
:
1124 return ctx
->Color
.ColorLogicOpEnabled
;
1125 case GL_MAP1_COLOR_4
:
1126 return ctx
->Eval
.Map1Color4
;
1128 return ctx
->Eval
.Map1Index
;
1129 case GL_MAP1_NORMAL
:
1130 return ctx
->Eval
.Map1Normal
;
1131 case GL_MAP1_TEXTURE_COORD_1
:
1132 return ctx
->Eval
.Map1TextureCoord1
;
1133 case GL_MAP1_TEXTURE_COORD_2
:
1134 return ctx
->Eval
.Map1TextureCoord2
;
1135 case GL_MAP1_TEXTURE_COORD_3
:
1136 return ctx
->Eval
.Map1TextureCoord3
;
1137 case GL_MAP1_TEXTURE_COORD_4
:
1138 return ctx
->Eval
.Map1TextureCoord4
;
1139 case GL_MAP1_VERTEX_3
:
1140 return ctx
->Eval
.Map1Vertex3
;
1141 case GL_MAP1_VERTEX_4
:
1142 return ctx
->Eval
.Map1Vertex4
;
1143 case GL_MAP2_COLOR_4
:
1144 return ctx
->Eval
.Map2Color4
;
1146 return ctx
->Eval
.Map2Index
;
1147 case GL_MAP2_NORMAL
:
1148 return ctx
->Eval
.Map2Normal
;
1149 case GL_MAP2_TEXTURE_COORD_1
:
1150 return ctx
->Eval
.Map2TextureCoord1
;
1151 case GL_MAP2_TEXTURE_COORD_2
:
1152 return ctx
->Eval
.Map2TextureCoord2
;
1153 case GL_MAP2_TEXTURE_COORD_3
:
1154 return ctx
->Eval
.Map2TextureCoord3
;
1155 case GL_MAP2_TEXTURE_COORD_4
:
1156 return ctx
->Eval
.Map2TextureCoord4
;
1157 case GL_MAP2_VERTEX_3
:
1158 return ctx
->Eval
.Map2Vertex3
;
1159 case GL_MAP2_VERTEX_4
:
1160 return ctx
->Eval
.Map2Vertex4
;
1162 return ctx
->Transform
.Normalize
;
1163 case GL_POINT_SMOOTH
:
1164 return ctx
->Point
.SmoothFlag
;
1165 case GL_POLYGON_SMOOTH
:
1166 return ctx
->Polygon
.SmoothFlag
;
1167 case GL_POLYGON_STIPPLE
:
1168 return ctx
->Polygon
.StippleFlag
;
1169 case GL_POLYGON_OFFSET_POINT
:
1170 return ctx
->Polygon
.OffsetPoint
;
1171 case GL_POLYGON_OFFSET_LINE
:
1172 return ctx
->Polygon
.OffsetLine
;
1173 case GL_POLYGON_OFFSET_FILL
:
1174 /*case GL_POLYGON_OFFSET_EXT:*/
1175 return ctx
->Polygon
.OffsetFill
;
1176 case GL_RESCALE_NORMAL_EXT
:
1177 return ctx
->Transform
.RescaleNormals
;
1178 case GL_SCISSOR_TEST
:
1179 return ctx
->Scissor
.Enabled
;
1180 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1181 return ctx
->Texture
.SharedPalette
;
1182 case GL_STENCIL_TEST
:
1183 return ctx
->Stencil
.Enabled
;
1185 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1187 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1189 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1190 case GL_TEXTURE_GEN_S
:
1191 case GL_TEXTURE_GEN_T
:
1192 case GL_TEXTURE_GEN_R
:
1193 case GL_TEXTURE_GEN_Q
:
1195 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1197 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1198 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1203 case GL_TEXTURE_GEN_STR_OES
:
1205 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1207 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1208 ? GL_TRUE
: GL_FALSE
;
1216 case GL_VERTEX_ARRAY
:
1217 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1218 case GL_NORMAL_ARRAY
:
1219 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1220 case GL_COLOR_ARRAY
:
1221 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1222 case GL_INDEX_ARRAY
:
1223 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1224 case GL_TEXTURE_COORD_ARRAY
:
1225 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
]
1227 case GL_EDGE_FLAG_ARRAY
:
1228 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1229 case GL_FOG_COORDINATE_ARRAY_EXT
:
1230 CHECK_EXTENSION(EXT_fog_coord
);
1231 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1232 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1233 CHECK_EXTENSION(EXT_secondary_color
);
1234 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1235 #if FEATURE_point_size_array
1236 case GL_POINT_SIZE_ARRAY_OES
:
1237 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1240 /* GL_ARB_texture_cube_map */
1241 case GL_TEXTURE_CUBE_MAP_ARB
:
1242 CHECK_EXTENSION(ARB_texture_cube_map
);
1243 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1245 /* GL_EXT_secondary_color */
1246 case GL_COLOR_SUM_EXT
:
1247 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1248 return ctx
->Fog
.ColorSumEnabled
;
1250 /* GL_ARB_multisample */
1251 case GL_MULTISAMPLE_ARB
:
1252 return ctx
->Multisample
.Enabled
;
1253 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1254 return ctx
->Multisample
.SampleAlphaToCoverage
;
1255 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1256 return ctx
->Multisample
.SampleAlphaToOne
;
1257 case GL_SAMPLE_COVERAGE_ARB
:
1258 return ctx
->Multisample
.SampleCoverage
;
1259 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1260 return ctx
->Multisample
.SampleCoverageInvert
;
1262 /* GL_IBM_rasterpos_clip */
1263 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1264 CHECK_EXTENSION(IBM_rasterpos_clip
);
1265 return ctx
->Transform
.RasterPositionUnclipped
;
1267 /* GL_NV_point_sprite */
1268 case GL_POINT_SPRITE_NV
:
1269 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1270 return ctx
->Point
.PointSprite
;
1272 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1273 case GL_VERTEX_PROGRAM_ARB
:
1274 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1275 return ctx
->VertexProgram
.Enabled
;
1276 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1277 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1278 return ctx
->VertexProgram
.PointSizeEnabled
;
1279 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1280 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1281 return ctx
->VertexProgram
.TwoSideEnabled
;
1283 #if FEATURE_NV_vertex_program
1284 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1285 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1286 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1287 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1288 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1289 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1290 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1291 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1292 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1293 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1294 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1295 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1296 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1297 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1298 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1299 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1300 CHECK_EXTENSION(NV_vertex_program
);
1302 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1303 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1304 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1306 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1307 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1308 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1309 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1310 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1311 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1312 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1313 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1314 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1315 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1316 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1317 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1318 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1319 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1320 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1321 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1322 CHECK_EXTENSION(NV_vertex_program
);
1324 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1325 return ctx
->Eval
.Map1Attrib
[map
];
1327 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1328 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1329 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1330 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1331 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1332 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1333 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1334 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1335 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1336 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1337 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1338 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1339 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1340 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1341 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1342 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1343 CHECK_EXTENSION(NV_vertex_program
);
1345 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1346 return ctx
->Eval
.Map2Attrib
[map
];
1348 #endif /* FEATURE_NV_vertex_program */
1350 #if FEATURE_NV_fragment_program
1351 case GL_FRAGMENT_PROGRAM_NV
:
1352 CHECK_EXTENSION(NV_fragment_program
);
1353 return ctx
->FragmentProgram
.Enabled
;
1354 #endif /* FEATURE_NV_fragment_program */
1356 /* GL_NV_texture_rectangle */
1357 case GL_TEXTURE_RECTANGLE_NV
:
1358 CHECK_EXTENSION(NV_texture_rectangle
);
1359 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1361 /* GL_EXT_stencil_two_side */
1362 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1363 CHECK_EXTENSION(EXT_stencil_two_side
);
1364 return ctx
->Stencil
.TestTwoSide
;
1366 #if FEATURE_ARB_fragment_program
1367 case GL_FRAGMENT_PROGRAM_ARB
:
1368 return ctx
->FragmentProgram
.Enabled
;
1369 #endif /* FEATURE_ARB_fragment_program */
1371 /* GL_EXT_depth_bounds_test */
1372 case GL_DEPTH_BOUNDS_TEST_EXT
:
1373 CHECK_EXTENSION(EXT_depth_bounds_test
);
1374 return ctx
->Depth
.BoundsTest
;
1376 /* GL_ARB_depth_clamp */
1377 case GL_DEPTH_CLAMP
:
1378 CHECK_EXTENSION(ARB_depth_clamp
);
1379 return ctx
->Transform
.DepthClamp
;
1381 #if FEATURE_ATI_fragment_shader
1382 case GL_FRAGMENT_SHADER_ATI
:
1383 CHECK_EXTENSION(ATI_fragment_shader
);
1384 return ctx
->ATIFragmentShader
.Enabled
;
1385 #endif /* FEATURE_ATI_fragment_shader */
1387 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1388 CHECK_EXTENSION(ARB_seamless_cube_map
);
1389 return ctx
->Texture
.CubeMapSeamless
;
1391 #if FEATURE_EXT_transform_feedback
1392 case GL_RASTERIZER_DISCARD
:
1393 CHECK_EXTENSION(EXT_transform_feedback
);
1394 return ctx
->TransformFeedback
.RasterDiscard
;
1397 /* GL_NV_primitive_restart */
1398 case GL_PRIMITIVE_RESTART_NV
:
1399 if (!ctx
->Extensions
.NV_primitive_restart
) {
1400 goto invalid_enum_error
;
1402 return ctx
->Array
.PrimitiveRestart
;
1404 /* GL 3.1 primitive restart */
1405 case GL_PRIMITIVE_RESTART
:
1406 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1407 goto invalid_enum_error
;
1409 return ctx
->Array
.PrimitiveRestart
;
1411 /* GL3.0 - GL_framebuffer_sRGB */
1412 case GL_FRAMEBUFFER_SRGB_EXT
:
1413 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1414 return ctx
->Color
.sRGBEnabled
;
1417 goto invalid_enum_error
;
1423 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);