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 * 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_NV_vertex_program
96 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
97 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
98 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
99 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
100 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
101 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
102 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
103 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
112 CHECK_EXTENSION(NV_vertex_program
, cap
);
114 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
115 var
= &ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
;
116 flag
= _NEW_ARRAY_ATTRIB(n
);
119 #endif /* FEATURE_NV_vertex_program */
122 _mesa_error( ctx
, GL_INVALID_ENUM
,
123 "glEnable/DisableClientState(0x%x)", cap
);
130 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
131 ctx
->Array
.NewState
|= flag
;
135 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
137 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
139 if (ctx
->Driver
.Enable
) {
140 ctx
->Driver
.Enable( ctx
, cap
, state
);
146 * Enable GL capability.
147 * \param cap state to enable/disable.
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.
163 * \param cap state to enable/disable.
165 * Get's the current context, assures that we're outside glBegin()/glEnd() and
166 * calls client_state().
169 _mesa_DisableClientState( GLenum cap
)
171 GET_CURRENT_CONTEXT(ctx
);
172 ASSERT_OUTSIDE_BEGIN_END(ctx
);
173 client_state( ctx
, cap
, GL_FALSE
);
177 #undef CHECK_EXTENSION
178 #define CHECK_EXTENSION(EXTNAME, CAP) \
179 if (!ctx->Extensions.EXTNAME) { \
180 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
181 state ? "Enable" : "Disable", CAP); \
185 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
186 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
187 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
188 state ? "Enable" : "Disable", CAP); \
195 * Helper function to enable or disable state.
197 * \param ctx GL context.
198 * \param cap the state to enable/disable
199 * \param state whether to enable or disable the specified capability.
201 * Updates the current context and flushes the vertices as needed. For
202 * capabilities associated with extensions it verifies that those extensions
203 * are effectivly present before updating. Notifies the driver via
204 * dd_function_table::Enable.
207 _mesa_set_enable(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
209 if (MESA_VERBOSE
& VERBOSE_API
)
210 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
211 state
? "glEnable" : "glDisable",
212 _mesa_lookup_enum_by_nr(cap
),
217 if (ctx
->Color
.AlphaEnabled
== state
)
219 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
220 ctx
->Color
.AlphaEnabled
= state
;
223 if (ctx
->Eval
.AutoNormal
== state
)
225 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
226 ctx
->Eval
.AutoNormal
= state
;
229 if (ctx
->Color
.BlendEnabled
== state
)
231 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
232 ctx
->Color
.BlendEnabled
= state
;
242 const GLuint p
= cap
- GL_CLIP_PLANE0
;
244 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
247 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
250 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
252 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
253 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
255 /* This derived state also calculated in clip.c and
256 * from _mesa_update_state() on changes to EyeUserPlane
257 * and ctx->ProjectionMatrix respectively.
259 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
260 ctx
->Transform
.EyeUserPlane
[p
],
261 ctx
->ProjectionMatrixStack
.Top
->inv
);
264 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
269 case GL_COLOR_MATERIAL
:
270 if (ctx
->Light
.ColorMaterialEnabled
== state
)
272 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
273 FLUSH_CURRENT(ctx
, 0);
274 ctx
->Light
.ColorMaterialEnabled
= state
;
276 _mesa_update_color_material( ctx
,
277 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
281 if (ctx
->Polygon
.CullFlag
== state
)
283 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
284 ctx
->Polygon
.CullFlag
= state
;
286 case GL_CULL_VERTEX_EXT
:
287 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
288 if (ctx
->Transform
.CullVertexFlag
== state
)
290 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
291 ctx
->Transform
.CullVertexFlag
= state
;
294 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
295 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
298 if (ctx
->Depth
.Test
== state
)
300 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
301 ctx
->Depth
.Test
= state
;
305 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
307 if (ctx
->Color
.DitherFlag
== state
)
309 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
310 ctx
->Color
.DitherFlag
= state
;
313 if (ctx
->Fog
.Enabled
== state
)
315 FLUSH_VERTICES(ctx
, _NEW_FOG
);
316 ctx
->Fog
.Enabled
= state
;
319 CHECK_EXTENSION(EXT_histogram
, cap
);
320 if (ctx
->Pixel
.HistogramEnabled
== state
)
322 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
323 ctx
->Pixel
.HistogramEnabled
= state
;
333 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
335 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
336 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
338 insert_at_tail(&ctx
->Light
.EnabledList
,
339 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
342 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
346 if (ctx
->Light
.Enabled
== state
)
348 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
349 ctx
->Light
.Enabled
= state
;
352 if (ctx
->Line
.SmoothFlag
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_LINE
);
355 ctx
->Line
.SmoothFlag
= state
;
357 case GL_LINE_STIPPLE
:
358 if (ctx
->Line
.StippleFlag
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_LINE
);
361 ctx
->Line
.StippleFlag
= state
;
363 case GL_INDEX_LOGIC_OP
:
364 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
366 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
367 ctx
->Color
.IndexLogicOpEnabled
= state
;
369 case GL_COLOR_LOGIC_OP
:
370 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
372 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
373 ctx
->Color
.ColorLogicOpEnabled
= state
;
375 case GL_MAP1_COLOR_4
:
376 if (ctx
->Eval
.Map1Color4
== state
)
378 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
379 ctx
->Eval
.Map1Color4
= state
;
382 if (ctx
->Eval
.Map1Index
== state
)
384 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
385 ctx
->Eval
.Map1Index
= state
;
388 if (ctx
->Eval
.Map1Normal
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
391 ctx
->Eval
.Map1Normal
= state
;
393 case GL_MAP1_TEXTURE_COORD_1
:
394 if (ctx
->Eval
.Map1TextureCoord1
== state
)
396 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
397 ctx
->Eval
.Map1TextureCoord1
= state
;
399 case GL_MAP1_TEXTURE_COORD_2
:
400 if (ctx
->Eval
.Map1TextureCoord2
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
403 ctx
->Eval
.Map1TextureCoord2
= state
;
405 case GL_MAP1_TEXTURE_COORD_3
:
406 if (ctx
->Eval
.Map1TextureCoord3
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
409 ctx
->Eval
.Map1TextureCoord3
= state
;
411 case GL_MAP1_TEXTURE_COORD_4
:
412 if (ctx
->Eval
.Map1TextureCoord4
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
415 ctx
->Eval
.Map1TextureCoord4
= state
;
417 case GL_MAP1_VERTEX_3
:
418 if (ctx
->Eval
.Map1Vertex3
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
421 ctx
->Eval
.Map1Vertex3
= state
;
423 case GL_MAP1_VERTEX_4
:
424 if (ctx
->Eval
.Map1Vertex4
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
427 ctx
->Eval
.Map1Vertex4
= state
;
429 case GL_MAP2_COLOR_4
:
430 if (ctx
->Eval
.Map2Color4
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
433 ctx
->Eval
.Map2Color4
= state
;
436 if (ctx
->Eval
.Map2Index
== state
)
438 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
439 ctx
->Eval
.Map2Index
= state
;
442 if (ctx
->Eval
.Map2Normal
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
445 ctx
->Eval
.Map2Normal
= state
;
447 case GL_MAP2_TEXTURE_COORD_1
:
448 if (ctx
->Eval
.Map2TextureCoord1
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
451 ctx
->Eval
.Map2TextureCoord1
= state
;
453 case GL_MAP2_TEXTURE_COORD_2
:
454 if (ctx
->Eval
.Map2TextureCoord2
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 ctx
->Eval
.Map2TextureCoord2
= state
;
459 case GL_MAP2_TEXTURE_COORD_3
:
460 if (ctx
->Eval
.Map2TextureCoord3
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map2TextureCoord3
= state
;
465 case GL_MAP2_TEXTURE_COORD_4
:
466 if (ctx
->Eval
.Map2TextureCoord4
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map2TextureCoord4
= state
;
471 case GL_MAP2_VERTEX_3
:
472 if (ctx
->Eval
.Map2Vertex3
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map2Vertex3
= state
;
477 case GL_MAP2_VERTEX_4
:
478 if (ctx
->Eval
.Map2Vertex4
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map2Vertex4
= state
;
484 if (ctx
->Pixel
.MinMaxEnabled
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
487 ctx
->Pixel
.MinMaxEnabled
= state
;
490 if (ctx
->Transform
.Normalize
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
493 ctx
->Transform
.Normalize
= state
;
495 case GL_POINT_SMOOTH
:
496 if (ctx
->Point
.SmoothFlag
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_POINT
);
499 ctx
->Point
.SmoothFlag
= state
;
501 case GL_POLYGON_SMOOTH
:
502 if (ctx
->Polygon
.SmoothFlag
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
505 ctx
->Polygon
.SmoothFlag
= state
;
507 case GL_POLYGON_STIPPLE
:
508 if (ctx
->Polygon
.StippleFlag
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
511 ctx
->Polygon
.StippleFlag
= state
;
513 case GL_POLYGON_OFFSET_POINT
:
514 if (ctx
->Polygon
.OffsetPoint
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
517 ctx
->Polygon
.OffsetPoint
= state
;
519 case GL_POLYGON_OFFSET_LINE
:
520 if (ctx
->Polygon
.OffsetLine
== state
)
522 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
523 ctx
->Polygon
.OffsetLine
= state
;
525 case GL_POLYGON_OFFSET_FILL
:
526 /*case GL_POLYGON_OFFSET_EXT:*/
527 if (ctx
->Polygon
.OffsetFill
== state
)
529 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
530 ctx
->Polygon
.OffsetFill
= state
;
532 case GL_RESCALE_NORMAL_EXT
:
533 if (ctx
->Transform
.RescaleNormals
== state
)
535 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
536 ctx
->Transform
.RescaleNormals
= state
;
538 case GL_SCISSOR_TEST
:
539 if (ctx
->Scissor
.Enabled
== state
)
541 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
542 ctx
->Scissor
.Enabled
= state
;
544 case GL_SHARED_TEXTURE_PALETTE_EXT
:
545 if (ctx
->Texture
.SharedPalette
== state
)
547 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
548 ctx
->Texture
.SharedPalette
= state
;
550 case GL_STENCIL_TEST
:
551 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
553 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
556 if (ctx
->Stencil
.Enabled
== state
)
558 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
559 ctx
->Stencil
.Enabled
= state
;
561 case GL_TEXTURE_1D
: {
562 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
563 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
564 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_1D_BIT
;
566 newenabled
|= TEXTURE_1D_BIT
;
567 if (!ctx
->DrawBuffer
->Visual
.rgbMode
568 || texUnit
->Enabled
== newenabled
)
570 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
571 texUnit
->Enabled
= newenabled
;
574 case GL_TEXTURE_2D
: {
575 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
576 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
577 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_2D_BIT
;
579 newenabled
|= TEXTURE_2D_BIT
;
580 if (!ctx
->DrawBuffer
->Visual
.rgbMode
581 || texUnit
->Enabled
== newenabled
)
583 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
584 texUnit
->Enabled
= newenabled
;
587 case GL_TEXTURE_3D
: {
588 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
589 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
590 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_3D_BIT
;
592 newenabled
|= TEXTURE_3D_BIT
;
593 if (!ctx
->DrawBuffer
->Visual
.rgbMode
594 || texUnit
->Enabled
== newenabled
)
596 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
597 texUnit
->Enabled
= newenabled
;
600 case GL_TEXTURE_GEN_Q
: {
601 GLuint unit
= ctx
->Texture
.CurrentUnit
;
602 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
603 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
606 if (texUnit
->TexGenEnabled
== newenabled
)
608 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
609 texUnit
->TexGenEnabled
= newenabled
;
612 case GL_TEXTURE_GEN_R
: {
613 GLuint unit
= ctx
->Texture
.CurrentUnit
;
614 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
615 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
618 if (texUnit
->TexGenEnabled
== newenabled
)
620 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
621 texUnit
->TexGenEnabled
= newenabled
;
624 case GL_TEXTURE_GEN_S
: {
625 GLuint unit
= ctx
->Texture
.CurrentUnit
;
626 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
627 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
630 if (texUnit
->TexGenEnabled
== newenabled
)
632 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
633 texUnit
->TexGenEnabled
= newenabled
;
636 case GL_TEXTURE_GEN_T
: {
637 GLuint unit
= ctx
->Texture
.CurrentUnit
;
638 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
639 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
642 if (texUnit
->TexGenEnabled
== newenabled
)
644 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
645 texUnit
->TexGenEnabled
= newenabled
;
652 case GL_VERTEX_ARRAY
:
653 case GL_NORMAL_ARRAY
:
656 case GL_TEXTURE_COORD_ARRAY
:
657 case GL_EDGE_FLAG_ARRAY
:
658 case GL_FOG_COORDINATE_ARRAY_EXT
:
659 case GL_SECONDARY_COLOR_ARRAY_EXT
:
660 client_state( ctx
, cap
, state
);
663 /* GL_SGI_color_table */
664 case GL_COLOR_TABLE_SGI
:
665 CHECK_EXTENSION(SGI_color_table
, cap
);
666 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] == state
)
668 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
669 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] = state
;
671 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
672 CHECK_EXTENSION(SGI_color_table
, cap
);
673 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] == state
)
675 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
676 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] = state
;
678 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
679 CHECK_EXTENSION(SGI_color_table
, cap
);
680 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] == state
)
682 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
683 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] = state
;
685 case GL_TEXTURE_COLOR_TABLE_SGI
:
686 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
687 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
689 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
690 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
693 /* GL_EXT_convolution */
694 case GL_CONVOLUTION_1D
:
695 CHECK_EXTENSION(EXT_convolution
, cap
);
696 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
698 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
699 ctx
->Pixel
.Convolution1DEnabled
= state
;
701 case GL_CONVOLUTION_2D
:
702 CHECK_EXTENSION(EXT_convolution
, cap
);
703 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
705 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
706 ctx
->Pixel
.Convolution2DEnabled
= state
;
708 case GL_SEPARABLE_2D
:
709 CHECK_EXTENSION(EXT_convolution
, cap
);
710 if (ctx
->Pixel
.Separable2DEnabled
== state
)
712 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
713 ctx
->Pixel
.Separable2DEnabled
= state
;
716 /* GL_ARB_texture_cube_map */
717 case GL_TEXTURE_CUBE_MAP_ARB
:
719 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
720 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
721 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_CUBE_BIT
;
722 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
724 newenabled
|= TEXTURE_CUBE_BIT
;
725 if (!ctx
->DrawBuffer
->Visual
.rgbMode
726 || texUnit
->Enabled
== newenabled
)
728 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
729 texUnit
->Enabled
= newenabled
;
733 /* GL_EXT_secondary_color */
734 case GL_COLOR_SUM_EXT
:
735 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
736 if (ctx
->Fog
.ColorSumEnabled
== state
)
738 FLUSH_VERTICES(ctx
, _NEW_FOG
);
739 ctx
->Fog
.ColorSumEnabled
= state
;
742 /* GL_ARB_multisample */
743 case GL_MULTISAMPLE_ARB
:
744 CHECK_EXTENSION(ARB_multisample
, cap
);
745 if (ctx
->Multisample
.Enabled
== state
)
747 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
748 ctx
->Multisample
.Enabled
= state
;
750 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
751 CHECK_EXTENSION(ARB_multisample
, cap
);
752 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
754 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
755 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
757 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
758 CHECK_EXTENSION(ARB_multisample
, cap
);
759 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
761 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
762 ctx
->Multisample
.SampleAlphaToOne
= state
;
764 case GL_SAMPLE_COVERAGE_ARB
:
765 CHECK_EXTENSION(ARB_multisample
, cap
);
766 if (ctx
->Multisample
.SampleCoverage
== state
)
768 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
769 ctx
->Multisample
.SampleCoverage
= state
;
771 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
772 CHECK_EXTENSION(ARB_multisample
, cap
);
773 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
775 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
776 ctx
->Multisample
.SampleCoverageInvert
= state
;
779 /* GL_IBM_rasterpos_clip */
780 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
781 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
782 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
784 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
785 ctx
->Transform
.RasterPositionUnclipped
= state
;
788 /* GL_NV_point_sprite */
789 case GL_POINT_SPRITE_NV
:
790 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
791 if (ctx
->Point
.PointSprite
== state
)
793 FLUSH_VERTICES(ctx
, _NEW_POINT
);
794 ctx
->Point
.PointSprite
= state
;
797 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
798 case GL_VERTEX_PROGRAM_ARB
:
799 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
800 if (ctx
->VertexProgram
.Enabled
== state
)
802 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
803 ctx
->VertexProgram
.Enabled
= state
;
805 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
806 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
807 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
809 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
810 ctx
->VertexProgram
.PointSizeEnabled
= state
;
812 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
813 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
814 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
816 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
817 ctx
->VertexProgram
.TwoSideEnabled
= state
;
820 #if FEATURE_NV_vertex_program
821 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
822 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
823 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
824 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
825 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
826 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
827 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
828 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
829 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
830 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
831 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
832 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
833 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
834 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
835 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
836 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
837 CHECK_EXTENSION(NV_vertex_program
, cap
);
839 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
840 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
841 ctx
->Eval
.Map1Attrib
[map
] = state
;
844 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
845 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
846 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
847 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
848 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
849 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
850 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
851 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
852 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
853 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
854 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
855 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
856 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
857 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
858 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
859 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
860 CHECK_EXTENSION(NV_vertex_program
, cap
);
862 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
863 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
864 ctx
->Eval
.Map2Attrib
[map
] = state
;
867 #endif /* FEATURE_NV_vertex_program */
869 #if FEATURE_NV_fragment_program
870 case GL_FRAGMENT_PROGRAM_NV
:
871 CHECK_EXTENSION(NV_fragment_program
, cap
);
872 if (ctx
->FragmentProgram
.Enabled
== state
)
874 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
875 ctx
->FragmentProgram
.Enabled
= state
;
877 #endif /* FEATURE_NV_fragment_program */
879 /* GL_NV_texture_rectangle */
880 case GL_TEXTURE_RECTANGLE_NV
:
881 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
883 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
884 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
885 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE_RECT_BIT
;
886 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
888 newenabled
|= TEXTURE_RECT_BIT
;
889 if (!ctx
->DrawBuffer
->Visual
.rgbMode
890 || texUnit
->Enabled
== newenabled
)
892 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
893 texUnit
->Enabled
= newenabled
;
897 /* GL_EXT_stencil_two_side */
898 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
899 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
900 if (ctx
->Stencil
.TestTwoSide
== state
)
902 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
903 ctx
->Stencil
.TestTwoSide
= state
;
906 #if FEATURE_ARB_fragment_program
907 case GL_FRAGMENT_PROGRAM_ARB
:
908 CHECK_EXTENSION(ARB_fragment_program
, cap
);
909 if (ctx
->FragmentProgram
.Enabled
== state
)
911 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
912 ctx
->FragmentProgram
.Enabled
= state
;
914 #endif /* FEATURE_ARB_fragment_program */
916 /* GL_EXT_depth_bounds_test */
917 case GL_DEPTH_BOUNDS_TEST_EXT
:
918 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
919 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
921 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
924 if (ctx
->Depth
.BoundsTest
== state
)
926 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
927 ctx
->Depth
.BoundsTest
= state
;
930 /* GL_MESA_program_debug */
931 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
932 CHECK_EXTENSION(MESA_program_debug
, cap
);
933 ctx
->FragmentProgram
.CallbackEnabled
= state
;
935 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
936 CHECK_EXTENSION(MESA_program_debug
, cap
);
937 ctx
->VertexProgram
.CallbackEnabled
= state
;
940 #if FEATURE_ATI_fragment_shader
941 case GL_FRAGMENT_SHADER_ATI
:
942 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
943 if (ctx
->ATIFragmentShader
.Enabled
== state
)
945 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
946 ctx
->ATIFragmentShader
.Enabled
= state
;
950 _mesa_error(ctx
, GL_INVALID_ENUM
,
951 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
955 if (ctx
->Driver
.Enable
) {
956 ctx
->Driver
.Enable( ctx
, cap
, state
);
962 * Enable GL capability. Called by glEnable()
963 * \param cap state to enable.
966 _mesa_Enable( GLenum cap
)
968 GET_CURRENT_CONTEXT(ctx
);
969 ASSERT_OUTSIDE_BEGIN_END(ctx
);
971 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
976 * Disable GL capability. Called by glDisable()
977 * \param cap state to disable.
980 _mesa_Disable( GLenum cap
)
982 GET_CURRENT_CONTEXT(ctx
);
983 ASSERT_OUTSIDE_BEGIN_END(ctx
);
985 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
989 #undef CHECK_EXTENSION
990 #define CHECK_EXTENSION(EXTNAME) \
991 if (!ctx->Extensions.EXTNAME) { \
992 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
996 #undef CHECK_EXTENSION2
997 #define CHECK_EXTENSION2(EXT1, EXT2) \
998 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
999 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1005 * Return simple enable/disable state.
1007 * \param cap state variable to query.
1009 * Returns the state of the specified capability from the current GL context.
1010 * For the capabilities associated with extensions verifies that those
1011 * extensions are effectively present before reporting.
1013 GLboolean GLAPIENTRY
1014 _mesa_IsEnabled( GLenum cap
)
1016 GET_CURRENT_CONTEXT(ctx
);
1019 return ctx
->Color
.AlphaEnabled
;
1020 case GL_AUTO_NORMAL
:
1021 return ctx
->Eval
.AutoNormal
;
1023 return ctx
->Color
.BlendEnabled
;
1024 case GL_CLIP_PLANE0
:
1025 case GL_CLIP_PLANE1
:
1026 case GL_CLIP_PLANE2
:
1027 case GL_CLIP_PLANE3
:
1028 case GL_CLIP_PLANE4
:
1029 case GL_CLIP_PLANE5
:
1030 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1031 case GL_COLOR_MATERIAL
:
1032 return ctx
->Light
.ColorMaterialEnabled
;
1034 return ctx
->Polygon
.CullFlag
;
1036 return ctx
->Depth
.Test
;
1038 return ctx
->Color
.DitherFlag
;
1040 return ctx
->Fog
.Enabled
;
1042 return ctx
->Light
.Enabled
;
1051 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1052 case GL_LINE_SMOOTH
:
1053 return ctx
->Line
.SmoothFlag
;
1054 case GL_LINE_STIPPLE
:
1055 return ctx
->Line
.StippleFlag
;
1056 case GL_INDEX_LOGIC_OP
:
1057 return ctx
->Color
.IndexLogicOpEnabled
;
1058 case GL_COLOR_LOGIC_OP
:
1059 return ctx
->Color
.ColorLogicOpEnabled
;
1060 case GL_MAP1_COLOR_4
:
1061 return ctx
->Eval
.Map1Color4
;
1063 return ctx
->Eval
.Map1Index
;
1064 case GL_MAP1_NORMAL
:
1065 return ctx
->Eval
.Map1Normal
;
1066 case GL_MAP1_TEXTURE_COORD_1
:
1067 return ctx
->Eval
.Map1TextureCoord1
;
1068 case GL_MAP1_TEXTURE_COORD_2
:
1069 return ctx
->Eval
.Map1TextureCoord2
;
1070 case GL_MAP1_TEXTURE_COORD_3
:
1071 return ctx
->Eval
.Map1TextureCoord3
;
1072 case GL_MAP1_TEXTURE_COORD_4
:
1073 return ctx
->Eval
.Map1TextureCoord4
;
1074 case GL_MAP1_VERTEX_3
:
1075 return ctx
->Eval
.Map1Vertex3
;
1076 case GL_MAP1_VERTEX_4
:
1077 return ctx
->Eval
.Map1Vertex4
;
1078 case GL_MAP2_COLOR_4
:
1079 return ctx
->Eval
.Map2Color4
;
1081 return ctx
->Eval
.Map2Index
;
1082 case GL_MAP2_NORMAL
:
1083 return ctx
->Eval
.Map2Normal
;
1084 case GL_MAP2_TEXTURE_COORD_1
:
1085 return ctx
->Eval
.Map2TextureCoord1
;
1086 case GL_MAP2_TEXTURE_COORD_2
:
1087 return ctx
->Eval
.Map2TextureCoord2
;
1088 case GL_MAP2_TEXTURE_COORD_3
:
1089 return ctx
->Eval
.Map2TextureCoord3
;
1090 case GL_MAP2_TEXTURE_COORD_4
:
1091 return ctx
->Eval
.Map2TextureCoord4
;
1092 case GL_MAP2_VERTEX_3
:
1093 return ctx
->Eval
.Map2Vertex3
;
1094 case GL_MAP2_VERTEX_4
:
1095 return ctx
->Eval
.Map2Vertex4
;
1097 return ctx
->Transform
.Normalize
;
1098 case GL_POINT_SMOOTH
:
1099 return ctx
->Point
.SmoothFlag
;
1100 case GL_POLYGON_SMOOTH
:
1101 return ctx
->Polygon
.SmoothFlag
;
1102 case GL_POLYGON_STIPPLE
:
1103 return ctx
->Polygon
.StippleFlag
;
1104 case GL_POLYGON_OFFSET_POINT
:
1105 return ctx
->Polygon
.OffsetPoint
;
1106 case GL_POLYGON_OFFSET_LINE
:
1107 return ctx
->Polygon
.OffsetLine
;
1108 case GL_POLYGON_OFFSET_FILL
:
1109 /*case GL_POLYGON_OFFSET_EXT:*/
1110 return ctx
->Polygon
.OffsetFill
;
1111 case GL_RESCALE_NORMAL_EXT
:
1112 return ctx
->Transform
.RescaleNormals
;
1113 case GL_SCISSOR_TEST
:
1114 return ctx
->Scissor
.Enabled
;
1115 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1116 return ctx
->Texture
.SharedPalette
;
1117 case GL_STENCIL_TEST
:
1118 return ctx
->Stencil
.Enabled
;
1121 const struct gl_texture_unit
*texUnit
;
1122 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1123 return (texUnit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
;
1127 const struct gl_texture_unit
*texUnit
;
1128 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1129 return (texUnit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
;
1133 const struct gl_texture_unit
*texUnit
;
1134 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1135 return (texUnit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
;
1137 case GL_TEXTURE_GEN_Q
:
1139 const struct gl_texture_unit
*texUnit
;
1140 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1141 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1143 case GL_TEXTURE_GEN_R
:
1145 const struct gl_texture_unit
*texUnit
;
1146 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1147 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1149 case GL_TEXTURE_GEN_S
:
1151 const struct gl_texture_unit
*texUnit
;
1152 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1153 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1155 case GL_TEXTURE_GEN_T
:
1157 const struct gl_texture_unit
*texUnit
;
1158 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1159 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1165 case GL_VERTEX_ARRAY
:
1166 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1167 case GL_NORMAL_ARRAY
:
1168 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1169 case GL_COLOR_ARRAY
:
1170 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1171 case GL_INDEX_ARRAY
:
1172 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1173 case GL_TEXTURE_COORD_ARRAY
:
1174 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1175 case GL_EDGE_FLAG_ARRAY
:
1176 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1177 case GL_FOG_COORDINATE_ARRAY_EXT
:
1178 CHECK_EXTENSION(EXT_fog_coord
);
1179 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1180 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1181 CHECK_EXTENSION(EXT_secondary_color
);
1182 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1184 /* GL_EXT_histogram */
1186 CHECK_EXTENSION(EXT_histogram
);
1187 return ctx
->Pixel
.HistogramEnabled
;
1189 CHECK_EXTENSION(EXT_histogram
);
1190 return ctx
->Pixel
.MinMaxEnabled
;
1192 /* GL_SGI_color_table */
1193 case GL_COLOR_TABLE_SGI
:
1194 CHECK_EXTENSION(SGI_color_table
);
1195 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
];
1196 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1197 CHECK_EXTENSION(SGI_color_table
);
1198 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
];
1199 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1200 CHECK_EXTENSION(SGI_color_table
);
1201 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
];
1203 /* GL_SGI_texture_color_table */
1204 case GL_TEXTURE_COLOR_TABLE_SGI
:
1205 CHECK_EXTENSION(SGI_texture_color_table
);
1206 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1208 /* GL_EXT_convolution */
1209 case GL_CONVOLUTION_1D
:
1210 CHECK_EXTENSION(EXT_convolution
);
1211 return ctx
->Pixel
.Convolution1DEnabled
;
1212 case GL_CONVOLUTION_2D
:
1213 CHECK_EXTENSION(EXT_convolution
);
1214 return ctx
->Pixel
.Convolution2DEnabled
;
1215 case GL_SEPARABLE_2D
:
1216 CHECK_EXTENSION(EXT_convolution
);
1217 return ctx
->Pixel
.Separable2DEnabled
;
1219 /* GL_ARB_texture_cube_map */
1220 case GL_TEXTURE_CUBE_MAP_ARB
:
1221 CHECK_EXTENSION(ARB_texture_cube_map
);
1223 const struct gl_texture_unit
*texUnit
;
1224 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1225 return (texUnit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
;
1228 /* GL_EXT_secondary_color */
1229 case GL_COLOR_SUM_EXT
:
1230 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1231 return ctx
->Fog
.ColorSumEnabled
;
1233 /* GL_ARB_multisample */
1234 case GL_MULTISAMPLE_ARB
:
1235 CHECK_EXTENSION(ARB_multisample
);
1236 return ctx
->Multisample
.Enabled
;
1237 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1238 CHECK_EXTENSION(ARB_multisample
);
1239 return ctx
->Multisample
.SampleAlphaToCoverage
;
1240 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1241 CHECK_EXTENSION(ARB_multisample
);
1242 return ctx
->Multisample
.SampleAlphaToOne
;
1243 case GL_SAMPLE_COVERAGE_ARB
:
1244 CHECK_EXTENSION(ARB_multisample
);
1245 return ctx
->Multisample
.SampleCoverage
;
1246 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1247 CHECK_EXTENSION(ARB_multisample
);
1248 return ctx
->Multisample
.SampleCoverageInvert
;
1250 /* GL_IBM_rasterpos_clip */
1251 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1252 CHECK_EXTENSION(IBM_rasterpos_clip
);
1253 return ctx
->Transform
.RasterPositionUnclipped
;
1255 /* GL_NV_point_sprite */
1256 case GL_POINT_SPRITE_NV
:
1257 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1258 return ctx
->Point
.PointSprite
;
1260 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1261 case GL_VERTEX_PROGRAM_ARB
:
1262 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1263 return ctx
->VertexProgram
.Enabled
;
1264 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1265 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1266 return ctx
->VertexProgram
.PointSizeEnabled
;
1267 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1268 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1269 return ctx
->VertexProgram
.TwoSideEnabled
;
1271 #if FEATURE_NV_vertex_program
1272 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1273 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1274 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1275 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1276 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1277 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1278 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1279 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1280 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1281 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1282 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1283 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1284 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1285 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1286 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1287 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1288 CHECK_EXTENSION(NV_vertex_program
);
1290 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1291 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1293 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1294 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1295 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1296 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1297 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1298 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1299 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1300 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1301 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1302 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1303 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1304 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1305 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1306 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1307 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1308 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1309 CHECK_EXTENSION(NV_vertex_program
);
1311 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1312 return ctx
->Eval
.Map1Attrib
[map
];
1314 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1315 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1316 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1317 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1318 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1319 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1320 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1321 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1322 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1323 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1324 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1325 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1326 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1327 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1328 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1329 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1330 CHECK_EXTENSION(NV_vertex_program
);
1332 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1333 return ctx
->Eval
.Map2Attrib
[map
];
1335 #endif /* FEATURE_NV_vertex_program */
1337 #if FEATURE_NV_fragment_program
1338 case GL_FRAGMENT_PROGRAM_NV
:
1339 CHECK_EXTENSION(NV_fragment_program
);
1340 return ctx
->FragmentProgram
.Enabled
;
1341 #endif /* FEATURE_NV_fragment_program */
1343 /* GL_NV_texture_rectangle */
1344 case GL_TEXTURE_RECTANGLE_NV
:
1345 CHECK_EXTENSION(NV_texture_rectangle
);
1347 const struct gl_texture_unit
*texUnit
;
1348 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1349 return (texUnit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
;
1352 /* GL_EXT_stencil_two_side */
1353 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1354 CHECK_EXTENSION(EXT_stencil_two_side
);
1355 return ctx
->Stencil
.TestTwoSide
;
1357 #if FEATURE_ARB_fragment_program
1358 case GL_FRAGMENT_PROGRAM_ARB
:
1359 return ctx
->FragmentProgram
.Enabled
;
1360 #endif /* FEATURE_ARB_fragment_program */
1362 /* GL_EXT_depth_bounds_test */
1363 case GL_DEPTH_BOUNDS_TEST_EXT
:
1364 CHECK_EXTENSION(EXT_depth_bounds_test
);
1365 return ctx
->Depth
.BoundsTest
;
1367 /* GL_MESA_program_debug */
1368 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1369 CHECK_EXTENSION(MESA_program_debug
);
1370 return ctx
->FragmentProgram
.CallbackEnabled
;
1371 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1372 CHECK_EXTENSION(MESA_program_debug
);
1373 return ctx
->VertexProgram
.CallbackEnabled
;
1374 #if FEATURE_ATI_fragment_shader
1375 case GL_FRAGMENT_SHADER_ATI
:
1376 CHECK_EXTENSION(ATI_fragment_shader
);
1377 return ctx
->ATIFragmentShader
.Enabled
;
1378 #endif /* FEATURE_ATI_fragment_shader */
1380 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);