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.
36 #include "simple_list.h"
39 #include "math/m_matrix.h"
40 #include "math/m_xform.h"
41 #include "api_arrayelt.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
48 state ? "Enable" : "Disable", CAP); \
54 * Helper to enable/disable client-side state.
57 client_state(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
64 var
= &ctx
->Array
.ArrayObj
->Vertex
.Enabled
;
65 flag
= _NEW_ARRAY_VERTEX
;
68 var
= &ctx
->Array
.ArrayObj
->Normal
.Enabled
;
69 flag
= _NEW_ARRAY_NORMAL
;
72 var
= &ctx
->Array
.ArrayObj
->Color
.Enabled
;
73 flag
= _NEW_ARRAY_COLOR0
;
76 var
= &ctx
->Array
.ArrayObj
->Index
.Enabled
;
77 flag
= _NEW_ARRAY_INDEX
;
79 case GL_TEXTURE_COORD_ARRAY
:
80 var
= &ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
81 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
83 case GL_EDGE_FLAG_ARRAY
:
84 var
= &ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
;
85 flag
= _NEW_ARRAY_EDGEFLAG
;
87 case GL_FOG_COORDINATE_ARRAY_EXT
:
88 var
= &ctx
->Array
.ArrayObj
->FogCoord
.Enabled
;
89 flag
= _NEW_ARRAY_FOGCOORD
;
91 case GL_SECONDARY_COLOR_ARRAY_EXT
:
92 var
= &ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
;
93 flag
= _NEW_ARRAY_COLOR1
;
96 #if FEATURE_point_size_array
97 case GL_POINT_SIZE_ARRAY_OES
:
98 var
= &ctx
->Array
.ArrayObj
->PointSize
.Enabled
;
99 flag
= _NEW_ARRAY_POINT_SIZE
;
103 #if FEATURE_NV_vertex_program
104 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
118 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
119 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
120 CHECK_EXTENSION(NV_vertex_program
, cap
);
122 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
123 var
= &ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
;
124 flag
= _NEW_ARRAY_ATTRIB(n
);
127 #endif /* FEATURE_NV_vertex_program */
130 _mesa_error( ctx
, GL_INVALID_ENUM
,
131 "glEnable/DisableClientState(0x%x)", cap
);
138 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
139 ctx
->Array
.NewState
|= flag
;
141 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
146 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
148 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
150 if (ctx
->Driver
.Enable
) {
151 ctx
->Driver
.Enable( ctx
, cap
, state
);
157 * Enable GL capability.
158 * \param cap state to enable/disable.
160 * Get's the current context, assures that we're outside glBegin()/glEnd() and
161 * calls client_state().
164 _mesa_EnableClientState( GLenum cap
)
166 GET_CURRENT_CONTEXT(ctx
);
167 ASSERT_OUTSIDE_BEGIN_END(ctx
);
168 client_state( ctx
, cap
, GL_TRUE
);
173 * Disable GL capability.
174 * \param cap state to enable/disable.
176 * Get's the current context, assures that we're outside glBegin()/glEnd() and
177 * calls client_state().
180 _mesa_DisableClientState( GLenum cap
)
182 GET_CURRENT_CONTEXT(ctx
);
183 ASSERT_OUTSIDE_BEGIN_END(ctx
);
184 client_state( ctx
, cap
, GL_FALSE
);
188 #undef CHECK_EXTENSION
189 #define CHECK_EXTENSION(EXTNAME, CAP) \
190 if (!ctx->Extensions.EXTNAME) { \
191 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
192 state ? "Enable" : "Disable", CAP); \
196 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
197 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
198 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
199 state ? "Enable" : "Disable", CAP); \
206 * Return pointer to current texture unit for setting/getting coordinate
208 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
209 * higher than the number of supported coordinate units. And we'll return NULL.
211 static struct gl_texture_unit
*
212 get_texcoord_unit(GLcontext
*ctx
)
214 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
215 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
219 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
225 * Helper function to enable or disable a texture target.
228 enable_texture(GLcontext
*ctx
, GLboolean state
, GLbitfield bit
)
230 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
231 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
232 const GLuint newenabled
= (!state
)
233 ? (texUnit
->Enabled
& ~bit
) : (texUnit
->Enabled
| bit
);
235 if (!ctx
->DrawBuffer
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
238 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
239 texUnit
->Enabled
= newenabled
;
245 * Helper function to enable or disable state.
247 * \param ctx GL context.
248 * \param cap the state to enable/disable
249 * \param state whether to enable or disable the specified capability.
251 * Updates the current context and flushes the vertices as needed. For
252 * capabilities associated with extensions it verifies that those extensions
253 * are effectivly present before updating. Notifies the driver via
254 * dd_function_table::Enable.
257 _mesa_set_enable(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
259 if (MESA_VERBOSE
& VERBOSE_API
)
260 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
261 state
? "glEnable" : "glDisable",
262 _mesa_lookup_enum_by_nr(cap
),
267 if (ctx
->Color
.AlphaEnabled
== state
)
269 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
270 ctx
->Color
.AlphaEnabled
= state
;
273 if (ctx
->Eval
.AutoNormal
== state
)
275 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
276 ctx
->Eval
.AutoNormal
= state
;
279 if (ctx
->Color
.BlendEnabled
== state
)
281 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
282 ctx
->Color
.BlendEnabled
= state
;
292 const GLuint p
= cap
- GL_CLIP_PLANE0
;
294 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
297 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
300 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
302 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
303 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
305 /* This derived state also calculated in clip.c and
306 * from _mesa_update_state() on changes to EyeUserPlane
307 * and ctx->ProjectionMatrix respectively.
309 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
310 ctx
->Transform
.EyeUserPlane
[p
],
311 ctx
->ProjectionMatrixStack
.Top
->inv
);
314 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
319 case GL_COLOR_MATERIAL
:
320 if (ctx
->Light
.ColorMaterialEnabled
== state
)
322 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
323 FLUSH_CURRENT(ctx
, 0);
324 ctx
->Light
.ColorMaterialEnabled
= state
;
326 _mesa_update_color_material( ctx
,
327 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
331 if (ctx
->Polygon
.CullFlag
== state
)
333 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
334 ctx
->Polygon
.CullFlag
= state
;
336 case GL_CULL_VERTEX_EXT
:
337 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
338 if (ctx
->Transform
.CullVertexFlag
== state
)
340 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
341 ctx
->Transform
.CullVertexFlag
= state
;
344 if (ctx
->Depth
.Test
== state
)
346 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
347 ctx
->Depth
.Test
= state
;
351 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
353 if (ctx
->Color
.DitherFlag
== state
)
355 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
356 ctx
->Color
.DitherFlag
= state
;
359 if (ctx
->Fog
.Enabled
== state
)
361 FLUSH_VERTICES(ctx
, _NEW_FOG
);
362 ctx
->Fog
.Enabled
= state
;
365 CHECK_EXTENSION(EXT_histogram
, cap
);
366 if (ctx
->Pixel
.HistogramEnabled
== state
)
368 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
369 ctx
->Pixel
.HistogramEnabled
= state
;
379 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
381 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
382 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
384 insert_at_tail(&ctx
->Light
.EnabledList
,
385 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
388 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
392 if (ctx
->Light
.Enabled
== state
)
394 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
395 ctx
->Light
.Enabled
= state
;
396 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
397 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
399 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
402 if (ctx
->Line
.SmoothFlag
== state
)
404 FLUSH_VERTICES(ctx
, _NEW_LINE
);
405 ctx
->Line
.SmoothFlag
= state
;
406 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
408 case GL_LINE_STIPPLE
:
409 if (ctx
->Line
.StippleFlag
== state
)
411 FLUSH_VERTICES(ctx
, _NEW_LINE
);
412 ctx
->Line
.StippleFlag
= state
;
413 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
415 case GL_INDEX_LOGIC_OP
:
416 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
418 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
419 ctx
->Color
.IndexLogicOpEnabled
= state
;
421 case GL_COLOR_LOGIC_OP
:
422 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
424 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
425 ctx
->Color
.ColorLogicOpEnabled
= state
;
427 case GL_MAP1_COLOR_4
:
428 if (ctx
->Eval
.Map1Color4
== state
)
430 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
431 ctx
->Eval
.Map1Color4
= state
;
434 if (ctx
->Eval
.Map1Index
== state
)
436 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
437 ctx
->Eval
.Map1Index
= state
;
440 if (ctx
->Eval
.Map1Normal
== state
)
442 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
443 ctx
->Eval
.Map1Normal
= state
;
445 case GL_MAP1_TEXTURE_COORD_1
:
446 if (ctx
->Eval
.Map1TextureCoord1
== state
)
448 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
449 ctx
->Eval
.Map1TextureCoord1
= state
;
451 case GL_MAP1_TEXTURE_COORD_2
:
452 if (ctx
->Eval
.Map1TextureCoord2
== state
)
454 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
455 ctx
->Eval
.Map1TextureCoord2
= state
;
457 case GL_MAP1_TEXTURE_COORD_3
:
458 if (ctx
->Eval
.Map1TextureCoord3
== state
)
460 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
461 ctx
->Eval
.Map1TextureCoord3
= state
;
463 case GL_MAP1_TEXTURE_COORD_4
:
464 if (ctx
->Eval
.Map1TextureCoord4
== state
)
466 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
467 ctx
->Eval
.Map1TextureCoord4
= state
;
469 case GL_MAP1_VERTEX_3
:
470 if (ctx
->Eval
.Map1Vertex3
== state
)
472 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
473 ctx
->Eval
.Map1Vertex3
= state
;
475 case GL_MAP1_VERTEX_4
:
476 if (ctx
->Eval
.Map1Vertex4
== state
)
478 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
479 ctx
->Eval
.Map1Vertex4
= state
;
481 case GL_MAP2_COLOR_4
:
482 if (ctx
->Eval
.Map2Color4
== state
)
484 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
485 ctx
->Eval
.Map2Color4
= state
;
488 if (ctx
->Eval
.Map2Index
== state
)
490 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
491 ctx
->Eval
.Map2Index
= state
;
494 if (ctx
->Eval
.Map2Normal
== state
)
496 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
497 ctx
->Eval
.Map2Normal
= state
;
499 case GL_MAP2_TEXTURE_COORD_1
:
500 if (ctx
->Eval
.Map2TextureCoord1
== state
)
502 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
503 ctx
->Eval
.Map2TextureCoord1
= state
;
505 case GL_MAP2_TEXTURE_COORD_2
:
506 if (ctx
->Eval
.Map2TextureCoord2
== state
)
508 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
509 ctx
->Eval
.Map2TextureCoord2
= state
;
511 case GL_MAP2_TEXTURE_COORD_3
:
512 if (ctx
->Eval
.Map2TextureCoord3
== state
)
514 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
515 ctx
->Eval
.Map2TextureCoord3
= state
;
517 case GL_MAP2_TEXTURE_COORD_4
:
518 if (ctx
->Eval
.Map2TextureCoord4
== state
)
520 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
521 ctx
->Eval
.Map2TextureCoord4
= state
;
523 case GL_MAP2_VERTEX_3
:
524 if (ctx
->Eval
.Map2Vertex3
== state
)
526 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
527 ctx
->Eval
.Map2Vertex3
= state
;
529 case GL_MAP2_VERTEX_4
:
530 if (ctx
->Eval
.Map2Vertex4
== state
)
532 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
533 ctx
->Eval
.Map2Vertex4
= state
;
536 if (ctx
->Pixel
.MinMaxEnabled
== state
)
538 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
539 ctx
->Pixel
.MinMaxEnabled
= state
;
542 if (ctx
->Transform
.Normalize
== state
)
544 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
545 ctx
->Transform
.Normalize
= state
;
547 case GL_POINT_SMOOTH
:
548 if (ctx
->Point
.SmoothFlag
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_POINT
);
551 ctx
->Point
.SmoothFlag
= state
;
552 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
554 case GL_POLYGON_SMOOTH
:
555 if (ctx
->Polygon
.SmoothFlag
== state
)
557 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
558 ctx
->Polygon
.SmoothFlag
= state
;
559 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
561 case GL_POLYGON_STIPPLE
:
562 if (ctx
->Polygon
.StippleFlag
== state
)
564 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
565 ctx
->Polygon
.StippleFlag
= state
;
566 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
568 case GL_POLYGON_OFFSET_POINT
:
569 if (ctx
->Polygon
.OffsetPoint
== state
)
571 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
572 ctx
->Polygon
.OffsetPoint
= state
;
574 case GL_POLYGON_OFFSET_LINE
:
575 if (ctx
->Polygon
.OffsetLine
== state
)
577 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
578 ctx
->Polygon
.OffsetLine
= state
;
580 case GL_POLYGON_OFFSET_FILL
:
581 /*case GL_POLYGON_OFFSET_EXT:*/
582 if (ctx
->Polygon
.OffsetFill
== state
)
584 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
585 ctx
->Polygon
.OffsetFill
= state
;
587 case GL_RESCALE_NORMAL_EXT
:
588 if (ctx
->Transform
.RescaleNormals
== state
)
590 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
591 ctx
->Transform
.RescaleNormals
= state
;
593 case GL_SCISSOR_TEST
:
594 if (ctx
->Scissor
.Enabled
== state
)
596 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
597 ctx
->Scissor
.Enabled
= state
;
599 case GL_SHARED_TEXTURE_PALETTE_EXT
:
600 if (ctx
->Texture
.SharedPalette
== state
)
602 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
603 ctx
->Texture
.SharedPalette
= state
;
605 case GL_STENCIL_TEST
:
606 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
608 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
611 if (ctx
->Stencil
.Enabled
== state
)
613 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
614 ctx
->Stencil
.Enabled
= state
;
617 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
622 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
627 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
631 case GL_TEXTURE_GEN_Q
:
633 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
635 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
638 if (texUnit
->TexGenEnabled
== newenabled
)
640 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
641 texUnit
->TexGenEnabled
= newenabled
;
645 case GL_TEXTURE_GEN_R
:
647 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
649 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
652 if (texUnit
->TexGenEnabled
== newenabled
)
654 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
655 texUnit
->TexGenEnabled
= newenabled
;
659 case GL_TEXTURE_GEN_S
:
661 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
663 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
666 if (texUnit
->TexGenEnabled
== newenabled
)
668 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
669 texUnit
->TexGenEnabled
= newenabled
;
673 case GL_TEXTURE_GEN_T
:
675 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
677 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
680 if (texUnit
->TexGenEnabled
== newenabled
)
682 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
683 texUnit
->TexGenEnabled
= newenabled
;
691 case GL_VERTEX_ARRAY
:
692 case GL_NORMAL_ARRAY
:
695 case GL_TEXTURE_COORD_ARRAY
:
696 case GL_EDGE_FLAG_ARRAY
:
697 case GL_FOG_COORDINATE_ARRAY_EXT
:
698 case GL_SECONDARY_COLOR_ARRAY_EXT
:
699 case GL_POINT_SIZE_ARRAY_OES
:
700 client_state( ctx
, cap
, state
);
703 /* GL_SGI_color_table */
704 case GL_COLOR_TABLE_SGI
:
705 CHECK_EXTENSION(SGI_color_table
, cap
);
706 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] == state
)
708 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
709 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] = state
;
711 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
712 CHECK_EXTENSION(SGI_color_table
, cap
);
713 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] == state
)
715 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
716 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] = state
;
718 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
719 CHECK_EXTENSION(SGI_color_table
, cap
);
720 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] == state
)
722 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
723 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] = state
;
725 case GL_TEXTURE_COLOR_TABLE_SGI
:
726 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
727 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
729 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
730 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
733 /* GL_EXT_convolution */
734 case GL_CONVOLUTION_1D
:
735 CHECK_EXTENSION(EXT_convolution
, cap
);
736 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
738 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
739 ctx
->Pixel
.Convolution1DEnabled
= state
;
741 case GL_CONVOLUTION_2D
:
742 CHECK_EXTENSION(EXT_convolution
, cap
);
743 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
745 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
746 ctx
->Pixel
.Convolution2DEnabled
= state
;
748 case GL_SEPARABLE_2D
:
749 CHECK_EXTENSION(EXT_convolution
, cap
);
750 if (ctx
->Pixel
.Separable2DEnabled
== state
)
752 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
753 ctx
->Pixel
.Separable2DEnabled
= state
;
756 /* GL_ARB_texture_cube_map */
757 case GL_TEXTURE_CUBE_MAP_ARB
:
758 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
759 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
764 /* GL_EXT_secondary_color */
765 case GL_COLOR_SUM_EXT
:
766 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
767 if (ctx
->Fog
.ColorSumEnabled
== state
)
769 FLUSH_VERTICES(ctx
, _NEW_FOG
);
770 ctx
->Fog
.ColorSumEnabled
= state
;
773 /* GL_ARB_multisample */
774 case GL_MULTISAMPLE_ARB
:
775 CHECK_EXTENSION(ARB_multisample
, cap
);
776 if (ctx
->Multisample
.Enabled
== state
)
778 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
779 ctx
->Multisample
.Enabled
= state
;
781 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
782 CHECK_EXTENSION(ARB_multisample
, cap
);
783 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
785 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
786 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
788 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
789 CHECK_EXTENSION(ARB_multisample
, cap
);
790 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
792 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
793 ctx
->Multisample
.SampleAlphaToOne
= state
;
795 case GL_SAMPLE_COVERAGE_ARB
:
796 CHECK_EXTENSION(ARB_multisample
, cap
);
797 if (ctx
->Multisample
.SampleCoverage
== state
)
799 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
800 ctx
->Multisample
.SampleCoverage
= state
;
802 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
803 CHECK_EXTENSION(ARB_multisample
, cap
);
804 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
806 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
807 ctx
->Multisample
.SampleCoverageInvert
= state
;
810 /* GL_IBM_rasterpos_clip */
811 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
812 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
813 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
815 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
816 ctx
->Transform
.RasterPositionUnclipped
= state
;
819 /* GL_NV_point_sprite */
820 case GL_POINT_SPRITE_NV
:
821 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
822 if (ctx
->Point
.PointSprite
== state
)
824 FLUSH_VERTICES(ctx
, _NEW_POINT
);
825 ctx
->Point
.PointSprite
= state
;
828 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
829 case GL_VERTEX_PROGRAM_ARB
:
830 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
831 if (ctx
->VertexProgram
.Enabled
== state
)
833 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
834 ctx
->VertexProgram
.Enabled
= state
;
836 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
837 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
838 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
840 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
841 ctx
->VertexProgram
.PointSizeEnabled
= state
;
843 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
844 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
845 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
847 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
848 ctx
->VertexProgram
.TwoSideEnabled
= state
;
851 #if FEATURE_NV_vertex_program
852 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
853 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
854 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
855 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
856 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
857 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
858 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
859 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
860 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
861 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
862 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
863 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
864 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
865 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
866 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
867 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
868 CHECK_EXTENSION(NV_vertex_program
, cap
);
870 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
871 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
872 ctx
->Eval
.Map1Attrib
[map
] = state
;
875 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
876 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
877 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
878 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
879 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
880 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
881 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
882 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
883 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
884 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
885 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
886 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
887 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
888 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
889 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
890 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
891 CHECK_EXTENSION(NV_vertex_program
, cap
);
893 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
894 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
895 ctx
->Eval
.Map2Attrib
[map
] = state
;
898 #endif /* FEATURE_NV_vertex_program */
900 #if FEATURE_NV_fragment_program
901 case GL_FRAGMENT_PROGRAM_NV
:
902 CHECK_EXTENSION(NV_fragment_program
, cap
);
903 if (ctx
->FragmentProgram
.Enabled
== state
)
905 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
906 ctx
->FragmentProgram
.Enabled
= state
;
908 #endif /* FEATURE_NV_fragment_program */
910 /* GL_NV_texture_rectangle */
911 case GL_TEXTURE_RECTANGLE_NV
:
912 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
913 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
918 /* GL_EXT_stencil_two_side */
919 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
920 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
921 if (ctx
->Stencil
.TestTwoSide
== state
)
923 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
924 ctx
->Stencil
.TestTwoSide
= state
;
926 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
928 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
931 #if FEATURE_ARB_fragment_program
932 case GL_FRAGMENT_PROGRAM_ARB
:
933 CHECK_EXTENSION(ARB_fragment_program
, cap
);
934 if (ctx
->FragmentProgram
.Enabled
== state
)
936 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
937 ctx
->FragmentProgram
.Enabled
= state
;
939 #endif /* FEATURE_ARB_fragment_program */
941 /* GL_EXT_depth_bounds_test */
942 case GL_DEPTH_BOUNDS_TEST_EXT
:
943 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
944 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
946 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
949 if (ctx
->Depth
.BoundsTest
== state
)
951 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
952 ctx
->Depth
.BoundsTest
= state
;
955 /* GL_MESA_program_debug */
956 #if FEATURE_MESA_program_debug
957 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
958 CHECK_EXTENSION(MESA_program_debug
, cap
);
959 ctx
->FragmentProgram
.CallbackEnabled
= state
;
961 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
962 CHECK_EXTENSION(MESA_program_debug
, cap
);
963 ctx
->VertexProgram
.CallbackEnabled
= state
;
967 #if FEATURE_ATI_fragment_shader
968 case GL_FRAGMENT_SHADER_ATI
:
969 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
970 if (ctx
->ATIFragmentShader
.Enabled
== state
)
972 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
973 ctx
->ATIFragmentShader
.Enabled
= state
;
977 /* GL_MESA_texture_array */
978 case GL_TEXTURE_1D_ARRAY_EXT
:
979 CHECK_EXTENSION(MESA_texture_array
, cap
);
980 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
985 case GL_TEXTURE_2D_ARRAY_EXT
:
986 CHECK_EXTENSION(MESA_texture_array
, cap
);
987 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
993 _mesa_error(ctx
, GL_INVALID_ENUM
,
994 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
998 if (ctx
->Driver
.Enable
) {
999 ctx
->Driver
.Enable( ctx
, cap
, state
);
1005 * Enable GL capability. Called by glEnable()
1006 * \param cap state to enable.
1009 _mesa_Enable( GLenum cap
)
1011 GET_CURRENT_CONTEXT(ctx
);
1012 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1014 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1019 * Disable GL capability. Called by glDisable()
1020 * \param cap state to disable.
1023 _mesa_Disable( GLenum cap
)
1025 GET_CURRENT_CONTEXT(ctx
);
1026 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1028 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1032 #undef CHECK_EXTENSION
1033 #define CHECK_EXTENSION(EXTNAME) \
1034 if (!ctx->Extensions.EXTNAME) { \
1035 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1039 #undef CHECK_EXTENSION2
1040 #define CHECK_EXTENSION2(EXT1, EXT2) \
1041 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1042 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1048 * Helper function to determine whether a texture target is enabled.
1051 is_texture_enabled(GLcontext
*ctx
, GLbitfield bit
)
1053 const struct gl_texture_unit
*const texUnit
=
1054 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1055 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1060 * Return simple enable/disable state.
1062 * \param cap state variable to query.
1064 * Returns the state of the specified capability from the current GL context.
1065 * For the capabilities associated with extensions verifies that those
1066 * extensions are effectively present before reporting.
1068 GLboolean GLAPIENTRY
1069 _mesa_IsEnabled( GLenum cap
)
1071 GET_CURRENT_CONTEXT(ctx
);
1074 return ctx
->Color
.AlphaEnabled
;
1075 case GL_AUTO_NORMAL
:
1076 return ctx
->Eval
.AutoNormal
;
1078 return ctx
->Color
.BlendEnabled
;
1079 case GL_CLIP_PLANE0
:
1080 case GL_CLIP_PLANE1
:
1081 case GL_CLIP_PLANE2
:
1082 case GL_CLIP_PLANE3
:
1083 case GL_CLIP_PLANE4
:
1084 case GL_CLIP_PLANE5
:
1085 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1086 case GL_COLOR_MATERIAL
:
1087 return ctx
->Light
.ColorMaterialEnabled
;
1089 return ctx
->Polygon
.CullFlag
;
1091 return ctx
->Depth
.Test
;
1093 return ctx
->Color
.DitherFlag
;
1095 return ctx
->Fog
.Enabled
;
1097 return ctx
->Light
.Enabled
;
1106 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1107 case GL_LINE_SMOOTH
:
1108 return ctx
->Line
.SmoothFlag
;
1109 case GL_LINE_STIPPLE
:
1110 return ctx
->Line
.StippleFlag
;
1111 case GL_INDEX_LOGIC_OP
:
1112 return ctx
->Color
.IndexLogicOpEnabled
;
1113 case GL_COLOR_LOGIC_OP
:
1114 return ctx
->Color
.ColorLogicOpEnabled
;
1115 case GL_MAP1_COLOR_4
:
1116 return ctx
->Eval
.Map1Color4
;
1118 return ctx
->Eval
.Map1Index
;
1119 case GL_MAP1_NORMAL
:
1120 return ctx
->Eval
.Map1Normal
;
1121 case GL_MAP1_TEXTURE_COORD_1
:
1122 return ctx
->Eval
.Map1TextureCoord1
;
1123 case GL_MAP1_TEXTURE_COORD_2
:
1124 return ctx
->Eval
.Map1TextureCoord2
;
1125 case GL_MAP1_TEXTURE_COORD_3
:
1126 return ctx
->Eval
.Map1TextureCoord3
;
1127 case GL_MAP1_TEXTURE_COORD_4
:
1128 return ctx
->Eval
.Map1TextureCoord4
;
1129 case GL_MAP1_VERTEX_3
:
1130 return ctx
->Eval
.Map1Vertex3
;
1131 case GL_MAP1_VERTEX_4
:
1132 return ctx
->Eval
.Map1Vertex4
;
1133 case GL_MAP2_COLOR_4
:
1134 return ctx
->Eval
.Map2Color4
;
1136 return ctx
->Eval
.Map2Index
;
1137 case GL_MAP2_NORMAL
:
1138 return ctx
->Eval
.Map2Normal
;
1139 case GL_MAP2_TEXTURE_COORD_1
:
1140 return ctx
->Eval
.Map2TextureCoord1
;
1141 case GL_MAP2_TEXTURE_COORD_2
:
1142 return ctx
->Eval
.Map2TextureCoord2
;
1143 case GL_MAP2_TEXTURE_COORD_3
:
1144 return ctx
->Eval
.Map2TextureCoord3
;
1145 case GL_MAP2_TEXTURE_COORD_4
:
1146 return ctx
->Eval
.Map2TextureCoord4
;
1147 case GL_MAP2_VERTEX_3
:
1148 return ctx
->Eval
.Map2Vertex3
;
1149 case GL_MAP2_VERTEX_4
:
1150 return ctx
->Eval
.Map2Vertex4
;
1152 return ctx
->Transform
.Normalize
;
1153 case GL_POINT_SMOOTH
:
1154 return ctx
->Point
.SmoothFlag
;
1155 case GL_POLYGON_SMOOTH
:
1156 return ctx
->Polygon
.SmoothFlag
;
1157 case GL_POLYGON_STIPPLE
:
1158 return ctx
->Polygon
.StippleFlag
;
1159 case GL_POLYGON_OFFSET_POINT
:
1160 return ctx
->Polygon
.OffsetPoint
;
1161 case GL_POLYGON_OFFSET_LINE
:
1162 return ctx
->Polygon
.OffsetLine
;
1163 case GL_POLYGON_OFFSET_FILL
:
1164 /*case GL_POLYGON_OFFSET_EXT:*/
1165 return ctx
->Polygon
.OffsetFill
;
1166 case GL_RESCALE_NORMAL_EXT
:
1167 return ctx
->Transform
.RescaleNormals
;
1168 case GL_SCISSOR_TEST
:
1169 return ctx
->Scissor
.Enabled
;
1170 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1171 return ctx
->Texture
.SharedPalette
;
1172 case GL_STENCIL_TEST
:
1173 return ctx
->Stencil
.Enabled
;
1175 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1177 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1179 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1180 case GL_TEXTURE_GEN_Q
:
1182 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1184 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1188 case GL_TEXTURE_GEN_R
:
1190 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1192 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1196 case GL_TEXTURE_GEN_S
:
1198 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1200 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1204 case GL_TEXTURE_GEN_T
:
1206 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1208 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1216 case GL_VERTEX_ARRAY
:
1217 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1218 case GL_NORMAL_ARRAY
:
1219 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1220 case GL_COLOR_ARRAY
:
1221 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1222 case GL_INDEX_ARRAY
:
1223 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1224 case GL_TEXTURE_COORD_ARRAY
:
1225 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1226 case GL_EDGE_FLAG_ARRAY
:
1227 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1228 case GL_FOG_COORDINATE_ARRAY_EXT
:
1229 CHECK_EXTENSION(EXT_fog_coord
);
1230 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1231 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1232 CHECK_EXTENSION(EXT_secondary_color
);
1233 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1234 #if FEATURE_point_size_array
1235 case GL_POINT_SIZE_ARRAY_OES
:
1236 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1239 /* GL_EXT_histogram */
1241 CHECK_EXTENSION(EXT_histogram
);
1242 return ctx
->Pixel
.HistogramEnabled
;
1244 CHECK_EXTENSION(EXT_histogram
);
1245 return ctx
->Pixel
.MinMaxEnabled
;
1247 /* GL_SGI_color_table */
1248 case GL_COLOR_TABLE_SGI
:
1249 CHECK_EXTENSION(SGI_color_table
);
1250 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
];
1251 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1252 CHECK_EXTENSION(SGI_color_table
);
1253 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
];
1254 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1255 CHECK_EXTENSION(SGI_color_table
);
1256 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
];
1258 /* GL_SGI_texture_color_table */
1259 case GL_TEXTURE_COLOR_TABLE_SGI
:
1260 CHECK_EXTENSION(SGI_texture_color_table
);
1261 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1263 /* GL_EXT_convolution */
1264 case GL_CONVOLUTION_1D
:
1265 CHECK_EXTENSION(EXT_convolution
);
1266 return ctx
->Pixel
.Convolution1DEnabled
;
1267 case GL_CONVOLUTION_2D
:
1268 CHECK_EXTENSION(EXT_convolution
);
1269 return ctx
->Pixel
.Convolution2DEnabled
;
1270 case GL_SEPARABLE_2D
:
1271 CHECK_EXTENSION(EXT_convolution
);
1272 return ctx
->Pixel
.Separable2DEnabled
;
1274 /* GL_ARB_texture_cube_map */
1275 case GL_TEXTURE_CUBE_MAP_ARB
:
1276 CHECK_EXTENSION(ARB_texture_cube_map
);
1277 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1279 /* GL_EXT_secondary_color */
1280 case GL_COLOR_SUM_EXT
:
1281 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1282 return ctx
->Fog
.ColorSumEnabled
;
1284 /* GL_ARB_multisample */
1285 case GL_MULTISAMPLE_ARB
:
1286 CHECK_EXTENSION(ARB_multisample
);
1287 return ctx
->Multisample
.Enabled
;
1288 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1289 CHECK_EXTENSION(ARB_multisample
);
1290 return ctx
->Multisample
.SampleAlphaToCoverage
;
1291 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1292 CHECK_EXTENSION(ARB_multisample
);
1293 return ctx
->Multisample
.SampleAlphaToOne
;
1294 case GL_SAMPLE_COVERAGE_ARB
:
1295 CHECK_EXTENSION(ARB_multisample
);
1296 return ctx
->Multisample
.SampleCoverage
;
1297 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1298 CHECK_EXTENSION(ARB_multisample
);
1299 return ctx
->Multisample
.SampleCoverageInvert
;
1301 /* GL_IBM_rasterpos_clip */
1302 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1303 CHECK_EXTENSION(IBM_rasterpos_clip
);
1304 return ctx
->Transform
.RasterPositionUnclipped
;
1306 /* GL_NV_point_sprite */
1307 case GL_POINT_SPRITE_NV
:
1308 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1309 return ctx
->Point
.PointSprite
;
1311 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1312 case GL_VERTEX_PROGRAM_ARB
:
1313 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1314 return ctx
->VertexProgram
.Enabled
;
1315 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1316 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1317 return ctx
->VertexProgram
.PointSizeEnabled
;
1318 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1319 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1320 return ctx
->VertexProgram
.TwoSideEnabled
;
1322 #if FEATURE_NV_vertex_program
1323 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1324 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1325 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1326 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1327 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1328 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1329 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1330 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1331 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1332 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1333 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1334 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1335 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1336 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1337 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1338 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1339 CHECK_EXTENSION(NV_vertex_program
);
1341 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1342 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1344 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1345 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1346 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1347 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1348 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1349 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1350 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1351 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1352 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1353 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1354 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1355 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1356 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1357 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1358 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1359 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1360 CHECK_EXTENSION(NV_vertex_program
);
1362 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1363 return ctx
->Eval
.Map1Attrib
[map
];
1365 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1366 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1367 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1368 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1369 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1370 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1371 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1372 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1373 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1374 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1375 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1376 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1377 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1378 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1379 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1380 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1381 CHECK_EXTENSION(NV_vertex_program
);
1383 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1384 return ctx
->Eval
.Map2Attrib
[map
];
1386 #endif /* FEATURE_NV_vertex_program */
1388 #if FEATURE_NV_fragment_program
1389 case GL_FRAGMENT_PROGRAM_NV
:
1390 CHECK_EXTENSION(NV_fragment_program
);
1391 return ctx
->FragmentProgram
.Enabled
;
1392 #endif /* FEATURE_NV_fragment_program */
1394 /* GL_NV_texture_rectangle */
1395 case GL_TEXTURE_RECTANGLE_NV
:
1396 CHECK_EXTENSION(NV_texture_rectangle
);
1397 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1399 /* GL_EXT_stencil_two_side */
1400 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1401 CHECK_EXTENSION(EXT_stencil_two_side
);
1402 return ctx
->Stencil
.TestTwoSide
;
1404 #if FEATURE_ARB_fragment_program
1405 case GL_FRAGMENT_PROGRAM_ARB
:
1406 return ctx
->FragmentProgram
.Enabled
;
1407 #endif /* FEATURE_ARB_fragment_program */
1409 /* GL_EXT_depth_bounds_test */
1410 case GL_DEPTH_BOUNDS_TEST_EXT
:
1411 CHECK_EXTENSION(EXT_depth_bounds_test
);
1412 return ctx
->Depth
.BoundsTest
;
1414 /* GL_MESA_program_debug */
1415 #if FEATURE_MESA_program_debug
1416 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1417 CHECK_EXTENSION(MESA_program_debug
);
1418 return ctx
->FragmentProgram
.CallbackEnabled
;
1419 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1420 CHECK_EXTENSION(MESA_program_debug
);
1421 return ctx
->VertexProgram
.CallbackEnabled
;
1424 #if FEATURE_ATI_fragment_shader
1425 case GL_FRAGMENT_SHADER_ATI
:
1426 CHECK_EXTENSION(ATI_fragment_shader
);
1427 return ctx
->ATIFragmentShader
.Enabled
;
1428 #endif /* FEATURE_ATI_fragment_shader */
1430 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);