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.
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 if the active texture unit is
217 * higher than the number of supported coordinate units. And we'll return NULL.
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
= state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
290 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
291 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
292 ctx
->Color
.BlendEnabled
= newEnabled
;
304 const GLuint p
= cap
- GL_CLIP_PLANE0
;
306 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
309 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
312 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
314 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
315 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
317 /* This derived state also calculated in clip.c and
318 * from _mesa_update_state() on changes to EyeUserPlane
319 * and ctx->ProjectionMatrix respectively.
321 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
322 ctx
->Transform
.EyeUserPlane
[p
],
323 ctx
->ProjectionMatrixStack
.Top
->inv
);
326 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
331 case GL_COLOR_MATERIAL
:
332 if (ctx
->Light
.ColorMaterialEnabled
== state
)
334 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
335 FLUSH_CURRENT(ctx
, 0);
336 ctx
->Light
.ColorMaterialEnabled
= state
;
338 _mesa_update_color_material( ctx
,
339 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
343 if (ctx
->Polygon
.CullFlag
== state
)
345 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
346 ctx
->Polygon
.CullFlag
= state
;
349 if (ctx
->Depth
.Test
== state
)
351 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
352 ctx
->Depth
.Test
= state
;
356 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
358 if (ctx
->Color
.DitherFlag
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
361 ctx
->Color
.DitherFlag
= state
;
364 if (ctx
->Fog
.Enabled
== state
)
366 FLUSH_VERTICES(ctx
, _NEW_FOG
);
367 ctx
->Fog
.Enabled
= state
;
377 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
379 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
380 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
382 insert_at_tail(&ctx
->Light
.EnabledList
,
383 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
386 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
390 if (ctx
->Light
.Enabled
== state
)
392 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
393 ctx
->Light
.Enabled
= state
;
394 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
395 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
397 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
400 if (ctx
->Line
.SmoothFlag
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_LINE
);
403 ctx
->Line
.SmoothFlag
= state
;
404 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
406 case GL_LINE_STIPPLE
:
407 if (ctx
->Line
.StippleFlag
== state
)
409 FLUSH_VERTICES(ctx
, _NEW_LINE
);
410 ctx
->Line
.StippleFlag
= state
;
411 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
413 case GL_INDEX_LOGIC_OP
:
414 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
416 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
417 ctx
->Color
.IndexLogicOpEnabled
= state
;
419 case GL_COLOR_LOGIC_OP
:
420 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
422 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
423 ctx
->Color
.ColorLogicOpEnabled
= state
;
425 case GL_MAP1_COLOR_4
:
426 if (ctx
->Eval
.Map1Color4
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
429 ctx
->Eval
.Map1Color4
= state
;
432 if (ctx
->Eval
.Map1Index
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
435 ctx
->Eval
.Map1Index
= state
;
438 if (ctx
->Eval
.Map1Normal
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
441 ctx
->Eval
.Map1Normal
= state
;
443 case GL_MAP1_TEXTURE_COORD_1
:
444 if (ctx
->Eval
.Map1TextureCoord1
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
447 ctx
->Eval
.Map1TextureCoord1
= state
;
449 case GL_MAP1_TEXTURE_COORD_2
:
450 if (ctx
->Eval
.Map1TextureCoord2
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map1TextureCoord2
= state
;
455 case GL_MAP1_TEXTURE_COORD_3
:
456 if (ctx
->Eval
.Map1TextureCoord3
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map1TextureCoord3
= state
;
461 case GL_MAP1_TEXTURE_COORD_4
:
462 if (ctx
->Eval
.Map1TextureCoord4
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map1TextureCoord4
= state
;
467 case GL_MAP1_VERTEX_3
:
468 if (ctx
->Eval
.Map1Vertex3
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map1Vertex3
= state
;
473 case GL_MAP1_VERTEX_4
:
474 if (ctx
->Eval
.Map1Vertex4
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map1Vertex4
= state
;
479 case GL_MAP2_COLOR_4
:
480 if (ctx
->Eval
.Map2Color4
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map2Color4
= state
;
486 if (ctx
->Eval
.Map2Index
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map2Index
= state
;
492 if (ctx
->Eval
.Map2Normal
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map2Normal
= state
;
497 case GL_MAP2_TEXTURE_COORD_1
:
498 if (ctx
->Eval
.Map2TextureCoord1
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
501 ctx
->Eval
.Map2TextureCoord1
= state
;
503 case GL_MAP2_TEXTURE_COORD_2
:
504 if (ctx
->Eval
.Map2TextureCoord2
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map2TextureCoord2
= state
;
509 case GL_MAP2_TEXTURE_COORD_3
:
510 if (ctx
->Eval
.Map2TextureCoord3
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map2TextureCoord3
= state
;
515 case GL_MAP2_TEXTURE_COORD_4
:
516 if (ctx
->Eval
.Map2TextureCoord4
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map2TextureCoord4
= state
;
521 case GL_MAP2_VERTEX_3
:
522 if (ctx
->Eval
.Map2Vertex3
== state
)
524 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
525 ctx
->Eval
.Map2Vertex3
= state
;
527 case GL_MAP2_VERTEX_4
:
528 if (ctx
->Eval
.Map2Vertex4
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
531 ctx
->Eval
.Map2Vertex4
= state
;
534 if (ctx
->Transform
.Normalize
== state
)
536 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
537 ctx
->Transform
.Normalize
= state
;
539 case GL_POINT_SMOOTH
:
540 if (ctx
->Point
.SmoothFlag
== state
)
542 FLUSH_VERTICES(ctx
, _NEW_POINT
);
543 ctx
->Point
.SmoothFlag
= state
;
544 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
546 case GL_POLYGON_SMOOTH
:
547 if (ctx
->Polygon
.SmoothFlag
== state
)
549 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
550 ctx
->Polygon
.SmoothFlag
= state
;
551 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
553 case GL_POLYGON_STIPPLE
:
554 if (ctx
->Polygon
.StippleFlag
== state
)
556 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
557 ctx
->Polygon
.StippleFlag
= state
;
558 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
560 case GL_POLYGON_OFFSET_POINT
:
561 if (ctx
->Polygon
.OffsetPoint
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
564 ctx
->Polygon
.OffsetPoint
= state
;
566 case GL_POLYGON_OFFSET_LINE
:
567 if (ctx
->Polygon
.OffsetLine
== state
)
569 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
570 ctx
->Polygon
.OffsetLine
= state
;
572 case GL_POLYGON_OFFSET_FILL
:
573 /*case GL_POLYGON_OFFSET_EXT:*/
574 if (ctx
->Polygon
.OffsetFill
== state
)
576 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
577 ctx
->Polygon
.OffsetFill
= state
;
579 case GL_RESCALE_NORMAL_EXT
:
580 if (ctx
->Transform
.RescaleNormals
== state
)
582 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
583 ctx
->Transform
.RescaleNormals
= state
;
585 case GL_SCISSOR_TEST
:
586 if (ctx
->Scissor
.Enabled
== state
)
588 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
589 ctx
->Scissor
.Enabled
= state
;
591 case GL_SHARED_TEXTURE_PALETTE_EXT
:
592 if (ctx
->Texture
.SharedPalette
== state
)
594 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
595 ctx
->Texture
.SharedPalette
= state
;
597 case GL_STENCIL_TEST
:
598 if (ctx
->Stencil
.Enabled
== state
)
600 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
601 ctx
->Stencil
.Enabled
= state
;
604 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
609 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
614 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
618 case GL_TEXTURE_GEN_Q
:
620 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
622 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
625 if (texUnit
->TexGenEnabled
== newenabled
)
627 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
628 texUnit
->TexGenEnabled
= newenabled
;
632 case GL_TEXTURE_GEN_R
:
634 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
636 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
639 if (texUnit
->TexGenEnabled
== newenabled
)
641 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
642 texUnit
->TexGenEnabled
= newenabled
;
646 case GL_TEXTURE_GEN_S
:
648 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
650 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
653 if (texUnit
->TexGenEnabled
== newenabled
)
655 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
656 texUnit
->TexGenEnabled
= newenabled
;
660 case GL_TEXTURE_GEN_T
:
662 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
664 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
667 if (texUnit
->TexGenEnabled
== newenabled
)
669 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
670 texUnit
->TexGenEnabled
= newenabled
;
676 case GL_TEXTURE_GEN_STR_OES
:
677 /* disable S, T, and R at the same time */
679 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
682 texUnit
->TexGenEnabled
& ~STR_BITS
;
684 newenabled
|= STR_BITS
;
685 if (texUnit
->TexGenEnabled
== newenabled
)
687 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
688 texUnit
->TexGenEnabled
= newenabled
;
697 case GL_VERTEX_ARRAY
:
698 case GL_NORMAL_ARRAY
:
701 case GL_TEXTURE_COORD_ARRAY
:
702 case GL_EDGE_FLAG_ARRAY
:
703 case GL_FOG_COORDINATE_ARRAY_EXT
:
704 case GL_SECONDARY_COLOR_ARRAY_EXT
:
705 case GL_POINT_SIZE_ARRAY_OES
:
706 client_state( ctx
, cap
, state
);
709 /* GL_SGI_texture_color_table */
710 case GL_TEXTURE_COLOR_TABLE_SGI
:
711 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
712 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
714 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
715 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
718 /* GL_ARB_texture_cube_map */
719 case GL_TEXTURE_CUBE_MAP_ARB
:
720 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
721 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
726 /* GL_EXT_secondary_color */
727 case GL_COLOR_SUM_EXT
:
728 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
729 if (ctx
->Fog
.ColorSumEnabled
== state
)
731 FLUSH_VERTICES(ctx
, _NEW_FOG
);
732 ctx
->Fog
.ColorSumEnabled
= state
;
735 /* GL_ARB_multisample */
736 case GL_MULTISAMPLE_ARB
:
737 if (ctx
->Multisample
.Enabled
== state
)
739 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
740 ctx
->Multisample
.Enabled
= state
;
742 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
743 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
745 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
746 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
748 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
749 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
751 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
752 ctx
->Multisample
.SampleAlphaToOne
= state
;
754 case GL_SAMPLE_COVERAGE_ARB
:
755 if (ctx
->Multisample
.SampleCoverage
== state
)
757 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
758 ctx
->Multisample
.SampleCoverage
= state
;
760 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
761 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
763 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
764 ctx
->Multisample
.SampleCoverageInvert
= state
;
767 /* GL_IBM_rasterpos_clip */
768 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
769 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
770 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
772 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
773 ctx
->Transform
.RasterPositionUnclipped
= state
;
776 /* GL_NV_point_sprite */
777 case GL_POINT_SPRITE_NV
:
778 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
779 if (ctx
->Point
.PointSprite
== state
)
781 FLUSH_VERTICES(ctx
, _NEW_POINT
);
782 ctx
->Point
.PointSprite
= state
;
785 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
786 case GL_VERTEX_PROGRAM_ARB
:
787 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
788 if (ctx
->VertexProgram
.Enabled
== state
)
790 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
791 ctx
->VertexProgram
.Enabled
= state
;
793 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
794 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
795 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
797 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
798 ctx
->VertexProgram
.PointSizeEnabled
= state
;
800 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
801 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
802 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
804 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
805 ctx
->VertexProgram
.TwoSideEnabled
= state
;
808 #if FEATURE_NV_vertex_program
809 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
810 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
811 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
812 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
813 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
814 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
815 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
816 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
817 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
818 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
819 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
820 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
821 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
822 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
823 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
824 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
825 CHECK_EXTENSION(NV_vertex_program
, cap
);
827 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
828 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
829 ctx
->Eval
.Map1Attrib
[map
] = state
;
832 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
833 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
834 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
835 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
836 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
837 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
838 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
839 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
840 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
841 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
842 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
843 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
844 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
845 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
846 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
847 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
848 CHECK_EXTENSION(NV_vertex_program
, cap
);
850 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
851 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
852 ctx
->Eval
.Map2Attrib
[map
] = state
;
855 #endif /* FEATURE_NV_vertex_program */
857 #if FEATURE_NV_fragment_program
858 case GL_FRAGMENT_PROGRAM_NV
:
859 CHECK_EXTENSION(NV_fragment_program
, cap
);
860 if (ctx
->FragmentProgram
.Enabled
== state
)
862 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
863 ctx
->FragmentProgram
.Enabled
= state
;
865 #endif /* FEATURE_NV_fragment_program */
867 /* GL_NV_texture_rectangle */
868 case GL_TEXTURE_RECTANGLE_NV
:
869 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
870 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
875 /* GL_EXT_stencil_two_side */
876 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
877 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
878 if (ctx
->Stencil
.TestTwoSide
== state
)
880 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
881 ctx
->Stencil
.TestTwoSide
= state
;
883 ctx
->Stencil
._BackFace
= 2;
884 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
886 ctx
->Stencil
._BackFace
= 1;
887 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
891 #if FEATURE_ARB_fragment_program
892 case GL_FRAGMENT_PROGRAM_ARB
:
893 CHECK_EXTENSION(ARB_fragment_program
, cap
);
894 if (ctx
->FragmentProgram
.Enabled
== state
)
896 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
897 ctx
->FragmentProgram
.Enabled
= state
;
899 #endif /* FEATURE_ARB_fragment_program */
901 /* GL_EXT_depth_bounds_test */
902 case GL_DEPTH_BOUNDS_TEST_EXT
:
903 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
904 if (ctx
->Depth
.BoundsTest
== state
)
906 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
907 ctx
->Depth
.BoundsTest
= state
;
911 if (ctx
->Transform
.DepthClamp
== state
)
913 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
914 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
915 ctx
->Transform
.DepthClamp
= state
;
918 #if FEATURE_ATI_fragment_shader
919 case GL_FRAGMENT_SHADER_ATI
:
920 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
921 if (ctx
->ATIFragmentShader
.Enabled
== state
)
923 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
924 ctx
->ATIFragmentShader
.Enabled
= state
;
928 /* GL_MESA_texture_array */
929 case GL_TEXTURE_1D_ARRAY_EXT
:
930 CHECK_EXTENSION(MESA_texture_array
, cap
);
931 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
936 case GL_TEXTURE_2D_ARRAY_EXT
:
937 CHECK_EXTENSION(MESA_texture_array
, cap
);
938 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
943 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
944 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
945 ctx
->Texture
.CubeMapSeamless
= state
;
948 #if FEATURE_EXT_transform_feedback
949 case GL_RASTERIZER_DISCARD
:
950 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
951 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
952 ctx
->TransformFeedback
.RasterDiscard
= state
;
953 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
958 /* GL 3.1 primitive restart. Note: this enum is different from
959 * GL_PRIMITIVE_RESTART_NV (which is client state).
961 case GL_PRIMITIVE_RESTART
:
962 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
963 goto invalid_enum_error
;
965 if (ctx
->Array
.PrimitiveRestart
!= state
) {
966 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
967 ctx
->Array
.PrimitiveRestart
= state
;
971 /* GL3.0 - GL_framebuffer_sRGB */
972 case GL_FRAMEBUFFER_SRGB_EXT
:
973 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
974 ctx
->Color
.sRGBEnabled
= state
;
978 goto invalid_enum_error
;
981 if (ctx
->Driver
.Enable
) {
982 ctx
->Driver
.Enable( ctx
, cap
, state
);
988 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
989 state
? "Enable" : "Disable", cap
);
994 * Enable GL capability. Called by glEnable()
995 * \param cap state to enable.
998 _mesa_Enable( GLenum cap
)
1000 GET_CURRENT_CONTEXT(ctx
);
1001 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1003 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1008 * Disable GL capability. Called by glDisable()
1009 * \param cap state to disable.
1012 _mesa_Disable( GLenum cap
)
1014 GET_CURRENT_CONTEXT(ctx
);
1015 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1017 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1023 * Enable/disable an indexed state var.
1026 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1028 ASSERT(state
== 0 || state
== 1);
1031 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1032 goto invalid_enum_error
;
1034 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1035 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1036 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1039 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1040 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1042 ctx
->Color
.BlendEnabled
|= (1 << index
);
1044 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1048 goto invalid_enum_error
;
1053 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1054 state
? "glEnablei" : "glDisablei",
1055 _mesa_lookup_enum_by_nr(cap
));
1060 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1062 GET_CURRENT_CONTEXT(ctx
);
1063 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1064 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1069 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1071 GET_CURRENT_CONTEXT(ctx
);
1072 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1073 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1077 GLboolean GLAPIENTRY
1078 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1080 GET_CURRENT_CONTEXT(ctx
);
1083 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1084 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1088 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1090 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1091 _mesa_lookup_enum_by_nr(cap
));
1099 #undef CHECK_EXTENSION
1100 #define CHECK_EXTENSION(EXTNAME) \
1101 if (!ctx->Extensions.EXTNAME) { \
1102 goto invalid_enum_error; \
1105 #undef CHECK_EXTENSION2
1106 #define CHECK_EXTENSION2(EXT1, EXT2) \
1107 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1108 goto invalid_enum_error; \
1113 * Helper function to determine whether a texture target is enabled.
1116 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1118 const struct gl_texture_unit
*const texUnit
=
1119 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1120 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1125 * Return simple enable/disable state.
1127 * \param cap state variable to query.
1129 * Returns the state of the specified capability from the current GL context.
1130 * For the capabilities associated with extensions verifies that those
1131 * extensions are effectively present before reporting.
1133 GLboolean GLAPIENTRY
1134 _mesa_IsEnabled( GLenum cap
)
1136 GET_CURRENT_CONTEXT(ctx
);
1139 return ctx
->Color
.AlphaEnabled
;
1140 case GL_AUTO_NORMAL
:
1141 return ctx
->Eval
.AutoNormal
;
1143 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1144 case GL_CLIP_PLANE0
:
1145 case GL_CLIP_PLANE1
:
1146 case GL_CLIP_PLANE2
:
1147 case GL_CLIP_PLANE3
:
1148 case GL_CLIP_PLANE4
:
1149 case GL_CLIP_PLANE5
:
1150 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1151 case GL_COLOR_MATERIAL
:
1152 return ctx
->Light
.ColorMaterialEnabled
;
1154 return ctx
->Polygon
.CullFlag
;
1156 return ctx
->Depth
.Test
;
1158 return ctx
->Color
.DitherFlag
;
1160 return ctx
->Fog
.Enabled
;
1162 return ctx
->Light
.Enabled
;
1171 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1172 case GL_LINE_SMOOTH
:
1173 return ctx
->Line
.SmoothFlag
;
1174 case GL_LINE_STIPPLE
:
1175 return ctx
->Line
.StippleFlag
;
1176 case GL_INDEX_LOGIC_OP
:
1177 return ctx
->Color
.IndexLogicOpEnabled
;
1178 case GL_COLOR_LOGIC_OP
:
1179 return ctx
->Color
.ColorLogicOpEnabled
;
1180 case GL_MAP1_COLOR_4
:
1181 return ctx
->Eval
.Map1Color4
;
1183 return ctx
->Eval
.Map1Index
;
1184 case GL_MAP1_NORMAL
:
1185 return ctx
->Eval
.Map1Normal
;
1186 case GL_MAP1_TEXTURE_COORD_1
:
1187 return ctx
->Eval
.Map1TextureCoord1
;
1188 case GL_MAP1_TEXTURE_COORD_2
:
1189 return ctx
->Eval
.Map1TextureCoord2
;
1190 case GL_MAP1_TEXTURE_COORD_3
:
1191 return ctx
->Eval
.Map1TextureCoord3
;
1192 case GL_MAP1_TEXTURE_COORD_4
:
1193 return ctx
->Eval
.Map1TextureCoord4
;
1194 case GL_MAP1_VERTEX_3
:
1195 return ctx
->Eval
.Map1Vertex3
;
1196 case GL_MAP1_VERTEX_4
:
1197 return ctx
->Eval
.Map1Vertex4
;
1198 case GL_MAP2_COLOR_4
:
1199 return ctx
->Eval
.Map2Color4
;
1201 return ctx
->Eval
.Map2Index
;
1202 case GL_MAP2_NORMAL
:
1203 return ctx
->Eval
.Map2Normal
;
1204 case GL_MAP2_TEXTURE_COORD_1
:
1205 return ctx
->Eval
.Map2TextureCoord1
;
1206 case GL_MAP2_TEXTURE_COORD_2
:
1207 return ctx
->Eval
.Map2TextureCoord2
;
1208 case GL_MAP2_TEXTURE_COORD_3
:
1209 return ctx
->Eval
.Map2TextureCoord3
;
1210 case GL_MAP2_TEXTURE_COORD_4
:
1211 return ctx
->Eval
.Map2TextureCoord4
;
1212 case GL_MAP2_VERTEX_3
:
1213 return ctx
->Eval
.Map2Vertex3
;
1214 case GL_MAP2_VERTEX_4
:
1215 return ctx
->Eval
.Map2Vertex4
;
1217 return ctx
->Transform
.Normalize
;
1218 case GL_POINT_SMOOTH
:
1219 return ctx
->Point
.SmoothFlag
;
1220 case GL_POLYGON_SMOOTH
:
1221 return ctx
->Polygon
.SmoothFlag
;
1222 case GL_POLYGON_STIPPLE
:
1223 return ctx
->Polygon
.StippleFlag
;
1224 case GL_POLYGON_OFFSET_POINT
:
1225 return ctx
->Polygon
.OffsetPoint
;
1226 case GL_POLYGON_OFFSET_LINE
:
1227 return ctx
->Polygon
.OffsetLine
;
1228 case GL_POLYGON_OFFSET_FILL
:
1229 /*case GL_POLYGON_OFFSET_EXT:*/
1230 return ctx
->Polygon
.OffsetFill
;
1231 case GL_RESCALE_NORMAL_EXT
:
1232 return ctx
->Transform
.RescaleNormals
;
1233 case GL_SCISSOR_TEST
:
1234 return ctx
->Scissor
.Enabled
;
1235 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1236 return ctx
->Texture
.SharedPalette
;
1237 case GL_STENCIL_TEST
:
1238 return ctx
->Stencil
.Enabled
;
1240 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1242 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1244 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1245 case GL_TEXTURE_GEN_Q
:
1247 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1249 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1253 case GL_TEXTURE_GEN_R
:
1255 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1257 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1261 case GL_TEXTURE_GEN_S
:
1263 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1265 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1269 case GL_TEXTURE_GEN_T
:
1271 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1273 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1278 case GL_TEXTURE_GEN_STR_OES
:
1280 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1282 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1290 case GL_VERTEX_ARRAY
:
1291 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1292 case GL_NORMAL_ARRAY
:
1293 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1294 case GL_COLOR_ARRAY
:
1295 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1296 case GL_INDEX_ARRAY
:
1297 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1298 case GL_TEXTURE_COORD_ARRAY
:
1299 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1300 case GL_EDGE_FLAG_ARRAY
:
1301 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1302 case GL_FOG_COORDINATE_ARRAY_EXT
:
1303 CHECK_EXTENSION(EXT_fog_coord
);
1304 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1305 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1306 CHECK_EXTENSION(EXT_secondary_color
);
1307 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1308 #if FEATURE_point_size_array
1309 case GL_POINT_SIZE_ARRAY_OES
:
1310 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1313 /* GL_SGI_texture_color_table */
1314 case GL_TEXTURE_COLOR_TABLE_SGI
:
1315 CHECK_EXTENSION(SGI_texture_color_table
);
1316 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1318 /* GL_ARB_texture_cube_map */
1319 case GL_TEXTURE_CUBE_MAP_ARB
:
1320 CHECK_EXTENSION(ARB_texture_cube_map
);
1321 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1323 /* GL_EXT_secondary_color */
1324 case GL_COLOR_SUM_EXT
:
1325 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1326 return ctx
->Fog
.ColorSumEnabled
;
1328 /* GL_ARB_multisample */
1329 case GL_MULTISAMPLE_ARB
:
1330 return ctx
->Multisample
.Enabled
;
1331 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1332 return ctx
->Multisample
.SampleAlphaToCoverage
;
1333 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1334 return ctx
->Multisample
.SampleAlphaToOne
;
1335 case GL_SAMPLE_COVERAGE_ARB
:
1336 return ctx
->Multisample
.SampleCoverage
;
1337 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1338 return ctx
->Multisample
.SampleCoverageInvert
;
1340 /* GL_IBM_rasterpos_clip */
1341 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1342 CHECK_EXTENSION(IBM_rasterpos_clip
);
1343 return ctx
->Transform
.RasterPositionUnclipped
;
1345 /* GL_NV_point_sprite */
1346 case GL_POINT_SPRITE_NV
:
1347 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1348 return ctx
->Point
.PointSprite
;
1350 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1351 case GL_VERTEX_PROGRAM_ARB
:
1352 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1353 return ctx
->VertexProgram
.Enabled
;
1354 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1355 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1356 return ctx
->VertexProgram
.PointSizeEnabled
;
1357 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1358 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1359 return ctx
->VertexProgram
.TwoSideEnabled
;
1361 #if FEATURE_NV_vertex_program
1362 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1363 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1364 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1365 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1366 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1367 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1368 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1369 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1370 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1371 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1372 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1373 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1374 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1375 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1376 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1377 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1378 CHECK_EXTENSION(NV_vertex_program
);
1380 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1381 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1382 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1384 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1385 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1386 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1387 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1388 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1389 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1390 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1391 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1392 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1393 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1394 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1395 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1396 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1397 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1398 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1399 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1400 CHECK_EXTENSION(NV_vertex_program
);
1402 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1403 return ctx
->Eval
.Map1Attrib
[map
];
1405 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1406 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1407 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1408 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1409 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1410 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1411 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1412 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1413 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1414 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1415 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1416 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1417 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1418 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1419 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1420 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1421 CHECK_EXTENSION(NV_vertex_program
);
1423 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1424 return ctx
->Eval
.Map2Attrib
[map
];
1426 #endif /* FEATURE_NV_vertex_program */
1428 #if FEATURE_NV_fragment_program
1429 case GL_FRAGMENT_PROGRAM_NV
:
1430 CHECK_EXTENSION(NV_fragment_program
);
1431 return ctx
->FragmentProgram
.Enabled
;
1432 #endif /* FEATURE_NV_fragment_program */
1434 /* GL_NV_texture_rectangle */
1435 case GL_TEXTURE_RECTANGLE_NV
:
1436 CHECK_EXTENSION(NV_texture_rectangle
);
1437 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1439 /* GL_EXT_stencil_two_side */
1440 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1441 CHECK_EXTENSION(EXT_stencil_two_side
);
1442 return ctx
->Stencil
.TestTwoSide
;
1444 #if FEATURE_ARB_fragment_program
1445 case GL_FRAGMENT_PROGRAM_ARB
:
1446 return ctx
->FragmentProgram
.Enabled
;
1447 #endif /* FEATURE_ARB_fragment_program */
1449 /* GL_EXT_depth_bounds_test */
1450 case GL_DEPTH_BOUNDS_TEST_EXT
:
1451 CHECK_EXTENSION(EXT_depth_bounds_test
);
1452 return ctx
->Depth
.BoundsTest
;
1454 /* GL_ARB_depth_clamp */
1455 case GL_DEPTH_CLAMP
:
1456 CHECK_EXTENSION(ARB_depth_clamp
);
1457 return ctx
->Transform
.DepthClamp
;
1459 #if FEATURE_ATI_fragment_shader
1460 case GL_FRAGMENT_SHADER_ATI
:
1461 CHECK_EXTENSION(ATI_fragment_shader
);
1462 return ctx
->ATIFragmentShader
.Enabled
;
1463 #endif /* FEATURE_ATI_fragment_shader */
1465 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1466 CHECK_EXTENSION(ARB_seamless_cube_map
);
1467 return ctx
->Texture
.CubeMapSeamless
;
1469 #if FEATURE_EXT_transform_feedback
1470 case GL_RASTERIZER_DISCARD
:
1471 CHECK_EXTENSION(EXT_transform_feedback
);
1472 return ctx
->TransformFeedback
.RasterDiscard
;
1475 /* GL_NV_primitive_restart */
1476 case GL_PRIMITIVE_RESTART_NV
:
1477 if (!ctx
->Extensions
.NV_primitive_restart
) {
1478 goto invalid_enum_error
;
1480 return ctx
->Array
.PrimitiveRestart
;
1482 /* GL 3.1 primitive restart */
1483 case GL_PRIMITIVE_RESTART
:
1484 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1485 goto invalid_enum_error
;
1487 return ctx
->Array
.PrimitiveRestart
;
1489 /* GL3.0 - GL_framebuffer_sRGB */
1490 case GL_FRAMEBUFFER_SRGB_EXT
:
1491 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1492 return ctx
->Color
.sRGBEnabled
;
1495 goto invalid_enum_error
;
1501 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);