3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2006 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"
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 client_state( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
60 var
= &ctx
->Array
.ArrayObj
->Vertex
.Enabled
;
61 flag
= _NEW_ARRAY_VERTEX
;
64 var
= &ctx
->Array
.ArrayObj
->Normal
.Enabled
;
65 flag
= _NEW_ARRAY_NORMAL
;
68 var
= &ctx
->Array
.ArrayObj
->Color
.Enabled
;
69 flag
= _NEW_ARRAY_COLOR0
;
72 var
= &ctx
->Array
.ArrayObj
->Index
.Enabled
;
73 flag
= _NEW_ARRAY_INDEX
;
75 case GL_TEXTURE_COORD_ARRAY
:
76 var
= &ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
77 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
79 case GL_EDGE_FLAG_ARRAY
:
80 var
= &ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
;
81 flag
= _NEW_ARRAY_EDGEFLAG
;
83 case GL_FOG_COORDINATE_ARRAY_EXT
:
84 var
= &ctx
->Array
.ArrayObj
->FogCoord
.Enabled
;
85 flag
= _NEW_ARRAY_FOGCOORD
;
87 case GL_SECONDARY_COLOR_ARRAY_EXT
:
88 var
= &ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
;
89 flag
= _NEW_ARRAY_COLOR1
;
92 #if FEATURE_NV_vertex_program
93 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
94 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
95 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
96 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
97 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
98 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
99 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
100 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
101 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
102 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
103 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
109 CHECK_EXTENSION(NV_vertex_program
, cap
);
111 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
112 var
= &ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
;
113 flag
= _NEW_ARRAY_ATTRIB(n
);
116 #endif /* FEATURE_NV_vertex_program */
119 _mesa_error( ctx
, GL_INVALID_ENUM
,
120 "glEnable/DisableClientState(0x%x)", cap
);
127 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
128 ctx
->Array
.NewState
|= flag
;
132 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
134 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
136 if (ctx
->Driver
.Enable
) {
137 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
143 * Enable GL capability.
145 * \param cap capability.
149 * Get's the current context, assures that we're outside glBegin()/glEnd() and
150 * calls client_state().
153 _mesa_EnableClientState( GLenum cap
)
155 GET_CURRENT_CONTEXT(ctx
);
156 ASSERT_OUTSIDE_BEGIN_END(ctx
);
157 client_state( ctx
, cap
, GL_TRUE
);
162 * Disable GL capability.
164 * \param cap capability.
168 * Get's the current context, assures that we're outside glBegin()/glEnd() and
169 * calls client_state().
172 _mesa_DisableClientState( GLenum cap
)
174 GET_CURRENT_CONTEXT(ctx
);
175 ASSERT_OUTSIDE_BEGIN_END(ctx
);
176 client_state( ctx
, cap
, GL_FALSE
);
180 #undef CHECK_EXTENSION
181 #define CHECK_EXTENSION(EXTNAME, CAP) \
182 if (!ctx->Extensions.EXTNAME) { \
183 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
184 state ? "Enable" : "Disable", CAP); \
188 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
189 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
190 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
191 state ? "Enable" : "Disable", CAP); \
198 * Perform glEnable() and glDisable() calls.
200 * \param ctx GL context.
201 * \param cap capability.
202 * \param state whether to enable or disable the specified capability.
204 * Updates the current context and flushes the vertices as needed. For
205 * capabilities associated with extensions it verifies that those extensions
206 * are effectivly present before updating. Notifies the driver via
207 * dd_function_table::Enable.
209 void _mesa_set_enable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
211 if (MESA_VERBOSE
& VERBOSE_API
)
212 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
213 state
? "glEnable" : "glDisable",
214 _mesa_lookup_enum_by_nr(cap
),
219 if (ctx
->Color
.AlphaEnabled
== state
)
221 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
222 ctx
->Color
.AlphaEnabled
= state
;
225 if (ctx
->Eval
.AutoNormal
== state
)
227 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
228 ctx
->Eval
.AutoNormal
= state
;
231 if (ctx
->Color
.BlendEnabled
== state
)
233 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
234 ctx
->Color
.BlendEnabled
= state
;
244 const GLuint p
= cap
- GL_CLIP_PLANE0
;
246 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
249 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
252 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
254 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
255 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
257 /* This derived state also calculated in clip.c and
258 * from _mesa_update_state() on changes to EyeUserPlane
259 * and ctx->ProjectionMatrix respectively.
261 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
262 ctx
->Transform
.EyeUserPlane
[p
],
263 ctx
->ProjectionMatrixStack
.Top
->inv
);
266 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
271 case GL_COLOR_MATERIAL
:
272 if (ctx
->Light
.ColorMaterialEnabled
== state
)
274 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
275 FLUSH_CURRENT(ctx
, 0);
276 ctx
->Light
.ColorMaterialEnabled
= state
;
278 _mesa_update_color_material( ctx
,
279 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
283 if (ctx
->Polygon
.CullFlag
== state
)
285 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
286 ctx
->Polygon
.CullFlag
= state
;
289 case GL_CULL_VERTEX_EXT
:
290 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
291 if (ctx
->Transform
.CullVertexFlag
== state
)
293 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
294 ctx
->Transform
.CullVertexFlag
= state
;
298 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
299 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
302 if (ctx
->Depth
.Test
==state
)
304 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
305 ctx
->Depth
.Test
= state
;
309 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
311 if (ctx
->Color
.DitherFlag
==state
)
313 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
314 ctx
->Color
.DitherFlag
= state
;
317 if (ctx
->Fog
.Enabled
==state
)
319 FLUSH_VERTICES(ctx
, _NEW_FOG
);
320 ctx
->Fog
.Enabled
= state
;
323 CHECK_EXTENSION(EXT_histogram
, cap
);
324 if (ctx
->Pixel
.HistogramEnabled
== state
)
326 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
327 ctx
->Pixel
.HistogramEnabled
= state
;
337 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
339 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
340 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
342 insert_at_tail(&ctx
->Light
.EnabledList
,
343 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
346 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
350 if (ctx
->Light
.Enabled
== state
)
352 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
353 ctx
->Light
.Enabled
= state
;
355 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
356 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
358 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
362 if (ctx
->Line
.SmoothFlag
== state
)
364 FLUSH_VERTICES(ctx
, _NEW_LINE
);
365 ctx
->Line
.SmoothFlag
= state
;
366 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
368 case GL_LINE_STIPPLE
:
369 if (ctx
->Line
.StippleFlag
== state
)
371 FLUSH_VERTICES(ctx
, _NEW_LINE
);
372 ctx
->Line
.StippleFlag
= state
;
373 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
375 case GL_INDEX_LOGIC_OP
:
376 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
378 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
379 ctx
->Color
.IndexLogicOpEnabled
= state
;
381 case GL_COLOR_LOGIC_OP
:
382 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
384 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
385 ctx
->Color
.ColorLogicOpEnabled
= state
;
387 case GL_MAP1_COLOR_4
:
388 if (ctx
->Eval
.Map1Color4
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
391 ctx
->Eval
.Map1Color4
= state
;
394 if (ctx
->Eval
.Map1Index
== state
)
396 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
397 ctx
->Eval
.Map1Index
= state
;
400 if (ctx
->Eval
.Map1Normal
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
403 ctx
->Eval
.Map1Normal
= state
;
405 case GL_MAP1_TEXTURE_COORD_1
:
406 if (ctx
->Eval
.Map1TextureCoord1
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
409 ctx
->Eval
.Map1TextureCoord1
= state
;
411 case GL_MAP1_TEXTURE_COORD_2
:
412 if (ctx
->Eval
.Map1TextureCoord2
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
415 ctx
->Eval
.Map1TextureCoord2
= state
;
417 case GL_MAP1_TEXTURE_COORD_3
:
418 if (ctx
->Eval
.Map1TextureCoord3
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
421 ctx
->Eval
.Map1TextureCoord3
= state
;
423 case GL_MAP1_TEXTURE_COORD_4
:
424 if (ctx
->Eval
.Map1TextureCoord4
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
427 ctx
->Eval
.Map1TextureCoord4
= state
;
429 case GL_MAP1_VERTEX_3
:
430 if (ctx
->Eval
.Map1Vertex3
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
433 ctx
->Eval
.Map1Vertex3
= state
;
435 case GL_MAP1_VERTEX_4
:
436 if (ctx
->Eval
.Map1Vertex4
== state
)
438 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
439 ctx
->Eval
.Map1Vertex4
= state
;
441 case GL_MAP2_COLOR_4
:
442 if (ctx
->Eval
.Map2Color4
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
445 ctx
->Eval
.Map2Color4
= state
;
448 if (ctx
->Eval
.Map2Index
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
451 ctx
->Eval
.Map2Index
= state
;
454 if (ctx
->Eval
.Map2Normal
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 ctx
->Eval
.Map2Normal
= state
;
459 case GL_MAP2_TEXTURE_COORD_1
:
460 if (ctx
->Eval
.Map2TextureCoord1
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map2TextureCoord1
= state
;
465 case GL_MAP2_TEXTURE_COORD_2
:
466 if (ctx
->Eval
.Map2TextureCoord2
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map2TextureCoord2
= state
;
471 case GL_MAP2_TEXTURE_COORD_3
:
472 if (ctx
->Eval
.Map2TextureCoord3
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map2TextureCoord3
= state
;
477 case GL_MAP2_TEXTURE_COORD_4
:
478 if (ctx
->Eval
.Map2TextureCoord4
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map2TextureCoord4
= state
;
483 case GL_MAP2_VERTEX_3
:
484 if (ctx
->Eval
.Map2Vertex3
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
487 ctx
->Eval
.Map2Vertex3
= state
;
489 case GL_MAP2_VERTEX_4
:
490 if (ctx
->Eval
.Map2Vertex4
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
493 ctx
->Eval
.Map2Vertex4
= state
;
496 if (ctx
->Pixel
.MinMaxEnabled
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
499 ctx
->Pixel
.MinMaxEnabled
= state
;
502 if (ctx
->Transform
.Normalize
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
505 ctx
->Transform
.Normalize
= state
;
507 case GL_POINT_SMOOTH
:
508 if (ctx
->Point
.SmoothFlag
==state
)
510 FLUSH_VERTICES(ctx
, _NEW_POINT
);
511 ctx
->Point
.SmoothFlag
= state
;
512 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
514 case GL_POLYGON_SMOOTH
:
515 if (ctx
->Polygon
.SmoothFlag
==state
)
517 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
518 ctx
->Polygon
.SmoothFlag
= state
;
519 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
521 case GL_POLYGON_STIPPLE
:
522 if (ctx
->Polygon
.StippleFlag
==state
)
524 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
525 ctx
->Polygon
.StippleFlag
= state
;
526 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
528 case GL_POLYGON_OFFSET_POINT
:
529 if (ctx
->Polygon
.OffsetPoint
==state
)
531 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
532 ctx
->Polygon
.OffsetPoint
= state
;
534 case GL_POLYGON_OFFSET_LINE
:
535 if (ctx
->Polygon
.OffsetLine
==state
)
537 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
538 ctx
->Polygon
.OffsetLine
= state
;
540 case GL_POLYGON_OFFSET_FILL
:
541 /*case GL_POLYGON_OFFSET_EXT:*/
542 if (ctx
->Polygon
.OffsetFill
==state
)
544 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
545 ctx
->Polygon
.OffsetFill
= state
;
547 case GL_RESCALE_NORMAL_EXT
:
548 if (ctx
->Transform
.RescaleNormals
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
551 ctx
->Transform
.RescaleNormals
= state
;
553 case GL_SCISSOR_TEST
:
554 if (ctx
->Scissor
.Enabled
==state
)
556 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
557 ctx
->Scissor
.Enabled
= state
;
559 case GL_SHARED_TEXTURE_PALETTE_EXT
:
560 if (ctx
->Texture
.SharedPalette
== state
)
562 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
563 ctx
->Texture
.SharedPalette
= state
;
565 case GL_STENCIL_TEST
:
566 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
568 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
571 if (ctx
->Stencil
.Enabled
==state
)
573 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
574 ctx
->Stencil
.Enabled
= state
;
576 case GL_TEXTURE_1D
: {
577 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
578 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
579 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_1D_BIT
;
581 newenabled
|= TEXTURE_1D_BIT
;
582 if (!ctx
->DrawBuffer
->Visual
.rgbMode
583 || texUnit
->Enabled
== newenabled
)
585 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
586 texUnit
->Enabled
= newenabled
;
589 case GL_TEXTURE_2D
: {
590 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
591 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
592 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_2D_BIT
;
594 newenabled
|= TEXTURE_2D_BIT
;
595 if (!ctx
->DrawBuffer
->Visual
.rgbMode
596 || texUnit
->Enabled
== newenabled
)
598 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
599 texUnit
->Enabled
= newenabled
;
602 case GL_TEXTURE_3D
: {
603 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
604 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
605 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_3D_BIT
;
607 newenabled
|= TEXTURE_3D_BIT
;
608 if (!ctx
->DrawBuffer
->Visual
.rgbMode
609 || texUnit
->Enabled
== newenabled
)
611 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
612 texUnit
->Enabled
= newenabled
;
615 case GL_TEXTURE_GEN_Q
: {
616 GLuint unit
= ctx
->Texture
.CurrentUnit
;
617 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
618 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
621 if (texUnit
->TexGenEnabled
== newenabled
)
623 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
624 texUnit
->TexGenEnabled
= newenabled
;
627 case GL_TEXTURE_GEN_R
: {
628 GLuint unit
= ctx
->Texture
.CurrentUnit
;
629 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
630 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
633 if (texUnit
->TexGenEnabled
== newenabled
)
635 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
636 texUnit
->TexGenEnabled
= newenabled
;
639 case GL_TEXTURE_GEN_S
: {
640 GLuint unit
= ctx
->Texture
.CurrentUnit
;
641 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
642 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
645 if (texUnit
->TexGenEnabled
== newenabled
)
647 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
648 texUnit
->TexGenEnabled
= newenabled
;
651 case GL_TEXTURE_GEN_T
: {
652 GLuint unit
= ctx
->Texture
.CurrentUnit
;
653 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
654 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
657 if (texUnit
->TexGenEnabled
== newenabled
)
659 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
660 texUnit
->TexGenEnabled
= newenabled
;
667 case GL_VERTEX_ARRAY
:
668 case GL_NORMAL_ARRAY
:
671 case GL_TEXTURE_COORD_ARRAY
:
672 case GL_EDGE_FLAG_ARRAY
:
673 case GL_FOG_COORDINATE_ARRAY_EXT
:
674 case GL_SECONDARY_COLOR_ARRAY_EXT
:
675 client_state( ctx
, cap
, state
);
678 /* GL_SGI_color_table */
679 case GL_COLOR_TABLE_SGI
:
680 CHECK_EXTENSION(SGI_color_table
, cap
);
681 if (ctx
->Pixel
.ColorTableEnabled
== state
)
683 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
684 ctx
->Pixel
.ColorTableEnabled
= state
;
686 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
687 CHECK_EXTENSION(SGI_color_table
, cap
);
688 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
== state
)
690 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
691 ctx
->Pixel
.PostConvolutionColorTableEnabled
= state
;
693 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
694 CHECK_EXTENSION(SGI_color_table
, cap
);
695 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
== state
)
697 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
698 ctx
->Pixel
.PostColorMatrixColorTableEnabled
= state
;
700 case GL_TEXTURE_COLOR_TABLE_SGI
:
701 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
702 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
704 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
705 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
708 /* GL_EXT_convolution */
709 case GL_CONVOLUTION_1D
:
710 CHECK_EXTENSION(EXT_convolution
, cap
);
711 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
713 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
714 ctx
->Pixel
.Convolution1DEnabled
= state
;
716 case GL_CONVOLUTION_2D
:
717 CHECK_EXTENSION(EXT_convolution
, cap
);
718 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
720 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
721 ctx
->Pixel
.Convolution2DEnabled
= state
;
723 case GL_SEPARABLE_2D
:
724 CHECK_EXTENSION(EXT_convolution
, cap
);
725 if (ctx
->Pixel
.Separable2DEnabled
== state
)
727 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
728 ctx
->Pixel
.Separable2DEnabled
= state
;
731 /* GL_ARB_texture_cube_map */
732 case GL_TEXTURE_CUBE_MAP_ARB
:
734 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
735 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
736 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_CUBE_BIT
;
737 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
739 newenabled
|= TEXTURE_CUBE_BIT
;
740 if (!ctx
->DrawBuffer
->Visual
.rgbMode
741 || texUnit
->Enabled
== newenabled
)
743 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
744 texUnit
->Enabled
= newenabled
;
748 /* GL_EXT_secondary_color */
749 case GL_COLOR_SUM_EXT
:
750 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
751 if (ctx
->Fog
.ColorSumEnabled
== state
)
753 FLUSH_VERTICES(ctx
, _NEW_FOG
);
754 ctx
->Fog
.ColorSumEnabled
= state
;
757 /* GL_ARB_multisample */
758 case GL_MULTISAMPLE_ARB
:
759 CHECK_EXTENSION(ARB_multisample
, cap
);
760 if (ctx
->Multisample
.Enabled
== state
)
762 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
763 ctx
->Multisample
.Enabled
= state
;
765 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
766 CHECK_EXTENSION(ARB_multisample
, cap
);
767 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
769 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
770 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
772 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
773 CHECK_EXTENSION(ARB_multisample
, cap
);
774 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
776 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
777 ctx
->Multisample
.SampleAlphaToOne
= state
;
779 case GL_SAMPLE_COVERAGE_ARB
:
780 CHECK_EXTENSION(ARB_multisample
, cap
);
781 if (ctx
->Multisample
.SampleCoverage
== state
)
783 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
784 ctx
->Multisample
.SampleCoverage
= state
;
786 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
787 CHECK_EXTENSION(ARB_multisample
, cap
);
788 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
790 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
791 ctx
->Multisample
.SampleCoverageInvert
= state
;
794 /* GL_IBM_rasterpos_clip */
795 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
796 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
797 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
799 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
800 ctx
->Transform
.RasterPositionUnclipped
= state
;
803 /* GL_NV_point_sprite */
804 case GL_POINT_SPRITE_NV
:
805 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
806 if (ctx
->Point
.PointSprite
== state
)
808 FLUSH_VERTICES(ctx
, _NEW_POINT
);
809 ctx
->Point
.PointSprite
= state
;
812 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
813 case GL_VERTEX_PROGRAM_ARB
:
814 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
815 if (ctx
->VertexProgram
.Enabled
== state
)
817 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
818 ctx
->VertexProgram
.Enabled
= state
;
820 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
821 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
822 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
824 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
825 ctx
->VertexProgram
.PointSizeEnabled
= state
;
827 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
828 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
829 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
831 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
832 ctx
->VertexProgram
.TwoSideEnabled
= state
;
835 #if FEATURE_NV_vertex_program
836 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
837 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
838 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
839 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
840 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
841 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
842 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
843 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
844 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
845 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
846 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
847 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
848 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
849 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
850 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
851 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
852 CHECK_EXTENSION(NV_vertex_program
, cap
);
854 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
855 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
856 ctx
->Eval
.Map1Attrib
[map
] = state
;
859 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
860 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
861 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
862 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
863 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
864 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
865 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
866 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
867 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
868 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
869 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
870 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
871 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
872 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
873 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
874 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
875 CHECK_EXTENSION(NV_vertex_program
, cap
);
877 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
878 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
879 ctx
->Eval
.Map2Attrib
[map
] = state
;
882 #endif /* FEATURE_NV_vertex_program */
884 #if FEATURE_NV_fragment_program
885 case GL_FRAGMENT_PROGRAM_NV
:
886 CHECK_EXTENSION(NV_fragment_program
, cap
);
887 if (ctx
->FragmentProgram
.Enabled
== state
)
889 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
890 ctx
->FragmentProgram
.Enabled
= state
;
892 #endif /* FEATURE_NV_fragment_program */
894 /* GL_NV_texture_rectangle */
895 case GL_TEXTURE_RECTANGLE_NV
:
896 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
898 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
899 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
900 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_RECT_BIT
;
901 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
903 newenabled
|= TEXTURE_RECT_BIT
;
904 if (!ctx
->DrawBuffer
->Visual
.rgbMode
905 || texUnit
->Enabled
== newenabled
)
907 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
908 texUnit
->Enabled
= newenabled
;
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
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
922 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
926 #if FEATURE_ARB_fragment_program
927 case GL_FRAGMENT_PROGRAM_ARB
:
928 CHECK_EXTENSION(ARB_fragment_program
, cap
);
929 if (ctx
->FragmentProgram
.Enabled
== state
)
931 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
932 ctx
->FragmentProgram
.Enabled
= state
;
934 #endif /* FEATURE_ARB_fragment_program */
936 /* GL_EXT_depth_bounds_test */
937 case GL_DEPTH_BOUNDS_TEST_EXT
:
938 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
939 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
941 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
944 if (ctx
->Depth
.BoundsTest
== state
)
946 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
947 ctx
->Depth
.BoundsTest
= state
;
950 /* GL_MESA_program_debug */
951 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
952 CHECK_EXTENSION(MESA_program_debug
, cap
);
953 ctx
->FragmentProgram
.CallbackEnabled
= state
;
955 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
956 CHECK_EXTENSION(MESA_program_debug
, cap
);
957 ctx
->VertexProgram
.CallbackEnabled
= state
;
960 #if FEATURE_ATI_fragment_shader
961 case GL_FRAGMENT_SHADER_ATI
:
962 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
963 if (ctx
->ATIFragmentShader
.Enabled
== state
)
965 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
966 ctx
->ATIFragmentShader
.Enabled
= state
;
970 _mesa_error(ctx
, GL_INVALID_ENUM
,
971 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
975 if (ctx
->Driver
.Enable
) {
976 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
982 * Enable GL capability.
984 * \param cap capability.
988 * Get's the current context, assures that we're outside glBegin()/glEnd() and
989 * calls _mesa_set_enable().
992 _mesa_Enable( GLenum cap
)
994 GET_CURRENT_CONTEXT(ctx
);
995 ASSERT_OUTSIDE_BEGIN_END(ctx
);
997 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1002 * Disable GL capability.
1004 * \param cap capability.
1008 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1009 * calls _mesa_set_enable().
1012 _mesa_Disable( GLenum cap
)
1014 GET_CURRENT_CONTEXT(ctx
);
1015 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1017 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1021 #undef CHECK_EXTENSION
1022 #define CHECK_EXTENSION(EXTNAME) \
1023 if (!ctx->Extensions.EXTNAME) { \
1024 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1028 #undef CHECK_EXTENSION2
1029 #define CHECK_EXTENSION2(EXT1, EXT2) \
1030 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1031 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1036 * Test whether a capability is enabled.
1038 * \param cap capability.
1040 * Returns the state of the specified capability from the current GL context.
1041 * For the capabilities associated with extensions verifies that those
1042 * extensions are effectively present before reporting.
1044 GLboolean GLAPIENTRY
1045 _mesa_IsEnabled( GLenum cap
)
1047 GET_CURRENT_CONTEXT(ctx
);
1050 return ctx
->Color
.AlphaEnabled
;
1051 case GL_AUTO_NORMAL
:
1052 return ctx
->Eval
.AutoNormal
;
1054 return ctx
->Color
.BlendEnabled
;
1055 case GL_CLIP_PLANE0
:
1056 case GL_CLIP_PLANE1
:
1057 case GL_CLIP_PLANE2
:
1058 case GL_CLIP_PLANE3
:
1059 case GL_CLIP_PLANE4
:
1060 case GL_CLIP_PLANE5
:
1061 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1062 case GL_COLOR_MATERIAL
:
1063 return ctx
->Light
.ColorMaterialEnabled
;
1065 return ctx
->Polygon
.CullFlag
;
1067 return ctx
->Depth
.Test
;
1069 return ctx
->Color
.DitherFlag
;
1071 return ctx
->Fog
.Enabled
;
1073 return ctx
->Light
.Enabled
;
1082 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1083 case GL_LINE_SMOOTH
:
1084 return ctx
->Line
.SmoothFlag
;
1085 case GL_LINE_STIPPLE
:
1086 return ctx
->Line
.StippleFlag
;
1087 case GL_INDEX_LOGIC_OP
:
1088 return ctx
->Color
.IndexLogicOpEnabled
;
1089 case GL_COLOR_LOGIC_OP
:
1090 return ctx
->Color
.ColorLogicOpEnabled
;
1091 case GL_MAP1_COLOR_4
:
1092 return ctx
->Eval
.Map1Color4
;
1094 return ctx
->Eval
.Map1Index
;
1095 case GL_MAP1_NORMAL
:
1096 return ctx
->Eval
.Map1Normal
;
1097 case GL_MAP1_TEXTURE_COORD_1
:
1098 return ctx
->Eval
.Map1TextureCoord1
;
1099 case GL_MAP1_TEXTURE_COORD_2
:
1100 return ctx
->Eval
.Map1TextureCoord2
;
1101 case GL_MAP1_TEXTURE_COORD_3
:
1102 return ctx
->Eval
.Map1TextureCoord3
;
1103 case GL_MAP1_TEXTURE_COORD_4
:
1104 return ctx
->Eval
.Map1TextureCoord4
;
1105 case GL_MAP1_VERTEX_3
:
1106 return ctx
->Eval
.Map1Vertex3
;
1107 case GL_MAP1_VERTEX_4
:
1108 return ctx
->Eval
.Map1Vertex4
;
1109 case GL_MAP2_COLOR_4
:
1110 return ctx
->Eval
.Map2Color4
;
1112 return ctx
->Eval
.Map2Index
;
1113 case GL_MAP2_NORMAL
:
1114 return ctx
->Eval
.Map2Normal
;
1115 case GL_MAP2_TEXTURE_COORD_1
:
1116 return ctx
->Eval
.Map2TextureCoord1
;
1117 case GL_MAP2_TEXTURE_COORD_2
:
1118 return ctx
->Eval
.Map2TextureCoord2
;
1119 case GL_MAP2_TEXTURE_COORD_3
:
1120 return ctx
->Eval
.Map2TextureCoord3
;
1121 case GL_MAP2_TEXTURE_COORD_4
:
1122 return ctx
->Eval
.Map2TextureCoord4
;
1123 case GL_MAP2_VERTEX_3
:
1124 return ctx
->Eval
.Map2Vertex3
;
1125 case GL_MAP2_VERTEX_4
:
1126 return ctx
->Eval
.Map2Vertex4
;
1128 return ctx
->Transform
.Normalize
;
1129 case GL_POINT_SMOOTH
:
1130 return ctx
->Point
.SmoothFlag
;
1131 case GL_POLYGON_SMOOTH
:
1132 return ctx
->Polygon
.SmoothFlag
;
1133 case GL_POLYGON_STIPPLE
:
1134 return ctx
->Polygon
.StippleFlag
;
1135 case GL_POLYGON_OFFSET_POINT
:
1136 return ctx
->Polygon
.OffsetPoint
;
1137 case GL_POLYGON_OFFSET_LINE
:
1138 return ctx
->Polygon
.OffsetLine
;
1139 case GL_POLYGON_OFFSET_FILL
:
1140 /*case GL_POLYGON_OFFSET_EXT:*/
1141 return ctx
->Polygon
.OffsetFill
;
1142 case GL_RESCALE_NORMAL_EXT
:
1143 return ctx
->Transform
.RescaleNormals
;
1144 case GL_SCISSOR_TEST
:
1145 return ctx
->Scissor
.Enabled
;
1146 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1147 return ctx
->Texture
.SharedPalette
;
1148 case GL_STENCIL_TEST
:
1149 return ctx
->Stencil
.Enabled
;
1152 const struct gl_texture_unit
*texUnit
;
1153 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1154 return (texUnit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
;
1158 const struct gl_texture_unit
*texUnit
;
1159 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1160 return (texUnit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
;
1164 const struct gl_texture_unit
*texUnit
;
1165 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1166 return (texUnit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
;
1168 case GL_TEXTURE_GEN_Q
:
1170 const struct gl_texture_unit
*texUnit
;
1171 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1172 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1174 case GL_TEXTURE_GEN_R
:
1176 const struct gl_texture_unit
*texUnit
;
1177 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1178 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1180 case GL_TEXTURE_GEN_S
:
1182 const struct gl_texture_unit
*texUnit
;
1183 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1184 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1186 case GL_TEXTURE_GEN_T
:
1188 const struct gl_texture_unit
*texUnit
;
1189 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1190 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1196 case GL_VERTEX_ARRAY
:
1197 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1198 case GL_NORMAL_ARRAY
:
1199 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1200 case GL_COLOR_ARRAY
:
1201 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1202 case GL_INDEX_ARRAY
:
1203 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1204 case GL_TEXTURE_COORD_ARRAY
:
1205 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1206 case GL_EDGE_FLAG_ARRAY
:
1207 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1208 case GL_FOG_COORDINATE_ARRAY_EXT
:
1209 CHECK_EXTENSION(EXT_fog_coord
);
1210 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1211 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1212 CHECK_EXTENSION(EXT_secondary_color
);
1213 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1215 /* GL_EXT_histogram */
1217 CHECK_EXTENSION(EXT_histogram
);
1218 return ctx
->Pixel
.HistogramEnabled
;
1220 CHECK_EXTENSION(EXT_histogram
);
1221 return ctx
->Pixel
.MinMaxEnabled
;
1223 /* GL_SGI_color_table */
1224 case GL_COLOR_TABLE_SGI
:
1225 CHECK_EXTENSION(SGI_color_table
);
1226 return ctx
->Pixel
.ColorTableEnabled
;
1227 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1228 CHECK_EXTENSION(SGI_color_table
);
1229 return ctx
->Pixel
.PostConvolutionColorTableEnabled
;
1230 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1231 CHECK_EXTENSION(SGI_color_table
);
1232 return ctx
->Pixel
.PostColorMatrixColorTableEnabled
;
1234 /* GL_SGI_texture_color_table */
1235 case GL_TEXTURE_COLOR_TABLE_SGI
:
1236 CHECK_EXTENSION(SGI_texture_color_table
);
1237 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1239 /* GL_EXT_convolution */
1240 case GL_CONVOLUTION_1D
:
1241 CHECK_EXTENSION(EXT_convolution
);
1242 return ctx
->Pixel
.Convolution1DEnabled
;
1243 case GL_CONVOLUTION_2D
:
1244 CHECK_EXTENSION(EXT_convolution
);
1245 return ctx
->Pixel
.Convolution2DEnabled
;
1246 case GL_SEPARABLE_2D
:
1247 CHECK_EXTENSION(EXT_convolution
);
1248 return ctx
->Pixel
.Separable2DEnabled
;
1250 /* GL_ARB_texture_cube_map */
1251 case GL_TEXTURE_CUBE_MAP_ARB
:
1252 CHECK_EXTENSION(ARB_texture_cube_map
);
1254 const struct gl_texture_unit
*texUnit
;
1255 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1256 return (texUnit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
;
1259 /* GL_EXT_secondary_color */
1260 case GL_COLOR_SUM_EXT
:
1261 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1262 return ctx
->Fog
.ColorSumEnabled
;
1264 /* GL_ARB_multisample */
1265 case GL_MULTISAMPLE_ARB
:
1266 CHECK_EXTENSION(ARB_multisample
);
1267 return ctx
->Multisample
.Enabled
;
1268 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1269 CHECK_EXTENSION(ARB_multisample
);
1270 return ctx
->Multisample
.SampleAlphaToCoverage
;
1271 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1272 CHECK_EXTENSION(ARB_multisample
);
1273 return ctx
->Multisample
.SampleAlphaToOne
;
1274 case GL_SAMPLE_COVERAGE_ARB
:
1275 CHECK_EXTENSION(ARB_multisample
);
1276 return ctx
->Multisample
.SampleCoverage
;
1277 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1278 CHECK_EXTENSION(ARB_multisample
);
1279 return ctx
->Multisample
.SampleCoverageInvert
;
1281 /* GL_IBM_rasterpos_clip */
1282 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1283 CHECK_EXTENSION(IBM_rasterpos_clip
);
1284 return ctx
->Transform
.RasterPositionUnclipped
;
1286 /* GL_NV_point_sprite */
1287 case GL_POINT_SPRITE_NV
:
1288 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1289 return ctx
->Point
.PointSprite
;
1291 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1292 case GL_VERTEX_PROGRAM_ARB
:
1293 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1294 return ctx
->VertexProgram
.Enabled
;
1295 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1296 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1297 return ctx
->VertexProgram
.PointSizeEnabled
;
1298 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1299 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1300 return ctx
->VertexProgram
.TwoSideEnabled
;
1302 #if FEATURE_NV_vertex_program
1303 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1304 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1305 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1306 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1307 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1308 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1309 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1310 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1311 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1312 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1313 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1314 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1315 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1316 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1317 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1318 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1319 CHECK_EXTENSION(NV_vertex_program
);
1321 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1322 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1324 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1325 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1326 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1327 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1328 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1329 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1330 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1331 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1332 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1333 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1334 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1335 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1336 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1337 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1338 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1339 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1340 CHECK_EXTENSION(NV_vertex_program
);
1342 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1343 return ctx
->Eval
.Map1Attrib
[map
];
1345 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1346 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1347 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1348 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1349 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1350 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1351 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1352 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1353 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1354 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1355 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1356 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1357 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1358 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1359 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1360 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1361 CHECK_EXTENSION(NV_vertex_program
);
1363 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1364 return ctx
->Eval
.Map2Attrib
[map
];
1366 #endif /* FEATURE_NV_vertex_program */
1368 #if FEATURE_NV_fragment_program
1369 case GL_FRAGMENT_PROGRAM_NV
:
1370 CHECK_EXTENSION(NV_fragment_program
);
1371 return ctx
->FragmentProgram
.Enabled
;
1372 #endif /* FEATURE_NV_fragment_program */
1374 /* GL_NV_texture_rectangle */
1375 case GL_TEXTURE_RECTANGLE_NV
:
1376 CHECK_EXTENSION(NV_texture_rectangle
);
1378 const struct gl_texture_unit
*texUnit
;
1379 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1380 return (texUnit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
;
1383 /* GL_EXT_stencil_two_side */
1384 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1385 CHECK_EXTENSION(EXT_stencil_two_side
);
1386 return ctx
->Stencil
.TestTwoSide
;
1388 #if FEATURE_ARB_fragment_program
1389 case GL_FRAGMENT_PROGRAM_ARB
:
1390 return ctx
->FragmentProgram
.Enabled
;
1391 #endif /* FEATURE_ARB_fragment_program */
1393 /* GL_EXT_depth_bounds_test */
1394 case GL_DEPTH_BOUNDS_TEST_EXT
:
1395 CHECK_EXTENSION(EXT_depth_bounds_test
);
1396 return ctx
->Depth
.BoundsTest
;
1398 /* GL_MESA_program_debug */
1399 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1400 CHECK_EXTENSION(MESA_program_debug
);
1401 return ctx
->FragmentProgram
.CallbackEnabled
;
1402 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1403 CHECK_EXTENSION(MESA_program_debug
);
1404 return ctx
->VertexProgram
.CallbackEnabled
;
1405 #if FEATURE_ATI_fragment_shader
1406 case GL_FRAGMENT_SHADER_ATI
:
1407 CHECK_EXTENSION(ATI_fragment_shader
);
1408 return ctx
->ATIFragmentShader
.Enabled
;
1409 #endif /* FEATURE_ATI_fragment_shader */
1411 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);