3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2005 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
.Vertex
.Enabled
;
61 flag
= _NEW_ARRAY_VERTEX
;
64 var
= &ctx
->Array
.Normal
.Enabled
;
65 flag
= _NEW_ARRAY_NORMAL
;
68 var
= &ctx
->Array
.Color
.Enabled
;
69 flag
= _NEW_ARRAY_COLOR0
;
72 var
= &ctx
->Array
.Index
.Enabled
;
73 flag
= _NEW_ARRAY_INDEX
;
75 case GL_TEXTURE_COORD_ARRAY
:
76 var
= &ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
77 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
79 case GL_EDGE_FLAG_ARRAY
:
80 var
= &ctx
->Array
.EdgeFlag
.Enabled
;
81 flag
= _NEW_ARRAY_EDGEFLAG
;
83 case GL_FOG_COORDINATE_ARRAY_EXT
:
84 var
= &ctx
->Array
.FogCoord
.Enabled
;
85 flag
= _NEW_ARRAY_FOGCOORD
;
87 case GL_SECONDARY_COLOR_ARRAY_EXT
:
88 var
= &ctx
->Array
.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
.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
._Enabled
|= flag
;
134 ctx
->Array
._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
;
235 /* This is needed to support 1.1's RGB logic ops AND
236 * 1.0's blending logicops.
238 ctx
->Color
._LogicOpEnabled
=
239 (ctx
->Color
.ColorLogicOpEnabled
||
240 (state
&& ctx
->Color
.BlendEquationRGB
== GL_LOGIC_OP
));
250 const GLuint p
= cap
- GL_CLIP_PLANE0
;
252 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
255 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
258 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
260 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
261 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
263 /* This derived state also calculated in clip.c and
264 * from _mesa_update_state() on changes to EyeUserPlane
265 * and ctx->ProjectionMatrix respectively.
267 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
268 ctx
->Transform
.EyeUserPlane
[p
],
269 ctx
->ProjectionMatrixStack
.Top
->inv
);
272 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
277 case GL_COLOR_MATERIAL
:
278 if (ctx
->Light
.ColorMaterialEnabled
== state
)
280 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
281 FLUSH_CURRENT(ctx
, 0);
282 ctx
->Light
.ColorMaterialEnabled
= state
;
284 _mesa_update_color_material( ctx
,
285 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
289 if (ctx
->Polygon
.CullFlag
== state
)
291 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
292 ctx
->Polygon
.CullFlag
= state
;
295 case GL_CULL_VERTEX_EXT
:
296 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
297 if (ctx
->Transform
.CullVertexFlag
== state
)
299 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
300 ctx
->Transform
.CullVertexFlag
= state
;
304 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
305 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
308 if (ctx
->Depth
.Test
==state
)
310 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
311 ctx
->Depth
.Test
= state
;
315 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
317 if (ctx
->Color
.DitherFlag
==state
)
319 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
320 ctx
->Color
.DitherFlag
= state
;
323 if (ctx
->Fog
.Enabled
==state
)
325 FLUSH_VERTICES(ctx
, _NEW_FOG
);
326 ctx
->Fog
.Enabled
= state
;
329 CHECK_EXTENSION(EXT_histogram
, cap
);
330 if (ctx
->Pixel
.HistogramEnabled
== state
)
332 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
333 ctx
->Pixel
.HistogramEnabled
= state
;
343 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
345 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
346 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
348 insert_at_tail(&ctx
->Light
.EnabledList
,
349 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
352 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
356 if (ctx
->Light
.Enabled
== state
)
358 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
359 ctx
->Light
.Enabled
= state
;
361 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
362 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
364 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
368 if (ctx
->Line
.SmoothFlag
== state
)
370 FLUSH_VERTICES(ctx
, _NEW_LINE
);
371 ctx
->Line
.SmoothFlag
= state
;
372 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
374 case GL_LINE_STIPPLE
:
375 if (ctx
->Line
.StippleFlag
== state
)
377 FLUSH_VERTICES(ctx
, _NEW_LINE
);
378 ctx
->Line
.StippleFlag
= state
;
379 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
381 case GL_INDEX_LOGIC_OP
:
382 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
384 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
385 ctx
->Color
.IndexLogicOpEnabled
= state
;
387 case GL_COLOR_LOGIC_OP
:
388 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
391 ctx
->Color
.ColorLogicOpEnabled
= state
;
392 /* This is needed to support 1.1's RGB logic ops AND
393 * 1.0's blending logicops.
395 ctx
->Color
._LogicOpEnabled
=
396 (state
|| (ctx
->Color
.BlendEnabled
&&
397 ctx
->Color
.BlendEquationRGB
== GL_LOGIC_OP
));
399 case GL_MAP1_COLOR_4
:
400 if (ctx
->Eval
.Map1Color4
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
403 ctx
->Eval
.Map1Color4
= state
;
406 if (ctx
->Eval
.Map1Index
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
409 ctx
->Eval
.Map1Index
= state
;
412 if (ctx
->Eval
.Map1Normal
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
415 ctx
->Eval
.Map1Normal
= state
;
417 case GL_MAP1_TEXTURE_COORD_1
:
418 if (ctx
->Eval
.Map1TextureCoord1
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
421 ctx
->Eval
.Map1TextureCoord1
= state
;
423 case GL_MAP1_TEXTURE_COORD_2
:
424 if (ctx
->Eval
.Map1TextureCoord2
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
427 ctx
->Eval
.Map1TextureCoord2
= state
;
429 case GL_MAP1_TEXTURE_COORD_3
:
430 if (ctx
->Eval
.Map1TextureCoord3
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
433 ctx
->Eval
.Map1TextureCoord3
= state
;
435 case GL_MAP1_TEXTURE_COORD_4
:
436 if (ctx
->Eval
.Map1TextureCoord4
== state
)
438 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
439 ctx
->Eval
.Map1TextureCoord4
= state
;
441 case GL_MAP1_VERTEX_3
:
442 if (ctx
->Eval
.Map1Vertex3
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
445 ctx
->Eval
.Map1Vertex3
= state
;
447 case GL_MAP1_VERTEX_4
:
448 if (ctx
->Eval
.Map1Vertex4
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
451 ctx
->Eval
.Map1Vertex4
= state
;
453 case GL_MAP2_COLOR_4
:
454 if (ctx
->Eval
.Map2Color4
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 ctx
->Eval
.Map2Color4
= state
;
460 if (ctx
->Eval
.Map2Index
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map2Index
= state
;
466 if (ctx
->Eval
.Map2Normal
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map2Normal
= state
;
471 case GL_MAP2_TEXTURE_COORD_1
:
472 if (ctx
->Eval
.Map2TextureCoord1
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map2TextureCoord1
= state
;
477 case GL_MAP2_TEXTURE_COORD_2
:
478 if (ctx
->Eval
.Map2TextureCoord2
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map2TextureCoord2
= state
;
483 case GL_MAP2_TEXTURE_COORD_3
:
484 if (ctx
->Eval
.Map2TextureCoord3
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
487 ctx
->Eval
.Map2TextureCoord3
= state
;
489 case GL_MAP2_TEXTURE_COORD_4
:
490 if (ctx
->Eval
.Map2TextureCoord4
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
493 ctx
->Eval
.Map2TextureCoord4
= state
;
495 case GL_MAP2_VERTEX_3
:
496 if (ctx
->Eval
.Map2Vertex3
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map2Vertex3
= state
;
501 case GL_MAP2_VERTEX_4
:
502 if (ctx
->Eval
.Map2Vertex4
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
505 ctx
->Eval
.Map2Vertex4
= state
;
508 if (ctx
->Pixel
.MinMaxEnabled
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
511 ctx
->Pixel
.MinMaxEnabled
= state
;
514 if (ctx
->Transform
.Normalize
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
517 ctx
->Transform
.Normalize
= state
;
519 case GL_POINT_SMOOTH
:
520 if (ctx
->Point
.SmoothFlag
==state
)
522 FLUSH_VERTICES(ctx
, _NEW_POINT
);
523 ctx
->Point
.SmoothFlag
= state
;
524 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
526 case GL_POLYGON_SMOOTH
:
527 if (ctx
->Polygon
.SmoothFlag
==state
)
529 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
530 ctx
->Polygon
.SmoothFlag
= state
;
531 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
533 case GL_POLYGON_STIPPLE
:
534 if (ctx
->Polygon
.StippleFlag
==state
)
536 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
537 ctx
->Polygon
.StippleFlag
= state
;
538 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
540 case GL_POLYGON_OFFSET_POINT
:
541 if (ctx
->Polygon
.OffsetPoint
==state
)
543 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
544 ctx
->Polygon
.OffsetPoint
= state
;
546 case GL_POLYGON_OFFSET_LINE
:
547 if (ctx
->Polygon
.OffsetLine
==state
)
549 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
550 ctx
->Polygon
.OffsetLine
= state
;
552 case GL_POLYGON_OFFSET_FILL
:
553 /*case GL_POLYGON_OFFSET_EXT:*/
554 if (ctx
->Polygon
.OffsetFill
==state
)
556 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
557 ctx
->Polygon
.OffsetFill
= state
;
559 case GL_RESCALE_NORMAL_EXT
:
560 if (ctx
->Transform
.RescaleNormals
== state
)
562 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
563 ctx
->Transform
.RescaleNormals
= state
;
565 case GL_SCISSOR_TEST
:
566 if (ctx
->Scissor
.Enabled
==state
)
568 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
569 ctx
->Scissor
.Enabled
= state
;
571 case GL_SHARED_TEXTURE_PALETTE_EXT
:
572 if (ctx
->Texture
.SharedPalette
== state
)
574 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
575 ctx
->Texture
.SharedPalette
= state
;
577 case GL_STENCIL_TEST
:
578 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
580 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
583 if (ctx
->Stencil
.Enabled
==state
)
585 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
586 ctx
->Stencil
.Enabled
= state
;
588 case GL_TEXTURE_1D
: {
589 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
590 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
591 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_1D_BIT
;
593 newenabled
|= TEXTURE_1D_BIT
;
594 if (!ctx
->DrawBuffer
->Visual
.rgbMode
595 || texUnit
->Enabled
== newenabled
)
597 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
598 texUnit
->Enabled
= newenabled
;
601 case GL_TEXTURE_2D
: {
602 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
603 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
604 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_2D_BIT
;
606 newenabled
|= TEXTURE_2D_BIT
;
607 if (!ctx
->DrawBuffer
->Visual
.rgbMode
608 || texUnit
->Enabled
== newenabled
)
610 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
611 texUnit
->Enabled
= newenabled
;
614 case GL_TEXTURE_3D
: {
615 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
616 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
617 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_3D_BIT
;
619 newenabled
|= TEXTURE_3D_BIT
;
620 if (!ctx
->DrawBuffer
->Visual
.rgbMode
621 || texUnit
->Enabled
== newenabled
)
623 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
624 texUnit
->Enabled
= newenabled
;
627 case GL_TEXTURE_GEN_Q
: {
628 GLuint unit
= ctx
->Texture
.CurrentUnit
;
629 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
630 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
633 if (texUnit
->TexGenEnabled
== newenabled
)
635 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
636 texUnit
->TexGenEnabled
= newenabled
;
639 case GL_TEXTURE_GEN_R
: {
640 GLuint unit
= ctx
->Texture
.CurrentUnit
;
641 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
642 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
645 if (texUnit
->TexGenEnabled
== newenabled
)
647 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
648 texUnit
->TexGenEnabled
= newenabled
;
651 case GL_TEXTURE_GEN_S
: {
652 GLuint unit
= ctx
->Texture
.CurrentUnit
;
653 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
654 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
657 if (texUnit
->TexGenEnabled
== newenabled
)
659 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
660 texUnit
->TexGenEnabled
= newenabled
;
663 case GL_TEXTURE_GEN_T
: {
664 GLuint unit
= ctx
->Texture
.CurrentUnit
;
665 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
666 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
669 if (texUnit
->TexGenEnabled
== newenabled
)
671 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
672 texUnit
->TexGenEnabled
= newenabled
;
679 case GL_VERTEX_ARRAY
:
680 case GL_NORMAL_ARRAY
:
683 case GL_TEXTURE_COORD_ARRAY
:
684 case GL_EDGE_FLAG_ARRAY
:
685 case GL_FOG_COORDINATE_ARRAY_EXT
:
686 case GL_SECONDARY_COLOR_ARRAY_EXT
:
687 client_state( ctx
, cap
, state
);
690 /* GL_SGI_color_table */
691 case GL_COLOR_TABLE_SGI
:
692 CHECK_EXTENSION(SGI_color_table
, cap
);
693 if (ctx
->Pixel
.ColorTableEnabled
== state
)
695 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
696 ctx
->Pixel
.ColorTableEnabled
= state
;
698 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
699 CHECK_EXTENSION(SGI_color_table
, cap
);
700 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
== state
)
702 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
703 ctx
->Pixel
.PostConvolutionColorTableEnabled
= state
;
705 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
706 CHECK_EXTENSION(SGI_color_table
, cap
);
707 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
== state
)
709 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
710 ctx
->Pixel
.PostColorMatrixColorTableEnabled
= state
;
712 case GL_TEXTURE_COLOR_TABLE_SGI
:
713 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
714 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
716 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
717 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
720 /* GL_EXT_convolution */
721 case GL_CONVOLUTION_1D
:
722 CHECK_EXTENSION(EXT_convolution
, cap
);
723 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
725 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
726 ctx
->Pixel
.Convolution1DEnabled
= state
;
728 case GL_CONVOLUTION_2D
:
729 CHECK_EXTENSION(EXT_convolution
, cap
);
730 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
732 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
733 ctx
->Pixel
.Convolution2DEnabled
= state
;
735 case GL_SEPARABLE_2D
:
736 CHECK_EXTENSION(EXT_convolution
, cap
);
737 if (ctx
->Pixel
.Separable2DEnabled
== state
)
739 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
740 ctx
->Pixel
.Separable2DEnabled
= state
;
743 /* GL_ARB_texture_cube_map */
744 case GL_TEXTURE_CUBE_MAP_ARB
:
746 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
747 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
748 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_CUBE_BIT
;
749 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
751 newenabled
|= TEXTURE_CUBE_BIT
;
752 if (!ctx
->DrawBuffer
->Visual
.rgbMode
753 || texUnit
->Enabled
== newenabled
)
755 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
756 texUnit
->Enabled
= newenabled
;
760 /* GL_EXT_secondary_color */
761 case GL_COLOR_SUM_EXT
:
762 CHECK_EXTENSION(EXT_secondary_color
, cap
);
763 if (ctx
->Fog
.ColorSumEnabled
== state
)
765 FLUSH_VERTICES(ctx
, _NEW_FOG
);
766 ctx
->Fog
.ColorSumEnabled
= state
;
769 /* GL_ARB_multisample */
770 case GL_MULTISAMPLE_ARB
:
771 CHECK_EXTENSION(ARB_multisample
, cap
);
772 if (ctx
->Multisample
.Enabled
== state
)
774 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
775 ctx
->Multisample
.Enabled
= state
;
777 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
778 CHECK_EXTENSION(ARB_multisample
, cap
);
779 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
781 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
782 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
784 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
785 CHECK_EXTENSION(ARB_multisample
, cap
);
786 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
788 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
789 ctx
->Multisample
.SampleAlphaToOne
= state
;
791 case GL_SAMPLE_COVERAGE_ARB
:
792 CHECK_EXTENSION(ARB_multisample
, cap
);
793 if (ctx
->Multisample
.SampleCoverage
== state
)
795 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
796 ctx
->Multisample
.SampleCoverage
= state
;
798 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
799 CHECK_EXTENSION(ARB_multisample
, cap
);
800 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
802 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
803 ctx
->Multisample
.SampleCoverageInvert
= state
;
806 /* GL_IBM_rasterpos_clip */
807 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
808 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
809 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
811 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
812 ctx
->Transform
.RasterPositionUnclipped
= state
;
815 /* GL_NV_point_sprite */
816 case GL_POINT_SPRITE_NV
:
817 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
818 if (ctx
->Point
.PointSprite
== state
)
820 FLUSH_VERTICES(ctx
, _NEW_POINT
);
821 ctx
->Point
.PointSprite
= state
;
824 #if FEATURE_NV_vertex_program
825 case GL_VERTEX_PROGRAM_NV
:
826 CHECK_EXTENSION2(NV_vertex_program
, ARB_vertex_program
, cap
);
827 if (ctx
->VertexProgram
.Enabled
== state
)
829 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
830 ctx
->VertexProgram
.Enabled
= state
;
832 case GL_VERTEX_PROGRAM_POINT_SIZE_NV
:
833 CHECK_EXTENSION2(NV_vertex_program
, ARB_vertex_program
, cap
);
834 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
836 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
837 ctx
->VertexProgram
.PointSizeEnabled
= state
;
839 case GL_VERTEX_PROGRAM_TWO_SIDE_NV
:
840 CHECK_EXTENSION2(NV_vertex_program
, ARB_vertex_program
, cap
);
841 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
843 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
844 ctx
->VertexProgram
.TwoSideEnabled
= state
;
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
);
908 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
909 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
910 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_RECT_BIT
;
911 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
913 newenabled
|= TEXTURE_RECT_BIT
;
914 if (!ctx
->DrawBuffer
->Visual
.rgbMode
915 || texUnit
->Enabled
== newenabled
)
917 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
918 texUnit
->Enabled
= newenabled
;
922 /* GL_EXT_stencil_two_side */
923 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
924 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
925 if (ctx
->Stencil
.TestTwoSide
== state
)
927 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
928 ctx
->Stencil
.TestTwoSide
= state
;
930 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
932 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
936 #if FEATURE_ARB_fragment_program
937 case GL_FRAGMENT_PROGRAM_ARB
:
938 CHECK_EXTENSION(ARB_fragment_program
, cap
);
939 if (ctx
->FragmentProgram
.Enabled
== state
)
941 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
942 ctx
->FragmentProgram
.Enabled
= state
;
944 #endif /* FEATURE_ARB_fragment_program */
946 /* GL_EXT_depth_bounds_test */
947 case GL_DEPTH_BOUNDS_TEST_EXT
:
948 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
949 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
951 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
954 if (ctx
->Depth
.BoundsTest
== state
)
956 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
957 ctx
->Depth
.BoundsTest
= state
;
960 /* GL_MESA_program_debug */
961 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
962 CHECK_EXTENSION(MESA_program_debug
, cap
);
963 ctx
->FragmentProgram
.CallbackEnabled
= state
;
965 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
966 CHECK_EXTENSION(MESA_program_debug
, cap
);
967 ctx
->VertexProgram
.CallbackEnabled
= state
;
970 #if FEATURE_ATI_fragment_shader
971 case GL_FRAGMENT_SHADER_ATI
:
972 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
973 if (ctx
->ATIFragmentShader
.Enabled
== state
)
975 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
976 ctx
->ATIFragmentShader
.Enabled
= state
;
980 _mesa_error(ctx
, GL_INVALID_ENUM
,
981 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
985 if (ctx
->Driver
.Enable
) {
986 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
992 * Enable GL capability.
994 * \param cap capability.
998 * Get's the current context, assures that we're outside glBegin()/glEnd() and
999 * calls _mesa_set_enable().
1002 _mesa_Enable( GLenum cap
)
1004 GET_CURRENT_CONTEXT(ctx
);
1005 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1007 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1012 * Disable GL capability.
1014 * \param cap capability.
1018 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1019 * calls _mesa_set_enable().
1022 _mesa_Disable( GLenum cap
)
1024 GET_CURRENT_CONTEXT(ctx
);
1025 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1027 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1031 #undef CHECK_EXTENSION
1032 #define CHECK_EXTENSION(EXTNAME) \
1033 if (!ctx->Extensions.EXTNAME) { \
1034 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1040 * Test whether a capability is enabled.
1042 * \param cap capability.
1044 * Returns the state of the specified capability from the current GL context.
1045 * For the capabilities associated with extensions verifies that those
1046 * extensions are effectively present before reporting.
1048 GLboolean GLAPIENTRY
1049 _mesa_IsEnabled( GLenum cap
)
1051 GET_CURRENT_CONTEXT(ctx
);
1054 return ctx
->Color
.AlphaEnabled
;
1055 case GL_AUTO_NORMAL
:
1056 return ctx
->Eval
.AutoNormal
;
1058 return ctx
->Color
.BlendEnabled
;
1059 case GL_CLIP_PLANE0
:
1060 case GL_CLIP_PLANE1
:
1061 case GL_CLIP_PLANE2
:
1062 case GL_CLIP_PLANE3
:
1063 case GL_CLIP_PLANE4
:
1064 case GL_CLIP_PLANE5
:
1065 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1066 case GL_COLOR_MATERIAL
:
1067 return ctx
->Light
.ColorMaterialEnabled
;
1069 return ctx
->Polygon
.CullFlag
;
1071 return ctx
->Depth
.Test
;
1073 return ctx
->Color
.DitherFlag
;
1075 return ctx
->Fog
.Enabled
;
1077 return ctx
->Light
.Enabled
;
1086 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1087 case GL_LINE_SMOOTH
:
1088 return ctx
->Line
.SmoothFlag
;
1089 case GL_LINE_STIPPLE
:
1090 return ctx
->Line
.StippleFlag
;
1091 case GL_INDEX_LOGIC_OP
:
1092 return ctx
->Color
.IndexLogicOpEnabled
;
1093 case GL_COLOR_LOGIC_OP
:
1094 return ctx
->Color
.ColorLogicOpEnabled
;
1095 case GL_MAP1_COLOR_4
:
1096 return ctx
->Eval
.Map1Color4
;
1098 return ctx
->Eval
.Map1Index
;
1099 case GL_MAP1_NORMAL
:
1100 return ctx
->Eval
.Map1Normal
;
1101 case GL_MAP1_TEXTURE_COORD_1
:
1102 return ctx
->Eval
.Map1TextureCoord1
;
1103 case GL_MAP1_TEXTURE_COORD_2
:
1104 return ctx
->Eval
.Map1TextureCoord2
;
1105 case GL_MAP1_TEXTURE_COORD_3
:
1106 return ctx
->Eval
.Map1TextureCoord3
;
1107 case GL_MAP1_TEXTURE_COORD_4
:
1108 return ctx
->Eval
.Map1TextureCoord4
;
1109 case GL_MAP1_VERTEX_3
:
1110 return ctx
->Eval
.Map1Vertex3
;
1111 case GL_MAP1_VERTEX_4
:
1112 return ctx
->Eval
.Map1Vertex4
;
1113 case GL_MAP2_COLOR_4
:
1114 return ctx
->Eval
.Map2Color4
;
1116 return ctx
->Eval
.Map2Index
;
1117 case GL_MAP2_NORMAL
:
1118 return ctx
->Eval
.Map2Normal
;
1119 case GL_MAP2_TEXTURE_COORD_1
:
1120 return ctx
->Eval
.Map2TextureCoord1
;
1121 case GL_MAP2_TEXTURE_COORD_2
:
1122 return ctx
->Eval
.Map2TextureCoord2
;
1123 case GL_MAP2_TEXTURE_COORD_3
:
1124 return ctx
->Eval
.Map2TextureCoord3
;
1125 case GL_MAP2_TEXTURE_COORD_4
:
1126 return ctx
->Eval
.Map2TextureCoord4
;
1127 case GL_MAP2_VERTEX_3
:
1128 return ctx
->Eval
.Map2Vertex3
;
1129 case GL_MAP2_VERTEX_4
:
1130 return ctx
->Eval
.Map2Vertex4
;
1132 return ctx
->Transform
.Normalize
;
1133 case GL_POINT_SMOOTH
:
1134 return ctx
->Point
.SmoothFlag
;
1135 case GL_POLYGON_SMOOTH
:
1136 return ctx
->Polygon
.SmoothFlag
;
1137 case GL_POLYGON_STIPPLE
:
1138 return ctx
->Polygon
.StippleFlag
;
1139 case GL_POLYGON_OFFSET_POINT
:
1140 return ctx
->Polygon
.OffsetPoint
;
1141 case GL_POLYGON_OFFSET_LINE
:
1142 return ctx
->Polygon
.OffsetLine
;
1143 case GL_POLYGON_OFFSET_FILL
:
1144 /*case GL_POLYGON_OFFSET_EXT:*/
1145 return ctx
->Polygon
.OffsetFill
;
1146 case GL_RESCALE_NORMAL_EXT
:
1147 return ctx
->Transform
.RescaleNormals
;
1148 case GL_SCISSOR_TEST
:
1149 return ctx
->Scissor
.Enabled
;
1150 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1151 return ctx
->Texture
.SharedPalette
;
1152 case GL_STENCIL_TEST
:
1153 return ctx
->Stencil
.Enabled
;
1156 const struct gl_texture_unit
*texUnit
;
1157 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1158 return (texUnit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
;
1162 const struct gl_texture_unit
*texUnit
;
1163 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1164 return (texUnit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
;
1168 const struct gl_texture_unit
*texUnit
;
1169 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1170 return (texUnit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
;
1172 case GL_TEXTURE_GEN_Q
:
1174 const struct gl_texture_unit
*texUnit
;
1175 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1176 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1178 case GL_TEXTURE_GEN_R
:
1180 const struct gl_texture_unit
*texUnit
;
1181 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1182 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1184 case GL_TEXTURE_GEN_S
:
1186 const struct gl_texture_unit
*texUnit
;
1187 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1188 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1190 case GL_TEXTURE_GEN_T
:
1192 const struct gl_texture_unit
*texUnit
;
1193 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1194 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1200 case GL_VERTEX_ARRAY
:
1201 return (ctx
->Array
.Vertex
.Enabled
!= 0);
1202 case GL_NORMAL_ARRAY
:
1203 return (ctx
->Array
.Normal
.Enabled
!= 0);
1204 case GL_COLOR_ARRAY
:
1205 return (ctx
->Array
.Color
.Enabled
!= 0);
1206 case GL_INDEX_ARRAY
:
1207 return (ctx
->Array
.Index
.Enabled
!= 0);
1208 case GL_TEXTURE_COORD_ARRAY
:
1209 return (ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1210 case GL_EDGE_FLAG_ARRAY
:
1211 return (ctx
->Array
.EdgeFlag
.Enabled
!= 0);
1212 case GL_FOG_COORDINATE_ARRAY_EXT
:
1213 CHECK_EXTENSION(EXT_fog_coord
);
1214 return (ctx
->Array
.FogCoord
.Enabled
!= 0);
1215 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1216 CHECK_EXTENSION(EXT_secondary_color
);
1217 return (ctx
->Array
.SecondaryColor
.Enabled
!= 0);
1219 /* GL_EXT_histogram */
1221 CHECK_EXTENSION(EXT_histogram
);
1222 return ctx
->Pixel
.HistogramEnabled
;
1224 CHECK_EXTENSION(EXT_histogram
);
1225 return ctx
->Pixel
.MinMaxEnabled
;
1227 /* GL_SGI_color_table */
1228 case GL_COLOR_TABLE_SGI
:
1229 CHECK_EXTENSION(SGI_color_table
);
1230 return ctx
->Pixel
.ColorTableEnabled
;
1231 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1232 CHECK_EXTENSION(SGI_color_table
);
1233 return ctx
->Pixel
.PostConvolutionColorTableEnabled
;
1234 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1235 CHECK_EXTENSION(SGI_color_table
);
1236 return ctx
->Pixel
.PostColorMatrixColorTableEnabled
;
1238 /* GL_SGI_texture_color_table */
1239 case GL_TEXTURE_COLOR_TABLE_SGI
:
1240 CHECK_EXTENSION(SGI_texture_color_table
);
1241 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1243 /* GL_EXT_convolution */
1244 case GL_CONVOLUTION_1D
:
1245 CHECK_EXTENSION(EXT_convolution
);
1246 return ctx
->Pixel
.Convolution1DEnabled
;
1247 case GL_CONVOLUTION_2D
:
1248 CHECK_EXTENSION(EXT_convolution
);
1249 return ctx
->Pixel
.Convolution2DEnabled
;
1250 case GL_SEPARABLE_2D
:
1251 CHECK_EXTENSION(EXT_convolution
);
1252 return ctx
->Pixel
.Separable2DEnabled
;
1254 /* GL_ARB_texture_cube_map */
1255 case GL_TEXTURE_CUBE_MAP_ARB
:
1256 CHECK_EXTENSION(ARB_texture_cube_map
);
1258 const struct gl_texture_unit
*texUnit
;
1259 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1260 return (texUnit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
;
1263 /* GL_ARB_multisample */
1264 case GL_MULTISAMPLE_ARB
:
1265 CHECK_EXTENSION(ARB_multisample
);
1266 return ctx
->Multisample
.Enabled
;
1267 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1268 CHECK_EXTENSION(ARB_multisample
);
1269 return ctx
->Multisample
.SampleAlphaToCoverage
;
1270 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1271 CHECK_EXTENSION(ARB_multisample
);
1272 return ctx
->Multisample
.SampleAlphaToOne
;
1273 case GL_SAMPLE_COVERAGE_ARB
:
1274 CHECK_EXTENSION(ARB_multisample
);
1275 return ctx
->Multisample
.SampleCoverage
;
1276 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1277 CHECK_EXTENSION(ARB_multisample
);
1278 return ctx
->Multisample
.SampleCoverageInvert
;
1280 /* GL_IBM_rasterpos_clip */
1281 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1282 CHECK_EXTENSION(IBM_rasterpos_clip
);
1283 return ctx
->Transform
.RasterPositionUnclipped
;
1285 /* GL_NV_point_sprite */
1286 case GL_POINT_SPRITE_NV
:
1287 return ctx
->Point
.PointSprite
;
1289 #if FEATURE_NV_vertex_program
1290 case GL_VERTEX_PROGRAM_NV
:
1291 CHECK_EXTENSION(NV_vertex_program
);
1292 return ctx
->VertexProgram
.Enabled
;
1293 case GL_VERTEX_PROGRAM_POINT_SIZE_NV
:
1294 CHECK_EXTENSION(NV_vertex_program
);
1295 return ctx
->VertexProgram
.PointSizeEnabled
;
1296 case GL_VERTEX_PROGRAM_TWO_SIDE_NV
:
1297 CHECK_EXTENSION(NV_vertex_program
);
1298 return ctx
->VertexProgram
.TwoSideEnabled
;
1299 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1300 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1301 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1302 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1303 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1304 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1305 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1306 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1307 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1308 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1309 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1310 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1311 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1312 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1313 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1314 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1315 CHECK_EXTENSION(NV_vertex_program
);
1317 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1318 return (ctx
->Array
.VertexAttrib
[n
].Enabled
!= 0);
1320 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1321 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1322 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1323 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1324 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1325 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1326 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1327 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1328 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1329 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1330 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1331 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1332 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1333 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1334 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1335 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1336 CHECK_EXTENSION(NV_vertex_program
);
1338 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1339 return ctx
->Eval
.Map1Attrib
[map
];
1341 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1342 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1343 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1344 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1345 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1346 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1347 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1348 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1349 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1350 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1351 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1352 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1353 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1354 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1355 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1356 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1357 CHECK_EXTENSION(NV_vertex_program
);
1359 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1360 return ctx
->Eval
.Map2Attrib
[map
];
1362 #endif /* FEATURE_NV_vertex_program */
1364 #if FEATURE_NV_fragment_program
1365 case GL_FRAGMENT_PROGRAM_NV
:
1366 CHECK_EXTENSION(NV_fragment_program
);
1367 return ctx
->FragmentProgram
.Enabled
;
1368 #endif /* FEATURE_NV_fragment_program */
1370 /* GL_NV_texture_rectangle */
1371 case GL_TEXTURE_RECTANGLE_NV
:
1372 CHECK_EXTENSION(NV_texture_rectangle
);
1374 const struct gl_texture_unit
*texUnit
;
1375 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1376 return (texUnit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
;
1379 /* GL_EXT_stencil_two_side */
1380 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1381 CHECK_EXTENSION(EXT_stencil_two_side
);
1382 return ctx
->Stencil
.TestTwoSide
;
1384 #if FEATURE_ARB_fragment_program
1385 case GL_FRAGMENT_PROGRAM_ARB
:
1386 return ctx
->FragmentProgram
.Enabled
;
1387 #endif /* FEATURE_ARB_fragment_program */
1389 /* GL_EXT_depth_bounds_test */
1390 case GL_DEPTH_BOUNDS_TEST_EXT
:
1391 CHECK_EXTENSION(EXT_depth_bounds_test
);
1392 return ctx
->Depth
.BoundsTest
;
1394 /* GL_MESA_program_debug */
1395 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1396 CHECK_EXTENSION(MESA_program_debug
);
1397 return ctx
->FragmentProgram
.CallbackEnabled
;
1398 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1399 CHECK_EXTENSION(MESA_program_debug
);
1400 return ctx
->VertexProgram
.CallbackEnabled
;
1401 #if FEATURE_ATI_fragment_shader
1402 case GL_FRAGMENT_SHADER_ATI
:
1403 CHECK_EXTENSION(ATI_fragment_shader
);
1404 return ctx
->ATIFragmentShader
.Enabled
;
1405 #endif /* FEATURE_ATI_fragment_shader */
1407 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);