3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 #include "simple_list.h"
36 #include "mfeatures.h"
39 #include "api_arrayelt.h"
44 #define CHECK_EXTENSION(EXTNAME, CAP) \
45 if (!ctx->Extensions.EXTNAME) { \
46 goto invalid_enum_error; \
51 * Helper to enable/disable client-side state.
54 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
56 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
62 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
66 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
67 flag
= VERT_BIT_NORMAL
;
70 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
71 flag
= VERT_BIT_COLOR0
;
74 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
75 flag
= VERT_BIT_COLOR_INDEX
;
77 case GL_TEXTURE_COORD_ARRAY
:
78 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
79 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
81 case GL_EDGE_FLAG_ARRAY
:
82 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
83 flag
= VERT_BIT_EDGEFLAG
;
85 case GL_FOG_COORDINATE_ARRAY_EXT
:
86 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
89 case GL_SECONDARY_COLOR_ARRAY_EXT
:
90 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
91 flag
= VERT_BIT_COLOR1
;
94 #if FEATURE_point_size_array
95 case GL_POINT_SIZE_ARRAY_OES
:
96 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
97 flag
= VERT_BIT_POINT_SIZE
;
101 #if FEATURE_NV_vertex_program
102 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
103 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
118 CHECK_EXTENSION(NV_vertex_program
, cap
);
120 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
121 ASSERT(VERT_ATTRIB_GENERIC(n
) < Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
122 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(n
)].Enabled
;
123 flag
= VERT_BIT_GENERIC(n
);
126 #endif /* FEATURE_NV_vertex_program */
128 /* GL_NV_primitive_restart */
129 case GL_PRIMITIVE_RESTART_NV
:
130 if (!ctx
->Extensions
.NV_primitive_restart
) {
131 goto invalid_enum_error
;
133 var
= &ctx
->Array
.PrimitiveRestart
;
138 goto invalid_enum_error
;
144 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
145 ctx
->Array
.NewState
|= flag
;
147 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
152 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
154 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
156 if (ctx
->Driver
.Enable
) {
157 ctx
->Driver
.Enable( ctx
, cap
, state
);
163 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(0x%x)",
164 state
? "Enable" : "Disable", cap
);
169 * Enable GL capability.
170 * \param cap state to enable/disable.
172 * Get's the current context, assures that we're outside glBegin()/glEnd() and
173 * calls client_state().
176 _mesa_EnableClientState( GLenum cap
)
178 GET_CURRENT_CONTEXT(ctx
);
179 ASSERT_OUTSIDE_BEGIN_END(ctx
);
180 client_state( ctx
, cap
, GL_TRUE
);
185 * Disable GL capability.
186 * \param cap state to enable/disable.
188 * Get's the current context, assures that we're outside glBegin()/glEnd() and
189 * calls client_state().
192 _mesa_DisableClientState( GLenum cap
)
194 GET_CURRENT_CONTEXT(ctx
);
195 ASSERT_OUTSIDE_BEGIN_END(ctx
);
196 client_state( ctx
, cap
, GL_FALSE
);
200 #undef CHECK_EXTENSION
201 #define CHECK_EXTENSION(EXTNAME, CAP) \
202 if (!ctx->Extensions.EXTNAME) { \
203 goto invalid_enum_error; \
206 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
207 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
208 goto invalid_enum_error; \
214 * Return pointer to current texture unit for setting/getting coordinate
216 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
217 * texture unit is higher than the number of supported coordinate units.
219 static struct gl_texture_unit
*
220 get_texcoord_unit(struct gl_context
*ctx
)
222 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
223 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
227 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
233 * Helper function to enable or disable a texture target.
234 * \param bit one of the TEXTURE_x_BIT values
235 * \return GL_TRUE if state is changing or GL_FALSE if no change
238 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
240 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
241 const GLbitfield newenabled
= state
242 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
244 if (texUnit
->Enabled
== newenabled
)
247 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
248 texUnit
->Enabled
= newenabled
;
254 * Helper function to enable or disable state.
256 * \param ctx GL context.
257 * \param cap the state to enable/disable
258 * \param state whether to enable or disable the specified capability.
260 * Updates the current context and flushes the vertices as needed. For
261 * capabilities associated with extensions it verifies that those extensions
262 * are effectivly present before updating. Notifies the driver via
263 * dd_function_table::Enable.
266 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
268 if (MESA_VERBOSE
& VERBOSE_API
)
269 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
270 state
? "glEnable" : "glDisable",
271 _mesa_lookup_enum_by_nr(cap
),
276 if (ctx
->Color
.AlphaEnabled
== state
)
278 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
279 ctx
->Color
.AlphaEnabled
= state
;
282 if (ctx
->Eval
.AutoNormal
== state
)
284 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
285 ctx
->Eval
.AutoNormal
= state
;
289 GLbitfield newEnabled
=
290 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
291 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
292 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
293 ctx
->Color
.BlendEnabled
= newEnabled
;
298 case GL_CLIP_DISTANCE0
:
299 case GL_CLIP_DISTANCE1
:
300 case GL_CLIP_DISTANCE2
:
301 case GL_CLIP_DISTANCE3
:
302 case GL_CLIP_DISTANCE4
:
303 case GL_CLIP_DISTANCE5
:
304 case GL_CLIP_DISTANCE6
:
305 case GL_CLIP_DISTANCE7
:
307 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
309 if (p
>= ctx
->Const
.MaxClipPlanes
)
310 goto invalid_enum_error
;
312 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
313 == ((GLuint
) state
<< p
))
316 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
319 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
320 _mesa_update_clip_plane(ctx
, p
);
323 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
328 case GL_COLOR_MATERIAL
:
329 if (ctx
->Light
.ColorMaterialEnabled
== state
)
331 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
332 FLUSH_CURRENT(ctx
, 0);
333 ctx
->Light
.ColorMaterialEnabled
= state
;
335 _mesa_update_color_material( ctx
,
336 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
340 if (ctx
->Polygon
.CullFlag
== state
)
342 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
343 ctx
->Polygon
.CullFlag
= state
;
346 if (ctx
->Depth
.Test
== state
)
348 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
349 ctx
->Depth
.Test
= state
;
352 if (ctx
->Color
.DitherFlag
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
355 ctx
->Color
.DitherFlag
= state
;
358 if (ctx
->Fog
.Enabled
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_FOG
);
361 ctx
->Fog
.Enabled
= state
;
371 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
373 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
374 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
376 insert_at_tail(&ctx
->Light
.EnabledList
,
377 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
380 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
384 if (ctx
->Light
.Enabled
== state
)
386 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
387 ctx
->Light
.Enabled
= state
;
388 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
389 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
391 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
394 if (ctx
->Line
.SmoothFlag
== state
)
396 FLUSH_VERTICES(ctx
, _NEW_LINE
);
397 ctx
->Line
.SmoothFlag
= state
;
398 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
400 case GL_LINE_STIPPLE
:
401 if (ctx
->Line
.StippleFlag
== state
)
403 FLUSH_VERTICES(ctx
, _NEW_LINE
);
404 ctx
->Line
.StippleFlag
= state
;
405 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
407 case GL_INDEX_LOGIC_OP
:
408 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
410 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
411 ctx
->Color
.IndexLogicOpEnabled
= state
;
413 case GL_COLOR_LOGIC_OP
:
414 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
416 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
417 ctx
->Color
.ColorLogicOpEnabled
= state
;
419 case GL_MAP1_COLOR_4
:
420 if (ctx
->Eval
.Map1Color4
== state
)
422 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
423 ctx
->Eval
.Map1Color4
= state
;
426 if (ctx
->Eval
.Map1Index
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
429 ctx
->Eval
.Map1Index
= state
;
432 if (ctx
->Eval
.Map1Normal
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
435 ctx
->Eval
.Map1Normal
= state
;
437 case GL_MAP1_TEXTURE_COORD_1
:
438 if (ctx
->Eval
.Map1TextureCoord1
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
441 ctx
->Eval
.Map1TextureCoord1
= state
;
443 case GL_MAP1_TEXTURE_COORD_2
:
444 if (ctx
->Eval
.Map1TextureCoord2
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
447 ctx
->Eval
.Map1TextureCoord2
= state
;
449 case GL_MAP1_TEXTURE_COORD_3
:
450 if (ctx
->Eval
.Map1TextureCoord3
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map1TextureCoord3
= state
;
455 case GL_MAP1_TEXTURE_COORD_4
:
456 if (ctx
->Eval
.Map1TextureCoord4
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map1TextureCoord4
= state
;
461 case GL_MAP1_VERTEX_3
:
462 if (ctx
->Eval
.Map1Vertex3
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map1Vertex3
= state
;
467 case GL_MAP1_VERTEX_4
:
468 if (ctx
->Eval
.Map1Vertex4
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map1Vertex4
= state
;
473 case GL_MAP2_COLOR_4
:
474 if (ctx
->Eval
.Map2Color4
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map2Color4
= state
;
480 if (ctx
->Eval
.Map2Index
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map2Index
= state
;
486 if (ctx
->Eval
.Map2Normal
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map2Normal
= state
;
491 case GL_MAP2_TEXTURE_COORD_1
:
492 if (ctx
->Eval
.Map2TextureCoord1
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map2TextureCoord1
= state
;
497 case GL_MAP2_TEXTURE_COORD_2
:
498 if (ctx
->Eval
.Map2TextureCoord2
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
501 ctx
->Eval
.Map2TextureCoord2
= state
;
503 case GL_MAP2_TEXTURE_COORD_3
:
504 if (ctx
->Eval
.Map2TextureCoord3
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map2TextureCoord3
= state
;
509 case GL_MAP2_TEXTURE_COORD_4
:
510 if (ctx
->Eval
.Map2TextureCoord4
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map2TextureCoord4
= state
;
515 case GL_MAP2_VERTEX_3
:
516 if (ctx
->Eval
.Map2Vertex3
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map2Vertex3
= state
;
521 case GL_MAP2_VERTEX_4
:
522 if (ctx
->Eval
.Map2Vertex4
== state
)
524 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
525 ctx
->Eval
.Map2Vertex4
= state
;
528 if (ctx
->Transform
.Normalize
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
531 ctx
->Transform
.Normalize
= state
;
533 case GL_POINT_SMOOTH
:
534 if (ctx
->Point
.SmoothFlag
== state
)
536 FLUSH_VERTICES(ctx
, _NEW_POINT
);
537 ctx
->Point
.SmoothFlag
= state
;
538 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
540 case GL_POLYGON_SMOOTH
:
541 if (ctx
->Polygon
.SmoothFlag
== state
)
543 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
544 ctx
->Polygon
.SmoothFlag
= state
;
545 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
547 case GL_POLYGON_STIPPLE
:
548 if (ctx
->Polygon
.StippleFlag
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
551 ctx
->Polygon
.StippleFlag
= state
;
552 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
554 case GL_POLYGON_OFFSET_POINT
:
555 if (ctx
->Polygon
.OffsetPoint
== state
)
557 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
558 ctx
->Polygon
.OffsetPoint
= state
;
560 case GL_POLYGON_OFFSET_LINE
:
561 if (ctx
->Polygon
.OffsetLine
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
564 ctx
->Polygon
.OffsetLine
= state
;
566 case GL_POLYGON_OFFSET_FILL
:
567 if (ctx
->Polygon
.OffsetFill
== state
)
569 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
570 ctx
->Polygon
.OffsetFill
= state
;
572 case GL_RESCALE_NORMAL_EXT
:
573 if (ctx
->Transform
.RescaleNormals
== state
)
575 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
576 ctx
->Transform
.RescaleNormals
= state
;
578 case GL_SCISSOR_TEST
:
579 if (ctx
->Scissor
.Enabled
== state
)
581 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
582 ctx
->Scissor
.Enabled
= state
;
584 case GL_STENCIL_TEST
:
585 if (ctx
->Stencil
.Enabled
== state
)
587 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
588 ctx
->Stencil
.Enabled
= state
;
591 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
596 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
601 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
605 case GL_TEXTURE_GEN_S
:
606 case GL_TEXTURE_GEN_T
:
607 case GL_TEXTURE_GEN_R
:
608 case GL_TEXTURE_GEN_Q
:
610 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
612 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
613 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
615 newenabled
|= coordBit
;
616 if (texUnit
->TexGenEnabled
== newenabled
)
618 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
619 texUnit
->TexGenEnabled
= newenabled
;
625 case GL_TEXTURE_GEN_STR_OES
:
626 /* disable S, T, and R at the same time */
628 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
631 texUnit
->TexGenEnabled
& ~STR_BITS
;
633 newenabled
|= STR_BITS
;
634 if (texUnit
->TexGenEnabled
== newenabled
)
636 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
637 texUnit
->TexGenEnabled
= newenabled
;
643 /* client-side state */
644 case GL_VERTEX_ARRAY
:
645 case GL_NORMAL_ARRAY
:
648 case GL_TEXTURE_COORD_ARRAY
:
649 case GL_EDGE_FLAG_ARRAY
:
650 case GL_FOG_COORDINATE_ARRAY_EXT
:
651 case GL_SECONDARY_COLOR_ARRAY_EXT
:
652 case GL_POINT_SIZE_ARRAY_OES
:
653 client_state( ctx
, cap
, state
);
656 /* GL_ARB_texture_cube_map */
657 case GL_TEXTURE_CUBE_MAP_ARB
:
658 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
659 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
664 /* GL_EXT_secondary_color */
665 case GL_COLOR_SUM_EXT
:
666 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
667 if (ctx
->Fog
.ColorSumEnabled
== state
)
669 FLUSH_VERTICES(ctx
, _NEW_FOG
);
670 ctx
->Fog
.ColorSumEnabled
= state
;
673 /* GL_ARB_multisample */
674 case GL_MULTISAMPLE_ARB
:
675 if (ctx
->Multisample
.Enabled
== state
)
677 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
678 ctx
->Multisample
.Enabled
= state
;
680 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
681 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
683 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
684 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
686 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
687 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
689 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
690 ctx
->Multisample
.SampleAlphaToOne
= state
;
692 case GL_SAMPLE_COVERAGE_ARB
:
693 if (ctx
->Multisample
.SampleCoverage
== state
)
695 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
696 ctx
->Multisample
.SampleCoverage
= state
;
698 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
699 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
701 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
702 ctx
->Multisample
.SampleCoverageInvert
= state
;
705 /* GL_IBM_rasterpos_clip */
706 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
707 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
708 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
710 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
711 ctx
->Transform
.RasterPositionUnclipped
= state
;
714 /* GL_NV_point_sprite */
715 case GL_POINT_SPRITE_NV
:
716 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
717 if (ctx
->Point
.PointSprite
== state
)
719 FLUSH_VERTICES(ctx
, _NEW_POINT
);
720 ctx
->Point
.PointSprite
= state
;
723 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
724 case GL_VERTEX_PROGRAM_ARB
:
725 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
726 if (ctx
->VertexProgram
.Enabled
== state
)
728 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
729 ctx
->VertexProgram
.Enabled
= state
;
731 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
732 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
733 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
735 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
736 ctx
->VertexProgram
.PointSizeEnabled
= state
;
738 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
739 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
740 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
743 ctx
->VertexProgram
.TwoSideEnabled
= state
;
746 #if FEATURE_NV_vertex_program
747 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
748 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
749 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
750 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
751 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
752 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
753 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
754 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
755 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
756 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
757 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
758 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
759 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
760 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
761 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
762 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
763 CHECK_EXTENSION(NV_vertex_program
, cap
);
765 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
766 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
767 ctx
->Eval
.Map1Attrib
[map
] = state
;
770 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
771 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
772 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
773 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
774 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
775 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
776 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
777 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
778 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
779 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
780 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
781 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
782 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
783 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
784 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
785 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
786 CHECK_EXTENSION(NV_vertex_program
, cap
);
788 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
789 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
790 ctx
->Eval
.Map2Attrib
[map
] = state
;
793 #endif /* FEATURE_NV_vertex_program */
795 #if FEATURE_NV_fragment_program
796 case GL_FRAGMENT_PROGRAM_NV
:
797 CHECK_EXTENSION(NV_fragment_program
, cap
);
798 if (ctx
->FragmentProgram
.Enabled
== state
)
800 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
801 ctx
->FragmentProgram
.Enabled
= state
;
803 #endif /* FEATURE_NV_fragment_program */
805 /* GL_NV_texture_rectangle */
806 case GL_TEXTURE_RECTANGLE_NV
:
807 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
808 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
813 /* GL_EXT_stencil_two_side */
814 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
815 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
816 if (ctx
->Stencil
.TestTwoSide
== state
)
818 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
819 ctx
->Stencil
.TestTwoSide
= state
;
821 ctx
->Stencil
._BackFace
= 2;
822 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
824 ctx
->Stencil
._BackFace
= 1;
825 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
829 #if FEATURE_ARB_fragment_program
830 case GL_FRAGMENT_PROGRAM_ARB
:
831 CHECK_EXTENSION(ARB_fragment_program
, cap
);
832 if (ctx
->FragmentProgram
.Enabled
== state
)
834 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
835 ctx
->FragmentProgram
.Enabled
= state
;
837 #endif /* FEATURE_ARB_fragment_program */
839 /* GL_EXT_depth_bounds_test */
840 case GL_DEPTH_BOUNDS_TEST_EXT
:
841 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
842 if (ctx
->Depth
.BoundsTest
== state
)
844 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
845 ctx
->Depth
.BoundsTest
= state
;
849 if (ctx
->Transform
.DepthClamp
== state
)
851 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
852 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
853 ctx
->Transform
.DepthClamp
= state
;
856 #if FEATURE_ATI_fragment_shader
857 case GL_FRAGMENT_SHADER_ATI
:
858 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
859 if (ctx
->ATIFragmentShader
.Enabled
== state
)
861 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
862 ctx
->ATIFragmentShader
.Enabled
= state
;
866 /* GL_MESA_texture_array */
867 case GL_TEXTURE_1D_ARRAY_EXT
:
868 CHECK_EXTENSION(MESA_texture_array
, cap
);
869 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
874 case GL_TEXTURE_2D_ARRAY_EXT
:
875 CHECK_EXTENSION(MESA_texture_array
, cap
);
876 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
881 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
882 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
883 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
884 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
885 ctx
->Texture
.CubeMapSeamless
= state
;
889 #if FEATURE_EXT_transform_feedback
890 case GL_RASTERIZER_DISCARD
:
891 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
892 if (ctx
->RasterDiscard
!= state
) {
893 FLUSH_VERTICES(ctx
, _NEW_RASTERIZER_DISCARD
);
894 ctx
->RasterDiscard
= state
;
899 /* GL 3.1 primitive restart. Note: this enum is different from
900 * GL_PRIMITIVE_RESTART_NV (which is client state).
902 case GL_PRIMITIVE_RESTART
:
903 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
904 goto invalid_enum_error
;
906 if (ctx
->Array
.PrimitiveRestart
!= state
) {
907 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
908 ctx
->Array
.PrimitiveRestart
= state
;
912 /* GL3.0 - GL_framebuffer_sRGB */
913 case GL_FRAMEBUFFER_SRGB_EXT
:
914 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
915 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
916 ctx
->Color
.sRGBEnabled
= state
;
919 /* GL_OES_EGL_image_external */
920 case GL_TEXTURE_EXTERNAL_OES
:
921 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
922 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
928 goto invalid_enum_error
;
931 if (ctx
->Driver
.Enable
) {
932 ctx
->Driver
.Enable( ctx
, cap
, state
);
938 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
939 state
? "Enable" : "Disable", cap
);
944 * Enable GL capability. Called by glEnable()
945 * \param cap state to enable.
948 _mesa_Enable( GLenum cap
)
950 GET_CURRENT_CONTEXT(ctx
);
951 ASSERT_OUTSIDE_BEGIN_END(ctx
);
953 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
958 * Disable GL capability. Called by glDisable()
959 * \param cap state to disable.
962 _mesa_Disable( GLenum cap
)
964 GET_CURRENT_CONTEXT(ctx
);
965 ASSERT_OUTSIDE_BEGIN_END(ctx
);
967 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
973 * Enable/disable an indexed state var.
976 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
977 GLuint index
, GLboolean state
)
979 ASSERT(state
== 0 || state
== 1);
982 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
983 goto invalid_enum_error
;
985 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
986 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
987 state
? "glEnableIndexed" : "glDisableIndexed", index
);
990 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
991 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
993 ctx
->Color
.BlendEnabled
|= (1 << index
);
995 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
999 goto invalid_enum_error
;
1004 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1005 state
? "glEnablei" : "glDisablei",
1006 _mesa_lookup_enum_by_nr(cap
));
1011 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1013 GET_CURRENT_CONTEXT(ctx
);
1014 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1015 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1020 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1022 GET_CURRENT_CONTEXT(ctx
);
1023 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1024 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1028 GLboolean GLAPIENTRY
1029 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1031 GET_CURRENT_CONTEXT(ctx
);
1032 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1035 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1036 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1040 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1042 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1043 _mesa_lookup_enum_by_nr(cap
));
1051 #undef CHECK_EXTENSION
1052 #define CHECK_EXTENSION(EXTNAME) \
1053 if (!ctx->Extensions.EXTNAME) { \
1054 goto invalid_enum_error; \
1057 #undef CHECK_EXTENSION2
1058 #define CHECK_EXTENSION2(EXT1, EXT2) \
1059 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1060 goto invalid_enum_error; \
1065 * Helper function to determine whether a texture target is enabled.
1068 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1070 const struct gl_texture_unit
*const texUnit
=
1071 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1072 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1077 * Return simple enable/disable state.
1079 * \param cap state variable to query.
1081 * Returns the state of the specified capability from the current GL context.
1082 * For the capabilities associated with extensions verifies that those
1083 * extensions are effectively present before reporting.
1085 GLboolean GLAPIENTRY
1086 _mesa_IsEnabled( GLenum cap
)
1088 GET_CURRENT_CONTEXT(ctx
);
1089 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1093 return ctx
->Color
.AlphaEnabled
;
1094 case GL_AUTO_NORMAL
:
1095 return ctx
->Eval
.AutoNormal
;
1097 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1098 case GL_CLIP_DISTANCE0
:
1099 case GL_CLIP_DISTANCE1
:
1100 case GL_CLIP_DISTANCE2
:
1101 case GL_CLIP_DISTANCE3
:
1102 case GL_CLIP_DISTANCE4
:
1103 case GL_CLIP_DISTANCE5
:
1104 case GL_CLIP_DISTANCE6
:
1105 case GL_CLIP_DISTANCE7
: {
1106 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1108 if (p
>= ctx
->Const
.MaxClipPlanes
)
1109 goto invalid_enum_error
;
1111 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1113 case GL_COLOR_MATERIAL
:
1114 return ctx
->Light
.ColorMaterialEnabled
;
1116 return ctx
->Polygon
.CullFlag
;
1118 return ctx
->Depth
.Test
;
1120 return ctx
->Color
.DitherFlag
;
1122 return ctx
->Fog
.Enabled
;
1124 return ctx
->Light
.Enabled
;
1133 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1134 case GL_LINE_SMOOTH
:
1135 return ctx
->Line
.SmoothFlag
;
1136 case GL_LINE_STIPPLE
:
1137 return ctx
->Line
.StippleFlag
;
1138 case GL_INDEX_LOGIC_OP
:
1139 return ctx
->Color
.IndexLogicOpEnabled
;
1140 case GL_COLOR_LOGIC_OP
:
1141 return ctx
->Color
.ColorLogicOpEnabled
;
1142 case GL_MAP1_COLOR_4
:
1143 return ctx
->Eval
.Map1Color4
;
1145 return ctx
->Eval
.Map1Index
;
1146 case GL_MAP1_NORMAL
:
1147 return ctx
->Eval
.Map1Normal
;
1148 case GL_MAP1_TEXTURE_COORD_1
:
1149 return ctx
->Eval
.Map1TextureCoord1
;
1150 case GL_MAP1_TEXTURE_COORD_2
:
1151 return ctx
->Eval
.Map1TextureCoord2
;
1152 case GL_MAP1_TEXTURE_COORD_3
:
1153 return ctx
->Eval
.Map1TextureCoord3
;
1154 case GL_MAP1_TEXTURE_COORD_4
:
1155 return ctx
->Eval
.Map1TextureCoord4
;
1156 case GL_MAP1_VERTEX_3
:
1157 return ctx
->Eval
.Map1Vertex3
;
1158 case GL_MAP1_VERTEX_4
:
1159 return ctx
->Eval
.Map1Vertex4
;
1160 case GL_MAP2_COLOR_4
:
1161 return ctx
->Eval
.Map2Color4
;
1163 return ctx
->Eval
.Map2Index
;
1164 case GL_MAP2_NORMAL
:
1165 return ctx
->Eval
.Map2Normal
;
1166 case GL_MAP2_TEXTURE_COORD_1
:
1167 return ctx
->Eval
.Map2TextureCoord1
;
1168 case GL_MAP2_TEXTURE_COORD_2
:
1169 return ctx
->Eval
.Map2TextureCoord2
;
1170 case GL_MAP2_TEXTURE_COORD_3
:
1171 return ctx
->Eval
.Map2TextureCoord3
;
1172 case GL_MAP2_TEXTURE_COORD_4
:
1173 return ctx
->Eval
.Map2TextureCoord4
;
1174 case GL_MAP2_VERTEX_3
:
1175 return ctx
->Eval
.Map2Vertex3
;
1176 case GL_MAP2_VERTEX_4
:
1177 return ctx
->Eval
.Map2Vertex4
;
1179 return ctx
->Transform
.Normalize
;
1180 case GL_POINT_SMOOTH
:
1181 return ctx
->Point
.SmoothFlag
;
1182 case GL_POLYGON_SMOOTH
:
1183 return ctx
->Polygon
.SmoothFlag
;
1184 case GL_POLYGON_STIPPLE
:
1185 return ctx
->Polygon
.StippleFlag
;
1186 case GL_POLYGON_OFFSET_POINT
:
1187 return ctx
->Polygon
.OffsetPoint
;
1188 case GL_POLYGON_OFFSET_LINE
:
1189 return ctx
->Polygon
.OffsetLine
;
1190 case GL_POLYGON_OFFSET_FILL
:
1191 return ctx
->Polygon
.OffsetFill
;
1192 case GL_RESCALE_NORMAL_EXT
:
1193 return ctx
->Transform
.RescaleNormals
;
1194 case GL_SCISSOR_TEST
:
1195 return ctx
->Scissor
.Enabled
;
1196 case GL_STENCIL_TEST
:
1197 return ctx
->Stencil
.Enabled
;
1199 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1201 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1203 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1204 case GL_TEXTURE_GEN_S
:
1205 case GL_TEXTURE_GEN_T
:
1206 case GL_TEXTURE_GEN_R
:
1207 case GL_TEXTURE_GEN_Q
:
1209 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1211 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1212 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1217 case GL_TEXTURE_GEN_STR_OES
:
1219 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1221 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1222 ? GL_TRUE
: GL_FALSE
;
1227 /* client-side state */
1228 case GL_VERTEX_ARRAY
:
1229 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
!= 0);
1230 case GL_NORMAL_ARRAY
:
1231 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1232 case GL_COLOR_ARRAY
:
1233 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
!= 0);
1234 case GL_INDEX_ARRAY
:
1235 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1236 case GL_TEXTURE_COORD_ARRAY
:
1237 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1239 case GL_EDGE_FLAG_ARRAY
:
1240 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1241 case GL_FOG_COORDINATE_ARRAY_EXT
:
1242 CHECK_EXTENSION(EXT_fog_coord
);
1243 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1244 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1245 CHECK_EXTENSION(EXT_secondary_color
);
1246 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1247 #if FEATURE_point_size_array
1248 case GL_POINT_SIZE_ARRAY_OES
:
1249 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1252 /* GL_ARB_texture_cube_map */
1253 case GL_TEXTURE_CUBE_MAP_ARB
:
1254 CHECK_EXTENSION(ARB_texture_cube_map
);
1255 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1257 /* GL_EXT_secondary_color */
1258 case GL_COLOR_SUM_EXT
:
1259 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1260 return ctx
->Fog
.ColorSumEnabled
;
1262 /* GL_ARB_multisample */
1263 case GL_MULTISAMPLE_ARB
:
1264 return ctx
->Multisample
.Enabled
;
1265 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1266 return ctx
->Multisample
.SampleAlphaToCoverage
;
1267 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1268 return ctx
->Multisample
.SampleAlphaToOne
;
1269 case GL_SAMPLE_COVERAGE_ARB
:
1270 return ctx
->Multisample
.SampleCoverage
;
1271 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1272 return ctx
->Multisample
.SampleCoverageInvert
;
1274 /* GL_IBM_rasterpos_clip */
1275 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1276 CHECK_EXTENSION(IBM_rasterpos_clip
);
1277 return ctx
->Transform
.RasterPositionUnclipped
;
1279 /* GL_NV_point_sprite */
1280 case GL_POINT_SPRITE_NV
:
1281 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1282 return ctx
->Point
.PointSprite
;
1284 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1285 case GL_VERTEX_PROGRAM_ARB
:
1286 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1287 return ctx
->VertexProgram
.Enabled
;
1288 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1289 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1290 return ctx
->VertexProgram
.PointSizeEnabled
;
1291 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1292 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1293 return ctx
->VertexProgram
.TwoSideEnabled
;
1295 #if FEATURE_NV_vertex_program
1296 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1297 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1298 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1299 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1300 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1301 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1302 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1303 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1304 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1305 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1306 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1307 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1308 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1309 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1310 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1311 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1312 CHECK_EXTENSION(NV_vertex_program
);
1314 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1315 ASSERT(VERT_ATTRIB_GENERIC(n
) < Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1316 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(n
)].Enabled
!= 0);
1318 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1319 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1320 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1321 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1322 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1323 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1324 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1325 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1326 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1327 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1328 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1329 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1330 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1331 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1332 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1333 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1334 CHECK_EXTENSION(NV_vertex_program
);
1336 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1337 return ctx
->Eval
.Map1Attrib
[map
];
1339 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1340 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1341 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1342 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1343 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1344 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1345 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1346 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1347 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1348 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1349 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1350 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1351 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1352 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1353 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1354 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1355 CHECK_EXTENSION(NV_vertex_program
);
1357 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1358 return ctx
->Eval
.Map2Attrib
[map
];
1360 #endif /* FEATURE_NV_vertex_program */
1362 #if FEATURE_NV_fragment_program
1363 case GL_FRAGMENT_PROGRAM_NV
:
1364 CHECK_EXTENSION(NV_fragment_program
);
1365 return ctx
->FragmentProgram
.Enabled
;
1366 #endif /* FEATURE_NV_fragment_program */
1368 /* GL_NV_texture_rectangle */
1369 case GL_TEXTURE_RECTANGLE_NV
:
1370 CHECK_EXTENSION(NV_texture_rectangle
);
1371 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1373 /* GL_EXT_stencil_two_side */
1374 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1375 CHECK_EXTENSION(EXT_stencil_two_side
);
1376 return ctx
->Stencil
.TestTwoSide
;
1378 #if FEATURE_ARB_fragment_program
1379 case GL_FRAGMENT_PROGRAM_ARB
:
1380 return ctx
->FragmentProgram
.Enabled
;
1381 #endif /* FEATURE_ARB_fragment_program */
1383 /* GL_EXT_depth_bounds_test */
1384 case GL_DEPTH_BOUNDS_TEST_EXT
:
1385 CHECK_EXTENSION(EXT_depth_bounds_test
);
1386 return ctx
->Depth
.BoundsTest
;
1388 /* GL_ARB_depth_clamp */
1389 case GL_DEPTH_CLAMP
:
1390 CHECK_EXTENSION(ARB_depth_clamp
);
1391 return ctx
->Transform
.DepthClamp
;
1393 #if FEATURE_ATI_fragment_shader
1394 case GL_FRAGMENT_SHADER_ATI
:
1395 CHECK_EXTENSION(ATI_fragment_shader
);
1396 return ctx
->ATIFragmentShader
.Enabled
;
1397 #endif /* FEATURE_ATI_fragment_shader */
1399 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1400 CHECK_EXTENSION(ARB_seamless_cube_map
);
1401 return ctx
->Texture
.CubeMapSeamless
;
1403 #if FEATURE_EXT_transform_feedback
1404 case GL_RASTERIZER_DISCARD
:
1405 CHECK_EXTENSION(EXT_transform_feedback
);
1406 return ctx
->RasterDiscard
;
1409 /* GL_NV_primitive_restart */
1410 case GL_PRIMITIVE_RESTART_NV
:
1411 if (!ctx
->Extensions
.NV_primitive_restart
) {
1412 goto invalid_enum_error
;
1414 return ctx
->Array
.PrimitiveRestart
;
1416 /* GL 3.1 primitive restart */
1417 case GL_PRIMITIVE_RESTART
:
1418 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1419 goto invalid_enum_error
;
1421 return ctx
->Array
.PrimitiveRestart
;
1423 /* GL3.0 - GL_framebuffer_sRGB */
1424 case GL_FRAMEBUFFER_SRGB_EXT
:
1425 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1426 return ctx
->Color
.sRGBEnabled
;
1428 /* GL_OES_EGL_image_external */
1429 case GL_TEXTURE_EXTERNAL_OES
:
1430 CHECK_EXTENSION(OES_EGL_image_external
);
1431 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1434 goto invalid_enum_error
;
1440 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);