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 "api_arrayelt.h"
44 #define CHECK_EXTENSION(EXTNAME, CAP) \
45 if (!ctx->Extensions.EXTNAME) { \
46 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
47 state ? "Enable" : "Disable", CAP); \
53 * Helper to enable/disable client-side state.
56 client_state(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
63 var
= &ctx
->Array
.ArrayObj
->Vertex
.Enabled
;
64 flag
= _NEW_ARRAY_VERTEX
;
67 var
= &ctx
->Array
.ArrayObj
->Normal
.Enabled
;
68 flag
= _NEW_ARRAY_NORMAL
;
71 var
= &ctx
->Array
.ArrayObj
->Color
.Enabled
;
72 flag
= _NEW_ARRAY_COLOR0
;
75 var
= &ctx
->Array
.ArrayObj
->Index
.Enabled
;
76 flag
= _NEW_ARRAY_INDEX
;
78 case GL_TEXTURE_COORD_ARRAY
:
79 var
= &ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
80 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
82 case GL_EDGE_FLAG_ARRAY
:
83 var
= &ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
;
84 flag
= _NEW_ARRAY_EDGEFLAG
;
86 case GL_FOG_COORDINATE_ARRAY_EXT
:
87 var
= &ctx
->Array
.ArrayObj
->FogCoord
.Enabled
;
88 flag
= _NEW_ARRAY_FOGCOORD
;
90 case GL_SECONDARY_COLOR_ARRAY_EXT
:
91 var
= &ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
;
92 flag
= _NEW_ARRAY_COLOR1
;
95 #if FEATURE_point_size_array
96 case GL_POINT_SIZE_ARRAY_OES
:
97 var
= &ctx
->Array
.ArrayObj
->PointSize
.Enabled
;
98 flag
= _NEW_ARRAY_POINT_SIZE
;
102 #if FEATURE_NV_vertex_program
103 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
118 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
119 CHECK_EXTENSION(NV_vertex_program
, cap
);
121 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
122 var
= &ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
;
123 flag
= _NEW_ARRAY_ATTRIB(n
);
126 #endif /* FEATURE_NV_vertex_program */
129 _mesa_error( ctx
, GL_INVALID_ENUM
,
130 "glEnable/DisableClientState(0x%x)", cap
);
137 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
138 ctx
->Array
.NewState
|= flag
;
140 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
145 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
147 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
149 if (ctx
->Driver
.Enable
) {
150 ctx
->Driver
.Enable( ctx
, cap
, state
);
156 * Enable GL capability.
157 * \param cap state to enable/disable.
159 * Get's the current context, assures that we're outside glBegin()/glEnd() and
160 * calls client_state().
163 _mesa_EnableClientState( GLenum cap
)
165 GET_CURRENT_CONTEXT(ctx
);
166 ASSERT_OUTSIDE_BEGIN_END(ctx
);
167 client_state( ctx
, cap
, GL_TRUE
);
172 * Disable GL capability.
173 * \param cap state to enable/disable.
175 * Get's the current context, assures that we're outside glBegin()/glEnd() and
176 * calls client_state().
179 _mesa_DisableClientState( GLenum cap
)
181 GET_CURRENT_CONTEXT(ctx
);
182 ASSERT_OUTSIDE_BEGIN_END(ctx
);
183 client_state( ctx
, cap
, GL_FALSE
);
187 #undef CHECK_EXTENSION
188 #define CHECK_EXTENSION(EXTNAME, CAP) \
189 if (!ctx->Extensions.EXTNAME) { \
190 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
191 state ? "Enable" : "Disable", CAP); \
195 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
196 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
197 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
198 state ? "Enable" : "Disable", CAP); \
205 * Return pointer to current texture unit for setting/getting coordinate
207 * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
208 * higher than the number of supported coordinate units. And we'll return NULL.
210 static struct gl_texture_unit
*
211 get_texcoord_unit(GLcontext
*ctx
)
213 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
214 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
218 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
224 * Helper function to enable or disable a texture target.
227 enable_texture(GLcontext
*ctx
, GLboolean state
, GLbitfield bit
)
229 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
230 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
231 const GLuint newenabled
= (!state
)
232 ? (texUnit
->Enabled
& ~bit
) : (texUnit
->Enabled
| bit
);
234 if (!ctx
->DrawBuffer
->Visual
.rgbMode
|| 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
;
278 if (ctx
->Color
.BlendEnabled
== state
)
280 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
281 ctx
->Color
.BlendEnabled
= state
;
291 const GLuint p
= cap
- GL_CLIP_PLANE0
;
293 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
296 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
299 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
301 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
302 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
304 /* This derived state also calculated in clip.c and
305 * from _mesa_update_state() on changes to EyeUserPlane
306 * and ctx->ProjectionMatrix respectively.
308 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
309 ctx
->Transform
.EyeUserPlane
[p
],
310 ctx
->ProjectionMatrixStack
.Top
->inv
);
313 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
318 case GL_COLOR_MATERIAL
:
319 if (ctx
->Light
.ColorMaterialEnabled
== state
)
321 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
322 FLUSH_CURRENT(ctx
, 0);
323 ctx
->Light
.ColorMaterialEnabled
= state
;
325 _mesa_update_color_material( ctx
,
326 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
330 if (ctx
->Polygon
.CullFlag
== state
)
332 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
333 ctx
->Polygon
.CullFlag
= state
;
335 case GL_CULL_VERTEX_EXT
:
336 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
337 if (ctx
->Transform
.CullVertexFlag
== state
)
339 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
340 ctx
->Transform
.CullVertexFlag
= state
;
343 if (ctx
->Depth
.Test
== state
)
345 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
346 ctx
->Depth
.Test
= state
;
350 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
352 if (ctx
->Color
.DitherFlag
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
355 ctx
->Color
.DitherFlag
= state
;
358 if (ctx
->Fog
.Enabled
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_FOG
);
361 ctx
->Fog
.Enabled
= state
;
364 CHECK_EXTENSION(EXT_histogram
, cap
);
365 if (ctx
->Pixel
.HistogramEnabled
== state
)
367 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
368 ctx
->Pixel
.HistogramEnabled
= state
;
378 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
380 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
381 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
383 insert_at_tail(&ctx
->Light
.EnabledList
,
384 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
387 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
391 if (ctx
->Light
.Enabled
== state
)
393 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
394 ctx
->Light
.Enabled
= state
;
395 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
396 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
398 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
401 if (ctx
->Line
.SmoothFlag
== state
)
403 FLUSH_VERTICES(ctx
, _NEW_LINE
);
404 ctx
->Line
.SmoothFlag
= state
;
405 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
407 case GL_LINE_STIPPLE
:
408 if (ctx
->Line
.StippleFlag
== state
)
410 FLUSH_VERTICES(ctx
, _NEW_LINE
);
411 ctx
->Line
.StippleFlag
= state
;
412 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
414 case GL_INDEX_LOGIC_OP
:
415 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
417 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
418 ctx
->Color
.IndexLogicOpEnabled
= state
;
420 case GL_COLOR_LOGIC_OP
:
421 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
423 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
424 ctx
->Color
.ColorLogicOpEnabled
= state
;
426 case GL_MAP1_COLOR_4
:
427 if (ctx
->Eval
.Map1Color4
== state
)
429 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
430 ctx
->Eval
.Map1Color4
= state
;
433 if (ctx
->Eval
.Map1Index
== state
)
435 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
436 ctx
->Eval
.Map1Index
= state
;
439 if (ctx
->Eval
.Map1Normal
== state
)
441 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
442 ctx
->Eval
.Map1Normal
= state
;
444 case GL_MAP1_TEXTURE_COORD_1
:
445 if (ctx
->Eval
.Map1TextureCoord1
== state
)
447 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
448 ctx
->Eval
.Map1TextureCoord1
= state
;
450 case GL_MAP1_TEXTURE_COORD_2
:
451 if (ctx
->Eval
.Map1TextureCoord2
== state
)
453 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
454 ctx
->Eval
.Map1TextureCoord2
= state
;
456 case GL_MAP1_TEXTURE_COORD_3
:
457 if (ctx
->Eval
.Map1TextureCoord3
== state
)
459 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
460 ctx
->Eval
.Map1TextureCoord3
= state
;
462 case GL_MAP1_TEXTURE_COORD_4
:
463 if (ctx
->Eval
.Map1TextureCoord4
== state
)
465 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
466 ctx
->Eval
.Map1TextureCoord4
= state
;
468 case GL_MAP1_VERTEX_3
:
469 if (ctx
->Eval
.Map1Vertex3
== state
)
471 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
472 ctx
->Eval
.Map1Vertex3
= state
;
474 case GL_MAP1_VERTEX_4
:
475 if (ctx
->Eval
.Map1Vertex4
== state
)
477 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
478 ctx
->Eval
.Map1Vertex4
= state
;
480 case GL_MAP2_COLOR_4
:
481 if (ctx
->Eval
.Map2Color4
== state
)
483 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
484 ctx
->Eval
.Map2Color4
= state
;
487 if (ctx
->Eval
.Map2Index
== state
)
489 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
490 ctx
->Eval
.Map2Index
= state
;
493 if (ctx
->Eval
.Map2Normal
== state
)
495 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
496 ctx
->Eval
.Map2Normal
= state
;
498 case GL_MAP2_TEXTURE_COORD_1
:
499 if (ctx
->Eval
.Map2TextureCoord1
== state
)
501 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
502 ctx
->Eval
.Map2TextureCoord1
= state
;
504 case GL_MAP2_TEXTURE_COORD_2
:
505 if (ctx
->Eval
.Map2TextureCoord2
== state
)
507 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
508 ctx
->Eval
.Map2TextureCoord2
= state
;
510 case GL_MAP2_TEXTURE_COORD_3
:
511 if (ctx
->Eval
.Map2TextureCoord3
== state
)
513 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
514 ctx
->Eval
.Map2TextureCoord3
= state
;
516 case GL_MAP2_TEXTURE_COORD_4
:
517 if (ctx
->Eval
.Map2TextureCoord4
== state
)
519 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
520 ctx
->Eval
.Map2TextureCoord4
= state
;
522 case GL_MAP2_VERTEX_3
:
523 if (ctx
->Eval
.Map2Vertex3
== state
)
525 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
526 ctx
->Eval
.Map2Vertex3
= state
;
528 case GL_MAP2_VERTEX_4
:
529 if (ctx
->Eval
.Map2Vertex4
== state
)
531 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
532 ctx
->Eval
.Map2Vertex4
= state
;
535 if (ctx
->Pixel
.MinMaxEnabled
== state
)
537 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
538 ctx
->Pixel
.MinMaxEnabled
= state
;
541 if (ctx
->Transform
.Normalize
== state
)
543 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
544 ctx
->Transform
.Normalize
= state
;
546 case GL_POINT_SMOOTH
:
547 if (ctx
->Point
.SmoothFlag
== state
)
549 FLUSH_VERTICES(ctx
, _NEW_POINT
);
550 ctx
->Point
.SmoothFlag
= state
;
551 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
553 case GL_POLYGON_SMOOTH
:
554 if (ctx
->Polygon
.SmoothFlag
== state
)
556 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
557 ctx
->Polygon
.SmoothFlag
= state
;
558 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
560 case GL_POLYGON_STIPPLE
:
561 if (ctx
->Polygon
.StippleFlag
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
564 ctx
->Polygon
.StippleFlag
= state
;
565 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
567 case GL_POLYGON_OFFSET_POINT
:
568 if (ctx
->Polygon
.OffsetPoint
== state
)
570 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
571 ctx
->Polygon
.OffsetPoint
= state
;
573 case GL_POLYGON_OFFSET_LINE
:
574 if (ctx
->Polygon
.OffsetLine
== state
)
576 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
577 ctx
->Polygon
.OffsetLine
= state
;
579 case GL_POLYGON_OFFSET_FILL
:
580 /*case GL_POLYGON_OFFSET_EXT:*/
581 if (ctx
->Polygon
.OffsetFill
== state
)
583 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
584 ctx
->Polygon
.OffsetFill
= state
;
586 case GL_RESCALE_NORMAL_EXT
:
587 if (ctx
->Transform
.RescaleNormals
== state
)
589 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
590 ctx
->Transform
.RescaleNormals
= state
;
592 case GL_SCISSOR_TEST
:
593 if (ctx
->Scissor
.Enabled
== state
)
595 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
596 ctx
->Scissor
.Enabled
= state
;
598 case GL_SHARED_TEXTURE_PALETTE_EXT
:
599 if (ctx
->Texture
.SharedPalette
== state
)
601 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
602 ctx
->Texture
.SharedPalette
= state
;
604 case GL_STENCIL_TEST
:
605 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
607 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
610 if (ctx
->Stencil
.Enabled
== state
)
612 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
613 ctx
->Stencil
.Enabled
= state
;
616 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
621 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
626 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
630 case GL_TEXTURE_GEN_Q
:
632 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
634 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
637 if (texUnit
->TexGenEnabled
== newenabled
)
639 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
640 texUnit
->TexGenEnabled
= newenabled
;
644 case GL_TEXTURE_GEN_R
:
646 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
648 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
651 if (texUnit
->TexGenEnabled
== newenabled
)
653 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
654 texUnit
->TexGenEnabled
= newenabled
;
658 case GL_TEXTURE_GEN_S
:
660 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
662 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
665 if (texUnit
->TexGenEnabled
== newenabled
)
667 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
668 texUnit
->TexGenEnabled
= newenabled
;
672 case GL_TEXTURE_GEN_T
:
674 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
676 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
679 if (texUnit
->TexGenEnabled
== newenabled
)
681 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
682 texUnit
->TexGenEnabled
= newenabled
;
690 case GL_VERTEX_ARRAY
:
691 case GL_NORMAL_ARRAY
:
694 case GL_TEXTURE_COORD_ARRAY
:
695 case GL_EDGE_FLAG_ARRAY
:
696 case GL_FOG_COORDINATE_ARRAY_EXT
:
697 case GL_SECONDARY_COLOR_ARRAY_EXT
:
698 case GL_POINT_SIZE_ARRAY_OES
:
699 client_state( ctx
, cap
, state
);
702 /* GL_SGI_color_table */
703 case GL_COLOR_TABLE_SGI
:
704 CHECK_EXTENSION(SGI_color_table
, cap
);
705 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] == state
)
707 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
708 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] = state
;
710 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
711 CHECK_EXTENSION(SGI_color_table
, cap
);
712 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] == state
)
714 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
715 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] = state
;
717 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
718 CHECK_EXTENSION(SGI_color_table
, cap
);
719 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] == state
)
721 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
722 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] = state
;
724 case GL_TEXTURE_COLOR_TABLE_SGI
:
725 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
726 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
728 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
729 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
732 /* GL_EXT_convolution */
733 case GL_CONVOLUTION_1D
:
734 CHECK_EXTENSION(EXT_convolution
, cap
);
735 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
737 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
738 ctx
->Pixel
.Convolution1DEnabled
= state
;
740 case GL_CONVOLUTION_2D
:
741 CHECK_EXTENSION(EXT_convolution
, cap
);
742 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
744 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
745 ctx
->Pixel
.Convolution2DEnabled
= state
;
747 case GL_SEPARABLE_2D
:
748 CHECK_EXTENSION(EXT_convolution
, cap
);
749 if (ctx
->Pixel
.Separable2DEnabled
== state
)
751 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
752 ctx
->Pixel
.Separable2DEnabled
= state
;
755 /* GL_ARB_texture_cube_map */
756 case GL_TEXTURE_CUBE_MAP_ARB
:
757 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
758 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
763 /* GL_EXT_secondary_color */
764 case GL_COLOR_SUM_EXT
:
765 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
766 if (ctx
->Fog
.ColorSumEnabled
== state
)
768 FLUSH_VERTICES(ctx
, _NEW_FOG
);
769 ctx
->Fog
.ColorSumEnabled
= state
;
772 /* GL_ARB_multisample */
773 case GL_MULTISAMPLE_ARB
:
774 if (ctx
->Multisample
.Enabled
== state
)
776 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
777 ctx
->Multisample
.Enabled
= state
;
779 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
780 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
782 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
783 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
785 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
786 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
788 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
789 ctx
->Multisample
.SampleAlphaToOne
= state
;
791 case GL_SAMPLE_COVERAGE_ARB
:
792 if (ctx
->Multisample
.SampleCoverage
== state
)
794 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
795 ctx
->Multisample
.SampleCoverage
= state
;
797 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
798 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
800 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
801 ctx
->Multisample
.SampleCoverageInvert
= state
;
804 /* GL_IBM_rasterpos_clip */
805 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
806 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
807 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
809 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
810 ctx
->Transform
.RasterPositionUnclipped
= state
;
813 /* GL_NV_point_sprite */
814 case GL_POINT_SPRITE_NV
:
815 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
816 if (ctx
->Point
.PointSprite
== state
)
818 FLUSH_VERTICES(ctx
, _NEW_POINT
);
819 ctx
->Point
.PointSprite
= state
;
822 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
823 case GL_VERTEX_PROGRAM_ARB
:
824 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
825 if (ctx
->VertexProgram
.Enabled
== state
)
827 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
828 ctx
->VertexProgram
.Enabled
= state
;
830 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
831 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
832 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
834 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
835 ctx
->VertexProgram
.PointSizeEnabled
= state
;
837 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
838 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
839 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
841 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
842 ctx
->VertexProgram
.TwoSideEnabled
= state
;
845 #if FEATURE_NV_vertex_program
846 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
847 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
848 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
849 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
850 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
851 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
852 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
853 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
854 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
855 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
856 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
857 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
858 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
859 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
860 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
861 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
862 CHECK_EXTENSION(NV_vertex_program
, cap
);
864 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
865 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
866 ctx
->Eval
.Map1Attrib
[map
] = state
;
869 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
870 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
871 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
872 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
873 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
874 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
875 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
876 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
877 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
878 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
879 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
880 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
881 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
882 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
883 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
884 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
885 CHECK_EXTENSION(NV_vertex_program
, cap
);
887 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
888 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
889 ctx
->Eval
.Map2Attrib
[map
] = state
;
892 #endif /* FEATURE_NV_vertex_program */
894 #if FEATURE_NV_fragment_program
895 case GL_FRAGMENT_PROGRAM_NV
:
896 CHECK_EXTENSION(NV_fragment_program
, cap
);
897 if (ctx
->FragmentProgram
.Enabled
== state
)
899 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
900 ctx
->FragmentProgram
.Enabled
= state
;
902 #endif /* FEATURE_NV_fragment_program */
904 /* GL_NV_texture_rectangle */
905 case GL_TEXTURE_RECTANGLE_NV
:
906 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
907 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
912 /* GL_EXT_stencil_two_side */
913 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
914 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
915 if (ctx
->Stencil
.TestTwoSide
== state
)
917 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
918 ctx
->Stencil
.TestTwoSide
= state
;
920 ctx
->Stencil
._BackFace
= 2;
921 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
923 ctx
->Stencil
._BackFace
= 1;
924 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
928 #if FEATURE_ARB_fragment_program
929 case GL_FRAGMENT_PROGRAM_ARB
:
930 CHECK_EXTENSION(ARB_fragment_program
, cap
);
931 if (ctx
->FragmentProgram
.Enabled
== state
)
933 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
934 ctx
->FragmentProgram
.Enabled
= state
;
936 #endif /* FEATURE_ARB_fragment_program */
938 /* GL_EXT_depth_bounds_test */
939 case GL_DEPTH_BOUNDS_TEST_EXT
:
940 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
941 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
943 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
946 if (ctx
->Depth
.BoundsTest
== state
)
948 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
949 ctx
->Depth
.BoundsTest
= state
;
952 /* GL_MESA_program_debug */
953 #if FEATURE_MESA_program_debug
954 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
955 CHECK_EXTENSION(MESA_program_debug
, cap
);
956 ctx
->FragmentProgram
.CallbackEnabled
= state
;
958 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
959 CHECK_EXTENSION(MESA_program_debug
, cap
);
960 ctx
->VertexProgram
.CallbackEnabled
= state
;
964 #if FEATURE_ATI_fragment_shader
965 case GL_FRAGMENT_SHADER_ATI
:
966 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
967 if (ctx
->ATIFragmentShader
.Enabled
== state
)
969 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
970 ctx
->ATIFragmentShader
.Enabled
= state
;
974 /* GL_MESA_texture_array */
975 case GL_TEXTURE_1D_ARRAY_EXT
:
976 CHECK_EXTENSION(MESA_texture_array
, cap
);
977 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
982 case GL_TEXTURE_2D_ARRAY_EXT
:
983 CHECK_EXTENSION(MESA_texture_array
, cap
);
984 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
990 _mesa_error(ctx
, GL_INVALID_ENUM
,
991 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
995 if (ctx
->Driver
.Enable
) {
996 ctx
->Driver
.Enable( ctx
, cap
, state
);
1002 * Enable GL capability. Called by glEnable()
1003 * \param cap state to enable.
1006 _mesa_Enable( GLenum cap
)
1008 GET_CURRENT_CONTEXT(ctx
);
1009 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1011 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1016 * Disable GL capability. Called by glDisable()
1017 * \param cap state to disable.
1020 _mesa_Disable( GLenum cap
)
1022 GET_CURRENT_CONTEXT(ctx
);
1023 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1025 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1029 #undef CHECK_EXTENSION
1030 #define CHECK_EXTENSION(EXTNAME) \
1031 if (!ctx->Extensions.EXTNAME) { \
1032 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1036 #undef CHECK_EXTENSION2
1037 #define CHECK_EXTENSION2(EXT1, EXT2) \
1038 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1039 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1045 * Helper function to determine whether a texture target is enabled.
1048 is_texture_enabled(GLcontext
*ctx
, GLbitfield bit
)
1050 const struct gl_texture_unit
*const texUnit
=
1051 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1052 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1057 * Return simple enable/disable state.
1059 * \param cap state variable to query.
1061 * Returns the state of the specified capability from the current GL context.
1062 * For the capabilities associated with extensions verifies that those
1063 * extensions are effectively present before reporting.
1065 GLboolean GLAPIENTRY
1066 _mesa_IsEnabled( GLenum cap
)
1068 GET_CURRENT_CONTEXT(ctx
);
1071 return ctx
->Color
.AlphaEnabled
;
1072 case GL_AUTO_NORMAL
:
1073 return ctx
->Eval
.AutoNormal
;
1075 return ctx
->Color
.BlendEnabled
;
1076 case GL_CLIP_PLANE0
:
1077 case GL_CLIP_PLANE1
:
1078 case GL_CLIP_PLANE2
:
1079 case GL_CLIP_PLANE3
:
1080 case GL_CLIP_PLANE4
:
1081 case GL_CLIP_PLANE5
:
1082 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1083 case GL_COLOR_MATERIAL
:
1084 return ctx
->Light
.ColorMaterialEnabled
;
1086 return ctx
->Polygon
.CullFlag
;
1088 return ctx
->Depth
.Test
;
1090 return ctx
->Color
.DitherFlag
;
1092 return ctx
->Fog
.Enabled
;
1094 return ctx
->Light
.Enabled
;
1103 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1104 case GL_LINE_SMOOTH
:
1105 return ctx
->Line
.SmoothFlag
;
1106 case GL_LINE_STIPPLE
:
1107 return ctx
->Line
.StippleFlag
;
1108 case GL_INDEX_LOGIC_OP
:
1109 return ctx
->Color
.IndexLogicOpEnabled
;
1110 case GL_COLOR_LOGIC_OP
:
1111 return ctx
->Color
.ColorLogicOpEnabled
;
1112 case GL_MAP1_COLOR_4
:
1113 return ctx
->Eval
.Map1Color4
;
1115 return ctx
->Eval
.Map1Index
;
1116 case GL_MAP1_NORMAL
:
1117 return ctx
->Eval
.Map1Normal
;
1118 case GL_MAP1_TEXTURE_COORD_1
:
1119 return ctx
->Eval
.Map1TextureCoord1
;
1120 case GL_MAP1_TEXTURE_COORD_2
:
1121 return ctx
->Eval
.Map1TextureCoord2
;
1122 case GL_MAP1_TEXTURE_COORD_3
:
1123 return ctx
->Eval
.Map1TextureCoord3
;
1124 case GL_MAP1_TEXTURE_COORD_4
:
1125 return ctx
->Eval
.Map1TextureCoord4
;
1126 case GL_MAP1_VERTEX_3
:
1127 return ctx
->Eval
.Map1Vertex3
;
1128 case GL_MAP1_VERTEX_4
:
1129 return ctx
->Eval
.Map1Vertex4
;
1130 case GL_MAP2_COLOR_4
:
1131 return ctx
->Eval
.Map2Color4
;
1133 return ctx
->Eval
.Map2Index
;
1134 case GL_MAP2_NORMAL
:
1135 return ctx
->Eval
.Map2Normal
;
1136 case GL_MAP2_TEXTURE_COORD_1
:
1137 return ctx
->Eval
.Map2TextureCoord1
;
1138 case GL_MAP2_TEXTURE_COORD_2
:
1139 return ctx
->Eval
.Map2TextureCoord2
;
1140 case GL_MAP2_TEXTURE_COORD_3
:
1141 return ctx
->Eval
.Map2TextureCoord3
;
1142 case GL_MAP2_TEXTURE_COORD_4
:
1143 return ctx
->Eval
.Map2TextureCoord4
;
1144 case GL_MAP2_VERTEX_3
:
1145 return ctx
->Eval
.Map2Vertex3
;
1146 case GL_MAP2_VERTEX_4
:
1147 return ctx
->Eval
.Map2Vertex4
;
1149 return ctx
->Transform
.Normalize
;
1150 case GL_POINT_SMOOTH
:
1151 return ctx
->Point
.SmoothFlag
;
1152 case GL_POLYGON_SMOOTH
:
1153 return ctx
->Polygon
.SmoothFlag
;
1154 case GL_POLYGON_STIPPLE
:
1155 return ctx
->Polygon
.StippleFlag
;
1156 case GL_POLYGON_OFFSET_POINT
:
1157 return ctx
->Polygon
.OffsetPoint
;
1158 case GL_POLYGON_OFFSET_LINE
:
1159 return ctx
->Polygon
.OffsetLine
;
1160 case GL_POLYGON_OFFSET_FILL
:
1161 /*case GL_POLYGON_OFFSET_EXT:*/
1162 return ctx
->Polygon
.OffsetFill
;
1163 case GL_RESCALE_NORMAL_EXT
:
1164 return ctx
->Transform
.RescaleNormals
;
1165 case GL_SCISSOR_TEST
:
1166 return ctx
->Scissor
.Enabled
;
1167 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1168 return ctx
->Texture
.SharedPalette
;
1169 case GL_STENCIL_TEST
:
1170 return ctx
->Stencil
.Enabled
;
1172 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1174 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1176 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1177 case GL_TEXTURE_GEN_Q
:
1179 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1181 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1185 case GL_TEXTURE_GEN_R
:
1187 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1189 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1193 case GL_TEXTURE_GEN_S
:
1195 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1197 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1201 case GL_TEXTURE_GEN_T
:
1203 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1205 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1213 case GL_VERTEX_ARRAY
:
1214 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1215 case GL_NORMAL_ARRAY
:
1216 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1217 case GL_COLOR_ARRAY
:
1218 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1219 case GL_INDEX_ARRAY
:
1220 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1221 case GL_TEXTURE_COORD_ARRAY
:
1222 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1223 case GL_EDGE_FLAG_ARRAY
:
1224 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1225 case GL_FOG_COORDINATE_ARRAY_EXT
:
1226 CHECK_EXTENSION(EXT_fog_coord
);
1227 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1228 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1229 CHECK_EXTENSION(EXT_secondary_color
);
1230 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1231 #if FEATURE_point_size_array
1232 case GL_POINT_SIZE_ARRAY_OES
:
1233 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1236 /* GL_EXT_histogram */
1238 CHECK_EXTENSION(EXT_histogram
);
1239 return ctx
->Pixel
.HistogramEnabled
;
1241 CHECK_EXTENSION(EXT_histogram
);
1242 return ctx
->Pixel
.MinMaxEnabled
;
1244 /* GL_SGI_color_table */
1245 case GL_COLOR_TABLE_SGI
:
1246 CHECK_EXTENSION(SGI_color_table
);
1247 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
];
1248 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1249 CHECK_EXTENSION(SGI_color_table
);
1250 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
];
1251 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1252 CHECK_EXTENSION(SGI_color_table
);
1253 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
];
1255 /* GL_SGI_texture_color_table */
1256 case GL_TEXTURE_COLOR_TABLE_SGI
:
1257 CHECK_EXTENSION(SGI_texture_color_table
);
1258 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1260 /* GL_EXT_convolution */
1261 case GL_CONVOLUTION_1D
:
1262 CHECK_EXTENSION(EXT_convolution
);
1263 return ctx
->Pixel
.Convolution1DEnabled
;
1264 case GL_CONVOLUTION_2D
:
1265 CHECK_EXTENSION(EXT_convolution
);
1266 return ctx
->Pixel
.Convolution2DEnabled
;
1267 case GL_SEPARABLE_2D
:
1268 CHECK_EXTENSION(EXT_convolution
);
1269 return ctx
->Pixel
.Separable2DEnabled
;
1271 /* GL_ARB_texture_cube_map */
1272 case GL_TEXTURE_CUBE_MAP_ARB
:
1273 CHECK_EXTENSION(ARB_texture_cube_map
);
1274 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1276 /* GL_EXT_secondary_color */
1277 case GL_COLOR_SUM_EXT
:
1278 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1279 return ctx
->Fog
.ColorSumEnabled
;
1281 /* GL_ARB_multisample */
1282 case GL_MULTISAMPLE_ARB
:
1283 return ctx
->Multisample
.Enabled
;
1284 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1285 return ctx
->Multisample
.SampleAlphaToCoverage
;
1286 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1287 return ctx
->Multisample
.SampleAlphaToOne
;
1288 case GL_SAMPLE_COVERAGE_ARB
:
1289 return ctx
->Multisample
.SampleCoverage
;
1290 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1291 return ctx
->Multisample
.SampleCoverageInvert
;
1293 /* GL_IBM_rasterpos_clip */
1294 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1295 CHECK_EXTENSION(IBM_rasterpos_clip
);
1296 return ctx
->Transform
.RasterPositionUnclipped
;
1298 /* GL_NV_point_sprite */
1299 case GL_POINT_SPRITE_NV
:
1300 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1301 return ctx
->Point
.PointSprite
;
1303 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1304 case GL_VERTEX_PROGRAM_ARB
:
1305 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1306 return ctx
->VertexProgram
.Enabled
;
1307 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1308 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1309 return ctx
->VertexProgram
.PointSizeEnabled
;
1310 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1311 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1312 return ctx
->VertexProgram
.TwoSideEnabled
;
1314 #if FEATURE_NV_vertex_program
1315 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1316 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1317 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1318 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1319 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1320 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1321 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1322 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1323 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1324 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1325 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1326 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1327 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1328 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1329 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1330 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1331 CHECK_EXTENSION(NV_vertex_program
);
1333 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1334 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1336 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1337 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1338 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1339 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1340 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1341 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1342 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1343 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1344 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1345 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1346 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1347 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1348 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1349 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1350 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1351 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1352 CHECK_EXTENSION(NV_vertex_program
);
1354 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1355 return ctx
->Eval
.Map1Attrib
[map
];
1357 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1358 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1359 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1360 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1361 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1362 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1363 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1364 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1365 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1366 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1367 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1368 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1369 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1370 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1371 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1372 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1373 CHECK_EXTENSION(NV_vertex_program
);
1375 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1376 return ctx
->Eval
.Map2Attrib
[map
];
1378 #endif /* FEATURE_NV_vertex_program */
1380 #if FEATURE_NV_fragment_program
1381 case GL_FRAGMENT_PROGRAM_NV
:
1382 CHECK_EXTENSION(NV_fragment_program
);
1383 return ctx
->FragmentProgram
.Enabled
;
1384 #endif /* FEATURE_NV_fragment_program */
1386 /* GL_NV_texture_rectangle */
1387 case GL_TEXTURE_RECTANGLE_NV
:
1388 CHECK_EXTENSION(NV_texture_rectangle
);
1389 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1391 /* GL_EXT_stencil_two_side */
1392 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1393 CHECK_EXTENSION(EXT_stencil_two_side
);
1394 return ctx
->Stencil
.TestTwoSide
;
1396 #if FEATURE_ARB_fragment_program
1397 case GL_FRAGMENT_PROGRAM_ARB
:
1398 return ctx
->FragmentProgram
.Enabled
;
1399 #endif /* FEATURE_ARB_fragment_program */
1401 /* GL_EXT_depth_bounds_test */
1402 case GL_DEPTH_BOUNDS_TEST_EXT
:
1403 CHECK_EXTENSION(EXT_depth_bounds_test
);
1404 return ctx
->Depth
.BoundsTest
;
1406 /* GL_MESA_program_debug */
1407 #if FEATURE_MESA_program_debug
1408 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1409 CHECK_EXTENSION(MESA_program_debug
);
1410 return ctx
->FragmentProgram
.CallbackEnabled
;
1411 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1412 CHECK_EXTENSION(MESA_program_debug
);
1413 return ctx
->VertexProgram
.CallbackEnabled
;
1416 #if FEATURE_ATI_fragment_shader
1417 case GL_FRAGMENT_SHADER_ATI
:
1418 CHECK_EXTENSION(ATI_fragment_shader
);
1419 return ctx
->ATIFragmentShader
.Enabled
;
1420 #endif /* FEATURE_ATI_fragment_shader */
1422 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);