3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 #include "simple_list.h"
39 #include "math/m_matrix.h"
40 #include "math/m_xform.h"
41 #include "api_arrayelt.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
48 state ? "Enable" : "Disable", CAP); \
54 * Helper to enable/disable client-side state.
57 client_state(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
64 var
= &ctx
->Array
.ArrayObj
->Vertex
.Enabled
;
65 flag
= _NEW_ARRAY_VERTEX
;
68 var
= &ctx
->Array
.ArrayObj
->Normal
.Enabled
;
69 flag
= _NEW_ARRAY_NORMAL
;
72 var
= &ctx
->Array
.ArrayObj
->Color
.Enabled
;
73 flag
= _NEW_ARRAY_COLOR0
;
76 var
= &ctx
->Array
.ArrayObj
->Index
.Enabled
;
77 flag
= _NEW_ARRAY_INDEX
;
79 case GL_TEXTURE_COORD_ARRAY
:
80 var
= &ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
81 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
83 case GL_EDGE_FLAG_ARRAY
:
84 var
= &ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
;
85 flag
= _NEW_ARRAY_EDGEFLAG
;
87 case GL_FOG_COORDINATE_ARRAY_EXT
:
88 var
= &ctx
->Array
.ArrayObj
->FogCoord
.Enabled
;
89 flag
= _NEW_ARRAY_FOGCOORD
;
91 case GL_SECONDARY_COLOR_ARRAY_EXT
:
92 var
= &ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
;
93 flag
= _NEW_ARRAY_COLOR1
;
96 #if FEATURE_point_size_array
97 case GL_POINT_SIZE_ARRAY_OES
:
98 var
= &ctx
->Array
.ArrayObj
->PointSize
.Enabled
;
99 flag
= _NEW_ARRAY_POINT_SIZE
;
103 #if FEATURE_NV_vertex_program
104 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
118 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
119 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
120 CHECK_EXTENSION(NV_vertex_program
, cap
);
122 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
123 var
= &ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
;
124 flag
= _NEW_ARRAY_ATTRIB(n
);
127 #endif /* FEATURE_NV_vertex_program */
130 _mesa_error( ctx
, GL_INVALID_ENUM
,
131 "glEnable/DisableClientState(0x%x)", cap
);
138 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
139 ctx
->Array
.NewState
|= flag
;
141 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
146 ctx
->Array
.ArrayObj
->_Enabled
|= flag
;
148 ctx
->Array
.ArrayObj
->_Enabled
&= ~flag
;
150 if (ctx
->Driver
.Enable
) {
151 ctx
->Driver
.Enable( ctx
, cap
, state
);
157 * Enable GL capability.
158 * \param cap state to enable/disable.
160 * Get's the current context, assures that we're outside glBegin()/glEnd() and
161 * calls client_state().
164 _mesa_EnableClientState( GLenum cap
)
166 GET_CURRENT_CONTEXT(ctx
);
167 ASSERT_OUTSIDE_BEGIN_END(ctx
);
168 client_state( ctx
, cap
, GL_TRUE
);
173 * Disable GL capability.
174 * \param cap state to enable/disable.
176 * Get's the current context, assures that we're outside glBegin()/glEnd() and
177 * calls client_state().
180 _mesa_DisableClientState( GLenum cap
)
182 GET_CURRENT_CONTEXT(ctx
);
183 ASSERT_OUTSIDE_BEGIN_END(ctx
);
184 client_state( ctx
, cap
, GL_FALSE
);
188 #undef CHECK_EXTENSION
189 #define CHECK_EXTENSION(EXTNAME, CAP) \
190 if (!ctx->Extensions.EXTNAME) { \
191 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
192 state ? "Enable" : "Disable", CAP); \
196 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
197 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
198 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
199 state ? "Enable" : "Disable", CAP); \
205 * Helper function to enable or disable a texture target.
208 enable_texture(GLcontext
*ctx
, GLboolean state
, GLbitfield bit
)
210 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
211 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
212 const GLuint newenabled
= (!state
)
213 ? (texUnit
->Enabled
& ~bit
) : (texUnit
->Enabled
| bit
);
215 if (!ctx
->DrawBuffer
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
218 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
219 texUnit
->Enabled
= newenabled
;
225 * Helper function to enable or disable state.
227 * \param ctx GL context.
228 * \param cap the state to enable/disable
229 * \param state whether to enable or disable the specified capability.
231 * Updates the current context and flushes the vertices as needed. For
232 * capabilities associated with extensions it verifies that those extensions
233 * are effectivly present before updating. Notifies the driver via
234 * dd_function_table::Enable.
237 _mesa_set_enable(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
239 if (MESA_VERBOSE
& VERBOSE_API
)
240 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
241 state
? "glEnable" : "glDisable",
242 _mesa_lookup_enum_by_nr(cap
),
247 if (ctx
->Color
.AlphaEnabled
== state
)
249 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
250 ctx
->Color
.AlphaEnabled
= state
;
253 if (ctx
->Eval
.AutoNormal
== state
)
255 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
256 ctx
->Eval
.AutoNormal
= state
;
259 if (ctx
->Color
.BlendEnabled
== state
)
261 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
262 ctx
->Color
.BlendEnabled
= state
;
272 const GLuint p
= cap
- GL_CLIP_PLANE0
;
274 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
277 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
280 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
282 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
283 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
285 /* This derived state also calculated in clip.c and
286 * from _mesa_update_state() on changes to EyeUserPlane
287 * and ctx->ProjectionMatrix respectively.
289 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
290 ctx
->Transform
.EyeUserPlane
[p
],
291 ctx
->ProjectionMatrixStack
.Top
->inv
);
294 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
299 case GL_COLOR_MATERIAL
:
300 if (ctx
->Light
.ColorMaterialEnabled
== state
)
302 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
303 FLUSH_CURRENT(ctx
, 0);
304 ctx
->Light
.ColorMaterialEnabled
= state
;
306 _mesa_update_color_material( ctx
,
307 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
311 if (ctx
->Polygon
.CullFlag
== state
)
313 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
314 ctx
->Polygon
.CullFlag
= state
;
316 case GL_CULL_VERTEX_EXT
:
317 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
318 if (ctx
->Transform
.CullVertexFlag
== state
)
320 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
321 ctx
->Transform
.CullVertexFlag
= state
;
324 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
325 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
328 if (ctx
->Depth
.Test
== state
)
330 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
331 ctx
->Depth
.Test
= state
;
335 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
337 if (ctx
->Color
.DitherFlag
== state
)
339 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
340 ctx
->Color
.DitherFlag
= state
;
343 if (ctx
->Fog
.Enabled
== state
)
345 FLUSH_VERTICES(ctx
, _NEW_FOG
);
346 ctx
->Fog
.Enabled
= state
;
349 CHECK_EXTENSION(EXT_histogram
, cap
);
350 if (ctx
->Pixel
.HistogramEnabled
== state
)
352 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
353 ctx
->Pixel
.HistogramEnabled
= state
;
363 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
365 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
366 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
368 insert_at_tail(&ctx
->Light
.EnabledList
,
369 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
372 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
376 if (ctx
->Light
.Enabled
== state
)
378 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
379 ctx
->Light
.Enabled
= state
;
380 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
381 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
383 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
386 if (ctx
->Line
.SmoothFlag
== state
)
388 FLUSH_VERTICES(ctx
, _NEW_LINE
);
389 ctx
->Line
.SmoothFlag
= state
;
390 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
392 case GL_LINE_STIPPLE
:
393 if (ctx
->Line
.StippleFlag
== state
)
395 FLUSH_VERTICES(ctx
, _NEW_LINE
);
396 ctx
->Line
.StippleFlag
= state
;
397 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
399 case GL_INDEX_LOGIC_OP
:
400 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
403 ctx
->Color
.IndexLogicOpEnabled
= state
;
405 case GL_COLOR_LOGIC_OP
:
406 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
409 ctx
->Color
.ColorLogicOpEnabled
= state
;
411 case GL_MAP1_COLOR_4
:
412 if (ctx
->Eval
.Map1Color4
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
415 ctx
->Eval
.Map1Color4
= state
;
418 if (ctx
->Eval
.Map1Index
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
421 ctx
->Eval
.Map1Index
= state
;
424 if (ctx
->Eval
.Map1Normal
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
427 ctx
->Eval
.Map1Normal
= state
;
429 case GL_MAP1_TEXTURE_COORD_1
:
430 if (ctx
->Eval
.Map1TextureCoord1
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
433 ctx
->Eval
.Map1TextureCoord1
= state
;
435 case GL_MAP1_TEXTURE_COORD_2
:
436 if (ctx
->Eval
.Map1TextureCoord2
== state
)
438 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
439 ctx
->Eval
.Map1TextureCoord2
= state
;
441 case GL_MAP1_TEXTURE_COORD_3
:
442 if (ctx
->Eval
.Map1TextureCoord3
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
445 ctx
->Eval
.Map1TextureCoord3
= state
;
447 case GL_MAP1_TEXTURE_COORD_4
:
448 if (ctx
->Eval
.Map1TextureCoord4
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
451 ctx
->Eval
.Map1TextureCoord4
= state
;
453 case GL_MAP1_VERTEX_3
:
454 if (ctx
->Eval
.Map1Vertex3
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 ctx
->Eval
.Map1Vertex3
= state
;
459 case GL_MAP1_VERTEX_4
:
460 if (ctx
->Eval
.Map1Vertex4
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map1Vertex4
= state
;
465 case GL_MAP2_COLOR_4
:
466 if (ctx
->Eval
.Map2Color4
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map2Color4
= state
;
472 if (ctx
->Eval
.Map2Index
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map2Index
= state
;
478 if (ctx
->Eval
.Map2Normal
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map2Normal
= state
;
483 case GL_MAP2_TEXTURE_COORD_1
:
484 if (ctx
->Eval
.Map2TextureCoord1
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
487 ctx
->Eval
.Map2TextureCoord1
= state
;
489 case GL_MAP2_TEXTURE_COORD_2
:
490 if (ctx
->Eval
.Map2TextureCoord2
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
493 ctx
->Eval
.Map2TextureCoord2
= state
;
495 case GL_MAP2_TEXTURE_COORD_3
:
496 if (ctx
->Eval
.Map2TextureCoord3
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map2TextureCoord3
= state
;
501 case GL_MAP2_TEXTURE_COORD_4
:
502 if (ctx
->Eval
.Map2TextureCoord4
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
505 ctx
->Eval
.Map2TextureCoord4
= state
;
507 case GL_MAP2_VERTEX_3
:
508 if (ctx
->Eval
.Map2Vertex3
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
511 ctx
->Eval
.Map2Vertex3
= state
;
513 case GL_MAP2_VERTEX_4
:
514 if (ctx
->Eval
.Map2Vertex4
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
517 ctx
->Eval
.Map2Vertex4
= state
;
520 if (ctx
->Pixel
.MinMaxEnabled
== state
)
522 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
523 ctx
->Pixel
.MinMaxEnabled
= state
;
526 if (ctx
->Transform
.Normalize
== state
)
528 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
529 ctx
->Transform
.Normalize
= state
;
531 case GL_POINT_SMOOTH
:
532 if (ctx
->Point
.SmoothFlag
== state
)
534 FLUSH_VERTICES(ctx
, _NEW_POINT
);
535 ctx
->Point
.SmoothFlag
= state
;
536 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
538 case GL_POLYGON_SMOOTH
:
539 if (ctx
->Polygon
.SmoothFlag
== state
)
541 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
542 ctx
->Polygon
.SmoothFlag
= state
;
543 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
545 case GL_POLYGON_STIPPLE
:
546 if (ctx
->Polygon
.StippleFlag
== state
)
548 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
549 ctx
->Polygon
.StippleFlag
= state
;
550 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
552 case GL_POLYGON_OFFSET_POINT
:
553 if (ctx
->Polygon
.OffsetPoint
== state
)
555 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
556 ctx
->Polygon
.OffsetPoint
= state
;
558 case GL_POLYGON_OFFSET_LINE
:
559 if (ctx
->Polygon
.OffsetLine
== state
)
561 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
562 ctx
->Polygon
.OffsetLine
= state
;
564 case GL_POLYGON_OFFSET_FILL
:
565 /*case GL_POLYGON_OFFSET_EXT:*/
566 if (ctx
->Polygon
.OffsetFill
== state
)
568 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
569 ctx
->Polygon
.OffsetFill
= state
;
571 case GL_RESCALE_NORMAL_EXT
:
572 if (ctx
->Transform
.RescaleNormals
== state
)
574 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
575 ctx
->Transform
.RescaleNormals
= state
;
577 case GL_SCISSOR_TEST
:
578 if (ctx
->Scissor
.Enabled
== state
)
580 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
581 ctx
->Scissor
.Enabled
= state
;
583 case GL_SHARED_TEXTURE_PALETTE_EXT
:
584 if (ctx
->Texture
.SharedPalette
== state
)
586 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
587 ctx
->Texture
.SharedPalette
= state
;
589 case GL_STENCIL_TEST
:
590 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
592 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
595 if (ctx
->Stencil
.Enabled
== state
)
597 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
598 ctx
->Stencil
.Enabled
= state
;
601 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
606 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
611 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
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 case GL_POINT_SIZE_ARRAY_OES
:
676 client_state( ctx
, cap
, state
);
679 /* GL_SGI_color_table */
680 case GL_COLOR_TABLE_SGI
:
681 CHECK_EXTENSION(SGI_color_table
, cap
);
682 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] == state
)
684 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
685 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] = state
;
687 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
688 CHECK_EXTENSION(SGI_color_table
, cap
);
689 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] == state
)
691 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
692 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] = state
;
694 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
695 CHECK_EXTENSION(SGI_color_table
, cap
);
696 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] == state
)
698 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
699 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] = state
;
701 case GL_TEXTURE_COLOR_TABLE_SGI
:
702 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
703 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
705 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
706 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
709 /* GL_EXT_convolution */
710 case GL_CONVOLUTION_1D
:
711 CHECK_EXTENSION(EXT_convolution
, cap
);
712 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
714 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
715 ctx
->Pixel
.Convolution1DEnabled
= state
;
717 case GL_CONVOLUTION_2D
:
718 CHECK_EXTENSION(EXT_convolution
, cap
);
719 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
721 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
722 ctx
->Pixel
.Convolution2DEnabled
= state
;
724 case GL_SEPARABLE_2D
:
725 CHECK_EXTENSION(EXT_convolution
, cap
);
726 if (ctx
->Pixel
.Separable2DEnabled
== state
)
728 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
729 ctx
->Pixel
.Separable2DEnabled
= state
;
732 /* GL_ARB_texture_cube_map */
733 case GL_TEXTURE_CUBE_MAP_ARB
:
734 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
735 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
740 /* GL_EXT_secondary_color */
741 case GL_COLOR_SUM_EXT
:
742 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
743 if (ctx
->Fog
.ColorSumEnabled
== state
)
745 FLUSH_VERTICES(ctx
, _NEW_FOG
);
746 ctx
->Fog
.ColorSumEnabled
= state
;
749 /* GL_ARB_multisample */
750 case GL_MULTISAMPLE_ARB
:
751 CHECK_EXTENSION(ARB_multisample
, cap
);
752 if (ctx
->Multisample
.Enabled
== state
)
754 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
755 ctx
->Multisample
.Enabled
= state
;
757 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
758 CHECK_EXTENSION(ARB_multisample
, cap
);
759 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
761 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
762 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
764 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
765 CHECK_EXTENSION(ARB_multisample
, cap
);
766 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
768 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
769 ctx
->Multisample
.SampleAlphaToOne
= state
;
771 case GL_SAMPLE_COVERAGE_ARB
:
772 CHECK_EXTENSION(ARB_multisample
, cap
);
773 if (ctx
->Multisample
.SampleCoverage
== state
)
775 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
776 ctx
->Multisample
.SampleCoverage
= state
;
778 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
779 CHECK_EXTENSION(ARB_multisample
, cap
);
780 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
782 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
783 ctx
->Multisample
.SampleCoverageInvert
= state
;
786 /* GL_IBM_rasterpos_clip */
787 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
788 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
789 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
791 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
792 ctx
->Transform
.RasterPositionUnclipped
= state
;
795 /* GL_NV_point_sprite */
796 case GL_POINT_SPRITE_NV
:
797 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
798 if (ctx
->Point
.PointSprite
== state
)
800 FLUSH_VERTICES(ctx
, _NEW_POINT
);
801 ctx
->Point
.PointSprite
= state
;
804 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
805 case GL_VERTEX_PROGRAM_ARB
:
806 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
807 if (ctx
->VertexProgram
.Enabled
== state
)
809 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
810 ctx
->VertexProgram
.Enabled
= state
;
812 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
813 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
814 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
816 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
817 ctx
->VertexProgram
.PointSizeEnabled
= state
;
819 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
820 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
821 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
823 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
824 ctx
->VertexProgram
.TwoSideEnabled
= state
;
827 #if FEATURE_NV_vertex_program
828 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
829 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
830 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
831 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
832 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
833 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
834 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
835 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
836 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
837 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
838 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
839 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
840 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
841 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
842 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
843 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
844 CHECK_EXTENSION(NV_vertex_program
, cap
);
846 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
847 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
848 ctx
->Eval
.Map1Attrib
[map
] = state
;
851 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
852 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
853 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
854 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
855 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
856 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
857 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
858 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
859 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
860 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
861 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
862 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
863 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
864 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
865 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
866 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
867 CHECK_EXTENSION(NV_vertex_program
, cap
);
869 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
870 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
871 ctx
->Eval
.Map2Attrib
[map
] = state
;
874 #endif /* FEATURE_NV_vertex_program */
876 #if FEATURE_NV_fragment_program
877 case GL_FRAGMENT_PROGRAM_NV
:
878 CHECK_EXTENSION(NV_fragment_program
, cap
);
879 if (ctx
->FragmentProgram
.Enabled
== state
)
881 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
882 ctx
->FragmentProgram
.Enabled
= state
;
884 #endif /* FEATURE_NV_fragment_program */
886 /* GL_NV_texture_rectangle */
887 case GL_TEXTURE_RECTANGLE_NV
:
888 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
889 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
894 /* GL_EXT_stencil_two_side */
895 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
896 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
897 if (ctx
->Stencil
.TestTwoSide
== state
)
899 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
900 ctx
->Stencil
.TestTwoSide
= state
;
902 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
904 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
907 #if FEATURE_ARB_fragment_program
908 case GL_FRAGMENT_PROGRAM_ARB
:
909 CHECK_EXTENSION(ARB_fragment_program
, cap
);
910 if (ctx
->FragmentProgram
.Enabled
== state
)
912 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
913 ctx
->FragmentProgram
.Enabled
= state
;
915 #endif /* FEATURE_ARB_fragment_program */
917 /* GL_EXT_depth_bounds_test */
918 case GL_DEPTH_BOUNDS_TEST_EXT
:
919 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
920 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
922 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
925 if (ctx
->Depth
.BoundsTest
== state
)
927 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
928 ctx
->Depth
.BoundsTest
= state
;
931 /* GL_MESA_program_debug */
932 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
933 CHECK_EXTENSION(MESA_program_debug
, cap
);
934 ctx
->FragmentProgram
.CallbackEnabled
= state
;
936 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
937 CHECK_EXTENSION(MESA_program_debug
, cap
);
938 ctx
->VertexProgram
.CallbackEnabled
= state
;
941 #if FEATURE_ATI_fragment_shader
942 case GL_FRAGMENT_SHADER_ATI
:
943 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
944 if (ctx
->ATIFragmentShader
.Enabled
== state
)
946 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
947 ctx
->ATIFragmentShader
.Enabled
= state
;
951 /* GL_MESA_texture_array */
952 case GL_TEXTURE_1D_ARRAY_EXT
:
953 CHECK_EXTENSION(MESA_texture_array
, cap
);
954 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
959 case GL_TEXTURE_2D_ARRAY_EXT
:
960 CHECK_EXTENSION(MESA_texture_array
, cap
);
961 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
967 _mesa_error(ctx
, GL_INVALID_ENUM
,
968 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
972 if (ctx
->Driver
.Enable
) {
973 ctx
->Driver
.Enable( ctx
, cap
, state
);
979 * Enable GL capability. Called by glEnable()
980 * \param cap state to enable.
983 _mesa_Enable( GLenum cap
)
985 GET_CURRENT_CONTEXT(ctx
);
986 ASSERT_OUTSIDE_BEGIN_END(ctx
);
988 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
993 * Disable GL capability. Called by glDisable()
994 * \param cap state to disable.
997 _mesa_Disable( GLenum cap
)
999 GET_CURRENT_CONTEXT(ctx
);
1000 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1002 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1006 #undef CHECK_EXTENSION
1007 #define CHECK_EXTENSION(EXTNAME) \
1008 if (!ctx->Extensions.EXTNAME) { \
1009 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1013 #undef CHECK_EXTENSION2
1014 #define CHECK_EXTENSION2(EXT1, EXT2) \
1015 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1016 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1022 * Helper function to determine whether a texture target is enabled.
1025 is_texture_enabled(GLcontext
*ctx
, GLbitfield bit
)
1027 const struct gl_texture_unit
*const texUnit
=
1028 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1029 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1034 * Return simple enable/disable state.
1036 * \param cap state variable to query.
1038 * Returns the state of the specified capability from the current GL context.
1039 * For the capabilities associated with extensions verifies that those
1040 * extensions are effectively present before reporting.
1042 GLboolean GLAPIENTRY
1043 _mesa_IsEnabled( GLenum cap
)
1045 GET_CURRENT_CONTEXT(ctx
);
1048 return ctx
->Color
.AlphaEnabled
;
1049 case GL_AUTO_NORMAL
:
1050 return ctx
->Eval
.AutoNormal
;
1052 return ctx
->Color
.BlendEnabled
;
1053 case GL_CLIP_PLANE0
:
1054 case GL_CLIP_PLANE1
:
1055 case GL_CLIP_PLANE2
:
1056 case GL_CLIP_PLANE3
:
1057 case GL_CLIP_PLANE4
:
1058 case GL_CLIP_PLANE5
:
1059 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1060 case GL_COLOR_MATERIAL
:
1061 return ctx
->Light
.ColorMaterialEnabled
;
1063 return ctx
->Polygon
.CullFlag
;
1065 return ctx
->Depth
.Test
;
1067 return ctx
->Color
.DitherFlag
;
1069 return ctx
->Fog
.Enabled
;
1071 return ctx
->Light
.Enabled
;
1080 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1081 case GL_LINE_SMOOTH
:
1082 return ctx
->Line
.SmoothFlag
;
1083 case GL_LINE_STIPPLE
:
1084 return ctx
->Line
.StippleFlag
;
1085 case GL_INDEX_LOGIC_OP
:
1086 return ctx
->Color
.IndexLogicOpEnabled
;
1087 case GL_COLOR_LOGIC_OP
:
1088 return ctx
->Color
.ColorLogicOpEnabled
;
1089 case GL_MAP1_COLOR_4
:
1090 return ctx
->Eval
.Map1Color4
;
1092 return ctx
->Eval
.Map1Index
;
1093 case GL_MAP1_NORMAL
:
1094 return ctx
->Eval
.Map1Normal
;
1095 case GL_MAP1_TEXTURE_COORD_1
:
1096 return ctx
->Eval
.Map1TextureCoord1
;
1097 case GL_MAP1_TEXTURE_COORD_2
:
1098 return ctx
->Eval
.Map1TextureCoord2
;
1099 case GL_MAP1_TEXTURE_COORD_3
:
1100 return ctx
->Eval
.Map1TextureCoord3
;
1101 case GL_MAP1_TEXTURE_COORD_4
:
1102 return ctx
->Eval
.Map1TextureCoord4
;
1103 case GL_MAP1_VERTEX_3
:
1104 return ctx
->Eval
.Map1Vertex3
;
1105 case GL_MAP1_VERTEX_4
:
1106 return ctx
->Eval
.Map1Vertex4
;
1107 case GL_MAP2_COLOR_4
:
1108 return ctx
->Eval
.Map2Color4
;
1110 return ctx
->Eval
.Map2Index
;
1111 case GL_MAP2_NORMAL
:
1112 return ctx
->Eval
.Map2Normal
;
1113 case GL_MAP2_TEXTURE_COORD_1
:
1114 return ctx
->Eval
.Map2TextureCoord1
;
1115 case GL_MAP2_TEXTURE_COORD_2
:
1116 return ctx
->Eval
.Map2TextureCoord2
;
1117 case GL_MAP2_TEXTURE_COORD_3
:
1118 return ctx
->Eval
.Map2TextureCoord3
;
1119 case GL_MAP2_TEXTURE_COORD_4
:
1120 return ctx
->Eval
.Map2TextureCoord4
;
1121 case GL_MAP2_VERTEX_3
:
1122 return ctx
->Eval
.Map2Vertex3
;
1123 case GL_MAP2_VERTEX_4
:
1124 return ctx
->Eval
.Map2Vertex4
;
1126 return ctx
->Transform
.Normalize
;
1127 case GL_POINT_SMOOTH
:
1128 return ctx
->Point
.SmoothFlag
;
1129 case GL_POLYGON_SMOOTH
:
1130 return ctx
->Polygon
.SmoothFlag
;
1131 case GL_POLYGON_STIPPLE
:
1132 return ctx
->Polygon
.StippleFlag
;
1133 case GL_POLYGON_OFFSET_POINT
:
1134 return ctx
->Polygon
.OffsetPoint
;
1135 case GL_POLYGON_OFFSET_LINE
:
1136 return ctx
->Polygon
.OffsetLine
;
1137 case GL_POLYGON_OFFSET_FILL
:
1138 /*case GL_POLYGON_OFFSET_EXT:*/
1139 return ctx
->Polygon
.OffsetFill
;
1140 case GL_RESCALE_NORMAL_EXT
:
1141 return ctx
->Transform
.RescaleNormals
;
1142 case GL_SCISSOR_TEST
:
1143 return ctx
->Scissor
.Enabled
;
1144 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1145 return ctx
->Texture
.SharedPalette
;
1146 case GL_STENCIL_TEST
:
1147 return ctx
->Stencil
.Enabled
;
1149 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1151 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1153 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1154 case GL_TEXTURE_GEN_Q
:
1156 const struct gl_texture_unit
*texUnit
;
1157 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1158 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1160 case GL_TEXTURE_GEN_R
:
1162 const struct gl_texture_unit
*texUnit
;
1163 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1164 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1166 case GL_TEXTURE_GEN_S
:
1168 const struct gl_texture_unit
*texUnit
;
1169 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1170 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1172 case GL_TEXTURE_GEN_T
:
1174 const struct gl_texture_unit
*texUnit
;
1175 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1176 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1182 case GL_VERTEX_ARRAY
:
1183 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1184 case GL_NORMAL_ARRAY
:
1185 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1186 case GL_COLOR_ARRAY
:
1187 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1188 case GL_INDEX_ARRAY
:
1189 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1190 case GL_TEXTURE_COORD_ARRAY
:
1191 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1192 case GL_EDGE_FLAG_ARRAY
:
1193 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1194 case GL_FOG_COORDINATE_ARRAY_EXT
:
1195 CHECK_EXTENSION(EXT_fog_coord
);
1196 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1197 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1198 CHECK_EXTENSION(EXT_secondary_color
);
1199 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1200 #if FEATURE_point_size_array
1201 case GL_POINT_SIZE_ARRAY_OES
:
1202 return (ctx
->Array
.ArrayObj
->PointSize
.Enabled
!= 0);
1205 /* GL_EXT_histogram */
1207 CHECK_EXTENSION(EXT_histogram
);
1208 return ctx
->Pixel
.HistogramEnabled
;
1210 CHECK_EXTENSION(EXT_histogram
);
1211 return ctx
->Pixel
.MinMaxEnabled
;
1213 /* GL_SGI_color_table */
1214 case GL_COLOR_TABLE_SGI
:
1215 CHECK_EXTENSION(SGI_color_table
);
1216 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
];
1217 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1218 CHECK_EXTENSION(SGI_color_table
);
1219 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
];
1220 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1221 CHECK_EXTENSION(SGI_color_table
);
1222 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
];
1224 /* GL_SGI_texture_color_table */
1225 case GL_TEXTURE_COLOR_TABLE_SGI
:
1226 CHECK_EXTENSION(SGI_texture_color_table
);
1227 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1229 /* GL_EXT_convolution */
1230 case GL_CONVOLUTION_1D
:
1231 CHECK_EXTENSION(EXT_convolution
);
1232 return ctx
->Pixel
.Convolution1DEnabled
;
1233 case GL_CONVOLUTION_2D
:
1234 CHECK_EXTENSION(EXT_convolution
);
1235 return ctx
->Pixel
.Convolution2DEnabled
;
1236 case GL_SEPARABLE_2D
:
1237 CHECK_EXTENSION(EXT_convolution
);
1238 return ctx
->Pixel
.Separable2DEnabled
;
1240 /* GL_ARB_texture_cube_map */
1241 case GL_TEXTURE_CUBE_MAP_ARB
:
1242 CHECK_EXTENSION(ARB_texture_cube_map
);
1243 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1245 /* GL_EXT_secondary_color */
1246 case GL_COLOR_SUM_EXT
:
1247 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1248 return ctx
->Fog
.ColorSumEnabled
;
1250 /* GL_ARB_multisample */
1251 case GL_MULTISAMPLE_ARB
:
1252 CHECK_EXTENSION(ARB_multisample
);
1253 return ctx
->Multisample
.Enabled
;
1254 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1255 CHECK_EXTENSION(ARB_multisample
);
1256 return ctx
->Multisample
.SampleAlphaToCoverage
;
1257 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1258 CHECK_EXTENSION(ARB_multisample
);
1259 return ctx
->Multisample
.SampleAlphaToOne
;
1260 case GL_SAMPLE_COVERAGE_ARB
:
1261 CHECK_EXTENSION(ARB_multisample
);
1262 return ctx
->Multisample
.SampleCoverage
;
1263 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1264 CHECK_EXTENSION(ARB_multisample
);
1265 return ctx
->Multisample
.SampleCoverageInvert
;
1267 /* GL_IBM_rasterpos_clip */
1268 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1269 CHECK_EXTENSION(IBM_rasterpos_clip
);
1270 return ctx
->Transform
.RasterPositionUnclipped
;
1272 /* GL_NV_point_sprite */
1273 case GL_POINT_SPRITE_NV
:
1274 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1275 return ctx
->Point
.PointSprite
;
1277 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1278 case GL_VERTEX_PROGRAM_ARB
:
1279 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1280 return ctx
->VertexProgram
.Enabled
;
1281 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1282 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1283 return ctx
->VertexProgram
.PointSizeEnabled
;
1284 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1285 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1286 return ctx
->VertexProgram
.TwoSideEnabled
;
1288 #if FEATURE_NV_vertex_program
1289 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1290 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1291 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1292 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1293 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1294 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1295 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1296 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1297 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1298 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1299 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1300 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1301 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1302 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1303 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1304 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1305 CHECK_EXTENSION(NV_vertex_program
);
1307 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1308 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1310 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1311 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1312 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1313 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1314 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1315 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1316 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1317 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1318 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1319 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1320 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1321 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1322 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1323 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1324 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1325 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1326 CHECK_EXTENSION(NV_vertex_program
);
1328 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1329 return ctx
->Eval
.Map1Attrib
[map
];
1331 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1332 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1333 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1334 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1335 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1336 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1337 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1338 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1339 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1340 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1341 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1342 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1343 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1344 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1345 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1346 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1347 CHECK_EXTENSION(NV_vertex_program
);
1349 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1350 return ctx
->Eval
.Map2Attrib
[map
];
1352 #endif /* FEATURE_NV_vertex_program */
1354 #if FEATURE_NV_fragment_program
1355 case GL_FRAGMENT_PROGRAM_NV
:
1356 CHECK_EXTENSION(NV_fragment_program
);
1357 return ctx
->FragmentProgram
.Enabled
;
1358 #endif /* FEATURE_NV_fragment_program */
1360 /* GL_NV_texture_rectangle */
1361 case GL_TEXTURE_RECTANGLE_NV
:
1362 CHECK_EXTENSION(NV_texture_rectangle
);
1363 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1365 /* GL_EXT_stencil_two_side */
1366 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1367 CHECK_EXTENSION(EXT_stencil_two_side
);
1368 return ctx
->Stencil
.TestTwoSide
;
1370 #if FEATURE_ARB_fragment_program
1371 case GL_FRAGMENT_PROGRAM_ARB
:
1372 return ctx
->FragmentProgram
.Enabled
;
1373 #endif /* FEATURE_ARB_fragment_program */
1375 /* GL_EXT_depth_bounds_test */
1376 case GL_DEPTH_BOUNDS_TEST_EXT
:
1377 CHECK_EXTENSION(EXT_depth_bounds_test
);
1378 return ctx
->Depth
.BoundsTest
;
1380 /* GL_MESA_program_debug */
1381 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1382 CHECK_EXTENSION(MESA_program_debug
);
1383 return ctx
->FragmentProgram
.CallbackEnabled
;
1384 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1385 CHECK_EXTENSION(MESA_program_debug
);
1386 return ctx
->VertexProgram
.CallbackEnabled
;
1387 #if FEATURE_ATI_fragment_shader
1388 case GL_FRAGMENT_SHADER_ATI
:
1389 CHECK_EXTENSION(ATI_fragment_shader
);
1390 return ctx
->ATIFragmentShader
.Enabled
;
1391 #endif /* FEATURE_ATI_fragment_shader */
1393 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);