1 /* $Id: enable.c,v 1.36 2000/12/08 00:20:15 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 #include "simple_list.h"
41 #include "math/m_matrix.h"
42 #include "math/m_xform.h"
49 * Perform glEnable and glDisable calls.
51 void _mesa_set_enable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
53 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
, "gl_enable/disable" );
55 if (MESA_VERBOSE
& VERBOSE_API
)
56 fprintf(stderr
, "%s %s (newstate is %x)\n",
57 state
? "glEnable" : "glDisable",
58 gl_lookup_enum_by_nr(cap
),
63 if (ctx
->Color
.AlphaEnabled
!=state
) {
64 ctx
->Color
.AlphaEnabled
= state
;
65 ctx
->NewState
|= _NEW_COLOR
;
69 ctx
->Eval
.AutoNormal
= state
;
70 ctx
->NewState
|= _NEW_EVAL
;
73 if (ctx
->Color
.BlendEnabled
!=state
) {
74 ctx
->Color
.BlendEnabled
= state
;
75 /* The following needed to accomodate 1.0 RGB logic op blending */
76 if (ctx
->Color
.BlendEquation
==GL_LOGIC_OP
&& state
) {
77 ctx
->Color
.ColorLogicOpEnabled
= GL_TRUE
;
80 ctx
->Color
.ColorLogicOpEnabled
= GL_FALSE
;
82 ctx
->NewState
|= _NEW_COLOR
;
91 if (ctx
->Transform
.ClipEnabled
[cap
-GL_CLIP_PLANE0
] != state
)
93 GLuint p
= cap
-GL_CLIP_PLANE0
;
95 ctx
->Transform
.ClipEnabled
[p
] = state
;
96 ctx
->NewState
|= _NEW_TRANSFORM
;
99 ctx
->_Enabled
|= ENABLE_USERCLIP
;
100 ctx
->Transform
._AnyClip
++;
102 if (ctx
->ProjectionMatrix
.flags
& MAT_DIRTY
) {
103 _math_matrix_analyse( &ctx
->ProjectionMatrix
);
106 /* This derived state also calculated in clip.c and
107 * from gl_update_state() on changes to EyeUserPlane
108 * and ctx->ProjectionMatrix respectively.
110 gl_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
111 ctx
->Transform
.EyeUserPlane
[p
],
112 ctx
->ProjectionMatrix
.inv
);
114 if (--ctx
->Transform
._AnyClip
== 0)
115 ctx
->_Enabled
&= ~ENABLE_USERCLIP
;
119 case GL_COLOR_MATERIAL
:
120 if (ctx
->Light
.ColorMaterialEnabled
!=state
) {
121 ctx
->Light
.ColorMaterialEnabled
= state
;
122 ctx
->NewState
|= _NEW_LIGHT
;
125 FLUSH_TNL( ctx
, FLUSH_UPDATE_CURRENT
);
126 gl_update_color_material( ctx
, ctx
->Current
.Color
);
131 if (ctx
->Polygon
.CullFlag
!=state
) {
132 ctx
->Polygon
.CullFlag
= state
;
133 /* ctx->_TriangleCaps ^= DD_TRI_CULL; */
134 ctx
->NewState
|= _NEW_POLYGON
;
138 if (state
&& ctx
->Visual
.DepthBits
==0) {
139 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
142 if (ctx
->Depth
.Test
!=state
) {
143 ctx
->Depth
.Test
= state
;
144 ctx
->NewState
|= _NEW_DEPTH
;
149 /* MESA_NO_DITHER env var */
152 if (ctx
->Color
.DitherFlag
!=state
) {
153 ctx
->Color
.DitherFlag
= state
;
154 ctx
->NewState
|= _NEW_COLOR
;
158 if (ctx
->Fog
.Enabled
!=state
) {
159 ctx
->Fog
.Enabled
= state
;
160 ctx
->_Enabled
^= ENABLE_FOG
;
161 ctx
->NewState
|= _NEW_FOG
;
165 if (ctx
->Extensions
.EXT_histogram
) {
166 ctx
->Pixel
.HistogramEnabled
= state
;
167 ctx
->NewState
|= _NEW_PIXEL
;
170 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
182 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
!= state
) {
183 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
185 insert_at_tail(&ctx
->Light
.EnabledList
,
186 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
189 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
191 ctx
->NewState
|= _NEW_LIGHT
;
195 if (ctx
->Light
.Enabled
!=state
) {
196 ctx
->Light
.Enabled
= state
;
197 ctx
->_Enabled
&= ~ENABLE_LIGHT
;
199 ctx
->_Enabled
|= ENABLE_LIGHT
;
200 ctx
->NewState
|= _NEW_LIGHT
;
204 if (ctx
->Line
.SmoothFlag
!=state
) {
205 ctx
->Line
.SmoothFlag
= state
;
206 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
207 ctx
->NewState
|= _NEW_LINE
;
210 case GL_LINE_STIPPLE
:
211 if (ctx
->Line
.StippleFlag
!=state
) {
212 ctx
->Line
.StippleFlag
= state
;
213 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
214 ctx
->NewState
|= _NEW_LINE
;
217 case GL_INDEX_LOGIC_OP
:
218 if (ctx
->Color
.IndexLogicOpEnabled
!=state
) {
219 ctx
->Color
.IndexLogicOpEnabled
= state
;
220 ctx
->NewState
|= _NEW_COLOR
;
223 case GL_COLOR_LOGIC_OP
:
224 if (ctx
->Color
.ColorLogicOpEnabled
!=state
) {
225 ctx
->Color
.ColorLogicOpEnabled
= state
;
226 ctx
->NewState
|= _NEW_COLOR
;
229 case GL_MAP1_COLOR_4
:
230 ctx
->Eval
.Map1Color4
= state
;
231 ctx
->NewState
|= _NEW_EVAL
;
234 ctx
->Eval
.Map1Index
= state
;
235 ctx
->NewState
|= _NEW_EVAL
;
238 ctx
->Eval
.Map1Normal
= state
;
239 ctx
->NewState
|= _NEW_EVAL
;
241 case GL_MAP1_TEXTURE_COORD_1
:
242 ctx
->Eval
.Map1TextureCoord1
= state
;
243 ctx
->NewState
|= _NEW_EVAL
;
245 case GL_MAP1_TEXTURE_COORD_2
:
246 ctx
->Eval
.Map1TextureCoord2
= state
;
247 ctx
->NewState
|= _NEW_EVAL
;
249 case GL_MAP1_TEXTURE_COORD_3
:
250 ctx
->Eval
.Map1TextureCoord3
= state
;
251 ctx
->NewState
|= _NEW_EVAL
;
253 case GL_MAP1_TEXTURE_COORD_4
:
254 ctx
->Eval
.Map1TextureCoord4
= state
;
255 ctx
->NewState
|= _NEW_EVAL
;
257 case GL_MAP1_VERTEX_3
:
258 ctx
->Eval
.Map1Vertex3
= state
;
259 ctx
->NewState
|= _NEW_EVAL
;
261 case GL_MAP1_VERTEX_4
:
262 ctx
->Eval
.Map1Vertex4
= state
;
263 ctx
->NewState
|= _NEW_EVAL
;
265 case GL_MAP2_COLOR_4
:
266 ctx
->Eval
.Map2Color4
= state
;
267 ctx
->NewState
|= _NEW_EVAL
;
270 ctx
->Eval
.Map2Index
= state
;
271 ctx
->NewState
|= _NEW_EVAL
;
274 ctx
->Eval
.Map2Normal
= state
;
275 ctx
->NewState
|= _NEW_EVAL
;
277 case GL_MAP2_TEXTURE_COORD_1
:
278 ctx
->Eval
.Map2TextureCoord1
= state
;
279 ctx
->NewState
|= _NEW_EVAL
;
281 case GL_MAP2_TEXTURE_COORD_2
:
282 ctx
->Eval
.Map2TextureCoord2
= state
;
283 ctx
->NewState
|= _NEW_EVAL
;
285 case GL_MAP2_TEXTURE_COORD_3
:
286 ctx
->Eval
.Map2TextureCoord3
= state
;
287 ctx
->NewState
|= _NEW_EVAL
;
289 case GL_MAP2_TEXTURE_COORD_4
:
290 ctx
->Eval
.Map2TextureCoord4
= state
;
291 ctx
->NewState
|= _NEW_EVAL
;
293 case GL_MAP2_VERTEX_3
:
294 ctx
->Eval
.Map2Vertex3
= state
;
295 ctx
->NewState
|= _NEW_EVAL
;
297 case GL_MAP2_VERTEX_4
:
298 ctx
->Eval
.Map2Vertex4
= state
;
299 ctx
->NewState
|= _NEW_EVAL
;
302 ctx
->Pixel
.MinMaxEnabled
= state
;
303 ctx
->NewState
|= _NEW_PIXEL
;
306 if (ctx
->Transform
.Normalize
!= state
) {
307 ctx
->Transform
.Normalize
= state
;
308 ctx
->NewState
|= _NEW_TRANSFORM
;
309 ctx
->_Enabled
^= ENABLE_NORMALIZE
;
312 case GL_POINT_SMOOTH
:
313 if (ctx
->Point
.SmoothFlag
!=state
) {
314 ctx
->Point
.SmoothFlag
= state
;
315 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
316 ctx
->NewState
|= _NEW_POINT
;
319 case GL_POLYGON_SMOOTH
:
320 if (ctx
->Polygon
.SmoothFlag
!=state
) {
321 ctx
->Polygon
.SmoothFlag
= state
;
322 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
323 ctx
->NewState
|= _NEW_POLYGON
;
326 case GL_POLYGON_STIPPLE
:
327 if (ctx
->Polygon
.StippleFlag
!=state
) {
328 ctx
->Polygon
.StippleFlag
= state
;
329 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
330 ctx
->NewState
|= _NEW_POLYGON
;
333 case GL_POLYGON_OFFSET_POINT
:
334 if (ctx
->Polygon
.OffsetPoint
!=state
) {
335 ctx
->Polygon
.OffsetPoint
= state
;
336 ctx
->NewState
|= _NEW_POLYGON
;
339 case GL_POLYGON_OFFSET_LINE
:
340 if (ctx
->Polygon
.OffsetLine
!=state
) {
341 ctx
->Polygon
.OffsetLine
= state
;
342 ctx
->NewState
|= _NEW_POLYGON
;
345 case GL_POLYGON_OFFSET_FILL
:
346 /*case GL_POLYGON_OFFSET_EXT:*/
347 if (ctx
->Polygon
.OffsetFill
!=state
) {
348 ctx
->Polygon
.OffsetFill
= state
;
349 ctx
->NewState
|= _NEW_POLYGON
;
352 case GL_RESCALE_NORMAL_EXT
:
353 if (ctx
->Transform
.RescaleNormals
!= state
) {
354 ctx
->Transform
.RescaleNormals
= state
;
355 ctx
->NewState
|= _NEW_TRANSFORM
;
356 ctx
->_Enabled
^= ENABLE_RESCALE
;
359 case GL_SCISSOR_TEST
:
360 if (ctx
->Scissor
.Enabled
!=state
) {
361 ctx
->Scissor
.Enabled
= state
;
362 ctx
->NewState
|= _NEW_SCISSOR
;
365 case GL_SHARED_TEXTURE_PALETTE_EXT
:
366 ctx
->Texture
.SharedPalette
= state
;
367 ctx
->NewState
|= _NEW_TEXTURE
;
369 case GL_STENCIL_TEST
:
370 if (state
&& ctx
->Visual
.StencilBits
==0) {
371 _mesa_warning(ctx
, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
374 if (ctx
->Stencil
.Enabled
!=state
) {
375 ctx
->Stencil
.Enabled
= state
;
376 ctx
->NewState
|= _NEW_STENCIL
;
377 ctx
->_TriangleCaps
^= DD_STENCIL
;
381 if (ctx
->Visual
.RGBAflag
) {
382 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
383 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
384 ctx
->NewState
|= _NEW_TEXTURE
;
386 texUnit
->Enabled
|= TEXTURE0_1D
;
389 texUnit
->Enabled
&= ~TEXTURE0_1D
;
394 if (ctx
->Visual
.RGBAflag
) {
395 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
396 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
397 ctx
->NewState
|= _NEW_TEXTURE
;
399 texUnit
->Enabled
|= TEXTURE0_2D
;
402 texUnit
->Enabled
&= ~TEXTURE0_2D
;
407 if (ctx
->Visual
.RGBAflag
) {
408 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
409 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
410 ctx
->NewState
|= _NEW_TEXTURE
;
412 texUnit
->Enabled
|= TEXTURE0_3D
;
415 texUnit
->Enabled
&= ~TEXTURE0_3D
;
419 case GL_TEXTURE_GEN_Q
:
421 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
423 texUnit
->TexGenEnabled
|= Q_BIT
;
425 texUnit
->TexGenEnabled
&= ~Q_BIT
;
426 ctx
->NewState
|= _NEW_TEXTURE
;
429 case GL_TEXTURE_GEN_R
:
431 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
433 texUnit
->TexGenEnabled
|= R_BIT
;
435 texUnit
->TexGenEnabled
&= ~R_BIT
;
436 ctx
->NewState
|= _NEW_TEXTURE
;
439 case GL_TEXTURE_GEN_S
:
441 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
443 texUnit
->TexGenEnabled
|= S_BIT
;
445 texUnit
->TexGenEnabled
&= ~S_BIT
;
446 ctx
->NewState
|= _NEW_TEXTURE
;
449 case GL_TEXTURE_GEN_T
:
451 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
453 texUnit
->TexGenEnabled
|= T_BIT
;
455 texUnit
->TexGenEnabled
&= ~T_BIT
;
456 ctx
->NewState
|= _NEW_TEXTURE
;
463 case GL_VERTEX_ARRAY
:
464 ctx
->Array
.Vertex
.Enabled
= state
;
465 ctx
->NewState
|= _NEW_ARRAY
;
467 case GL_NORMAL_ARRAY
:
468 ctx
->Array
.Normal
.Enabled
= state
;
469 ctx
->NewState
|= _NEW_ARRAY
;
472 ctx
->Array
.Color
.Enabled
= state
;
473 ctx
->NewState
|= _NEW_ARRAY
;
476 ctx
->Array
.Index
.Enabled
= state
;
477 ctx
->NewState
|= _NEW_ARRAY
;
479 case GL_TEXTURE_COORD_ARRAY
:
480 ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
= state
;
481 ctx
->NewState
|= _NEW_ARRAY
;
483 case GL_EDGE_FLAG_ARRAY
:
484 ctx
->Array
.EdgeFlag
.Enabled
= state
;
485 ctx
->NewState
|= _NEW_ARRAY
;
488 /* GL_HP_occlusion_test */
489 case GL_OCCLUSION_TEST_HP
:
490 if (ctx
->Extensions
.HP_occlusion_test
) {
491 ctx
->Depth
.OcclusionTest
= state
;
492 ctx
->NewState
|= _NEW_DEPTH
;
494 ctx
->OcclusionResult
= ctx
->OcclusionResultSaved
;
496 ctx
->OcclusionResultSaved
= ctx
->OcclusionResult
;
499 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
504 /* GL_SGIS_pixel_texture */
505 case GL_PIXEL_TEXTURE_SGIS
:
506 if (ctx
->Extensions
.SGIS_pixel_texture
) {
507 ctx
->Pixel
.PixelTextureEnabled
= state
;
508 ctx
->NewState
|= _NEW_PIXEL
;
511 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
516 /* GL_SGIX_pixel_texture */
517 case GL_PIXEL_TEX_GEN_SGIX
:
518 if (ctx
->Extensions
.SGIX_pixel_texture
) {
519 ctx
->Pixel
.PixelTextureEnabled
= state
;
520 ctx
->NewState
|= _NEW_PIXEL
;
523 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
528 /* GL_SGI_color_table */
529 case GL_COLOR_TABLE_SGI
:
530 if (ctx
->Extensions
.SGI_color_table
) {
531 ctx
->Pixel
.ColorTableEnabled
= state
;
532 ctx
->NewState
|= _NEW_PIXEL
;
535 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
539 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
540 if (ctx
->Extensions
.SGI_color_table
) {
541 ctx
->Pixel
.PostConvolutionColorTableEnabled
= state
;
542 ctx
->NewState
|= _NEW_PIXEL
;
545 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
549 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
550 if (ctx
->Extensions
.SGI_color_table
) {
551 ctx
->Pixel
.PostColorMatrixColorTableEnabled
= state
;
552 ctx
->NewState
|= _NEW_PIXEL
;
555 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
560 /* GL_EXT_convolution */
561 case GL_CONVOLUTION_1D
:
562 if (ctx
->Extensions
.EXT_convolution
) {
563 ctx
->Pixel
.Convolution1DEnabled
= state
;
564 ctx
->NewState
|= _NEW_PIXEL
;
567 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
571 case GL_CONVOLUTION_2D
:
572 if (ctx
->Extensions
.EXT_convolution
) {
573 ctx
->Pixel
.Convolution2DEnabled
= state
;
574 ctx
->NewState
|= _NEW_PIXEL
;
577 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
581 case GL_SEPARABLE_2D
:
582 if (ctx
->Extensions
.EXT_convolution
) {
583 ctx
->Pixel
.Separable2DEnabled
= state
;
584 ctx
->NewState
|= _NEW_PIXEL
;
587 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
592 /* GL_ARB_texture_cube_map */
593 case GL_TEXTURE_CUBE_MAP_ARB
:
594 if (ctx
->Extensions
.ARB_texture_cube_map
) {
595 if (ctx
->Visual
.RGBAflag
) {
596 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
597 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
598 ctx
->NewState
|= _NEW_TEXTURE
;
600 texUnit
->Enabled
|= TEXTURE0_CUBE
;
603 texUnit
->Enabled
&= ~TEXTURE0_CUBE
;
608 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
613 /* GL_EXT_secondary_color */
614 case GL_COLOR_SUM_EXT
:
615 if (ctx
->Extensions
.EXT_secondary_color
) {
616 ctx
->Fog
.ColorSumEnabled
= state
;
618 SET_BITS(ctx
->_TriangleCaps
, DD_SEPERATE_SPECULAR
);
619 else if (ctx
->Light
.Model
.ColorControl
== GL_SINGLE_COLOR
)
620 CLEAR_BITS(ctx
->_TriangleCaps
, DD_SEPERATE_SPECULAR
);
621 ctx
->NewState
|= _NEW_FOG
;
624 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
629 /* GL_MESA_sprite_point */
630 case GL_SPRITE_POINT_MESA
:
631 if (ctx
->Extensions
.MESA_sprite_point
) {
632 ctx
->Point
.SpriteMode
= state
;
633 ctx
->NewState
|= _NEW_POINT
;
636 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
642 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
646 if (ctx
->Driver
.Enable
) {
647 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
655 _mesa_Enable( GLenum cap
)
657 GET_CURRENT_CONTEXT(ctx
);
658 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
664 _mesa_Disable( GLenum cap
)
666 GET_CURRENT_CONTEXT(ctx
);
667 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
673 _mesa_IsEnabled( GLenum cap
)
675 GET_CURRENT_CONTEXT(ctx
);
678 return ctx
->Color
.AlphaEnabled
;
680 return ctx
->Eval
.AutoNormal
;
682 return ctx
->Color
.BlendEnabled
;
689 return ctx
->Transform
.ClipEnabled
[cap
-GL_CLIP_PLANE0
];
690 case GL_COLOR_MATERIAL
:
691 return ctx
->Light
.ColorMaterialEnabled
;
693 return ctx
->Polygon
.CullFlag
;
695 return ctx
->Depth
.Test
;
697 return ctx
->Color
.DitherFlag
;
699 return ctx
->Fog
.Enabled
;
701 if (ctx
->Extensions
.EXT_histogram
) {
702 return ctx
->Pixel
.HistogramEnabled
;
705 gl_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled");
709 return ctx
->Light
.Enabled
;
718 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
720 return ctx
->Line
.SmoothFlag
;
721 case GL_LINE_STIPPLE
:
722 return ctx
->Line
.StippleFlag
;
723 case GL_INDEX_LOGIC_OP
:
724 return ctx
->Color
.IndexLogicOpEnabled
;
725 case GL_COLOR_LOGIC_OP
:
726 return ctx
->Color
.ColorLogicOpEnabled
;
727 case GL_MAP1_COLOR_4
:
728 return ctx
->Eval
.Map1Color4
;
730 return ctx
->Eval
.Map1Index
;
732 return ctx
->Eval
.Map1Normal
;
733 case GL_MAP1_TEXTURE_COORD_1
:
734 return ctx
->Eval
.Map1TextureCoord1
;
735 case GL_MAP1_TEXTURE_COORD_2
:
736 return ctx
->Eval
.Map1TextureCoord2
;
737 case GL_MAP1_TEXTURE_COORD_3
:
738 return ctx
->Eval
.Map1TextureCoord3
;
739 case GL_MAP1_TEXTURE_COORD_4
:
740 return ctx
->Eval
.Map1TextureCoord4
;
741 case GL_MAP1_VERTEX_3
:
742 return ctx
->Eval
.Map1Vertex3
;
743 case GL_MAP1_VERTEX_4
:
744 return ctx
->Eval
.Map1Vertex4
;
745 case GL_MAP2_COLOR_4
:
746 return ctx
->Eval
.Map2Color4
;
748 return ctx
->Eval
.Map2Index
;
750 return ctx
->Eval
.Map2Normal
;
751 case GL_MAP2_TEXTURE_COORD_1
:
752 return ctx
->Eval
.Map2TextureCoord1
;
753 case GL_MAP2_TEXTURE_COORD_2
:
754 return ctx
->Eval
.Map2TextureCoord2
;
755 case GL_MAP2_TEXTURE_COORD_3
:
756 return ctx
->Eval
.Map2TextureCoord3
;
757 case GL_MAP2_TEXTURE_COORD_4
:
758 return ctx
->Eval
.Map2TextureCoord4
;
759 case GL_MAP2_VERTEX_3
:
760 return ctx
->Eval
.Map2Vertex3
;
761 case GL_MAP2_VERTEX_4
:
762 return ctx
->Eval
.Map2Vertex4
;
764 return ctx
->Pixel
.MinMaxEnabled
;
766 return ctx
->Transform
.Normalize
;
767 case GL_POINT_SMOOTH
:
768 return ctx
->Point
.SmoothFlag
;
769 case GL_POLYGON_SMOOTH
:
770 return ctx
->Polygon
.SmoothFlag
;
771 case GL_POLYGON_STIPPLE
:
772 return ctx
->Polygon
.StippleFlag
;
773 case GL_POLYGON_OFFSET_POINT
:
774 return ctx
->Polygon
.OffsetPoint
;
775 case GL_POLYGON_OFFSET_LINE
:
776 return ctx
->Polygon
.OffsetLine
;
777 case GL_POLYGON_OFFSET_FILL
:
778 /*case GL_POLYGON_OFFSET_EXT:*/
779 return ctx
->Polygon
.OffsetFill
;
780 case GL_RESCALE_NORMAL_EXT
:
781 return ctx
->Transform
.RescaleNormals
;
782 case GL_SCISSOR_TEST
:
783 return ctx
->Scissor
.Enabled
;
784 case GL_SHARED_TEXTURE_PALETTE_EXT
:
785 return ctx
->Texture
.SharedPalette
;
786 case GL_STENCIL_TEST
:
787 return ctx
->Stencil
.Enabled
;
790 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
791 return (texUnit
->Enabled
& TEXTURE0_1D
) ? GL_TRUE
: GL_FALSE
;
795 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
796 return (texUnit
->Enabled
& TEXTURE0_2D
) ? GL_TRUE
: GL_FALSE
;
800 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
801 return (texUnit
->Enabled
& TEXTURE0_3D
) ? GL_TRUE
: GL_FALSE
;
803 case GL_TEXTURE_GEN_Q
:
805 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
806 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
808 case GL_TEXTURE_GEN_R
:
810 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
811 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
813 case GL_TEXTURE_GEN_S
:
815 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
816 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
818 case GL_TEXTURE_GEN_T
:
820 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
821 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
827 case GL_VERTEX_ARRAY
:
828 return ctx
->Array
.Vertex
.Enabled
;
829 case GL_NORMAL_ARRAY
:
830 return ctx
->Array
.Normal
.Enabled
;
832 return ctx
->Array
.Color
.Enabled
;
834 return ctx
->Array
.Index
.Enabled
;
835 case GL_TEXTURE_COORD_ARRAY
:
836 return ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
837 case GL_EDGE_FLAG_ARRAY
:
838 return ctx
->Array
.EdgeFlag
.Enabled
;
840 /* GL_HP_occlusion_test */
841 case GL_OCCLUSION_TEST_HP
:
842 if (ctx
->Extensions
.HP_occlusion_test
) {
843 return ctx
->Depth
.OcclusionTest
;
846 gl_error( ctx
, GL_INVALID_ENUM
, "glIsEnabled" );
850 /* GL_SGIS_pixel_texture */
851 case GL_PIXEL_TEXTURE_SGIS
:
852 return ctx
->Pixel
.PixelTextureEnabled
;
854 /* GL_SGIX_pixel_texture */
855 case GL_PIXEL_TEX_GEN_SGIX
:
856 return ctx
->Pixel
.PixelTextureEnabled
;
858 /* GL_SGI_color_table */
859 case GL_COLOR_TABLE_SGI
:
860 return ctx
->Pixel
.ColorTableEnabled
;
861 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
862 return ctx
->Pixel
.PostConvolutionColorTableEnabled
;
863 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
864 return ctx
->Pixel
.PostColorMatrixColorTableEnabled
;
866 /* GL_EXT_convolution */
867 case GL_CONVOLUTION_1D
:
868 return ctx
->Pixel
.Convolution1DEnabled
;
869 case GL_CONVOLUTION_2D
:
870 return ctx
->Pixel
.Convolution2DEnabled
;
871 case GL_SEPARABLE_2D
:
872 return ctx
->Pixel
.Separable2DEnabled
;
874 /* GL_ARB_texture_cube_map */
875 case GL_TEXTURE_CUBE_MAP_ARB
:
876 if (ctx
->Extensions
.ARB_texture_cube_map
) {
877 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
878 return (texUnit
->Enabled
& TEXTURE0_CUBE
) ? GL_TRUE
: GL_FALSE
;
881 gl_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled");
885 /* GL_MESA_sprite_point */
886 case GL_SPRITE_POINT_MESA
:
887 return ctx
->Point
.SpriteMode
;
890 gl_error( ctx
, GL_INVALID_ENUM
, "glIsEnabled" );
899 client_state( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
901 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
,
903 ? "glEnableClientState"
904 : "glDisableClientState") );
907 case GL_VERTEX_ARRAY
:
908 ctx
->Array
.Vertex
.Enabled
= state
;
910 case GL_NORMAL_ARRAY
:
911 ctx
->Array
.Normal
.Enabled
= state
;
914 ctx
->Array
.Color
.Enabled
= state
;
917 ctx
->Array
.Index
.Enabled
= state
;
919 case GL_TEXTURE_COORD_ARRAY
:
920 ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
= state
;
922 case GL_EDGE_FLAG_ARRAY
:
923 ctx
->Array
.EdgeFlag
.Enabled
= state
;
925 case GL_FOG_COORDINATE_ARRAY_EXT
:
926 ctx
->Array
.FogCoord
.Enabled
= state
;
928 case GL_SECONDARY_COLOR_ARRAY_EXT
:
929 ctx
->Array
.SecondaryColor
.Enabled
= state
;
932 gl_error( ctx
, GL_INVALID_ENUM
, "glEnable/DisableClientState" );
935 ctx
->NewState
|= _NEW_ARRAY
;
941 _mesa_EnableClientState( GLenum cap
)
943 GET_CURRENT_CONTEXT(ctx
);
944 client_state( ctx
, cap
, GL_TRUE
);
950 _mesa_DisableClientState( GLenum cap
)
952 GET_CURRENT_CONTEXT(ctx
);
953 client_state( ctx
, cap
, GL_FALSE
);