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"
38 #include "api_arrayelt.h"
43 #define CHECK_EXTENSION(EXTNAME, CAP) \
44 if (!ctx->Extensions.EXTNAME) { \
45 goto invalid_enum_error; \
50 * Helper to enable/disable client-side state.
53 client_state(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
55 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
61 var
= &arrayObj
->Vertex
.Enabled
;
62 flag
= _NEW_ARRAY_VERTEX
;
65 var
= &arrayObj
->Normal
.Enabled
;
66 flag
= _NEW_ARRAY_NORMAL
;
69 var
= &arrayObj
->Color
.Enabled
;
70 flag
= _NEW_ARRAY_COLOR0
;
73 var
= &arrayObj
->Index
.Enabled
;
74 flag
= _NEW_ARRAY_INDEX
;
76 case GL_TEXTURE_COORD_ARRAY
:
77 var
= &arrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
78 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
80 case GL_EDGE_FLAG_ARRAY
:
81 var
= &arrayObj
->EdgeFlag
.Enabled
;
82 flag
= _NEW_ARRAY_EDGEFLAG
;
84 case GL_FOG_COORDINATE_ARRAY_EXT
:
85 var
= &arrayObj
->FogCoord
.Enabled
;
86 flag
= _NEW_ARRAY_FOGCOORD
;
88 case GL_SECONDARY_COLOR_ARRAY_EXT
:
89 var
= &arrayObj
->SecondaryColor
.Enabled
;
90 flag
= _NEW_ARRAY_COLOR1
;
93 #if FEATURE_point_size_array
94 case GL_POINT_SIZE_ARRAY_OES
:
95 var
= &arrayObj
->PointSize
.Enabled
;
96 flag
= _NEW_ARRAY_POINT_SIZE
;
100 #if FEATURE_NV_vertex_program
101 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
102 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
103 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
117 CHECK_EXTENSION(NV_vertex_program
, cap
);
119 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
120 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
121 var
= &arrayObj
->VertexAttrib
[n
].Enabled
;
122 flag
= _NEW_ARRAY_ATTRIB(n
);
125 #endif /* FEATURE_NV_vertex_program */
128 goto invalid_enum_error
;
134 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
135 ctx
->Array
.NewState
|= flag
;
137 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
142 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
144 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
146 if (ctx
->Driver
.Enable
) {
147 ctx
->Driver
.Enable( ctx
, cap
, state
);
153 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(0x%x)",
154 state
? "Enable" : "Disable", cap
);
159 * Enable GL capability.
160 * \param cap state to enable/disable.
162 * Get's the current context, assures that we're outside glBegin()/glEnd() and
163 * calls client_state().
166 _mesa_EnableClientState( GLenum cap
)
168 GET_CURRENT_CONTEXT(ctx
);
169 ASSERT_OUTSIDE_BEGIN_END(ctx
);
170 client_state( ctx
, cap
, GL_TRUE
);
175 * Disable GL capability.
176 * \param cap state to enable/disable.
178 * Get's the current context, assures that we're outside glBegin()/glEnd() and
179 * calls client_state().
182 _mesa_DisableClientState( GLenum cap
)
184 GET_CURRENT_CONTEXT(ctx
);
185 ASSERT_OUTSIDE_BEGIN_END(ctx
);
186 client_state( ctx
, cap
, GL_FALSE
);
190 #undef CHECK_EXTENSION
191 #define CHECK_EXTENSION(EXTNAME, CAP) \
192 if (!ctx->Extensions.EXTNAME) { \
193 goto invalid_enum_error; \
196 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
197 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
198 goto invalid_enum_error; \
204 * Return pointer to current texture unit for setting/getting coordinate
206 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
207 * higher than the number of supported coordinate units. And we'll return NULL.
209 static struct gl_texture_unit
*
210 get_texcoord_unit(GLcontext
*ctx
)
212 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
213 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
217 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
223 * Helper function to enable or disable a texture target.
224 * \param bit one of the TEXTURE_x_BIT values
225 * \return GL_TRUE if state is changing or GL_FALSE if no change
228 enable_texture(GLcontext
*ctx
, GLboolean state
, GLbitfield texBit
)
230 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
231 const GLbitfield newenabled
= state
232 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
234 if (texUnit
->Enabled
== newenabled
)
237 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
238 texUnit
->Enabled
= newenabled
;
244 * Helper function to enable or disable state.
246 * \param ctx GL context.
247 * \param cap the state to enable/disable
248 * \param state whether to enable or disable the specified capability.
250 * Updates the current context and flushes the vertices as needed. For
251 * capabilities associated with extensions it verifies that those extensions
252 * are effectivly present before updating. Notifies the driver via
253 * dd_function_table::Enable.
256 _mesa_set_enable(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
258 if (MESA_VERBOSE
& VERBOSE_API
)
259 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
260 state
? "glEnable" : "glDisable",
261 _mesa_lookup_enum_by_nr(cap
),
266 if (ctx
->Color
.AlphaEnabled
== state
)
268 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
269 ctx
->Color
.AlphaEnabled
= state
;
272 if (ctx
->Eval
.AutoNormal
== state
)
274 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
275 ctx
->Eval
.AutoNormal
= state
;
279 GLbitfield newEnabled
= state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
280 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
281 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
282 ctx
->Color
.BlendEnabled
= newEnabled
;
294 const GLuint p
= cap
- GL_CLIP_PLANE0
;
296 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
299 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
302 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
304 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
305 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
307 /* This derived state also calculated in clip.c and
308 * from _mesa_update_state() on changes to EyeUserPlane
309 * and ctx->ProjectionMatrix respectively.
311 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
312 ctx
->Transform
.EyeUserPlane
[p
],
313 ctx
->ProjectionMatrixStack
.Top
->inv
);
316 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
321 case GL_COLOR_MATERIAL
:
322 if (ctx
->Light
.ColorMaterialEnabled
== state
)
324 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
325 FLUSH_CURRENT(ctx
, 0);
326 ctx
->Light
.ColorMaterialEnabled
= state
;
328 _mesa_update_color_material( ctx
,
329 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
333 if (ctx
->Polygon
.CullFlag
== state
)
335 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
336 ctx
->Polygon
.CullFlag
= state
;
338 case GL_CULL_VERTEX_EXT
:
339 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
340 if (ctx
->Transform
.CullVertexFlag
== state
)
342 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
343 ctx
->Transform
.CullVertexFlag
= state
;
346 if (ctx
->Depth
.Test
== state
)
348 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
349 ctx
->Depth
.Test
= state
;
353 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
355 if (ctx
->Color
.DitherFlag
== state
)
357 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
358 ctx
->Color
.DitherFlag
= state
;
361 if (ctx
->Fog
.Enabled
== state
)
363 FLUSH_VERTICES(ctx
, _NEW_FOG
);
364 ctx
->Fog
.Enabled
= state
;
374 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
376 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
377 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
379 insert_at_tail(&ctx
->Light
.EnabledList
,
380 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
383 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
387 if (ctx
->Light
.Enabled
== state
)
389 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
390 ctx
->Light
.Enabled
= state
;
391 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
392 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
394 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
397 if (ctx
->Line
.SmoothFlag
== state
)
399 FLUSH_VERTICES(ctx
, _NEW_LINE
);
400 ctx
->Line
.SmoothFlag
= state
;
401 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
403 case GL_LINE_STIPPLE
:
404 if (ctx
->Line
.StippleFlag
== state
)
406 FLUSH_VERTICES(ctx
, _NEW_LINE
);
407 ctx
->Line
.StippleFlag
= state
;
408 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
410 case GL_INDEX_LOGIC_OP
:
411 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
413 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
414 ctx
->Color
.IndexLogicOpEnabled
= state
;
416 case GL_COLOR_LOGIC_OP
:
417 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
419 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
420 ctx
->Color
.ColorLogicOpEnabled
= state
;
422 case GL_MAP1_COLOR_4
:
423 if (ctx
->Eval
.Map1Color4
== state
)
425 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
426 ctx
->Eval
.Map1Color4
= state
;
429 if (ctx
->Eval
.Map1Index
== state
)
431 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
432 ctx
->Eval
.Map1Index
= state
;
435 if (ctx
->Eval
.Map1Normal
== state
)
437 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
438 ctx
->Eval
.Map1Normal
= state
;
440 case GL_MAP1_TEXTURE_COORD_1
:
441 if (ctx
->Eval
.Map1TextureCoord1
== state
)
443 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
444 ctx
->Eval
.Map1TextureCoord1
= state
;
446 case GL_MAP1_TEXTURE_COORD_2
:
447 if (ctx
->Eval
.Map1TextureCoord2
== state
)
449 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
450 ctx
->Eval
.Map1TextureCoord2
= state
;
452 case GL_MAP1_TEXTURE_COORD_3
:
453 if (ctx
->Eval
.Map1TextureCoord3
== state
)
455 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
456 ctx
->Eval
.Map1TextureCoord3
= state
;
458 case GL_MAP1_TEXTURE_COORD_4
:
459 if (ctx
->Eval
.Map1TextureCoord4
== state
)
461 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
462 ctx
->Eval
.Map1TextureCoord4
= state
;
464 case GL_MAP1_VERTEX_3
:
465 if (ctx
->Eval
.Map1Vertex3
== state
)
467 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
468 ctx
->Eval
.Map1Vertex3
= state
;
470 case GL_MAP1_VERTEX_4
:
471 if (ctx
->Eval
.Map1Vertex4
== state
)
473 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
474 ctx
->Eval
.Map1Vertex4
= state
;
476 case GL_MAP2_COLOR_4
:
477 if (ctx
->Eval
.Map2Color4
== state
)
479 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
480 ctx
->Eval
.Map2Color4
= state
;
483 if (ctx
->Eval
.Map2Index
== state
)
485 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
486 ctx
->Eval
.Map2Index
= state
;
489 if (ctx
->Eval
.Map2Normal
== state
)
491 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
492 ctx
->Eval
.Map2Normal
= state
;
494 case GL_MAP2_TEXTURE_COORD_1
:
495 if (ctx
->Eval
.Map2TextureCoord1
== state
)
497 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
498 ctx
->Eval
.Map2TextureCoord1
= state
;
500 case GL_MAP2_TEXTURE_COORD_2
:
501 if (ctx
->Eval
.Map2TextureCoord2
== state
)
503 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
504 ctx
->Eval
.Map2TextureCoord2
= state
;
506 case GL_MAP2_TEXTURE_COORD_3
:
507 if (ctx
->Eval
.Map2TextureCoord3
== state
)
509 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
510 ctx
->Eval
.Map2TextureCoord3
= state
;
512 case GL_MAP2_TEXTURE_COORD_4
:
513 if (ctx
->Eval
.Map2TextureCoord4
== state
)
515 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
516 ctx
->Eval
.Map2TextureCoord4
= state
;
518 case GL_MAP2_VERTEX_3
:
519 if (ctx
->Eval
.Map2Vertex3
== state
)
521 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
522 ctx
->Eval
.Map2Vertex3
= state
;
524 case GL_MAP2_VERTEX_4
:
525 if (ctx
->Eval
.Map2Vertex4
== state
)
527 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
528 ctx
->Eval
.Map2Vertex4
= state
;
531 if (ctx
->Transform
.Normalize
== state
)
533 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
534 ctx
->Transform
.Normalize
= state
;
536 case GL_POINT_SMOOTH
:
537 if (ctx
->Point
.SmoothFlag
== state
)
539 FLUSH_VERTICES(ctx
, _NEW_POINT
);
540 ctx
->Point
.SmoothFlag
= state
;
541 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
543 case GL_POLYGON_SMOOTH
:
544 if (ctx
->Polygon
.SmoothFlag
== state
)
546 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
547 ctx
->Polygon
.SmoothFlag
= state
;
548 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
550 case GL_POLYGON_STIPPLE
:
551 if (ctx
->Polygon
.StippleFlag
== state
)
553 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
554 ctx
->Polygon
.StippleFlag
= state
;
555 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
557 case GL_POLYGON_OFFSET_POINT
:
558 if (ctx
->Polygon
.OffsetPoint
== state
)
560 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
561 ctx
->Polygon
.OffsetPoint
= state
;
563 case GL_POLYGON_OFFSET_LINE
:
564 if (ctx
->Polygon
.OffsetLine
== state
)
566 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
567 ctx
->Polygon
.OffsetLine
= state
;
569 case GL_POLYGON_OFFSET_FILL
:
570 /*case GL_POLYGON_OFFSET_EXT:*/
571 if (ctx
->Polygon
.OffsetFill
== state
)
573 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
574 ctx
->Polygon
.OffsetFill
= state
;
576 case GL_RESCALE_NORMAL_EXT
:
577 if (ctx
->Transform
.RescaleNormals
== state
)
579 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
580 ctx
->Transform
.RescaleNormals
= state
;
582 case GL_SCISSOR_TEST
:
583 if (ctx
->Scissor
.Enabled
== state
)
585 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
586 ctx
->Scissor
.Enabled
= state
;
588 case GL_SHARED_TEXTURE_PALETTE_EXT
:
589 if (ctx
->Texture
.SharedPalette
== state
)
591 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
592 ctx
->Texture
.SharedPalette
= state
;
594 case GL_STENCIL_TEST
:
595 if (ctx
->Stencil
.Enabled
== state
)
597 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
598 ctx
->Stencil
.Enabled
= state
;
601 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
606 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
611 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
615 case GL_TEXTURE_GEN_Q
:
617 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
619 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
622 if (texUnit
->TexGenEnabled
== newenabled
)
624 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
625 texUnit
->TexGenEnabled
= newenabled
;
629 case GL_TEXTURE_GEN_R
:
631 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
633 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
636 if (texUnit
->TexGenEnabled
== newenabled
)
638 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
639 texUnit
->TexGenEnabled
= newenabled
;
643 case GL_TEXTURE_GEN_S
:
645 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
647 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
650 if (texUnit
->TexGenEnabled
== newenabled
)
652 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
653 texUnit
->TexGenEnabled
= newenabled
;
657 case GL_TEXTURE_GEN_T
:
659 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
661 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
664 if (texUnit
->TexGenEnabled
== newenabled
)
666 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
667 texUnit
->TexGenEnabled
= newenabled
;
673 case GL_TEXTURE_GEN_STR_OES
:
674 /* disable S, T, and R at the same time */
676 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
679 texUnit
->TexGenEnabled
& ~STR_BITS
;
681 newenabled
|= STR_BITS
;
682 if (texUnit
->TexGenEnabled
== newenabled
)
684 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
685 texUnit
->TexGenEnabled
= newenabled
;
694 case GL_VERTEX_ARRAY
:
695 case GL_NORMAL_ARRAY
:
698 case GL_TEXTURE_COORD_ARRAY
:
699 case GL_EDGE_FLAG_ARRAY
:
700 case GL_FOG_COORDINATE_ARRAY_EXT
:
701 case GL_SECONDARY_COLOR_ARRAY_EXT
:
702 case GL_POINT_SIZE_ARRAY_OES
:
703 client_state( ctx
, cap
, state
);
706 /* GL_SGI_texture_color_table */
707 case GL_TEXTURE_COLOR_TABLE_SGI
:
708 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
709 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
711 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
712 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
715 /* GL_ARB_texture_cube_map */
716 case GL_TEXTURE_CUBE_MAP_ARB
:
717 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
718 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
723 /* GL_EXT_secondary_color */
724 case GL_COLOR_SUM_EXT
:
725 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
726 if (ctx
->Fog
.ColorSumEnabled
== state
)
728 FLUSH_VERTICES(ctx
, _NEW_FOG
);
729 ctx
->Fog
.ColorSumEnabled
= state
;
732 /* GL_ARB_multisample */
733 case GL_MULTISAMPLE_ARB
:
734 if (ctx
->Multisample
.Enabled
== state
)
736 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
737 ctx
->Multisample
.Enabled
= state
;
739 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
740 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
743 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
745 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
746 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
748 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
749 ctx
->Multisample
.SampleAlphaToOne
= state
;
751 case GL_SAMPLE_COVERAGE_ARB
:
752 if (ctx
->Multisample
.SampleCoverage
== state
)
754 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
755 ctx
->Multisample
.SampleCoverage
= state
;
757 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
758 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
760 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
761 ctx
->Multisample
.SampleCoverageInvert
= state
;
764 /* GL_IBM_rasterpos_clip */
765 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
766 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
767 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
769 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
770 ctx
->Transform
.RasterPositionUnclipped
= state
;
773 /* GL_NV_point_sprite */
774 case GL_POINT_SPRITE_NV
:
775 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
776 if (ctx
->Point
.PointSprite
== state
)
778 FLUSH_VERTICES(ctx
, _NEW_POINT
);
779 ctx
->Point
.PointSprite
= state
;
782 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
783 case GL_VERTEX_PROGRAM_ARB
:
784 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
785 if (ctx
->VertexProgram
.Enabled
== state
)
787 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
788 ctx
->VertexProgram
.Enabled
= state
;
790 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
791 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
792 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
794 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
795 ctx
->VertexProgram
.PointSizeEnabled
= state
;
797 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
798 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
799 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
801 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
802 ctx
->VertexProgram
.TwoSideEnabled
= state
;
805 #if FEATURE_NV_vertex_program
806 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
807 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
808 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
809 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
810 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
811 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
812 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
813 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
814 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
815 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
816 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
817 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
818 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
819 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
820 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
821 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
822 CHECK_EXTENSION(NV_vertex_program
, cap
);
824 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
825 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
826 ctx
->Eval
.Map1Attrib
[map
] = state
;
829 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
830 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
831 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
832 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
833 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
834 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
835 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
836 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
837 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
838 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
839 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
840 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
841 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
842 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
843 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
844 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
845 CHECK_EXTENSION(NV_vertex_program
, cap
);
847 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
848 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
849 ctx
->Eval
.Map2Attrib
[map
] = state
;
852 #endif /* FEATURE_NV_vertex_program */
854 #if FEATURE_NV_fragment_program
855 case GL_FRAGMENT_PROGRAM_NV
:
856 CHECK_EXTENSION(NV_fragment_program
, cap
);
857 if (ctx
->FragmentProgram
.Enabled
== state
)
859 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
860 ctx
->FragmentProgram
.Enabled
= state
;
862 #endif /* FEATURE_NV_fragment_program */
864 /* GL_NV_texture_rectangle */
865 case GL_TEXTURE_RECTANGLE_NV
:
866 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
867 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
872 /* GL_EXT_stencil_two_side */
873 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
874 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
875 if (ctx
->Stencil
.TestTwoSide
== state
)
877 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
878 ctx
->Stencil
.TestTwoSide
= state
;
880 ctx
->Stencil
._BackFace
= 2;
881 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
883 ctx
->Stencil
._BackFace
= 1;
884 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
888 #if FEATURE_ARB_fragment_program
889 case GL_FRAGMENT_PROGRAM_ARB
:
890 CHECK_EXTENSION(ARB_fragment_program
, cap
);
891 if (ctx
->FragmentProgram
.Enabled
== state
)
893 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
894 ctx
->FragmentProgram
.Enabled
= state
;
896 #endif /* FEATURE_ARB_fragment_program */
898 /* GL_EXT_depth_bounds_test */
899 case GL_DEPTH_BOUNDS_TEST_EXT
:
900 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
901 if (ctx
->Depth
.BoundsTest
== state
)
903 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
904 ctx
->Depth
.BoundsTest
= state
;
908 if (ctx
->Transform
.DepthClamp
== state
)
910 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
911 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
912 ctx
->Transform
.DepthClamp
= state
;
915 #if FEATURE_ATI_fragment_shader
916 case GL_FRAGMENT_SHADER_ATI
:
917 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
918 if (ctx
->ATIFragmentShader
.Enabled
== state
)
920 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
921 ctx
->ATIFragmentShader
.Enabled
= state
;
925 /* GL_MESA_texture_array */
926 case GL_TEXTURE_1D_ARRAY_EXT
:
927 CHECK_EXTENSION(MESA_texture_array
, cap
);
928 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
933 case GL_TEXTURE_2D_ARRAY_EXT
:
934 CHECK_EXTENSION(MESA_texture_array
, cap
);
935 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
940 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
941 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
942 ctx
->Texture
.CubeMapSeamless
= state
;
945 #if FEATURE_EXT_transform_feedback
946 case GL_RASTERIZER_DISCARD
:
947 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
948 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
949 ctx
->TransformFeedback
.RasterDiscard
= state
;
950 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
955 /* GL 3.1 primitive restart */
956 case GL_PRIMITIVE_RESTART
:
957 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
958 goto invalid_enum_error
;
960 if (ctx
->Array
.PrimitiveRestart
!= state
) {
961 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
962 ctx
->Array
.PrimitiveRestart
= state
;
967 goto invalid_enum_error
;
970 if (ctx
->Driver
.Enable
) {
971 ctx
->Driver
.Enable( ctx
, cap
, state
);
977 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
978 state
? "Enable" : "Disable", cap
);
983 * Enable GL capability. Called by glEnable()
984 * \param cap state to enable.
987 _mesa_Enable( GLenum cap
)
989 GET_CURRENT_CONTEXT(ctx
);
990 ASSERT_OUTSIDE_BEGIN_END(ctx
);
992 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
997 * Disable GL capability. Called by glDisable()
998 * \param cap state to disable.
1001 _mesa_Disable( GLenum cap
)
1003 GET_CURRENT_CONTEXT(ctx
);
1004 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1006 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1012 * Enable/disable an indexed state var.
1015 _mesa_set_enablei(GLcontext
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1017 ASSERT(state
== 0 || state
== 1);
1020 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1021 goto invalid_enum_error
;
1023 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1024 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1025 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1028 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1029 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1031 ctx
->Color
.BlendEnabled
|= (1 << index
);
1033 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1037 goto invalid_enum_error
;
1042 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1043 state
? "glEnablei" : "glDisablei",
1044 _mesa_lookup_enum_by_nr(cap
));
1049 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1051 GET_CURRENT_CONTEXT(ctx
);
1052 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1053 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1058 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1060 GET_CURRENT_CONTEXT(ctx
);
1061 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1062 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1066 GLboolean GLAPIENTRY
1067 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1069 GET_CURRENT_CONTEXT(ctx
);
1072 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1073 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1077 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1079 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1080 _mesa_lookup_enum_by_nr(cap
));
1088 #undef CHECK_EXTENSION
1089 #define CHECK_EXTENSION(EXTNAME) \
1090 if (!ctx->Extensions.EXTNAME) { \
1091 goto invalid_enum_error; \
1094 #undef CHECK_EXTENSION2
1095 #define CHECK_EXTENSION2(EXT1, EXT2) \
1096 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1097 goto invalid_enum_error; \
1102 * Helper function to determine whether a texture target is enabled.
1105 is_texture_enabled(GLcontext
*ctx
, GLbitfield bit
)
1107 const struct gl_texture_unit
*const texUnit
=
1108 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1109 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1114 * Return simple enable/disable state.
1116 * \param cap state variable to query.
1118 * Returns the state of the specified capability from the current GL context.
1119 * For the capabilities associated with extensions verifies that those
1120 * extensions are effectively present before reporting.
1122 GLboolean GLAPIENTRY
1123 _mesa_IsEnabled( GLenum cap
)
1125 GET_CURRENT_CONTEXT(ctx
);
1128 return ctx
->Color
.AlphaEnabled
;
1129 case GL_AUTO_NORMAL
:
1130 return ctx
->Eval
.AutoNormal
;
1132 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1133 case GL_CLIP_PLANE0
:
1134 case GL_CLIP_PLANE1
:
1135 case GL_CLIP_PLANE2
:
1136 case GL_CLIP_PLANE3
:
1137 case GL_CLIP_PLANE4
:
1138 case GL_CLIP_PLANE5
:
1139 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1140 case GL_COLOR_MATERIAL
:
1141 return ctx
->Light
.ColorMaterialEnabled
;
1143 return ctx
->Polygon
.CullFlag
;
1145 return ctx
->Depth
.Test
;
1147 return ctx
->Color
.DitherFlag
;
1149 return ctx
->Fog
.Enabled
;
1151 return ctx
->Light
.Enabled
;
1160 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1161 case GL_LINE_SMOOTH
:
1162 return ctx
->Line
.SmoothFlag
;
1163 case GL_LINE_STIPPLE
:
1164 return ctx
->Line
.StippleFlag
;
1165 case GL_INDEX_LOGIC_OP
:
1166 return ctx
->Color
.IndexLogicOpEnabled
;
1167 case GL_COLOR_LOGIC_OP
:
1168 return ctx
->Color
.ColorLogicOpEnabled
;
1169 case GL_MAP1_COLOR_4
:
1170 return ctx
->Eval
.Map1Color4
;
1172 return ctx
->Eval
.Map1Index
;
1173 case GL_MAP1_NORMAL
:
1174 return ctx
->Eval
.Map1Normal
;
1175 case GL_MAP1_TEXTURE_COORD_1
:
1176 return ctx
->Eval
.Map1TextureCoord1
;
1177 case GL_MAP1_TEXTURE_COORD_2
:
1178 return ctx
->Eval
.Map1TextureCoord2
;
1179 case GL_MAP1_TEXTURE_COORD_3
:
1180 return ctx
->Eval
.Map1TextureCoord3
;
1181 case GL_MAP1_TEXTURE_COORD_4
:
1182 return ctx
->Eval
.Map1TextureCoord4
;
1183 case GL_MAP1_VERTEX_3
:
1184 return ctx
->Eval
.Map1Vertex3
;
1185 case GL_MAP1_VERTEX_4
:
1186 return ctx
->Eval
.Map1Vertex4
;
1187 case GL_MAP2_COLOR_4
:
1188 return ctx
->Eval
.Map2Color4
;
1190 return ctx
->Eval
.Map2Index
;
1191 case GL_MAP2_NORMAL
:
1192 return ctx
->Eval
.Map2Normal
;
1193 case GL_MAP2_TEXTURE_COORD_1
:
1194 return ctx
->Eval
.Map2TextureCoord1
;
1195 case GL_MAP2_TEXTURE_COORD_2
:
1196 return ctx
->Eval
.Map2TextureCoord2
;
1197 case GL_MAP2_TEXTURE_COORD_3
:
1198 return ctx
->Eval
.Map2TextureCoord3
;
1199 case GL_MAP2_TEXTURE_COORD_4
:
1200 return ctx
->Eval
.Map2TextureCoord4
;
1201 case GL_MAP2_VERTEX_3
:
1202 return ctx
->Eval
.Map2Vertex3
;
1203 case GL_MAP2_VERTEX_4
:
1204 return ctx
->Eval
.Map2Vertex4
;
1206 return ctx
->Transform
.Normalize
;
1207 case GL_POINT_SMOOTH
:
1208 return ctx
->Point
.SmoothFlag
;
1209 case GL_POLYGON_SMOOTH
:
1210 return ctx
->Polygon
.SmoothFlag
;
1211 case GL_POLYGON_STIPPLE
:
1212 return ctx
->Polygon
.StippleFlag
;
1213 case GL_POLYGON_OFFSET_POINT
:
1214 return ctx
->Polygon
.OffsetPoint
;
1215 case GL_POLYGON_OFFSET_LINE
:
1216 return ctx
->Polygon
.OffsetLine
;
1217 case GL_POLYGON_OFFSET_FILL
:
1218 /*case GL_POLYGON_OFFSET_EXT:*/
1219 return ctx
->Polygon
.OffsetFill
;
1220 case GL_RESCALE_NORMAL_EXT
:
1221 return ctx
->Transform
.RescaleNormals
;
1222 case GL_SCISSOR_TEST
:
1223 return ctx
->Scissor
.Enabled
;
1224 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1225 return ctx
->Texture
.SharedPalette
;
1226 case GL_STENCIL_TEST
:
1227 return ctx
->Stencil
.Enabled
;
1229 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1231 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1233 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1234 case GL_TEXTURE_GEN_Q
:
1236 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1238 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1242 case GL_TEXTURE_GEN_R
:
1244 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1246 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1250 case GL_TEXTURE_GEN_S
:
1252 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1254 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1258 case GL_TEXTURE_GEN_T
:
1260 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1262 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1267 case GL_TEXTURE_GEN_STR_OES
:
1269 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1271 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1279 case GL_VERTEX_ARRAY
:
1280 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1281 case GL_NORMAL_ARRAY
:
1282 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1283 case GL_COLOR_ARRAY
:
1284 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1285 case GL_INDEX_ARRAY
:
1286 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1287 case GL_TEXTURE_COORD_ARRAY
:
1288 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1289 case GL_EDGE_FLAG_ARRAY
:
1290 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1291 case GL_FOG_COORDINATE_ARRAY_EXT
:
1292 CHECK_EXTENSION(EXT_fog_coord
);
1293 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1294 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1295 CHECK_EXTENSION(EXT_secondary_color
);
1296 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1297 #if FEATURE_point_size_array
1298 case GL_POINT_SIZE_ARRAY_OES
:
1299 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1302 /* GL_SGI_texture_color_table */
1303 case GL_TEXTURE_COLOR_TABLE_SGI
:
1304 CHECK_EXTENSION(SGI_texture_color_table
);
1305 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1307 /* GL_ARB_texture_cube_map */
1308 case GL_TEXTURE_CUBE_MAP_ARB
:
1309 CHECK_EXTENSION(ARB_texture_cube_map
);
1310 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1312 /* GL_EXT_secondary_color */
1313 case GL_COLOR_SUM_EXT
:
1314 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1315 return ctx
->Fog
.ColorSumEnabled
;
1317 /* GL_ARB_multisample */
1318 case GL_MULTISAMPLE_ARB
:
1319 return ctx
->Multisample
.Enabled
;
1320 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1321 return ctx
->Multisample
.SampleAlphaToCoverage
;
1322 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1323 return ctx
->Multisample
.SampleAlphaToOne
;
1324 case GL_SAMPLE_COVERAGE_ARB
:
1325 return ctx
->Multisample
.SampleCoverage
;
1326 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1327 return ctx
->Multisample
.SampleCoverageInvert
;
1329 /* GL_IBM_rasterpos_clip */
1330 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1331 CHECK_EXTENSION(IBM_rasterpos_clip
);
1332 return ctx
->Transform
.RasterPositionUnclipped
;
1334 /* GL_NV_point_sprite */
1335 case GL_POINT_SPRITE_NV
:
1336 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1337 return ctx
->Point
.PointSprite
;
1339 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1340 case GL_VERTEX_PROGRAM_ARB
:
1341 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1342 return ctx
->VertexProgram
.Enabled
;
1343 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1344 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1345 return ctx
->VertexProgram
.PointSizeEnabled
;
1346 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1347 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1348 return ctx
->VertexProgram
.TwoSideEnabled
;
1350 #if FEATURE_NV_vertex_program
1351 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1352 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1353 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1354 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1355 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1356 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1357 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1358 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1359 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1360 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1361 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1362 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1363 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1364 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1365 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1366 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1367 CHECK_EXTENSION(NV_vertex_program
);
1369 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1370 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1371 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1373 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1374 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1375 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1376 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1377 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1378 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1379 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1380 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1381 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1382 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1383 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1384 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1385 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1386 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1387 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1388 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1389 CHECK_EXTENSION(NV_vertex_program
);
1391 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1392 return ctx
->Eval
.Map1Attrib
[map
];
1394 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1395 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1396 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1397 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1398 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1399 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1400 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1401 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1402 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1403 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1404 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1405 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1406 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1407 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1408 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1409 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1410 CHECK_EXTENSION(NV_vertex_program
);
1412 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1413 return ctx
->Eval
.Map2Attrib
[map
];
1415 #endif /* FEATURE_NV_vertex_program */
1417 #if FEATURE_NV_fragment_program
1418 case GL_FRAGMENT_PROGRAM_NV
:
1419 CHECK_EXTENSION(NV_fragment_program
);
1420 return ctx
->FragmentProgram
.Enabled
;
1421 #endif /* FEATURE_NV_fragment_program */
1423 /* GL_NV_texture_rectangle */
1424 case GL_TEXTURE_RECTANGLE_NV
:
1425 CHECK_EXTENSION(NV_texture_rectangle
);
1426 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1428 /* GL_EXT_stencil_two_side */
1429 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1430 CHECK_EXTENSION(EXT_stencil_two_side
);
1431 return ctx
->Stencil
.TestTwoSide
;
1433 #if FEATURE_ARB_fragment_program
1434 case GL_FRAGMENT_PROGRAM_ARB
:
1435 return ctx
->FragmentProgram
.Enabled
;
1436 #endif /* FEATURE_ARB_fragment_program */
1438 /* GL_EXT_depth_bounds_test */
1439 case GL_DEPTH_BOUNDS_TEST_EXT
:
1440 CHECK_EXTENSION(EXT_depth_bounds_test
);
1441 return ctx
->Depth
.BoundsTest
;
1443 /* GL_ARB_depth_clamp */
1444 case GL_DEPTH_CLAMP
:
1445 CHECK_EXTENSION(ARB_depth_clamp
);
1446 return ctx
->Transform
.DepthClamp
;
1448 #if FEATURE_ATI_fragment_shader
1449 case GL_FRAGMENT_SHADER_ATI
:
1450 CHECK_EXTENSION(ATI_fragment_shader
);
1451 return ctx
->ATIFragmentShader
.Enabled
;
1452 #endif /* FEATURE_ATI_fragment_shader */
1454 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1455 CHECK_EXTENSION(ARB_seamless_cube_map
);
1456 return ctx
->Texture
.CubeMapSeamless
;
1458 #if FEATURE_EXT_transform_feedback
1459 case GL_RASTERIZER_DISCARD
:
1460 CHECK_EXTENSION(EXT_transform_feedback
);
1461 return ctx
->TransformFeedback
.RasterDiscard
;
1464 /* GL 3.1 primitive restart */
1465 case GL_PRIMITIVE_RESTART
:
1466 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1467 goto invalid_enum_error
;
1469 return ctx
->Array
.PrimitiveRestart
;
1472 goto invalid_enum_error
;
1478 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);