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"
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); \
194 * Helper function to enable or disable a texture target.
197 enable_texture(GLcontext
*ctx
, GLboolean state
, GLbitfield bit
)
199 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
200 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
201 const GLuint newenabled
= (!state
)
202 ? (texUnit
->Enabled
& ~bit
) : (texUnit
->Enabled
| bit
);
204 if (!ctx
->DrawBuffer
->Visual
.rgbMode
|| texUnit
->Enabled
== newenabled
)
207 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
208 texUnit
->Enabled
= newenabled
;
214 * Helper function to enable or disable state.
216 * \param ctx GL context.
217 * \param cap the state to enable/disable
218 * \param state whether to enable or disable the specified capability.
220 * Updates the current context and flushes the vertices as needed. For
221 * capabilities associated with extensions it verifies that those extensions
222 * are effectivly present before updating. Notifies the driver via
223 * dd_function_table::Enable.
226 _mesa_set_enable(GLcontext
*ctx
, GLenum cap
, GLboolean state
)
228 if (MESA_VERBOSE
& VERBOSE_API
)
229 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
230 state
? "glEnable" : "glDisable",
231 _mesa_lookup_enum_by_nr(cap
),
236 if (ctx
->Color
.AlphaEnabled
== state
)
238 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
239 ctx
->Color
.AlphaEnabled
= state
;
242 if (ctx
->Eval
.AutoNormal
== state
)
244 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
245 ctx
->Eval
.AutoNormal
= state
;
248 if (ctx
->Color
.BlendEnabled
== state
)
250 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
251 ctx
->Color
.BlendEnabled
= state
;
261 const GLuint p
= cap
- GL_CLIP_PLANE0
;
263 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) == ((GLuint
) state
<< p
))
266 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
269 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
271 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
272 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
274 /* This derived state also calculated in clip.c and
275 * from _mesa_update_state() on changes to EyeUserPlane
276 * and ctx->ProjectionMatrix respectively.
278 _mesa_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
279 ctx
->Transform
.EyeUserPlane
[p
],
280 ctx
->ProjectionMatrixStack
.Top
->inv
);
283 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
288 case GL_COLOR_MATERIAL
:
289 if (ctx
->Light
.ColorMaterialEnabled
== state
)
291 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
292 FLUSH_CURRENT(ctx
, 0);
293 ctx
->Light
.ColorMaterialEnabled
= state
;
295 _mesa_update_color_material( ctx
,
296 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
300 if (ctx
->Polygon
.CullFlag
== state
)
302 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
303 ctx
->Polygon
.CullFlag
= state
;
305 case GL_CULL_VERTEX_EXT
:
306 CHECK_EXTENSION(EXT_cull_vertex
, cap
);
307 if (ctx
->Transform
.CullVertexFlag
== state
)
309 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
310 ctx
->Transform
.CullVertexFlag
= state
;
313 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
314 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
317 if (ctx
->Depth
.Test
== state
)
319 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
320 ctx
->Depth
.Test
= state
;
324 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
326 if (ctx
->Color
.DitherFlag
== state
)
328 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
329 ctx
->Color
.DitherFlag
= state
;
332 if (ctx
->Fog
.Enabled
== state
)
334 FLUSH_VERTICES(ctx
, _NEW_FOG
);
335 ctx
->Fog
.Enabled
= state
;
338 CHECK_EXTENSION(EXT_histogram
, cap
);
339 if (ctx
->Pixel
.HistogramEnabled
== state
)
341 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
342 ctx
->Pixel
.HistogramEnabled
= state
;
352 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
355 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
357 insert_at_tail(&ctx
->Light
.EnabledList
,
358 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
361 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
365 if (ctx
->Light
.Enabled
== state
)
367 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
368 ctx
->Light
.Enabled
= state
;
369 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
370 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
372 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
375 if (ctx
->Line
.SmoothFlag
== state
)
377 FLUSH_VERTICES(ctx
, _NEW_LINE
);
378 ctx
->Line
.SmoothFlag
= state
;
379 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
381 case GL_LINE_STIPPLE
:
382 if (ctx
->Line
.StippleFlag
== state
)
384 FLUSH_VERTICES(ctx
, _NEW_LINE
);
385 ctx
->Line
.StippleFlag
= state
;
386 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
388 case GL_INDEX_LOGIC_OP
:
389 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
391 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
392 ctx
->Color
.IndexLogicOpEnabled
= state
;
394 case GL_COLOR_LOGIC_OP
:
395 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
397 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
398 ctx
->Color
.ColorLogicOpEnabled
= state
;
400 case GL_MAP1_COLOR_4
:
401 if (ctx
->Eval
.Map1Color4
== state
)
403 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
404 ctx
->Eval
.Map1Color4
= state
;
407 if (ctx
->Eval
.Map1Index
== state
)
409 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
410 ctx
->Eval
.Map1Index
= state
;
413 if (ctx
->Eval
.Map1Normal
== state
)
415 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
416 ctx
->Eval
.Map1Normal
= state
;
418 case GL_MAP1_TEXTURE_COORD_1
:
419 if (ctx
->Eval
.Map1TextureCoord1
== state
)
421 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
422 ctx
->Eval
.Map1TextureCoord1
= state
;
424 case GL_MAP1_TEXTURE_COORD_2
:
425 if (ctx
->Eval
.Map1TextureCoord2
== state
)
427 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
428 ctx
->Eval
.Map1TextureCoord2
= state
;
430 case GL_MAP1_TEXTURE_COORD_3
:
431 if (ctx
->Eval
.Map1TextureCoord3
== state
)
433 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
434 ctx
->Eval
.Map1TextureCoord3
= state
;
436 case GL_MAP1_TEXTURE_COORD_4
:
437 if (ctx
->Eval
.Map1TextureCoord4
== state
)
439 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
440 ctx
->Eval
.Map1TextureCoord4
= state
;
442 case GL_MAP1_VERTEX_3
:
443 if (ctx
->Eval
.Map1Vertex3
== state
)
445 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
446 ctx
->Eval
.Map1Vertex3
= state
;
448 case GL_MAP1_VERTEX_4
:
449 if (ctx
->Eval
.Map1Vertex4
== state
)
451 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
452 ctx
->Eval
.Map1Vertex4
= state
;
454 case GL_MAP2_COLOR_4
:
455 if (ctx
->Eval
.Map2Color4
== state
)
457 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
458 ctx
->Eval
.Map2Color4
= state
;
461 if (ctx
->Eval
.Map2Index
== state
)
463 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
464 ctx
->Eval
.Map2Index
= state
;
467 if (ctx
->Eval
.Map2Normal
== state
)
469 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
470 ctx
->Eval
.Map2Normal
= state
;
472 case GL_MAP2_TEXTURE_COORD_1
:
473 if (ctx
->Eval
.Map2TextureCoord1
== state
)
475 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
476 ctx
->Eval
.Map2TextureCoord1
= state
;
478 case GL_MAP2_TEXTURE_COORD_2
:
479 if (ctx
->Eval
.Map2TextureCoord2
== state
)
481 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
482 ctx
->Eval
.Map2TextureCoord2
= state
;
484 case GL_MAP2_TEXTURE_COORD_3
:
485 if (ctx
->Eval
.Map2TextureCoord3
== state
)
487 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
488 ctx
->Eval
.Map2TextureCoord3
= state
;
490 case GL_MAP2_TEXTURE_COORD_4
:
491 if (ctx
->Eval
.Map2TextureCoord4
== state
)
493 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
494 ctx
->Eval
.Map2TextureCoord4
= state
;
496 case GL_MAP2_VERTEX_3
:
497 if (ctx
->Eval
.Map2Vertex3
== state
)
499 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
500 ctx
->Eval
.Map2Vertex3
= state
;
502 case GL_MAP2_VERTEX_4
:
503 if (ctx
->Eval
.Map2Vertex4
== state
)
505 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
506 ctx
->Eval
.Map2Vertex4
= state
;
509 if (ctx
->Pixel
.MinMaxEnabled
== state
)
511 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
512 ctx
->Pixel
.MinMaxEnabled
= state
;
515 if (ctx
->Transform
.Normalize
== state
)
517 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
518 ctx
->Transform
.Normalize
= state
;
520 case GL_POINT_SMOOTH
:
521 if (ctx
->Point
.SmoothFlag
== state
)
523 FLUSH_VERTICES(ctx
, _NEW_POINT
);
524 ctx
->Point
.SmoothFlag
= state
;
525 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
527 case GL_POLYGON_SMOOTH
:
528 if (ctx
->Polygon
.SmoothFlag
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
531 ctx
->Polygon
.SmoothFlag
= state
;
532 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
534 case GL_POLYGON_STIPPLE
:
535 if (ctx
->Polygon
.StippleFlag
== state
)
537 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
538 ctx
->Polygon
.StippleFlag
= state
;
539 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
541 case GL_POLYGON_OFFSET_POINT
:
542 if (ctx
->Polygon
.OffsetPoint
== state
)
544 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
545 ctx
->Polygon
.OffsetPoint
= state
;
547 case GL_POLYGON_OFFSET_LINE
:
548 if (ctx
->Polygon
.OffsetLine
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
551 ctx
->Polygon
.OffsetLine
= state
;
553 case GL_POLYGON_OFFSET_FILL
:
554 /*case GL_POLYGON_OFFSET_EXT:*/
555 if (ctx
->Polygon
.OffsetFill
== state
)
557 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
558 ctx
->Polygon
.OffsetFill
= state
;
560 case GL_RESCALE_NORMAL_EXT
:
561 if (ctx
->Transform
.RescaleNormals
== state
)
563 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
564 ctx
->Transform
.RescaleNormals
= state
;
566 case GL_SCISSOR_TEST
:
567 if (ctx
->Scissor
.Enabled
== state
)
569 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
570 ctx
->Scissor
.Enabled
= state
;
572 case GL_SHARED_TEXTURE_PALETTE_EXT
:
573 if (ctx
->Texture
.SharedPalette
== state
)
575 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
576 ctx
->Texture
.SharedPalette
= state
;
578 case GL_STENCIL_TEST
:
579 if (state
&& ctx
->DrawBuffer
->Visual
.stencilBits
== 0) {
581 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
584 if (ctx
->Stencil
.Enabled
== state
)
586 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
587 ctx
->Stencil
.Enabled
= state
;
590 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
595 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
600 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
604 case GL_TEXTURE_GEN_Q
: {
605 GLuint unit
= ctx
->Texture
.CurrentUnit
;
606 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
607 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
610 if (texUnit
->TexGenEnabled
== newenabled
)
612 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
613 texUnit
->TexGenEnabled
= newenabled
;
616 case GL_TEXTURE_GEN_R
: {
617 GLuint unit
= ctx
->Texture
.CurrentUnit
;
618 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
619 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
622 if (texUnit
->TexGenEnabled
== newenabled
)
624 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
625 texUnit
->TexGenEnabled
= newenabled
;
628 case GL_TEXTURE_GEN_S
: {
629 GLuint unit
= ctx
->Texture
.CurrentUnit
;
630 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
631 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
634 if (texUnit
->TexGenEnabled
== newenabled
)
636 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
637 texUnit
->TexGenEnabled
= newenabled
;
640 case GL_TEXTURE_GEN_T
: {
641 GLuint unit
= ctx
->Texture
.CurrentUnit
;
642 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
643 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
646 if (texUnit
->TexGenEnabled
== newenabled
)
648 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
649 texUnit
->TexGenEnabled
= newenabled
;
656 case GL_VERTEX_ARRAY
:
657 case GL_NORMAL_ARRAY
:
660 case GL_TEXTURE_COORD_ARRAY
:
661 case GL_EDGE_FLAG_ARRAY
:
662 case GL_FOG_COORDINATE_ARRAY_EXT
:
663 case GL_SECONDARY_COLOR_ARRAY_EXT
:
664 client_state( ctx
, cap
, state
);
667 /* GL_SGI_color_table */
668 case GL_COLOR_TABLE_SGI
:
669 CHECK_EXTENSION(SGI_color_table
, cap
);
670 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] == state
)
672 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
673 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
] = state
;
675 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
676 CHECK_EXTENSION(SGI_color_table
, cap
);
677 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] == state
)
679 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
680 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
] = state
;
682 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
683 CHECK_EXTENSION(SGI_color_table
, cap
);
684 if (ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] == state
)
686 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
687 ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
] = state
;
689 case GL_TEXTURE_COLOR_TABLE_SGI
:
690 CHECK_EXTENSION(SGI_texture_color_table
, cap
);
691 if (ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
== state
)
693 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
694 ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
= state
;
697 /* GL_EXT_convolution */
698 case GL_CONVOLUTION_1D
:
699 CHECK_EXTENSION(EXT_convolution
, cap
);
700 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
702 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
703 ctx
->Pixel
.Convolution1DEnabled
= state
;
705 case GL_CONVOLUTION_2D
:
706 CHECK_EXTENSION(EXT_convolution
, cap
);
707 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
709 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
710 ctx
->Pixel
.Convolution2DEnabled
= state
;
712 case GL_SEPARABLE_2D
:
713 CHECK_EXTENSION(EXT_convolution
, cap
);
714 if (ctx
->Pixel
.Separable2DEnabled
== state
)
716 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
717 ctx
->Pixel
.Separable2DEnabled
= state
;
720 /* GL_ARB_texture_cube_map */
721 case GL_TEXTURE_CUBE_MAP_ARB
:
722 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
723 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
728 /* GL_EXT_secondary_color */
729 case GL_COLOR_SUM_EXT
:
730 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
731 if (ctx
->Fog
.ColorSumEnabled
== state
)
733 FLUSH_VERTICES(ctx
, _NEW_FOG
);
734 ctx
->Fog
.ColorSumEnabled
= state
;
737 /* GL_ARB_multisample */
738 case GL_MULTISAMPLE_ARB
:
739 CHECK_EXTENSION(ARB_multisample
, cap
);
740 if (ctx
->Multisample
.Enabled
== state
)
742 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
743 ctx
->Multisample
.Enabled
= state
;
745 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
746 CHECK_EXTENSION(ARB_multisample
, cap
);
747 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
749 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
750 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
752 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
753 CHECK_EXTENSION(ARB_multisample
, cap
);
754 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
756 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
757 ctx
->Multisample
.SampleAlphaToOne
= state
;
759 case GL_SAMPLE_COVERAGE_ARB
:
760 CHECK_EXTENSION(ARB_multisample
, cap
);
761 if (ctx
->Multisample
.SampleCoverage
== state
)
763 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
764 ctx
->Multisample
.SampleCoverage
= state
;
766 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
767 CHECK_EXTENSION(ARB_multisample
, cap
);
768 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
770 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
771 ctx
->Multisample
.SampleCoverageInvert
= state
;
774 /* GL_IBM_rasterpos_clip */
775 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
776 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
777 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
779 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
780 ctx
->Transform
.RasterPositionUnclipped
= state
;
783 /* GL_NV_point_sprite */
784 case GL_POINT_SPRITE_NV
:
785 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
786 if (ctx
->Point
.PointSprite
== state
)
788 FLUSH_VERTICES(ctx
, _NEW_POINT
);
789 ctx
->Point
.PointSprite
= state
;
792 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
793 case GL_VERTEX_PROGRAM_ARB
:
794 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
795 if (ctx
->VertexProgram
.Enabled
== state
)
797 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
798 ctx
->VertexProgram
.Enabled
= state
;
800 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
801 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
802 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
804 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
805 ctx
->VertexProgram
.PointSizeEnabled
= state
;
807 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
808 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
809 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
811 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
812 ctx
->VertexProgram
.TwoSideEnabled
= state
;
815 #if FEATURE_NV_vertex_program
816 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
817 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
818 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
819 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
820 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
821 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
822 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
823 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
824 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
825 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
826 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
827 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
828 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
829 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
830 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
831 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
832 CHECK_EXTENSION(NV_vertex_program
, cap
);
834 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
835 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
836 ctx
->Eval
.Map1Attrib
[map
] = state
;
839 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
840 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
841 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
842 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
843 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
844 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
845 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
846 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
847 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
848 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
849 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
850 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
851 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
852 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
853 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
854 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
855 CHECK_EXTENSION(NV_vertex_program
, cap
);
857 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
858 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
859 ctx
->Eval
.Map2Attrib
[map
] = state
;
862 #endif /* FEATURE_NV_vertex_program */
864 #if FEATURE_NV_fragment_program
865 case GL_FRAGMENT_PROGRAM_NV
:
866 CHECK_EXTENSION(NV_fragment_program
, cap
);
867 if (ctx
->FragmentProgram
.Enabled
== state
)
869 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
870 ctx
->FragmentProgram
.Enabled
= state
;
872 #endif /* FEATURE_NV_fragment_program */
874 /* GL_NV_texture_rectangle */
875 case GL_TEXTURE_RECTANGLE_NV
:
876 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
877 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
882 /* GL_EXT_stencil_two_side */
883 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
884 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
885 if (ctx
->Stencil
.TestTwoSide
== state
)
887 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
888 ctx
->Stencil
.TestTwoSide
= state
;
890 ctx
->_TriangleCaps
|= DD_TRI_TWOSTENCIL
;
892 ctx
->_TriangleCaps
&= ~DD_TRI_TWOSTENCIL
;
895 #if FEATURE_ARB_fragment_program
896 case GL_FRAGMENT_PROGRAM_ARB
:
897 CHECK_EXTENSION(ARB_fragment_program
, cap
);
898 if (ctx
->FragmentProgram
.Enabled
== state
)
900 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
901 ctx
->FragmentProgram
.Enabled
= state
;
903 #endif /* FEATURE_ARB_fragment_program */
905 /* GL_EXT_depth_bounds_test */
906 case GL_DEPTH_BOUNDS_TEST_EXT
:
907 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
908 if (state
&& ctx
->DrawBuffer
->Visual
.depthBits
== 0) {
910 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
913 if (ctx
->Depth
.BoundsTest
== state
)
915 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
916 ctx
->Depth
.BoundsTest
= state
;
919 /* GL_MESA_program_debug */
920 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
921 CHECK_EXTENSION(MESA_program_debug
, cap
);
922 ctx
->FragmentProgram
.CallbackEnabled
= state
;
924 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
925 CHECK_EXTENSION(MESA_program_debug
, cap
);
926 ctx
->VertexProgram
.CallbackEnabled
= state
;
929 #if FEATURE_ATI_fragment_shader
930 case GL_FRAGMENT_SHADER_ATI
:
931 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
932 if (ctx
->ATIFragmentShader
.Enabled
== state
)
934 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
935 ctx
->ATIFragmentShader
.Enabled
= state
;
939 /* GL_MESA_texture_array */
940 case GL_TEXTURE_1D_ARRAY_EXT
:
941 CHECK_EXTENSION(MESA_texture_array
, cap
);
942 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
947 case GL_TEXTURE_2D_ARRAY_EXT
:
948 CHECK_EXTENSION(MESA_texture_array
, cap
);
949 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
955 _mesa_error(ctx
, GL_INVALID_ENUM
,
956 "%s(0x%x)", state
? "glEnable" : "glDisable", cap
);
960 if (ctx
->Driver
.Enable
) {
961 ctx
->Driver
.Enable( ctx
, cap
, state
);
967 * Enable GL capability. Called by glEnable()
968 * \param cap state to enable.
971 _mesa_Enable( GLenum cap
)
973 GET_CURRENT_CONTEXT(ctx
);
974 ASSERT_OUTSIDE_BEGIN_END(ctx
);
976 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
981 * Disable GL capability. Called by glDisable()
982 * \param cap state to disable.
985 _mesa_Disable( GLenum cap
)
987 GET_CURRENT_CONTEXT(ctx
);
988 ASSERT_OUTSIDE_BEGIN_END(ctx
);
990 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
994 #undef CHECK_EXTENSION
995 #define CHECK_EXTENSION(EXTNAME) \
996 if (!ctx->Extensions.EXTNAME) { \
997 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1001 #undef CHECK_EXTENSION2
1002 #define CHECK_EXTENSION2(EXT1, EXT2) \
1003 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1004 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1010 * Helper function to determine whether a texture target is enabled.
1013 is_texture_enabled(GLcontext
*ctx
, GLbitfield bit
)
1015 const struct gl_texture_unit
*const texUnit
=
1016 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1017 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1022 * Return simple enable/disable state.
1024 * \param cap state variable to query.
1026 * Returns the state of the specified capability from the current GL context.
1027 * For the capabilities associated with extensions verifies that those
1028 * extensions are effectively present before reporting.
1030 GLboolean GLAPIENTRY
1031 _mesa_IsEnabled( GLenum cap
)
1033 GET_CURRENT_CONTEXT(ctx
);
1036 return ctx
->Color
.AlphaEnabled
;
1037 case GL_AUTO_NORMAL
:
1038 return ctx
->Eval
.AutoNormal
;
1040 return ctx
->Color
.BlendEnabled
;
1041 case GL_CLIP_PLANE0
:
1042 case GL_CLIP_PLANE1
:
1043 case GL_CLIP_PLANE2
:
1044 case GL_CLIP_PLANE3
:
1045 case GL_CLIP_PLANE4
:
1046 case GL_CLIP_PLANE5
:
1047 return (ctx
->Transform
.ClipPlanesEnabled
>> (cap
- GL_CLIP_PLANE0
)) & 1;
1048 case GL_COLOR_MATERIAL
:
1049 return ctx
->Light
.ColorMaterialEnabled
;
1051 return ctx
->Polygon
.CullFlag
;
1053 return ctx
->Depth
.Test
;
1055 return ctx
->Color
.DitherFlag
;
1057 return ctx
->Fog
.Enabled
;
1059 return ctx
->Light
.Enabled
;
1068 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1069 case GL_LINE_SMOOTH
:
1070 return ctx
->Line
.SmoothFlag
;
1071 case GL_LINE_STIPPLE
:
1072 return ctx
->Line
.StippleFlag
;
1073 case GL_INDEX_LOGIC_OP
:
1074 return ctx
->Color
.IndexLogicOpEnabled
;
1075 case GL_COLOR_LOGIC_OP
:
1076 return ctx
->Color
.ColorLogicOpEnabled
;
1077 case GL_MAP1_COLOR_4
:
1078 return ctx
->Eval
.Map1Color4
;
1080 return ctx
->Eval
.Map1Index
;
1081 case GL_MAP1_NORMAL
:
1082 return ctx
->Eval
.Map1Normal
;
1083 case GL_MAP1_TEXTURE_COORD_1
:
1084 return ctx
->Eval
.Map1TextureCoord1
;
1085 case GL_MAP1_TEXTURE_COORD_2
:
1086 return ctx
->Eval
.Map1TextureCoord2
;
1087 case GL_MAP1_TEXTURE_COORD_3
:
1088 return ctx
->Eval
.Map1TextureCoord3
;
1089 case GL_MAP1_TEXTURE_COORD_4
:
1090 return ctx
->Eval
.Map1TextureCoord4
;
1091 case GL_MAP1_VERTEX_3
:
1092 return ctx
->Eval
.Map1Vertex3
;
1093 case GL_MAP1_VERTEX_4
:
1094 return ctx
->Eval
.Map1Vertex4
;
1095 case GL_MAP2_COLOR_4
:
1096 return ctx
->Eval
.Map2Color4
;
1098 return ctx
->Eval
.Map2Index
;
1099 case GL_MAP2_NORMAL
:
1100 return ctx
->Eval
.Map2Normal
;
1101 case GL_MAP2_TEXTURE_COORD_1
:
1102 return ctx
->Eval
.Map2TextureCoord1
;
1103 case GL_MAP2_TEXTURE_COORD_2
:
1104 return ctx
->Eval
.Map2TextureCoord2
;
1105 case GL_MAP2_TEXTURE_COORD_3
:
1106 return ctx
->Eval
.Map2TextureCoord3
;
1107 case GL_MAP2_TEXTURE_COORD_4
:
1108 return ctx
->Eval
.Map2TextureCoord4
;
1109 case GL_MAP2_VERTEX_3
:
1110 return ctx
->Eval
.Map2Vertex3
;
1111 case GL_MAP2_VERTEX_4
:
1112 return ctx
->Eval
.Map2Vertex4
;
1114 return ctx
->Transform
.Normalize
;
1115 case GL_POINT_SMOOTH
:
1116 return ctx
->Point
.SmoothFlag
;
1117 case GL_POLYGON_SMOOTH
:
1118 return ctx
->Polygon
.SmoothFlag
;
1119 case GL_POLYGON_STIPPLE
:
1120 return ctx
->Polygon
.StippleFlag
;
1121 case GL_POLYGON_OFFSET_POINT
:
1122 return ctx
->Polygon
.OffsetPoint
;
1123 case GL_POLYGON_OFFSET_LINE
:
1124 return ctx
->Polygon
.OffsetLine
;
1125 case GL_POLYGON_OFFSET_FILL
:
1126 /*case GL_POLYGON_OFFSET_EXT:*/
1127 return ctx
->Polygon
.OffsetFill
;
1128 case GL_RESCALE_NORMAL_EXT
:
1129 return ctx
->Transform
.RescaleNormals
;
1130 case GL_SCISSOR_TEST
:
1131 return ctx
->Scissor
.Enabled
;
1132 case GL_SHARED_TEXTURE_PALETTE_EXT
:
1133 return ctx
->Texture
.SharedPalette
;
1134 case GL_STENCIL_TEST
:
1135 return ctx
->Stencil
.Enabled
;
1137 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1139 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1141 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1142 case GL_TEXTURE_GEN_Q
:
1144 const struct gl_texture_unit
*texUnit
;
1145 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1146 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
1148 case GL_TEXTURE_GEN_R
:
1150 const struct gl_texture_unit
*texUnit
;
1151 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1152 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
1154 case GL_TEXTURE_GEN_S
:
1156 const struct gl_texture_unit
*texUnit
;
1157 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1158 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
1160 case GL_TEXTURE_GEN_T
:
1162 const struct gl_texture_unit
*texUnit
;
1163 texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1164 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
1170 case GL_VERTEX_ARRAY
:
1171 return (ctx
->Array
.ArrayObj
->Vertex
.Enabled
!= 0);
1172 case GL_NORMAL_ARRAY
:
1173 return (ctx
->Array
.ArrayObj
->Normal
.Enabled
!= 0);
1174 case GL_COLOR_ARRAY
:
1175 return (ctx
->Array
.ArrayObj
->Color
.Enabled
!= 0);
1176 case GL_INDEX_ARRAY
:
1177 return (ctx
->Array
.ArrayObj
->Index
.Enabled
!= 0);
1178 case GL_TEXTURE_COORD_ARRAY
:
1179 return (ctx
->Array
.ArrayObj
->TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
!= 0);
1180 case GL_EDGE_FLAG_ARRAY
:
1181 return (ctx
->Array
.ArrayObj
->EdgeFlag
.Enabled
!= 0);
1182 case GL_FOG_COORDINATE_ARRAY_EXT
:
1183 CHECK_EXTENSION(EXT_fog_coord
);
1184 return (ctx
->Array
.ArrayObj
->FogCoord
.Enabled
!= 0);
1185 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1186 CHECK_EXTENSION(EXT_secondary_color
);
1187 return (ctx
->Array
.ArrayObj
->SecondaryColor
.Enabled
!= 0);
1189 /* GL_EXT_histogram */
1191 CHECK_EXTENSION(EXT_histogram
);
1192 return ctx
->Pixel
.HistogramEnabled
;
1194 CHECK_EXTENSION(EXT_histogram
);
1195 return ctx
->Pixel
.MinMaxEnabled
;
1197 /* GL_SGI_color_table */
1198 case GL_COLOR_TABLE_SGI
:
1199 CHECK_EXTENSION(SGI_color_table
);
1200 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
];
1201 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
1202 CHECK_EXTENSION(SGI_color_table
);
1203 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
];
1204 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
1205 CHECK_EXTENSION(SGI_color_table
);
1206 return ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
];
1208 /* GL_SGI_texture_color_table */
1209 case GL_TEXTURE_COLOR_TABLE_SGI
:
1210 CHECK_EXTENSION(SGI_texture_color_table
);
1211 return ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
].ColorTableEnabled
;
1213 /* GL_EXT_convolution */
1214 case GL_CONVOLUTION_1D
:
1215 CHECK_EXTENSION(EXT_convolution
);
1216 return ctx
->Pixel
.Convolution1DEnabled
;
1217 case GL_CONVOLUTION_2D
:
1218 CHECK_EXTENSION(EXT_convolution
);
1219 return ctx
->Pixel
.Convolution2DEnabled
;
1220 case GL_SEPARABLE_2D
:
1221 CHECK_EXTENSION(EXT_convolution
);
1222 return ctx
->Pixel
.Separable2DEnabled
;
1224 /* GL_ARB_texture_cube_map */
1225 case GL_TEXTURE_CUBE_MAP_ARB
:
1226 CHECK_EXTENSION(ARB_texture_cube_map
);
1227 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1229 /* GL_EXT_secondary_color */
1230 case GL_COLOR_SUM_EXT
:
1231 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1232 return ctx
->Fog
.ColorSumEnabled
;
1234 /* GL_ARB_multisample */
1235 case GL_MULTISAMPLE_ARB
:
1236 CHECK_EXTENSION(ARB_multisample
);
1237 return ctx
->Multisample
.Enabled
;
1238 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1239 CHECK_EXTENSION(ARB_multisample
);
1240 return ctx
->Multisample
.SampleAlphaToCoverage
;
1241 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1242 CHECK_EXTENSION(ARB_multisample
);
1243 return ctx
->Multisample
.SampleAlphaToOne
;
1244 case GL_SAMPLE_COVERAGE_ARB
:
1245 CHECK_EXTENSION(ARB_multisample
);
1246 return ctx
->Multisample
.SampleCoverage
;
1247 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1248 CHECK_EXTENSION(ARB_multisample
);
1249 return ctx
->Multisample
.SampleCoverageInvert
;
1251 /* GL_IBM_rasterpos_clip */
1252 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1253 CHECK_EXTENSION(IBM_rasterpos_clip
);
1254 return ctx
->Transform
.RasterPositionUnclipped
;
1256 /* GL_NV_point_sprite */
1257 case GL_POINT_SPRITE_NV
:
1258 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1259 return ctx
->Point
.PointSprite
;
1261 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1262 case GL_VERTEX_PROGRAM_ARB
:
1263 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1264 return ctx
->VertexProgram
.Enabled
;
1265 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1266 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1267 return ctx
->VertexProgram
.PointSizeEnabled
;
1268 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1269 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1270 return ctx
->VertexProgram
.TwoSideEnabled
;
1272 #if FEATURE_NV_vertex_program
1273 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1274 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1275 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1276 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1277 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1278 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1279 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1280 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1281 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1282 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1283 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1284 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1285 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1286 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1287 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1288 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1289 CHECK_EXTENSION(NV_vertex_program
);
1291 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1292 return (ctx
->Array
.ArrayObj
->VertexAttrib
[n
].Enabled
!= 0);
1294 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1295 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1296 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1297 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1298 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1299 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1300 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1301 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1302 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1303 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1304 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1305 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1306 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1307 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1308 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1309 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1310 CHECK_EXTENSION(NV_vertex_program
);
1312 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1313 return ctx
->Eval
.Map1Attrib
[map
];
1315 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1316 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1317 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1318 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1319 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1320 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1321 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1322 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1323 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1324 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1325 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1326 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1327 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1328 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1329 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1330 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1331 CHECK_EXTENSION(NV_vertex_program
);
1333 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1334 return ctx
->Eval
.Map2Attrib
[map
];
1336 #endif /* FEATURE_NV_vertex_program */
1338 #if FEATURE_NV_fragment_program
1339 case GL_FRAGMENT_PROGRAM_NV
:
1340 CHECK_EXTENSION(NV_fragment_program
);
1341 return ctx
->FragmentProgram
.Enabled
;
1342 #endif /* FEATURE_NV_fragment_program */
1344 /* GL_NV_texture_rectangle */
1345 case GL_TEXTURE_RECTANGLE_NV
:
1346 CHECK_EXTENSION(NV_texture_rectangle
);
1347 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1349 /* GL_EXT_stencil_two_side */
1350 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1351 CHECK_EXTENSION(EXT_stencil_two_side
);
1352 return ctx
->Stencil
.TestTwoSide
;
1354 #if FEATURE_ARB_fragment_program
1355 case GL_FRAGMENT_PROGRAM_ARB
:
1356 return ctx
->FragmentProgram
.Enabled
;
1357 #endif /* FEATURE_ARB_fragment_program */
1359 /* GL_EXT_depth_bounds_test */
1360 case GL_DEPTH_BOUNDS_TEST_EXT
:
1361 CHECK_EXTENSION(EXT_depth_bounds_test
);
1362 return ctx
->Depth
.BoundsTest
;
1364 /* GL_MESA_program_debug */
1365 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA
:
1366 CHECK_EXTENSION(MESA_program_debug
);
1367 return ctx
->FragmentProgram
.CallbackEnabled
;
1368 case GL_VERTEX_PROGRAM_CALLBACK_MESA
:
1369 CHECK_EXTENSION(MESA_program_debug
);
1370 return ctx
->VertexProgram
.CallbackEnabled
;
1371 #if FEATURE_ATI_fragment_shader
1372 case GL_FRAGMENT_SHADER_ATI
:
1373 CHECK_EXTENSION(ATI_fragment_shader
);
1374 return ctx
->ATIFragmentShader
.Enabled
;
1375 #endif /* FEATURE_ATI_fragment_shader */
1377 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(0x%x)", (int) cap
);