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
;
305 const GLuint p
= cap
- GL_CLIP_PLANE0
;
307 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
308 == ((GLuint
) state
<< p
))
311 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
314 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
315 _mesa_update_clip_plane(ctx
, p
);
318 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
323 case GL_COLOR_MATERIAL
:
324 if (ctx
->Light
.ColorMaterialEnabled
== state
)
326 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
327 FLUSH_CURRENT(ctx
, 0);
328 ctx
->Light
.ColorMaterialEnabled
= state
;
330 _mesa_update_color_material( ctx
,
331 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
335 if (ctx
->Polygon
.CullFlag
== state
)
337 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
338 ctx
->Polygon
.CullFlag
= state
;
341 if (ctx
->Depth
.Test
== state
)
343 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
344 ctx
->Depth
.Test
= state
;
347 if (ctx
->Color
.DitherFlag
== state
)
349 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
350 ctx
->Color
.DitherFlag
= state
;
353 if (ctx
->Fog
.Enabled
== state
)
355 FLUSH_VERTICES(ctx
, _NEW_FOG
);
356 ctx
->Fog
.Enabled
= state
;
366 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
368 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
369 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
371 insert_at_tail(&ctx
->Light
.EnabledList
,
372 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
375 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
379 if (ctx
->Light
.Enabled
== state
)
381 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
382 ctx
->Light
.Enabled
= state
;
383 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
384 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
386 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
389 if (ctx
->Line
.SmoothFlag
== state
)
391 FLUSH_VERTICES(ctx
, _NEW_LINE
);
392 ctx
->Line
.SmoothFlag
= state
;
393 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
395 case GL_LINE_STIPPLE
:
396 if (ctx
->Line
.StippleFlag
== state
)
398 FLUSH_VERTICES(ctx
, _NEW_LINE
);
399 ctx
->Line
.StippleFlag
= state
;
400 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
402 case GL_INDEX_LOGIC_OP
:
403 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
405 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
406 ctx
->Color
.IndexLogicOpEnabled
= state
;
408 case GL_COLOR_LOGIC_OP
:
409 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
411 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
412 ctx
->Color
.ColorLogicOpEnabled
= state
;
414 case GL_MAP1_COLOR_4
:
415 if (ctx
->Eval
.Map1Color4
== state
)
417 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
418 ctx
->Eval
.Map1Color4
= state
;
421 if (ctx
->Eval
.Map1Index
== state
)
423 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
424 ctx
->Eval
.Map1Index
= state
;
427 if (ctx
->Eval
.Map1Normal
== state
)
429 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
430 ctx
->Eval
.Map1Normal
= state
;
432 case GL_MAP1_TEXTURE_COORD_1
:
433 if (ctx
->Eval
.Map1TextureCoord1
== state
)
435 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
436 ctx
->Eval
.Map1TextureCoord1
= state
;
438 case GL_MAP1_TEXTURE_COORD_2
:
439 if (ctx
->Eval
.Map1TextureCoord2
== state
)
441 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
442 ctx
->Eval
.Map1TextureCoord2
= state
;
444 case GL_MAP1_TEXTURE_COORD_3
:
445 if (ctx
->Eval
.Map1TextureCoord3
== state
)
447 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
448 ctx
->Eval
.Map1TextureCoord3
= state
;
450 case GL_MAP1_TEXTURE_COORD_4
:
451 if (ctx
->Eval
.Map1TextureCoord4
== state
)
453 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
454 ctx
->Eval
.Map1TextureCoord4
= state
;
456 case GL_MAP1_VERTEX_3
:
457 if (ctx
->Eval
.Map1Vertex3
== state
)
459 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
460 ctx
->Eval
.Map1Vertex3
= state
;
462 case GL_MAP1_VERTEX_4
:
463 if (ctx
->Eval
.Map1Vertex4
== state
)
465 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
466 ctx
->Eval
.Map1Vertex4
= state
;
468 case GL_MAP2_COLOR_4
:
469 if (ctx
->Eval
.Map2Color4
== state
)
471 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
472 ctx
->Eval
.Map2Color4
= state
;
475 if (ctx
->Eval
.Map2Index
== state
)
477 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
478 ctx
->Eval
.Map2Index
= state
;
481 if (ctx
->Eval
.Map2Normal
== state
)
483 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
484 ctx
->Eval
.Map2Normal
= state
;
486 case GL_MAP2_TEXTURE_COORD_1
:
487 if (ctx
->Eval
.Map2TextureCoord1
== state
)
489 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
490 ctx
->Eval
.Map2TextureCoord1
= state
;
492 case GL_MAP2_TEXTURE_COORD_2
:
493 if (ctx
->Eval
.Map2TextureCoord2
== state
)
495 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
496 ctx
->Eval
.Map2TextureCoord2
= state
;
498 case GL_MAP2_TEXTURE_COORD_3
:
499 if (ctx
->Eval
.Map2TextureCoord3
== state
)
501 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
502 ctx
->Eval
.Map2TextureCoord3
= state
;
504 case GL_MAP2_TEXTURE_COORD_4
:
505 if (ctx
->Eval
.Map2TextureCoord4
== state
)
507 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
508 ctx
->Eval
.Map2TextureCoord4
= state
;
510 case GL_MAP2_VERTEX_3
:
511 if (ctx
->Eval
.Map2Vertex3
== state
)
513 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
514 ctx
->Eval
.Map2Vertex3
= state
;
516 case GL_MAP2_VERTEX_4
:
517 if (ctx
->Eval
.Map2Vertex4
== state
)
519 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
520 ctx
->Eval
.Map2Vertex4
= state
;
523 if (ctx
->Transform
.Normalize
== state
)
525 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
526 ctx
->Transform
.Normalize
= state
;
528 case GL_POINT_SMOOTH
:
529 if (ctx
->Point
.SmoothFlag
== state
)
531 FLUSH_VERTICES(ctx
, _NEW_POINT
);
532 ctx
->Point
.SmoothFlag
= state
;
533 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
535 case GL_POLYGON_SMOOTH
:
536 if (ctx
->Polygon
.SmoothFlag
== state
)
538 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
539 ctx
->Polygon
.SmoothFlag
= state
;
540 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
542 case GL_POLYGON_STIPPLE
:
543 if (ctx
->Polygon
.StippleFlag
== state
)
545 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
546 ctx
->Polygon
.StippleFlag
= state
;
547 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
549 case GL_POLYGON_OFFSET_POINT
:
550 if (ctx
->Polygon
.OffsetPoint
== state
)
552 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
553 ctx
->Polygon
.OffsetPoint
= state
;
555 case GL_POLYGON_OFFSET_LINE
:
556 if (ctx
->Polygon
.OffsetLine
== state
)
558 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
559 ctx
->Polygon
.OffsetLine
= state
;
561 case GL_POLYGON_OFFSET_FILL
:
562 if (ctx
->Polygon
.OffsetFill
== state
)
564 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
565 ctx
->Polygon
.OffsetFill
= state
;
567 case GL_RESCALE_NORMAL_EXT
:
568 if (ctx
->Transform
.RescaleNormals
== state
)
570 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
571 ctx
->Transform
.RescaleNormals
= state
;
573 case GL_SCISSOR_TEST
:
574 if (ctx
->Scissor
.Enabled
== state
)
576 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
577 ctx
->Scissor
.Enabled
= state
;
579 case GL_STENCIL_TEST
:
580 if (ctx
->Stencil
.Enabled
== state
)
582 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
583 ctx
->Stencil
.Enabled
= state
;
586 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
591 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
596 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
600 case GL_TEXTURE_GEN_S
:
601 case GL_TEXTURE_GEN_T
:
602 case GL_TEXTURE_GEN_R
:
603 case GL_TEXTURE_GEN_Q
:
605 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
607 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
608 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
610 newenabled
|= coordBit
;
611 if (texUnit
->TexGenEnabled
== newenabled
)
613 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
614 texUnit
->TexGenEnabled
= newenabled
;
620 case GL_TEXTURE_GEN_STR_OES
:
621 /* disable S, T, and R at the same time */
623 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
626 texUnit
->TexGenEnabled
& ~STR_BITS
;
628 newenabled
|= STR_BITS
;
629 if (texUnit
->TexGenEnabled
== newenabled
)
631 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
632 texUnit
->TexGenEnabled
= newenabled
;
638 /* client-side state */
639 case GL_VERTEX_ARRAY
:
640 case GL_NORMAL_ARRAY
:
643 case GL_TEXTURE_COORD_ARRAY
:
644 case GL_EDGE_FLAG_ARRAY
:
645 case GL_FOG_COORDINATE_ARRAY_EXT
:
646 case GL_SECONDARY_COLOR_ARRAY_EXT
:
647 case GL_POINT_SIZE_ARRAY_OES
:
648 client_state( ctx
, cap
, state
);
651 /* GL_ARB_texture_cube_map */
652 case GL_TEXTURE_CUBE_MAP_ARB
:
653 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
654 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
659 /* GL_EXT_secondary_color */
660 case GL_COLOR_SUM_EXT
:
661 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
662 if (ctx
->Fog
.ColorSumEnabled
== state
)
664 FLUSH_VERTICES(ctx
, _NEW_FOG
);
665 ctx
->Fog
.ColorSumEnabled
= state
;
668 /* GL_ARB_multisample */
669 case GL_MULTISAMPLE_ARB
:
670 if (ctx
->Multisample
.Enabled
== state
)
672 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
673 ctx
->Multisample
.Enabled
= state
;
675 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
676 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
678 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
679 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
681 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
682 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
684 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
685 ctx
->Multisample
.SampleAlphaToOne
= state
;
687 case GL_SAMPLE_COVERAGE_ARB
:
688 if (ctx
->Multisample
.SampleCoverage
== state
)
690 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
691 ctx
->Multisample
.SampleCoverage
= state
;
693 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
694 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
696 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
697 ctx
->Multisample
.SampleCoverageInvert
= state
;
700 /* GL_IBM_rasterpos_clip */
701 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
702 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
703 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
705 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
706 ctx
->Transform
.RasterPositionUnclipped
= state
;
709 /* GL_NV_point_sprite */
710 case GL_POINT_SPRITE_NV
:
711 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
712 if (ctx
->Point
.PointSprite
== state
)
714 FLUSH_VERTICES(ctx
, _NEW_POINT
);
715 ctx
->Point
.PointSprite
= state
;
718 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
719 case GL_VERTEX_PROGRAM_ARB
:
720 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
721 if (ctx
->VertexProgram
.Enabled
== state
)
723 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
724 ctx
->VertexProgram
.Enabled
= state
;
726 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
727 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
728 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
730 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
731 ctx
->VertexProgram
.PointSizeEnabled
= state
;
733 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
734 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
735 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
737 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
738 ctx
->VertexProgram
.TwoSideEnabled
= state
;
741 #if FEATURE_NV_vertex_program
742 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
743 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
744 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
745 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
746 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
747 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
748 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
749 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
750 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
751 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
752 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
753 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
754 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
755 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
756 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
757 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
758 CHECK_EXTENSION(NV_vertex_program
, cap
);
760 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
761 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
762 ctx
->Eval
.Map1Attrib
[map
] = state
;
765 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
766 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
767 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
768 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
769 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
770 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
771 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
772 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
773 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
774 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
775 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
776 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
777 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
778 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
779 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
780 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
781 CHECK_EXTENSION(NV_vertex_program
, cap
);
783 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
784 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
785 ctx
->Eval
.Map2Attrib
[map
] = state
;
788 #endif /* FEATURE_NV_vertex_program */
790 #if FEATURE_NV_fragment_program
791 case GL_FRAGMENT_PROGRAM_NV
:
792 CHECK_EXTENSION(NV_fragment_program
, cap
);
793 if (ctx
->FragmentProgram
.Enabled
== state
)
795 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
796 ctx
->FragmentProgram
.Enabled
= state
;
798 #endif /* FEATURE_NV_fragment_program */
800 /* GL_NV_texture_rectangle */
801 case GL_TEXTURE_RECTANGLE_NV
:
802 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
803 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
808 /* GL_EXT_stencil_two_side */
809 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
810 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
811 if (ctx
->Stencil
.TestTwoSide
== state
)
813 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
814 ctx
->Stencil
.TestTwoSide
= state
;
816 ctx
->Stencil
._BackFace
= 2;
817 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
819 ctx
->Stencil
._BackFace
= 1;
820 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
824 #if FEATURE_ARB_fragment_program
825 case GL_FRAGMENT_PROGRAM_ARB
:
826 CHECK_EXTENSION(ARB_fragment_program
, cap
);
827 if (ctx
->FragmentProgram
.Enabled
== state
)
829 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
830 ctx
->FragmentProgram
.Enabled
= state
;
832 #endif /* FEATURE_ARB_fragment_program */
834 /* GL_EXT_depth_bounds_test */
835 case GL_DEPTH_BOUNDS_TEST_EXT
:
836 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
837 if (ctx
->Depth
.BoundsTest
== state
)
839 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
840 ctx
->Depth
.BoundsTest
= state
;
844 if (ctx
->Transform
.DepthClamp
== state
)
846 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
847 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
848 ctx
->Transform
.DepthClamp
= state
;
851 #if FEATURE_ATI_fragment_shader
852 case GL_FRAGMENT_SHADER_ATI
:
853 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
854 if (ctx
->ATIFragmentShader
.Enabled
== state
)
856 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
857 ctx
->ATIFragmentShader
.Enabled
= state
;
861 /* GL_MESA_texture_array */
862 case GL_TEXTURE_1D_ARRAY_EXT
:
863 CHECK_EXTENSION(MESA_texture_array
, cap
);
864 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
869 case GL_TEXTURE_2D_ARRAY_EXT
:
870 CHECK_EXTENSION(MESA_texture_array
, cap
);
871 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
876 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
877 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
878 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
879 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
880 ctx
->Texture
.CubeMapSeamless
= state
;
884 #if FEATURE_EXT_transform_feedback
885 case GL_RASTERIZER_DISCARD
:
886 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
887 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
888 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
889 ctx
->TransformFeedback
.RasterDiscard
= state
;
894 /* GL 3.1 primitive restart. Note: this enum is different from
895 * GL_PRIMITIVE_RESTART_NV (which is client state).
897 case GL_PRIMITIVE_RESTART
:
898 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
899 goto invalid_enum_error
;
901 if (ctx
->Array
.PrimitiveRestart
!= state
) {
902 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
903 ctx
->Array
.PrimitiveRestart
= state
;
907 /* GL3.0 - GL_framebuffer_sRGB */
908 case GL_FRAMEBUFFER_SRGB_EXT
:
909 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
910 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
911 ctx
->Color
.sRGBEnabled
= state
;
915 goto invalid_enum_error
;
918 if (ctx
->Driver
.Enable
) {
919 ctx
->Driver
.Enable( ctx
, cap
, state
);
925 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
926 state
? "Enable" : "Disable", cap
);
931 * Enable GL capability. Called by glEnable()
932 * \param cap state to enable.
935 _mesa_Enable( GLenum cap
)
937 GET_CURRENT_CONTEXT(ctx
);
938 ASSERT_OUTSIDE_BEGIN_END(ctx
);
940 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
945 * Disable GL capability. Called by glDisable()
946 * \param cap state to disable.
949 _mesa_Disable( GLenum cap
)
951 GET_CURRENT_CONTEXT(ctx
);
952 ASSERT_OUTSIDE_BEGIN_END(ctx
);
954 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
960 * Enable/disable an indexed state var.
963 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
964 GLuint index
, GLboolean state
)
966 ASSERT(state
== 0 || state
== 1);
969 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
970 goto invalid_enum_error
;
972 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
973 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
974 state
? "glEnableIndexed" : "glDisableIndexed", index
);
977 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
978 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
980 ctx
->Color
.BlendEnabled
|= (1 << index
);
982 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
986 goto invalid_enum_error
;
991 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
992 state
? "glEnablei" : "glDisablei",
993 _mesa_lookup_enum_by_nr(cap
));
998 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1000 GET_CURRENT_CONTEXT(ctx
);
1001 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1002 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1007 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1009 GET_CURRENT_CONTEXT(ctx
);
1010 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1011 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1015 GLboolean GLAPIENTRY
1016 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1018 GET_CURRENT_CONTEXT(ctx
);
1019 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1022 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1023 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1027 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1029 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1030 _mesa_lookup_enum_by_nr(cap
));
1038 #undef CHECK_EXTENSION
1039 #define CHECK_EXTENSION(EXTNAME) \
1040 if (!ctx->Extensions.EXTNAME) { \
1041 goto invalid_enum_error; \
1044 #undef CHECK_EXTENSION2
1045 #define CHECK_EXTENSION2(EXT1, EXT2) \
1046 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1047 goto invalid_enum_error; \
1052 * Helper function to determine whether a texture target is enabled.
1055 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1057 const struct gl_texture_unit
*const texUnit
=
1058 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1059 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1064 * Return simple enable/disable state.
1066 * \param cap state variable to query.
1068 * Returns the state of the specified capability from the current GL context.
1069 * For the capabilities associated with extensions verifies that those
1070 * extensions are effectively present before reporting.
1072 GLboolean GLAPIENTRY
1073 _mesa_IsEnabled( GLenum cap
)
1075 GET_CURRENT_CONTEXT(ctx
);
1076 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1080 return ctx
->Color
.AlphaEnabled
;
1081 case GL_AUTO_NORMAL
:
1082 return ctx
->Eval
.AutoNormal
;
1084 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1085 case GL_CLIP_PLANE0
:
1086 case GL_CLIP_PLANE1
:
1087 case GL_CLIP_PLANE2
:
1088 case GL_CLIP_PLANE3
:
1089 case GL_CLIP_PLANE4
:
1090 case GL_CLIP_PLANE5
:
1091 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1092 case GL_COLOR_MATERIAL
:
1093 return ctx
->Light
.ColorMaterialEnabled
;
1095 return ctx
->Polygon
.CullFlag
;
1097 return ctx
->Depth
.Test
;
1099 return ctx
->Color
.DitherFlag
;
1101 return ctx
->Fog
.Enabled
;
1103 return ctx
->Light
.Enabled
;
1112 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1113 case GL_LINE_SMOOTH
:
1114 return ctx
->Line
.SmoothFlag
;
1115 case GL_LINE_STIPPLE
:
1116 return ctx
->Line
.StippleFlag
;
1117 case GL_INDEX_LOGIC_OP
:
1118 return ctx
->Color
.IndexLogicOpEnabled
;
1119 case GL_COLOR_LOGIC_OP
:
1120 return ctx
->Color
.ColorLogicOpEnabled
;
1121 case GL_MAP1_COLOR_4
:
1122 return ctx
->Eval
.Map1Color4
;
1124 return ctx
->Eval
.Map1Index
;
1125 case GL_MAP1_NORMAL
:
1126 return ctx
->Eval
.Map1Normal
;
1127 case GL_MAP1_TEXTURE_COORD_1
:
1128 return ctx
->Eval
.Map1TextureCoord1
;
1129 case GL_MAP1_TEXTURE_COORD_2
:
1130 return ctx
->Eval
.Map1TextureCoord2
;
1131 case GL_MAP1_TEXTURE_COORD_3
:
1132 return ctx
->Eval
.Map1TextureCoord3
;
1133 case GL_MAP1_TEXTURE_COORD_4
:
1134 return ctx
->Eval
.Map1TextureCoord4
;
1135 case GL_MAP1_VERTEX_3
:
1136 return ctx
->Eval
.Map1Vertex3
;
1137 case GL_MAP1_VERTEX_4
:
1138 return ctx
->Eval
.Map1Vertex4
;
1139 case GL_MAP2_COLOR_4
:
1140 return ctx
->Eval
.Map2Color4
;
1142 return ctx
->Eval
.Map2Index
;
1143 case GL_MAP2_NORMAL
:
1144 return ctx
->Eval
.Map2Normal
;
1145 case GL_MAP2_TEXTURE_COORD_1
:
1146 return ctx
->Eval
.Map2TextureCoord1
;
1147 case GL_MAP2_TEXTURE_COORD_2
:
1148 return ctx
->Eval
.Map2TextureCoord2
;
1149 case GL_MAP2_TEXTURE_COORD_3
:
1150 return ctx
->Eval
.Map2TextureCoord3
;
1151 case GL_MAP2_TEXTURE_COORD_4
:
1152 return ctx
->Eval
.Map2TextureCoord4
;
1153 case GL_MAP2_VERTEX_3
:
1154 return ctx
->Eval
.Map2Vertex3
;
1155 case GL_MAP2_VERTEX_4
:
1156 return ctx
->Eval
.Map2Vertex4
;
1158 return ctx
->Transform
.Normalize
;
1159 case GL_POINT_SMOOTH
:
1160 return ctx
->Point
.SmoothFlag
;
1161 case GL_POLYGON_SMOOTH
:
1162 return ctx
->Polygon
.SmoothFlag
;
1163 case GL_POLYGON_STIPPLE
:
1164 return ctx
->Polygon
.StippleFlag
;
1165 case GL_POLYGON_OFFSET_POINT
:
1166 return ctx
->Polygon
.OffsetPoint
;
1167 case GL_POLYGON_OFFSET_LINE
:
1168 return ctx
->Polygon
.OffsetLine
;
1169 case GL_POLYGON_OFFSET_FILL
:
1170 return ctx
->Polygon
.OffsetFill
;
1171 case GL_RESCALE_NORMAL_EXT
:
1172 return ctx
->Transform
.RescaleNormals
;
1173 case GL_SCISSOR_TEST
:
1174 return ctx
->Scissor
.Enabled
;
1175 case GL_STENCIL_TEST
:
1176 return ctx
->Stencil
.Enabled
;
1178 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1180 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1182 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1183 case GL_TEXTURE_GEN_S
:
1184 case GL_TEXTURE_GEN_T
:
1185 case GL_TEXTURE_GEN_R
:
1186 case GL_TEXTURE_GEN_Q
:
1188 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1190 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1191 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1196 case GL_TEXTURE_GEN_STR_OES
:
1198 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1200 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1201 ? GL_TRUE
: GL_FALSE
;
1206 /* client-side state */
1207 case GL_VERTEX_ARRAY
:
1208 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1209 case GL_NORMAL_ARRAY
:
1210 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1211 case GL_COLOR_ARRAY
:
1212 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1213 case GL_INDEX_ARRAY
:
1214 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1215 case GL_TEXTURE_COORD_ARRAY
:
1216 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
]
1218 case GL_EDGE_FLAG_ARRAY
:
1219 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1220 case GL_FOG_COORDINATE_ARRAY_EXT
:
1221 CHECK_EXTENSION(EXT_fog_coord
);
1222 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1223 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1224 CHECK_EXTENSION(EXT_secondary_color
);
1225 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1226 #if FEATURE_point_size_array
1227 case GL_POINT_SIZE_ARRAY_OES
:
1228 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1231 /* GL_ARB_texture_cube_map */
1232 case GL_TEXTURE_CUBE_MAP_ARB
:
1233 CHECK_EXTENSION(ARB_texture_cube_map
);
1234 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1236 /* GL_EXT_secondary_color */
1237 case GL_COLOR_SUM_EXT
:
1238 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1239 return ctx
->Fog
.ColorSumEnabled
;
1241 /* GL_ARB_multisample */
1242 case GL_MULTISAMPLE_ARB
:
1243 return ctx
->Multisample
.Enabled
;
1244 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1245 return ctx
->Multisample
.SampleAlphaToCoverage
;
1246 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1247 return ctx
->Multisample
.SampleAlphaToOne
;
1248 case GL_SAMPLE_COVERAGE_ARB
:
1249 return ctx
->Multisample
.SampleCoverage
;
1250 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1251 return ctx
->Multisample
.SampleCoverageInvert
;
1253 /* GL_IBM_rasterpos_clip */
1254 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1255 CHECK_EXTENSION(IBM_rasterpos_clip
);
1256 return ctx
->Transform
.RasterPositionUnclipped
;
1258 /* GL_NV_point_sprite */
1259 case GL_POINT_SPRITE_NV
:
1260 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1261 return ctx
->Point
.PointSprite
;
1263 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1264 case GL_VERTEX_PROGRAM_ARB
:
1265 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1266 return ctx
->VertexProgram
.Enabled
;
1267 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1268 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1269 return ctx
->VertexProgram
.PointSizeEnabled
;
1270 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1271 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1272 return ctx
->VertexProgram
.TwoSideEnabled
;
1274 #if FEATURE_NV_vertex_program
1275 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1276 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1277 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1278 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1279 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1280 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1281 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1282 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1283 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1284 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1285 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1286 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1287 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1288 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1289 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1290 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1291 CHECK_EXTENSION(NV_vertex_program
);
1293 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1294 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1295 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1297 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1298 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1299 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1300 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1301 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1302 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1303 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1304 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1305 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1306 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1307 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1308 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1309 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1310 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1311 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1312 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1313 CHECK_EXTENSION(NV_vertex_program
);
1315 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1316 return ctx
->Eval
.Map1Attrib
[map
];
1318 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1319 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1320 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1321 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1322 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1323 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1324 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1325 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1326 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1327 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1328 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1329 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1330 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1331 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1332 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1333 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1334 CHECK_EXTENSION(NV_vertex_program
);
1336 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1337 return ctx
->Eval
.Map2Attrib
[map
];
1339 #endif /* FEATURE_NV_vertex_program */
1341 #if FEATURE_NV_fragment_program
1342 case GL_FRAGMENT_PROGRAM_NV
:
1343 CHECK_EXTENSION(NV_fragment_program
);
1344 return ctx
->FragmentProgram
.Enabled
;
1345 #endif /* FEATURE_NV_fragment_program */
1347 /* GL_NV_texture_rectangle */
1348 case GL_TEXTURE_RECTANGLE_NV
:
1349 CHECK_EXTENSION(NV_texture_rectangle
);
1350 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1352 /* GL_EXT_stencil_two_side */
1353 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1354 CHECK_EXTENSION(EXT_stencil_two_side
);
1355 return ctx
->Stencil
.TestTwoSide
;
1357 #if FEATURE_ARB_fragment_program
1358 case GL_FRAGMENT_PROGRAM_ARB
:
1359 return ctx
->FragmentProgram
.Enabled
;
1360 #endif /* FEATURE_ARB_fragment_program */
1362 /* GL_EXT_depth_bounds_test */
1363 case GL_DEPTH_BOUNDS_TEST_EXT
:
1364 CHECK_EXTENSION(EXT_depth_bounds_test
);
1365 return ctx
->Depth
.BoundsTest
;
1367 /* GL_ARB_depth_clamp */
1368 case GL_DEPTH_CLAMP
:
1369 CHECK_EXTENSION(ARB_depth_clamp
);
1370 return ctx
->Transform
.DepthClamp
;
1372 #if FEATURE_ATI_fragment_shader
1373 case GL_FRAGMENT_SHADER_ATI
:
1374 CHECK_EXTENSION(ATI_fragment_shader
);
1375 return ctx
->ATIFragmentShader
.Enabled
;
1376 #endif /* FEATURE_ATI_fragment_shader */
1378 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1379 CHECK_EXTENSION(ARB_seamless_cube_map
);
1380 return ctx
->Texture
.CubeMapSeamless
;
1382 #if FEATURE_EXT_transform_feedback
1383 case GL_RASTERIZER_DISCARD
:
1384 CHECK_EXTENSION(EXT_transform_feedback
);
1385 return ctx
->TransformFeedback
.RasterDiscard
;
1388 /* GL_NV_primitive_restart */
1389 case GL_PRIMITIVE_RESTART_NV
:
1390 if (!ctx
->Extensions
.NV_primitive_restart
) {
1391 goto invalid_enum_error
;
1393 return ctx
->Array
.PrimitiveRestart
;
1395 /* GL 3.1 primitive restart */
1396 case GL_PRIMITIVE_RESTART
:
1397 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1398 goto invalid_enum_error
;
1400 return ctx
->Array
.PrimitiveRestart
;
1402 /* GL3.0 - GL_framebuffer_sRGB */
1403 case GL_FRAMEBUFFER_SRGB_EXT
:
1404 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1405 return ctx
->Color
.sRGBEnabled
;
1408 goto invalid_enum_error
;
1414 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);