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_EXT_convolution */
716 case GL_CONVOLUTION_1D
:
717 CHECK_EXTENSION(EXT_convolution
, cap
);
718 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
720 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
721 ctx
->Pixel
.Convolution1DEnabled
= state
;
723 case GL_CONVOLUTION_2D
:
724 CHECK_EXTENSION(EXT_convolution
, cap
);
725 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
727 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
728 ctx
->Pixel
.Convolution2DEnabled
= state
;
730 case GL_SEPARABLE_2D
:
731 CHECK_EXTENSION(EXT_convolution
, cap
);
732 if (ctx
->Pixel
.Separable2DEnabled
== state
)
734 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
735 ctx
->Pixel
.Separable2DEnabled
= state
;
738 /* GL_ARB_texture_cube_map */
739 case GL_TEXTURE_CUBE_MAP_ARB
:
740 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
741 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
746 /* GL_EXT_secondary_color */
747 case GL_COLOR_SUM_EXT
:
748 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
749 if (ctx
->Fog
.ColorSumEnabled
== state
)
751 FLUSH_VERTICES(ctx
, _NEW_FOG
);
752 ctx
->Fog
.ColorSumEnabled
= state
;
755 /* GL_ARB_multisample */
756 case GL_MULTISAMPLE_ARB
:
757 if (ctx
->Multisample
.Enabled
== state
)
759 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
760 ctx
->Multisample
.Enabled
= state
;
762 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
763 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
765 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
766 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
768 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
769 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
771 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
772 ctx
->Multisample
.SampleAlphaToOne
= state
;
774 case GL_SAMPLE_COVERAGE_ARB
:
775 if (ctx
->Multisample
.SampleCoverage
== state
)
777 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
778 ctx
->Multisample
.SampleCoverage
= state
;
780 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
781 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
783 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
784 ctx
->Multisample
.SampleCoverageInvert
= state
;
787 /* GL_IBM_rasterpos_clip */
788 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
789 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
790 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
792 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
793 ctx
->Transform
.RasterPositionUnclipped
= state
;
796 /* GL_NV_point_sprite */
797 case GL_POINT_SPRITE_NV
:
798 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
799 if (ctx
->Point
.PointSprite
== state
)
801 FLUSH_VERTICES(ctx
, _NEW_POINT
);
802 ctx
->Point
.PointSprite
= state
;
805 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
806 case GL_VERTEX_PROGRAM_ARB
:
807 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
808 if (ctx
->VertexProgram
.Enabled
== state
)
810 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
811 ctx
->VertexProgram
.Enabled
= state
;
813 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
814 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
815 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
817 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
818 ctx
->VertexProgram
.PointSizeEnabled
= state
;
820 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
821 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
822 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
824 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
825 ctx
->VertexProgram
.TwoSideEnabled
= state
;
828 #if FEATURE_NV_vertex_program
829 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
830 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
831 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
832 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
833 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
834 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
835 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
836 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
837 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
838 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
839 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
840 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
841 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
842 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
843 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
844 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
845 CHECK_EXTENSION(NV_vertex_program
, cap
);
847 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
848 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
849 ctx
->Eval
.Map1Attrib
[map
] = state
;
852 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
853 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
854 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
855 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
856 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
857 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
858 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
859 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
860 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
861 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
862 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
863 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
864 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
865 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
866 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
867 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
868 CHECK_EXTENSION(NV_vertex_program
, cap
);
870 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
871 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
872 ctx
->Eval
.Map2Attrib
[map
] = state
;
875 #endif /* FEATURE_NV_vertex_program */
877 #if FEATURE_NV_fragment_program
878 case GL_FRAGMENT_PROGRAM_NV
:
879 CHECK_EXTENSION(NV_fragment_program
, cap
);
880 if (ctx
->FragmentProgram
.Enabled
== state
)
882 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
883 ctx
->FragmentProgram
.Enabled
= state
;
885 #endif /* FEATURE_NV_fragment_program */
887 /* GL_NV_texture_rectangle */
888 case GL_TEXTURE_RECTANGLE_NV
:
889 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
890 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
895 /* GL_EXT_stencil_two_side */
896 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
897 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
898 if (ctx
->Stencil
.TestTwoSide
== state
)
900 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
901 ctx
->Stencil
.TestTwoSide
= state
;
903 ctx
->Stencil
._BackFace
= 2;
904 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
906 ctx
->Stencil
._BackFace
= 1;
907 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
911 #if FEATURE_ARB_fragment_program
912 case GL_FRAGMENT_PROGRAM_ARB
:
913 CHECK_EXTENSION(ARB_fragment_program
, cap
);
914 if (ctx
->FragmentProgram
.Enabled
== state
)
916 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
917 ctx
->FragmentProgram
.Enabled
= state
;
919 #endif /* FEATURE_ARB_fragment_program */
921 /* GL_EXT_depth_bounds_test */
922 case GL_DEPTH_BOUNDS_TEST_EXT
:
923 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
924 if (ctx
->Depth
.BoundsTest
== state
)
926 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
927 ctx
->Depth
.BoundsTest
= state
;
931 if (ctx
->Transform
.DepthClamp
== state
)
933 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
934 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
935 ctx
->Transform
.DepthClamp
= state
;
938 #if FEATURE_ATI_fragment_shader
939 case GL_FRAGMENT_SHADER_ATI
:
940 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
941 if (ctx
->ATIFragmentShader
.Enabled
== state
)
943 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
944 ctx
->ATIFragmentShader
.Enabled
= state
;
948 /* GL_MESA_texture_array */
949 case GL_TEXTURE_1D_ARRAY_EXT
:
950 CHECK_EXTENSION(MESA_texture_array
, cap
);
951 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
956 case GL_TEXTURE_2D_ARRAY_EXT
:
957 CHECK_EXTENSION(MESA_texture_array
, cap
);
958 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
963 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
964 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
965 ctx
->Texture
.CubeMapSeamless
= state
;
968 #if FEATURE_EXT_transform_feedback
969 case GL_RASTERIZER_DISCARD
:
970 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
971 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
972 ctx
->TransformFeedback
.RasterDiscard
= state
;
973 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
978 /* GL 3.1 primitive restart */
979 case GL_PRIMITIVE_RESTART
:
980 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
981 goto invalid_enum_error
;
983 if (ctx
->Array
.PrimitiveRestart
!= state
) {
984 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
985 ctx
->Array
.PrimitiveRestart
= state
;
990 goto invalid_enum_error
;
993 if (ctx
->Driver
.Enable
) {
994 ctx
->Driver
.Enable( ctx
, cap
, state
);
1000 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
1001 state
? "Enable" : "Disable", cap
);
1006 * Enable GL capability. Called by glEnable()
1007 * \param cap state to enable.
1010 _mesa_Enable( GLenum cap
)
1012 GET_CURRENT_CONTEXT(ctx
);
1013 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1015 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1020 * Disable GL capability. Called by glDisable()
1021 * \param cap state to disable.
1024 _mesa_Disable( GLenum cap
)
1026 GET_CURRENT_CONTEXT(ctx
);
1027 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1029 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1035 * Enable/disable an indexed state var.
1038 _mesa_set_enablei(GLcontext
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1040 ASSERT(state
== 0 || state
== 1);
1043 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1044 goto invalid_enum_error
;
1046 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1047 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1048 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1051 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1052 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1054 ctx
->Color
.BlendEnabled
|= (1 << index
);
1056 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1060 goto invalid_enum_error
;
1065 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1066 state
? "glEnablei" : "glDisablei",
1067 _mesa_lookup_enum_by_nr(cap
));
1072 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1074 GET_CURRENT_CONTEXT(ctx
);
1075 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1076 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1081 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1083 GET_CURRENT_CONTEXT(ctx
);
1084 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1085 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1089 GLboolean GLAPIENTRY
1090 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1092 GET_CURRENT_CONTEXT(ctx
);
1095 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1096 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1100 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1102 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1103 _mesa_lookup_enum_by_nr(cap
));
1111 #undef CHECK_EXTENSION
1112 #define CHECK_EXTENSION(EXTNAME) \
1113 if (!ctx->Extensions.EXTNAME) { \
1114 goto invalid_enum_error; \
1117 #undef CHECK_EXTENSION2
1118 #define CHECK_EXTENSION2(EXT1, EXT2) \
1119 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1120 goto invalid_enum_error; \
1125 * Helper function to determine whether a texture target is enabled.
1128 is_texture_enabled(GLcontext
*ctx
, GLbitfield bit
)
1130 const struct gl_texture_unit
*const texUnit
=
1131 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1132 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1137 * Return simple enable/disable state.
1139 * \param cap state variable to query.
1141 * Returns the state of the specified capability from the current GL context.
1142 * For the capabilities associated with extensions verifies that those
1143 * extensions are effectively present before reporting.
1145 GLboolean GLAPIENTRY
1146 _mesa_IsEnabled( GLenum cap
)
1148 GET_CURRENT_CONTEXT(ctx
);
1151 return ctx
->Color
.AlphaEnabled
;
1152 case GL_AUTO_NORMAL
:
1153 return ctx
->Eval
.AutoNormal
;
1155 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1156 case GL_CLIP_PLANE0
:
1157 case GL_CLIP_PLANE1
:
1158 case GL_CLIP_PLANE2
:
1159 case GL_CLIP_PLANE3
:
1160 case GL_CLIP_PLANE4
:
1161 case GL_CLIP_PLANE5
:
1162 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1163 case GL_COLOR_MATERIAL
:
1164 return ctx
->Light
.ColorMaterialEnabled
;
1166 return ctx
->Polygon
.CullFlag
;
1168 return ctx
->Depth
.Test
;
1170 return ctx
->Color
.DitherFlag
;
1172 return ctx
->Fog
.Enabled
;
1174 return ctx
->Light
.Enabled
;
1183 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1184 case GL_LINE_SMOOTH
:
1185 return ctx
->Line
.SmoothFlag
;
1186 case GL_LINE_STIPPLE
:
1187 return ctx
->Line
.StippleFlag
;
1188 case GL_INDEX_LOGIC_OP
:
1189 return ctx
->Color
.IndexLogicOpEnabled
;
1190 case GL_COLOR_LOGIC_OP
:
1191 return ctx
->Color
.ColorLogicOpEnabled
;
1192 case GL_MAP1_COLOR_4
:
1193 return ctx
->Eval
.Map1Color4
;
1195 return ctx
->Eval
.Map1Index
;
1196 case GL_MAP1_NORMAL
:
1197 return ctx
->Eval
.Map1Normal
;
1198 case GL_MAP1_TEXTURE_COORD_1
:
1199 return ctx
->Eval
.Map1TextureCoord1
;
1200 case GL_MAP1_TEXTURE_COORD_2
:
1201 return ctx
->Eval
.Map1TextureCoord2
;
1202 case GL_MAP1_TEXTURE_COORD_3
:
1203 return ctx
->Eval
.Map1TextureCoord3
;
1204 case GL_MAP1_TEXTURE_COORD_4
:
1205 return ctx
->Eval
.Map1TextureCoord4
;
1206 case GL_MAP1_VERTEX_3
:
1207 return ctx
->Eval
.Map1Vertex3
;
1208 case GL_MAP1_VERTEX_4
:
1209 return ctx
->Eval
.Map1Vertex4
;
1210 case GL_MAP2_COLOR_4
:
1211 return ctx
->Eval
.Map2Color4
;
1213 return ctx
->Eval
.Map2Index
;
1214 case GL_MAP2_NORMAL
:
1215 return ctx
->Eval
.Map2Normal
;
1216 case GL_MAP2_TEXTURE_COORD_1
:
1217 return ctx
->Eval
.Map2TextureCoord1
;
1218 case GL_MAP2_TEXTURE_COORD_2
:
1219 return ctx
->Eval
.Map2TextureCoord2
;
1220 case GL_MAP2_TEXTURE_COORD_3
:
1221 return ctx
->Eval
.Map2TextureCoord3
;
1222 case GL_MAP2_TEXTURE_COORD_4
:
1223 return ctx
->Eval
.Map2TextureCoord4
;
1224 case GL_MAP2_VERTEX_3
:
1225 return ctx
->Eval
.Map2Vertex3
;
1226 case GL_MAP2_VERTEX_4
:
1227 return ctx
->Eval
.Map2Vertex4
;
1229 return ctx
->Transform
.Normalize
;
1230 case GL_POINT_SMOOTH
:
1231 return ctx
->Point
.SmoothFlag
;
1232 case GL_POLYGON_SMOOTH
:
1233 return ctx
->Polygon
.SmoothFlag
;
1234 case GL_POLYGON_STIPPLE
:
1235 return ctx
->Polygon
.StippleFlag
;
1236 case GL_POLYGON_OFFSET_POINT
:
1237 return ctx
->Polygon
.OffsetPoint
;
1238 case GL_POLYGON_OFFSET_LINE
:
1239 return ctx
->Polygon
.OffsetLine
;
1240 case GL_POLYGON_OFFSET_FILL
:
1241 /*case GL_POLYGON_OFFSET_EXT:*/
1242 return ctx
->Polygon
.OffsetFill
;
1243 case GL_RESCALE_NORMAL_EXT
:
1244 return ctx
->Transform
.RescaleNormals
;
1245 case GL_SCISSOR_TEST
:
1246 return ctx
->Scissor
.Enabled
;
1247 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1248 return ctx
->Texture
.SharedPalette
;
1249 case GL_STENCIL_TEST
:
1250 return ctx
->Stencil
.Enabled
;
1252 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1254 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1256 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1257 case GL_TEXTURE_GEN_Q
:
1259 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1261 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1265 case GL_TEXTURE_GEN_R
:
1267 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1269 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1273 case GL_TEXTURE_GEN_S
:
1275 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1277 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1281 case GL_TEXTURE_GEN_T
:
1283 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1285 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1290 case GL_TEXTURE_GEN_STR_OES
:
1292 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1294 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1302 case GL_VERTEX_ARRAY
:
1303 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1304 case GL_NORMAL_ARRAY
:
1305 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1306 case GL_COLOR_ARRAY
:
1307 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1308 case GL_INDEX_ARRAY
:
1309 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1310 case GL_TEXTURE_COORD_ARRAY
:
1311 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1312 case GL_EDGE_FLAG_ARRAY
:
1313 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1314 case GL_FOG_COORDINATE_ARRAY_EXT
:
1315 CHECK_EXTENSION(EXT_fog_coord
);
1316 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1317 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1318 CHECK_EXTENSION(EXT_secondary_color
);
1319 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1320 #if FEATURE_point_size_array
1321 case GL_POINT_SIZE_ARRAY_OES
:
1322 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1325 /* GL_SGI_texture_color_table */
1326 case GL_TEXTURE_COLOR_TABLE_SGI
:
1327 CHECK_EXTENSION(SGI_texture_color_table
);
1328 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1330 /* GL_EXT_convolution */
1331 case GL_CONVOLUTION_1D
:
1332 CHECK_EXTENSION(EXT_convolution
);
1333 return ctx
->Pixel
.Convolution1DEnabled
;
1334 case GL_CONVOLUTION_2D
:
1335 CHECK_EXTENSION(EXT_convolution
);
1336 return ctx
->Pixel
.Convolution2DEnabled
;
1337 case GL_SEPARABLE_2D
:
1338 CHECK_EXTENSION(EXT_convolution
);
1339 return ctx
->Pixel
.Separable2DEnabled
;
1341 /* GL_ARB_texture_cube_map */
1342 case GL_TEXTURE_CUBE_MAP_ARB
:
1343 CHECK_EXTENSION(ARB_texture_cube_map
);
1344 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1346 /* GL_EXT_secondary_color */
1347 case GL_COLOR_SUM_EXT
:
1348 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1349 return ctx
->Fog
.ColorSumEnabled
;
1351 /* GL_ARB_multisample */
1352 case GL_MULTISAMPLE_ARB
:
1353 return ctx
->Multisample
.Enabled
;
1354 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1355 return ctx
->Multisample
.SampleAlphaToCoverage
;
1356 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1357 return ctx
->Multisample
.SampleAlphaToOne
;
1358 case GL_SAMPLE_COVERAGE_ARB
:
1359 return ctx
->Multisample
.SampleCoverage
;
1360 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1361 return ctx
->Multisample
.SampleCoverageInvert
;
1363 /* GL_IBM_rasterpos_clip */
1364 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1365 CHECK_EXTENSION(IBM_rasterpos_clip
);
1366 return ctx
->Transform
.RasterPositionUnclipped
;
1368 /* GL_NV_point_sprite */
1369 case GL_POINT_SPRITE_NV
:
1370 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1371 return ctx
->Point
.PointSprite
;
1373 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1374 case GL_VERTEX_PROGRAM_ARB
:
1375 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1376 return ctx
->VertexProgram
.Enabled
;
1377 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1378 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1379 return ctx
->VertexProgram
.PointSizeEnabled
;
1380 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1381 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1382 return ctx
->VertexProgram
.TwoSideEnabled
;
1384 #if FEATURE_NV_vertex_program
1385 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1386 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1387 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1388 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1389 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1390 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1391 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1392 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1393 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1394 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1395 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1396 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1397 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1398 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1399 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1400 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1401 CHECK_EXTENSION(NV_vertex_program
);
1403 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1404 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1405 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1407 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1408 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1409 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1410 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1411 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1412 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1413 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1414 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1415 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1416 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1417 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1418 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1419 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1420 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1421 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1422 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1423 CHECK_EXTENSION(NV_vertex_program
);
1425 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1426 return ctx
->Eval
.Map1Attrib
[map
];
1428 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1429 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1430 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1431 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1432 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1433 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1434 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1435 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1436 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1437 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1438 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1439 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1440 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1441 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1442 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1443 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1444 CHECK_EXTENSION(NV_vertex_program
);
1446 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1447 return ctx
->Eval
.Map2Attrib
[map
];
1449 #endif /* FEATURE_NV_vertex_program */
1451 #if FEATURE_NV_fragment_program
1452 case GL_FRAGMENT_PROGRAM_NV
:
1453 CHECK_EXTENSION(NV_fragment_program
);
1454 return ctx
->FragmentProgram
.Enabled
;
1455 #endif /* FEATURE_NV_fragment_program */
1457 /* GL_NV_texture_rectangle */
1458 case GL_TEXTURE_RECTANGLE_NV
:
1459 CHECK_EXTENSION(NV_texture_rectangle
);
1460 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1462 /* GL_EXT_stencil_two_side */
1463 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1464 CHECK_EXTENSION(EXT_stencil_two_side
);
1465 return ctx
->Stencil
.TestTwoSide
;
1467 #if FEATURE_ARB_fragment_program
1468 case GL_FRAGMENT_PROGRAM_ARB
:
1469 return ctx
->FragmentProgram
.Enabled
;
1470 #endif /* FEATURE_ARB_fragment_program */
1472 /* GL_EXT_depth_bounds_test */
1473 case GL_DEPTH_BOUNDS_TEST_EXT
:
1474 CHECK_EXTENSION(EXT_depth_bounds_test
);
1475 return ctx
->Depth
.BoundsTest
;
1477 /* GL_ARB_depth_clamp */
1478 case GL_DEPTH_CLAMP
:
1479 CHECK_EXTENSION(ARB_depth_clamp
);
1480 return ctx
->Transform
.DepthClamp
;
1482 #if FEATURE_ATI_fragment_shader
1483 case GL_FRAGMENT_SHADER_ATI
:
1484 CHECK_EXTENSION(ATI_fragment_shader
);
1485 return ctx
->ATIFragmentShader
.Enabled
;
1486 #endif /* FEATURE_ATI_fragment_shader */
1488 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1489 CHECK_EXTENSION(ARB_seamless_cube_map
);
1490 return ctx
->Texture
.CubeMapSeamless
;
1492 #if FEATURE_EXT_transform_feedback
1493 case GL_RASTERIZER_DISCARD
:
1494 CHECK_EXTENSION(EXT_transform_feedback
);
1495 return ctx
->TransformFeedback
.RasterDiscard
;
1498 /* GL 3.1 primitive restart */
1499 case GL_PRIMITIVE_RESTART
:
1500 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1501 goto invalid_enum_error
;
1503 return ctx
->Array
.PrimitiveRestart
;
1506 goto invalid_enum_error
;
1512 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);