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(struct gl_context
*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 */
127 /* GL_NV_primitive_restart */
128 case GL_PRIMITIVE_RESTART_NV
:
129 if (!ctx
->Extensions
.NV_primitive_restart
) {
130 goto invalid_enum_error
;
132 var
= &ctx
->Array
.PrimitiveRestart
;
136 goto invalid_enum_error
;
142 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
143 ctx
->Array
.NewState
|= flag
;
145 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
150 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
152 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
154 if (ctx
->Driver
.Enable
) {
155 ctx
->Driver
.Enable( ctx
, cap
, state
);
161 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(0x%x)",
162 state
? "Enable" : "Disable", cap
);
167 * Enable GL capability.
168 * \param cap state to enable/disable.
170 * Get's the current context, assures that we're outside glBegin()/glEnd() and
171 * calls client_state().
174 _mesa_EnableClientState( GLenum cap
)
176 GET_CURRENT_CONTEXT(ctx
);
177 ASSERT_OUTSIDE_BEGIN_END(ctx
);
178 client_state( ctx
, cap
, GL_TRUE
);
183 * Disable GL capability.
184 * \param cap state to enable/disable.
186 * Get's the current context, assures that we're outside glBegin()/glEnd() and
187 * calls client_state().
190 _mesa_DisableClientState( GLenum cap
)
192 GET_CURRENT_CONTEXT(ctx
);
193 ASSERT_OUTSIDE_BEGIN_END(ctx
);
194 client_state( ctx
, cap
, GL_FALSE
);
198 #undef CHECK_EXTENSION
199 #define CHECK_EXTENSION(EXTNAME, CAP) \
200 if (!ctx->Extensions.EXTNAME) { \
201 goto invalid_enum_error; \
204 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
205 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
206 goto invalid_enum_error; \
212 * Return pointer to current texture unit for setting/getting coordinate
214 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
215 * higher than the number of supported coordinate units. And we'll return NULL.
217 static struct gl_texture_unit
*
218 get_texcoord_unit(struct gl_context
*ctx
)
220 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
221 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
225 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
231 * Helper function to enable or disable a texture target.
232 * \param bit one of the TEXTURE_x_BIT values
233 * \return GL_TRUE if state is changing or GL_FALSE if no change
236 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
238 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
239 const GLbitfield newenabled
= state
240 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
242 if (texUnit
->Enabled
== newenabled
)
245 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
246 texUnit
->Enabled
= newenabled
;
252 * Helper function to enable or disable state.
254 * \param ctx GL context.
255 * \param cap the state to enable/disable
256 * \param state whether to enable or disable the specified capability.
258 * Updates the current context and flushes the vertices as needed. For
259 * capabilities associated with extensions it verifies that those extensions
260 * are effectivly present before updating. Notifies the driver via
261 * dd_function_table::Enable.
264 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
266 if (MESA_VERBOSE
& VERBOSE_API
)
267 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
268 state
? "glEnable" : "glDisable",
269 _mesa_lookup_enum_by_nr(cap
),
274 if (ctx
->Color
.AlphaEnabled
== state
)
276 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
277 ctx
->Color
.AlphaEnabled
= state
;
280 if (ctx
->Eval
.AutoNormal
== state
)
282 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
283 ctx
->Eval
.AutoNormal
= state
;
287 GLbitfield newEnabled
= state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
288 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
289 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
290 ctx
->Color
.BlendEnabled
= newEnabled
;
302 const GLuint p
= cap
- GL_CLIP_PLANE0
;
304 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
307 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
310 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
312 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
313 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
315 /* This derived state also calculated in clip.c and
316 * from _mesa_update_state() on changes to EyeUserPlane
317 * and ctx->ProjectionMatrix respectively.
319 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
320 ctx
->Transform
.EyeUserPlane
[p
],
321 ctx
->ProjectionMatrixStack
.Top
->inv
);
324 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
329 case GL_COLOR_MATERIAL
:
330 if (ctx
->Light
.ColorMaterialEnabled
== state
)
332 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
333 FLUSH_CURRENT(ctx
, 0);
334 ctx
->Light
.ColorMaterialEnabled
= state
;
336 _mesa_update_color_material( ctx
,
337 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
341 if (ctx
->Polygon
.CullFlag
== state
)
343 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
344 ctx
->Polygon
.CullFlag
= state
;
347 if (ctx
->Depth
.Test
== state
)
349 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
350 ctx
->Depth
.Test
= state
;
354 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
356 if (ctx
->Color
.DitherFlag
== state
)
358 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
359 ctx
->Color
.DitherFlag
= state
;
362 if (ctx
->Fog
.Enabled
== state
)
364 FLUSH_VERTICES(ctx
, _NEW_FOG
);
365 ctx
->Fog
.Enabled
= state
;
375 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
377 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
378 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
380 insert_at_tail(&ctx
->Light
.EnabledList
,
381 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
384 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
388 if (ctx
->Light
.Enabled
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
391 ctx
->Light
.Enabled
= state
;
392 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
393 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
395 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
398 if (ctx
->Line
.SmoothFlag
== state
)
400 FLUSH_VERTICES(ctx
, _NEW_LINE
);
401 ctx
->Line
.SmoothFlag
= state
;
402 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
404 case GL_LINE_STIPPLE
:
405 if (ctx
->Line
.StippleFlag
== state
)
407 FLUSH_VERTICES(ctx
, _NEW_LINE
);
408 ctx
->Line
.StippleFlag
= state
;
409 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
411 case GL_INDEX_LOGIC_OP
:
412 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
415 ctx
->Color
.IndexLogicOpEnabled
= state
;
417 case GL_COLOR_LOGIC_OP
:
418 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
421 ctx
->Color
.ColorLogicOpEnabled
= state
;
423 case GL_MAP1_COLOR_4
:
424 if (ctx
->Eval
.Map1Color4
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
427 ctx
->Eval
.Map1Color4
= state
;
430 if (ctx
->Eval
.Map1Index
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
433 ctx
->Eval
.Map1Index
= state
;
436 if (ctx
->Eval
.Map1Normal
== state
)
438 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
439 ctx
->Eval
.Map1Normal
= state
;
441 case GL_MAP1_TEXTURE_COORD_1
:
442 if (ctx
->Eval
.Map1TextureCoord1
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
445 ctx
->Eval
.Map1TextureCoord1
= state
;
447 case GL_MAP1_TEXTURE_COORD_2
:
448 if (ctx
->Eval
.Map1TextureCoord2
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
451 ctx
->Eval
.Map1TextureCoord2
= state
;
453 case GL_MAP1_TEXTURE_COORD_3
:
454 if (ctx
->Eval
.Map1TextureCoord3
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 ctx
->Eval
.Map1TextureCoord3
= state
;
459 case GL_MAP1_TEXTURE_COORD_4
:
460 if (ctx
->Eval
.Map1TextureCoord4
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map1TextureCoord4
= state
;
465 case GL_MAP1_VERTEX_3
:
466 if (ctx
->Eval
.Map1Vertex3
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map1Vertex3
= state
;
471 case GL_MAP1_VERTEX_4
:
472 if (ctx
->Eval
.Map1Vertex4
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map1Vertex4
= state
;
477 case GL_MAP2_COLOR_4
:
478 if (ctx
->Eval
.Map2Color4
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map2Color4
= state
;
484 if (ctx
->Eval
.Map2Index
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
487 ctx
->Eval
.Map2Index
= state
;
490 if (ctx
->Eval
.Map2Normal
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
493 ctx
->Eval
.Map2Normal
= state
;
495 case GL_MAP2_TEXTURE_COORD_1
:
496 if (ctx
->Eval
.Map2TextureCoord1
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map2TextureCoord1
= state
;
501 case GL_MAP2_TEXTURE_COORD_2
:
502 if (ctx
->Eval
.Map2TextureCoord2
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
505 ctx
->Eval
.Map2TextureCoord2
= state
;
507 case GL_MAP2_TEXTURE_COORD_3
:
508 if (ctx
->Eval
.Map2TextureCoord3
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
511 ctx
->Eval
.Map2TextureCoord3
= state
;
513 case GL_MAP2_TEXTURE_COORD_4
:
514 if (ctx
->Eval
.Map2TextureCoord4
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
517 ctx
->Eval
.Map2TextureCoord4
= state
;
519 case GL_MAP2_VERTEX_3
:
520 if (ctx
->Eval
.Map2Vertex3
== state
)
522 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
523 ctx
->Eval
.Map2Vertex3
= state
;
525 case GL_MAP2_VERTEX_4
:
526 if (ctx
->Eval
.Map2Vertex4
== state
)
528 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
529 ctx
->Eval
.Map2Vertex4
= state
;
532 if (ctx
->Transform
.Normalize
== state
)
534 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
535 ctx
->Transform
.Normalize
= state
;
537 case GL_POINT_SMOOTH
:
538 if (ctx
->Point
.SmoothFlag
== state
)
540 FLUSH_VERTICES(ctx
, _NEW_POINT
);
541 ctx
->Point
.SmoothFlag
= state
;
542 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
544 case GL_POLYGON_SMOOTH
:
545 if (ctx
->Polygon
.SmoothFlag
== state
)
547 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
548 ctx
->Polygon
.SmoothFlag
= state
;
549 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
551 case GL_POLYGON_STIPPLE
:
552 if (ctx
->Polygon
.StippleFlag
== state
)
554 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
555 ctx
->Polygon
.StippleFlag
= state
;
556 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
558 case GL_POLYGON_OFFSET_POINT
:
559 if (ctx
->Polygon
.OffsetPoint
== state
)
561 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
562 ctx
->Polygon
.OffsetPoint
= state
;
564 case GL_POLYGON_OFFSET_LINE
:
565 if (ctx
->Polygon
.OffsetLine
== state
)
567 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
568 ctx
->Polygon
.OffsetLine
= state
;
570 case GL_POLYGON_OFFSET_FILL
:
571 /*case GL_POLYGON_OFFSET_EXT:*/
572 if (ctx
->Polygon
.OffsetFill
== state
)
574 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
575 ctx
->Polygon
.OffsetFill
= state
;
577 case GL_RESCALE_NORMAL_EXT
:
578 if (ctx
->Transform
.RescaleNormals
== state
)
580 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
581 ctx
->Transform
.RescaleNormals
= state
;
583 case GL_SCISSOR_TEST
:
584 if (ctx
->Scissor
.Enabled
== state
)
586 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
587 ctx
->Scissor
.Enabled
= state
;
589 case GL_SHARED_TEXTURE_PALETTE_EXT
:
590 if (ctx
->Texture
.SharedPalette
== state
)
592 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
593 ctx
->Texture
.SharedPalette
= state
;
595 case GL_STENCIL_TEST
:
596 if (ctx
->Stencil
.Enabled
== state
)
598 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
599 ctx
->Stencil
.Enabled
= state
;
602 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
607 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
612 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
616 case GL_TEXTURE_GEN_Q
:
618 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
620 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
623 if (texUnit
->TexGenEnabled
== newenabled
)
625 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
626 texUnit
->TexGenEnabled
= newenabled
;
630 case GL_TEXTURE_GEN_R
:
632 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
634 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
637 if (texUnit
->TexGenEnabled
== newenabled
)
639 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
640 texUnit
->TexGenEnabled
= newenabled
;
644 case GL_TEXTURE_GEN_S
:
646 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
648 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
651 if (texUnit
->TexGenEnabled
== newenabled
)
653 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
654 texUnit
->TexGenEnabled
= newenabled
;
658 case GL_TEXTURE_GEN_T
:
660 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
662 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
665 if (texUnit
->TexGenEnabled
== newenabled
)
667 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
668 texUnit
->TexGenEnabled
= newenabled
;
674 case GL_TEXTURE_GEN_STR_OES
:
675 /* disable S, T, and R at the same time */
677 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
680 texUnit
->TexGenEnabled
& ~STR_BITS
;
682 newenabled
|= STR_BITS
;
683 if (texUnit
->TexGenEnabled
== newenabled
)
685 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
686 texUnit
->TexGenEnabled
= newenabled
;
695 case GL_VERTEX_ARRAY
:
696 case GL_NORMAL_ARRAY
:
699 case GL_TEXTURE_COORD_ARRAY
:
700 case GL_EDGE_FLAG_ARRAY
:
701 case GL_FOG_COORDINATE_ARRAY_EXT
:
702 case GL_SECONDARY_COLOR_ARRAY_EXT
:
703 case GL_POINT_SIZE_ARRAY_OES
:
704 client_state( ctx
, cap
, state
);
707 /* GL_SGI_texture_color_table */
708 case GL_TEXTURE_COLOR_TABLE_SGI
:
709 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
710 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
712 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
713 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
716 /* GL_ARB_texture_cube_map */
717 case GL_TEXTURE_CUBE_MAP_ARB
:
718 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
719 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
724 /* GL_EXT_secondary_color */
725 case GL_COLOR_SUM_EXT
:
726 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
727 if (ctx
->Fog
.ColorSumEnabled
== state
)
729 FLUSH_VERTICES(ctx
, _NEW_FOG
);
730 ctx
->Fog
.ColorSumEnabled
= state
;
733 /* GL_ARB_multisample */
734 case GL_MULTISAMPLE_ARB
:
735 if (ctx
->Multisample
.Enabled
== state
)
737 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
738 ctx
->Multisample
.Enabled
= state
;
740 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
741 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
743 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
744 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
746 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
747 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
749 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
750 ctx
->Multisample
.SampleAlphaToOne
= state
;
752 case GL_SAMPLE_COVERAGE_ARB
:
753 if (ctx
->Multisample
.SampleCoverage
== state
)
755 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
756 ctx
->Multisample
.SampleCoverage
= state
;
758 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
759 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
761 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
762 ctx
->Multisample
.SampleCoverageInvert
= state
;
765 /* GL_IBM_rasterpos_clip */
766 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
767 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
768 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
770 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
771 ctx
->Transform
.RasterPositionUnclipped
= state
;
774 /* GL_NV_point_sprite */
775 case GL_POINT_SPRITE_NV
:
776 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
777 if (ctx
->Point
.PointSprite
== state
)
779 FLUSH_VERTICES(ctx
, _NEW_POINT
);
780 ctx
->Point
.PointSprite
= state
;
783 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
784 case GL_VERTEX_PROGRAM_ARB
:
785 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
786 if (ctx
->VertexProgram
.Enabled
== state
)
788 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
789 ctx
->VertexProgram
.Enabled
= state
;
791 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
792 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
793 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
795 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
796 ctx
->VertexProgram
.PointSizeEnabled
= state
;
798 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
799 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
800 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
802 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
803 ctx
->VertexProgram
.TwoSideEnabled
= state
;
806 #if FEATURE_NV_vertex_program
807 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
808 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
809 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
810 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
811 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
812 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
813 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
814 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
815 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
816 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
817 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
818 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
819 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
820 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
821 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
822 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
823 CHECK_EXTENSION(NV_vertex_program
, cap
);
825 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
826 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
827 ctx
->Eval
.Map1Attrib
[map
] = state
;
830 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
831 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
832 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
833 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
834 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
835 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
836 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
837 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
838 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
839 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
840 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
841 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
842 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
843 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
844 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
845 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
846 CHECK_EXTENSION(NV_vertex_program
, cap
);
848 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
849 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
850 ctx
->Eval
.Map2Attrib
[map
] = state
;
853 #endif /* FEATURE_NV_vertex_program */
855 #if FEATURE_NV_fragment_program
856 case GL_FRAGMENT_PROGRAM_NV
:
857 CHECK_EXTENSION(NV_fragment_program
, cap
);
858 if (ctx
->FragmentProgram
.Enabled
== state
)
860 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
861 ctx
->FragmentProgram
.Enabled
= state
;
863 #endif /* FEATURE_NV_fragment_program */
865 /* GL_NV_texture_rectangle */
866 case GL_TEXTURE_RECTANGLE_NV
:
867 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
868 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
873 /* GL_EXT_stencil_two_side */
874 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
875 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
876 if (ctx
->Stencil
.TestTwoSide
== state
)
878 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
879 ctx
->Stencil
.TestTwoSide
= state
;
881 ctx
->Stencil
._BackFace
= 2;
882 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
884 ctx
->Stencil
._BackFace
= 1;
885 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
889 #if FEATURE_ARB_fragment_program
890 case GL_FRAGMENT_PROGRAM_ARB
:
891 CHECK_EXTENSION(ARB_fragment_program
, cap
);
892 if (ctx
->FragmentProgram
.Enabled
== state
)
894 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
895 ctx
->FragmentProgram
.Enabled
= state
;
897 #endif /* FEATURE_ARB_fragment_program */
899 /* GL_EXT_depth_bounds_test */
900 case GL_DEPTH_BOUNDS_TEST_EXT
:
901 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
902 if (ctx
->Depth
.BoundsTest
== state
)
904 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
905 ctx
->Depth
.BoundsTest
= state
;
909 if (ctx
->Transform
.DepthClamp
== state
)
911 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
912 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
913 ctx
->Transform
.DepthClamp
= state
;
916 #if FEATURE_ATI_fragment_shader
917 case GL_FRAGMENT_SHADER_ATI
:
918 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
919 if (ctx
->ATIFragmentShader
.Enabled
== state
)
921 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
922 ctx
->ATIFragmentShader
.Enabled
= state
;
926 /* GL_MESA_texture_array */
927 case GL_TEXTURE_1D_ARRAY_EXT
:
928 CHECK_EXTENSION(MESA_texture_array
, cap
);
929 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
934 case GL_TEXTURE_2D_ARRAY_EXT
:
935 CHECK_EXTENSION(MESA_texture_array
, cap
);
936 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
941 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
942 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
943 ctx
->Texture
.CubeMapSeamless
= state
;
946 #if FEATURE_EXT_transform_feedback
947 case GL_RASTERIZER_DISCARD
:
948 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
949 if (ctx
->TransformFeedback
.RasterDiscard
!= state
) {
950 ctx
->TransformFeedback
.RasterDiscard
= state
;
951 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
956 /* GL 3.1 primitive restart. Note: this enum is different from
957 * GL_PRIMITIVE_RESTART_NV (which is client state).
959 case GL_PRIMITIVE_RESTART
:
960 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
961 goto invalid_enum_error
;
963 if (ctx
->Array
.PrimitiveRestart
!= state
) {
964 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
965 ctx
->Array
.PrimitiveRestart
= state
;
970 goto invalid_enum_error
;
973 if (ctx
->Driver
.Enable
) {
974 ctx
->Driver
.Enable( ctx
, cap
, state
);
980 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(0x%x)",
981 state
? "Enable" : "Disable", cap
);
986 * Enable GL capability. Called by glEnable()
987 * \param cap state to enable.
990 _mesa_Enable( GLenum cap
)
992 GET_CURRENT_CONTEXT(ctx
);
993 ASSERT_OUTSIDE_BEGIN_END(ctx
);
995 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1000 * Disable GL capability. Called by glDisable()
1001 * \param cap state to disable.
1004 _mesa_Disable( GLenum cap
)
1006 GET_CURRENT_CONTEXT(ctx
);
1007 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1009 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1015 * Enable/disable an indexed state var.
1018 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
, GLuint index
, GLboolean state
)
1020 ASSERT(state
== 0 || state
== 1);
1023 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1024 goto invalid_enum_error
;
1026 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1027 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1028 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1031 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1032 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1034 ctx
->Color
.BlendEnabled
|= (1 << index
);
1036 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1040 goto invalid_enum_error
;
1045 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1046 state
? "glEnablei" : "glDisablei",
1047 _mesa_lookup_enum_by_nr(cap
));
1052 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1054 GET_CURRENT_CONTEXT(ctx
);
1055 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1056 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1061 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1063 GET_CURRENT_CONTEXT(ctx
);
1064 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1065 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1069 GLboolean GLAPIENTRY
1070 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1072 GET_CURRENT_CONTEXT(ctx
);
1075 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1076 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1080 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1082 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1083 _mesa_lookup_enum_by_nr(cap
));
1091 #undef CHECK_EXTENSION
1092 #define CHECK_EXTENSION(EXTNAME) \
1093 if (!ctx->Extensions.EXTNAME) { \
1094 goto invalid_enum_error; \
1097 #undef CHECK_EXTENSION2
1098 #define CHECK_EXTENSION2(EXT1, EXT2) \
1099 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1100 goto invalid_enum_error; \
1105 * Helper function to determine whether a texture target is enabled.
1108 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1110 const struct gl_texture_unit
*const texUnit
=
1111 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1112 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1117 * Return simple enable/disable state.
1119 * \param cap state variable to query.
1121 * Returns the state of the specified capability from the current GL context.
1122 * For the capabilities associated with extensions verifies that those
1123 * extensions are effectively present before reporting.
1125 GLboolean GLAPIENTRY
1126 _mesa_IsEnabled( GLenum cap
)
1128 GET_CURRENT_CONTEXT(ctx
);
1131 return ctx
->Color
.AlphaEnabled
;
1132 case GL_AUTO_NORMAL
:
1133 return ctx
->Eval
.AutoNormal
;
1135 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1136 case GL_CLIP_PLANE0
:
1137 case GL_CLIP_PLANE1
:
1138 case GL_CLIP_PLANE2
:
1139 case GL_CLIP_PLANE3
:
1140 case GL_CLIP_PLANE4
:
1141 case GL_CLIP_PLANE5
:
1142 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1143 case GL_COLOR_MATERIAL
:
1144 return ctx
->Light
.ColorMaterialEnabled
;
1146 return ctx
->Polygon
.CullFlag
;
1148 return ctx
->Depth
.Test
;
1150 return ctx
->Color
.DitherFlag
;
1152 return ctx
->Fog
.Enabled
;
1154 return ctx
->Light
.Enabled
;
1163 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1164 case GL_LINE_SMOOTH
:
1165 return ctx
->Line
.SmoothFlag
;
1166 case GL_LINE_STIPPLE
:
1167 return ctx
->Line
.StippleFlag
;
1168 case GL_INDEX_LOGIC_OP
:
1169 return ctx
->Color
.IndexLogicOpEnabled
;
1170 case GL_COLOR_LOGIC_OP
:
1171 return ctx
->Color
.ColorLogicOpEnabled
;
1172 case GL_MAP1_COLOR_4
:
1173 return ctx
->Eval
.Map1Color4
;
1175 return ctx
->Eval
.Map1Index
;
1176 case GL_MAP1_NORMAL
:
1177 return ctx
->Eval
.Map1Normal
;
1178 case GL_MAP1_TEXTURE_COORD_1
:
1179 return ctx
->Eval
.Map1TextureCoord1
;
1180 case GL_MAP1_TEXTURE_COORD_2
:
1181 return ctx
->Eval
.Map1TextureCoord2
;
1182 case GL_MAP1_TEXTURE_COORD_3
:
1183 return ctx
->Eval
.Map1TextureCoord3
;
1184 case GL_MAP1_TEXTURE_COORD_4
:
1185 return ctx
->Eval
.Map1TextureCoord4
;
1186 case GL_MAP1_VERTEX_3
:
1187 return ctx
->Eval
.Map1Vertex3
;
1188 case GL_MAP1_VERTEX_4
:
1189 return ctx
->Eval
.Map1Vertex4
;
1190 case GL_MAP2_COLOR_4
:
1191 return ctx
->Eval
.Map2Color4
;
1193 return ctx
->Eval
.Map2Index
;
1194 case GL_MAP2_NORMAL
:
1195 return ctx
->Eval
.Map2Normal
;
1196 case GL_MAP2_TEXTURE_COORD_1
:
1197 return ctx
->Eval
.Map2TextureCoord1
;
1198 case GL_MAP2_TEXTURE_COORD_2
:
1199 return ctx
->Eval
.Map2TextureCoord2
;
1200 case GL_MAP2_TEXTURE_COORD_3
:
1201 return ctx
->Eval
.Map2TextureCoord3
;
1202 case GL_MAP2_TEXTURE_COORD_4
:
1203 return ctx
->Eval
.Map2TextureCoord4
;
1204 case GL_MAP2_VERTEX_3
:
1205 return ctx
->Eval
.Map2Vertex3
;
1206 case GL_MAP2_VERTEX_4
:
1207 return ctx
->Eval
.Map2Vertex4
;
1209 return ctx
->Transform
.Normalize
;
1210 case GL_POINT_SMOOTH
:
1211 return ctx
->Point
.SmoothFlag
;
1212 case GL_POLYGON_SMOOTH
:
1213 return ctx
->Polygon
.SmoothFlag
;
1214 case GL_POLYGON_STIPPLE
:
1215 return ctx
->Polygon
.StippleFlag
;
1216 case GL_POLYGON_OFFSET_POINT
:
1217 return ctx
->Polygon
.OffsetPoint
;
1218 case GL_POLYGON_OFFSET_LINE
:
1219 return ctx
->Polygon
.OffsetLine
;
1220 case GL_POLYGON_OFFSET_FILL
:
1221 /*case GL_POLYGON_OFFSET_EXT:*/
1222 return ctx
->Polygon
.OffsetFill
;
1223 case GL_RESCALE_NORMAL_EXT
:
1224 return ctx
->Transform
.RescaleNormals
;
1225 case GL_SCISSOR_TEST
:
1226 return ctx
->Scissor
.Enabled
;
1227 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1228 return ctx
->Texture
.SharedPalette
;
1229 case GL_STENCIL_TEST
:
1230 return ctx
->Stencil
.Enabled
;
1232 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1234 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1236 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1237 case GL_TEXTURE_GEN_Q
:
1239 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1241 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1245 case GL_TEXTURE_GEN_R
:
1247 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1249 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1253 case GL_TEXTURE_GEN_S
:
1255 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1257 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1261 case GL_TEXTURE_GEN_T
:
1263 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1265 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1270 case GL_TEXTURE_GEN_STR_OES
:
1272 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1274 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
? GL_TRUE
: GL_FALSE
;
1282 case GL_VERTEX_ARRAY
:
1283 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1284 case GL_NORMAL_ARRAY
:
1285 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1286 case GL_COLOR_ARRAY
:
1287 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1288 case GL_INDEX_ARRAY
:
1289 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1290 case GL_TEXTURE_COORD_ARRAY
:
1291 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1292 case GL_EDGE_FLAG_ARRAY
:
1293 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1294 case GL_FOG_COORDINATE_ARRAY_EXT
:
1295 CHECK_EXTENSION(EXT_fog_coord
);
1296 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1297 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1298 CHECK_EXTENSION(EXT_secondary_color
);
1299 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1300 #if FEATURE_point_size_array
1301 case GL_POINT_SIZE_ARRAY_OES
:
1302 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1305 /* GL_SGI_texture_color_table */
1306 case GL_TEXTURE_COLOR_TABLE_SGI
:
1307 CHECK_EXTENSION(SGI_texture_color_table
);
1308 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1310 /* GL_ARB_texture_cube_map */
1311 case GL_TEXTURE_CUBE_MAP_ARB
:
1312 CHECK_EXTENSION(ARB_texture_cube_map
);
1313 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1315 /* GL_EXT_secondary_color */
1316 case GL_COLOR_SUM_EXT
:
1317 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1318 return ctx
->Fog
.ColorSumEnabled
;
1320 /* GL_ARB_multisample */
1321 case GL_MULTISAMPLE_ARB
:
1322 return ctx
->Multisample
.Enabled
;
1323 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1324 return ctx
->Multisample
.SampleAlphaToCoverage
;
1325 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1326 return ctx
->Multisample
.SampleAlphaToOne
;
1327 case GL_SAMPLE_COVERAGE_ARB
:
1328 return ctx
->Multisample
.SampleCoverage
;
1329 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1330 return ctx
->Multisample
.SampleCoverageInvert
;
1332 /* GL_IBM_rasterpos_clip */
1333 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1334 CHECK_EXTENSION(IBM_rasterpos_clip
);
1335 return ctx
->Transform
.RasterPositionUnclipped
;
1337 /* GL_NV_point_sprite */
1338 case GL_POINT_SPRITE_NV
:
1339 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1340 return ctx
->Point
.PointSprite
;
1342 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1343 case GL_VERTEX_PROGRAM_ARB
:
1344 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1345 return ctx
->VertexProgram
.Enabled
;
1346 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1347 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1348 return ctx
->VertexProgram
.PointSizeEnabled
;
1349 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1350 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1351 return ctx
->VertexProgram
.TwoSideEnabled
;
1353 #if FEATURE_NV_vertex_program
1354 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1355 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1356 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1357 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1358 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1359 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1360 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1361 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1362 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1363 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1364 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1365 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1366 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1367 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1368 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1369 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1370 CHECK_EXTENSION(NV_vertex_program
);
1372 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1373 ASSERT(n
< Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1374 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1376 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1377 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1378 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1379 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1380 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1381 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1382 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1383 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1384 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1385 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1386 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1387 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1388 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1389 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1390 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1391 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1392 CHECK_EXTENSION(NV_vertex_program
);
1394 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1395 return ctx
->Eval
.Map1Attrib
[map
];
1397 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1398 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1399 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1400 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1401 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1402 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1403 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1404 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1405 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1406 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1407 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1408 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1409 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1410 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1411 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1412 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1413 CHECK_EXTENSION(NV_vertex_program
);
1415 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1416 return ctx
->Eval
.Map2Attrib
[map
];
1418 #endif /* FEATURE_NV_vertex_program */
1420 #if FEATURE_NV_fragment_program
1421 case GL_FRAGMENT_PROGRAM_NV
:
1422 CHECK_EXTENSION(NV_fragment_program
);
1423 return ctx
->FragmentProgram
.Enabled
;
1424 #endif /* FEATURE_NV_fragment_program */
1426 /* GL_NV_texture_rectangle */
1427 case GL_TEXTURE_RECTANGLE_NV
:
1428 CHECK_EXTENSION(NV_texture_rectangle
);
1429 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1431 /* GL_EXT_stencil_two_side */
1432 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1433 CHECK_EXTENSION(EXT_stencil_two_side
);
1434 return ctx
->Stencil
.TestTwoSide
;
1436 #if FEATURE_ARB_fragment_program
1437 case GL_FRAGMENT_PROGRAM_ARB
:
1438 return ctx
->FragmentProgram
.Enabled
;
1439 #endif /* FEATURE_ARB_fragment_program */
1441 /* GL_EXT_depth_bounds_test */
1442 case GL_DEPTH_BOUNDS_TEST_EXT
:
1443 CHECK_EXTENSION(EXT_depth_bounds_test
);
1444 return ctx
->Depth
.BoundsTest
;
1446 /* GL_ARB_depth_clamp */
1447 case GL_DEPTH_CLAMP
:
1448 CHECK_EXTENSION(ARB_depth_clamp
);
1449 return ctx
->Transform
.DepthClamp
;
1451 #if FEATURE_ATI_fragment_shader
1452 case GL_FRAGMENT_SHADER_ATI
:
1453 CHECK_EXTENSION(ATI_fragment_shader
);
1454 return ctx
->ATIFragmentShader
.Enabled
;
1455 #endif /* FEATURE_ATI_fragment_shader */
1457 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1458 CHECK_EXTENSION(ARB_seamless_cube_map
);
1459 return ctx
->Texture
.CubeMapSeamless
;
1461 #if FEATURE_EXT_transform_feedback
1462 case GL_RASTERIZER_DISCARD
:
1463 CHECK_EXTENSION(EXT_transform_feedback
);
1464 return ctx
->TransformFeedback
.RasterDiscard
;
1467 /* GL_NV_primitive_restart */
1468 case GL_PRIMITIVE_RESTART_NV
:
1469 if (!ctx
->Extensions
.NV_primitive_restart
) {
1470 goto invalid_enum_error
;
1472 return ctx
->Array
.PrimitiveRestart
;
1474 /* GL 3.1 primitive restart */
1475 case GL_PRIMITIVE_RESTART
:
1476 if (ctx
->VersionMajor
* 10 + ctx
->VersionMinor
< 31) {
1477 goto invalid_enum_error
;
1479 return ctx
->Array
.PrimitiveRestart
;
1482 goto invalid_enum_error
;
1488 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);