1 /* $Id: enable.c,v 1.39 2001/01/05 05:31:42 keithw 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"
48 client_state( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
55 var
= &ctx
->Array
.Vertex
.Enabled
;
56 flag
= _NEW_ARRAY_VERTEX
;
59 var
= &ctx
->Array
.Normal
.Enabled
;
60 flag
= _NEW_ARRAY_NORMAL
;
63 var
= &ctx
->Array
.Color
.Enabled
;
64 flag
= _NEW_ARRAY_COLOR
;
67 var
= &ctx
->Array
.Index
.Enabled
;
68 flag
= _NEW_ARRAY_INDEX
;
70 case GL_TEXTURE_COORD_ARRAY
:
71 var
= &ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
72 flag
= _NEW_ARRAY_TEXCOORD(ctx
->Array
.ActiveTexture
);
74 case GL_EDGE_FLAG_ARRAY
:
75 var
= &ctx
->Array
.EdgeFlag
.Enabled
;
76 flag
= _NEW_ARRAY_EDGEFLAG
;
78 case GL_FOG_COORDINATE_ARRAY_EXT
:
79 var
= &ctx
->Array
.FogCoord
.Enabled
;
80 flag
= _NEW_ARRAY_FOGCOORD
;
82 case GL_SECONDARY_COLOR_ARRAY_EXT
:
83 var
= &ctx
->Array
.SecondaryColor
.Enabled
;
84 flag
= _NEW_ARRAY_SECONDARYCOLOR
;
87 gl_error( ctx
, GL_INVALID_ENUM
, "glEnable/DisableClientState" );
94 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
95 ctx
->Array
.NewState
|= flag
;
99 ctx
->Array
._Enabled
|= flag
;
101 ctx
->Array
._Enabled
&= ~flag
;
103 if (ctx
->Driver
.Enable
) {
104 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
111 _mesa_EnableClientState( GLenum cap
)
113 GET_CURRENT_CONTEXT(ctx
);
114 ASSERT_OUTSIDE_BEGIN_END(ctx
);
115 client_state( ctx
, cap
, GL_TRUE
);
121 _mesa_DisableClientState( GLenum cap
)
123 GET_CURRENT_CONTEXT(ctx
);
124 ASSERT_OUTSIDE_BEGIN_END(ctx
);
125 client_state( ctx
, cap
, GL_FALSE
);
130 * Perform glEnable and glDisable calls.
132 void _mesa_set_enable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
134 if (MESA_VERBOSE
& VERBOSE_API
)
135 fprintf(stderr
, "%s %s (newstate is %x)\n",
136 state
? "glEnable" : "glDisable",
137 gl_lookup_enum_by_nr(cap
),
142 if (ctx
->Color
.AlphaEnabled
== state
)
144 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
145 ctx
->Color
.AlphaEnabled
= state
;
148 if (ctx
->Eval
.AutoNormal
== state
)
150 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
151 ctx
->Eval
.AutoNormal
= state
;
154 if (ctx
->Color
.BlendEnabled
== state
)
157 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
158 ctx
->Color
.BlendEnabled
= state
;
159 /* The following needed to accomodate 1.0 RGB logic op blending */
160 ctx
->Color
.ColorLogicOpEnabled
=
161 (ctx
->Color
.BlendEquation
== GL_LOGIC_OP
&& state
);
168 case GL_CLIP_PLANE5
: {
169 GLuint p
= cap
-GL_CLIP_PLANE0
;
171 if (ctx
->Transform
.ClipEnabled
[p
] == state
)
174 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
175 ctx
->Transform
.ClipEnabled
[p
] = state
;
178 ctx
->_Enabled
|= ENABLE_USERCLIP
;
179 ctx
->Transform
._AnyClip
++;
181 if (ctx
->ProjectionMatrix
.flags
& MAT_DIRTY
) {
182 _math_matrix_analyse( &ctx
->ProjectionMatrix
);
185 /* This derived state also calculated in clip.c and
186 * from gl_update_state() on changes to EyeUserPlane
187 * and ctx->ProjectionMatrix respectively.
189 gl_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
190 ctx
->Transform
.EyeUserPlane
[p
],
191 ctx
->ProjectionMatrix
.inv
);
193 if (--ctx
->Transform
._AnyClip
== 0)
194 ctx
->_Enabled
&= ~ENABLE_USERCLIP
;
198 case GL_COLOR_MATERIAL
:
199 if (ctx
->Light
.ColorMaterialEnabled
== state
)
201 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
202 ctx
->Light
.ColorMaterialEnabled
= state
;
204 FLUSH_CURRENT(ctx
, 0);
205 gl_update_color_material( ctx
, ctx
->Current
.Color
);
209 if (ctx
->Polygon
.CullFlag
== state
)
211 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
212 ctx
->Polygon
.CullFlag
= state
;
215 if (state
&& ctx
->Visual
.DepthBits
==0) {
216 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
219 if (ctx
->Depth
.Test
==state
)
221 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
222 ctx
->Depth
.Test
= state
;
226 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
228 if (ctx
->Color
.DitherFlag
==state
)
230 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
231 ctx
->Color
.DitherFlag
= state
;
234 if (ctx
->Fog
.Enabled
==state
)
236 FLUSH_VERTICES(ctx
, _NEW_FOG
);
237 ctx
->Fog
.Enabled
= state
;
238 ctx
->_Enabled
^= ENABLE_FOG
;
241 if (!ctx
->Extensions
.EXT_histogram
) {
242 gl_error(ctx
, GL_INVALID_ENUM
, "enable GL_HISTOGRAM");
245 if (ctx
->Pixel
.HistogramEnabled
== state
)
247 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
248 ctx
->Pixel
.HistogramEnabled
= state
;
258 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
260 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
261 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
263 insert_at_tail(&ctx
->Light
.EnabledList
,
264 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
267 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
271 if (ctx
->Light
.Enabled
== state
)
273 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
274 ctx
->Light
.Enabled
= state
;
275 ctx
->_Enabled
^= ENABLE_LIGHT
;
278 if (ctx
->Line
.SmoothFlag
== state
)
280 FLUSH_VERTICES(ctx
, _NEW_LINE
);
281 ctx
->Line
.SmoothFlag
= state
;
282 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
284 case GL_LINE_STIPPLE
:
285 if (ctx
->Line
.StippleFlag
== state
)
287 FLUSH_VERTICES(ctx
, _NEW_LINE
);
288 ctx
->Line
.StippleFlag
= state
;
289 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
291 case GL_INDEX_LOGIC_OP
:
292 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
294 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
295 ctx
->Color
.IndexLogicOpEnabled
= state
;
297 case GL_COLOR_LOGIC_OP
:
298 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
300 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
301 ctx
->Color
.ColorLogicOpEnabled
= state
;
303 case GL_MAP1_COLOR_4
:
304 if (ctx
->Eval
.Map1Color4
== state
)
306 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
307 ctx
->Eval
.Map1Color4
= state
;
310 if (ctx
->Eval
.Map1Index
== state
)
312 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
313 ctx
->Eval
.Map1Index
= state
;
316 if (ctx
->Eval
.Map1Normal
== state
)
318 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
319 ctx
->Eval
.Map1Normal
= state
;
321 case GL_MAP1_TEXTURE_COORD_1
:
322 if (ctx
->Eval
.Map1TextureCoord1
== state
)
324 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
325 ctx
->Eval
.Map1TextureCoord1
= state
;
327 case GL_MAP1_TEXTURE_COORD_2
:
328 if (ctx
->Eval
.Map1TextureCoord2
== state
)
330 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
331 ctx
->Eval
.Map1TextureCoord2
= state
;
333 case GL_MAP1_TEXTURE_COORD_3
:
334 if (ctx
->Eval
.Map1TextureCoord3
== state
)
336 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
337 ctx
->Eval
.Map1TextureCoord3
= state
;
339 case GL_MAP1_TEXTURE_COORD_4
:
340 if (ctx
->Eval
.Map1TextureCoord4
== state
)
342 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
343 ctx
->Eval
.Map1TextureCoord4
= state
;
345 case GL_MAP1_VERTEX_3
:
346 if (ctx
->Eval
.Map1Vertex3
== state
)
348 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
349 ctx
->Eval
.Map1Vertex3
= state
;
351 case GL_MAP1_VERTEX_4
:
352 if (ctx
->Eval
.Map1Vertex4
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
355 ctx
->Eval
.Map1Vertex4
= state
;
357 case GL_MAP2_COLOR_4
:
358 if (ctx
->Eval
.Map2Color4
== state
)
360 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
361 ctx
->Eval
.Map2Color4
= state
;
364 if (ctx
->Eval
.Map2Index
== state
)
366 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
367 ctx
->Eval
.Map2Index
= state
;
370 if (ctx
->Eval
.Map2Normal
== state
)
372 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
373 ctx
->Eval
.Map2Normal
= state
;
375 case GL_MAP2_TEXTURE_COORD_1
:
376 if (ctx
->Eval
.Map2TextureCoord1
== state
)
378 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
379 ctx
->Eval
.Map2TextureCoord1
= state
;
381 case GL_MAP2_TEXTURE_COORD_2
:
382 if (ctx
->Eval
.Map2TextureCoord2
== state
)
384 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
385 ctx
->Eval
.Map2TextureCoord2
= state
;
387 case GL_MAP2_TEXTURE_COORD_3
:
388 if (ctx
->Eval
.Map2TextureCoord3
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
391 ctx
->Eval
.Map2TextureCoord3
= state
;
393 case GL_MAP2_TEXTURE_COORD_4
:
394 if (ctx
->Eval
.Map2TextureCoord4
== state
)
396 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
397 ctx
->Eval
.Map2TextureCoord4
= state
;
399 case GL_MAP2_VERTEX_3
:
400 if (ctx
->Eval
.Map2Vertex3
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
403 ctx
->Eval
.Map2Vertex3
= state
;
405 case GL_MAP2_VERTEX_4
:
406 if (ctx
->Eval
.Map2Vertex4
== state
)
408 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
409 ctx
->Eval
.Map2Vertex4
= state
;
412 if (ctx
->Pixel
.MinMaxEnabled
== state
)
414 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
415 ctx
->Pixel
.MinMaxEnabled
= state
;
418 if (ctx
->Transform
.Normalize
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
421 ctx
->Transform
.Normalize
= state
;
422 ctx
->_Enabled
^= ENABLE_NORMALIZE
;
424 case GL_POINT_SMOOTH
:
425 if (ctx
->Point
.SmoothFlag
==state
)
427 FLUSH_VERTICES(ctx
, _NEW_POINT
);
428 ctx
->Point
.SmoothFlag
= state
;
429 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
431 case GL_POLYGON_SMOOTH
:
432 if (ctx
->Polygon
.SmoothFlag
==state
)
434 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
435 ctx
->Polygon
.SmoothFlag
= state
;
436 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
438 case GL_POLYGON_STIPPLE
:
439 if (ctx
->Polygon
.StippleFlag
==state
)
441 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
442 ctx
->Polygon
.StippleFlag
= state
;
443 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
445 case GL_POLYGON_OFFSET_POINT
:
446 if (ctx
->Polygon
.OffsetPoint
==state
)
448 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
449 ctx
->Polygon
.OffsetPoint
= state
;
451 case GL_POLYGON_OFFSET_LINE
:
452 if (ctx
->Polygon
.OffsetLine
==state
)
454 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
455 ctx
->Polygon
.OffsetLine
= state
;
457 case GL_POLYGON_OFFSET_FILL
:
458 /*case GL_POLYGON_OFFSET_EXT:*/
459 if (ctx
->Polygon
.OffsetFill
==state
)
461 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
462 ctx
->Polygon
.OffsetFill
= state
;
464 case GL_RESCALE_NORMAL_EXT
:
465 if (ctx
->Transform
.RescaleNormals
== state
)
467 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
468 ctx
->Transform
.RescaleNormals
= state
;
469 ctx
->_Enabled
^= ENABLE_RESCALE
;
471 case GL_SCISSOR_TEST
:
472 if (ctx
->Scissor
.Enabled
==state
)
474 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
475 ctx
->Scissor
.Enabled
= state
;
477 case GL_SHARED_TEXTURE_PALETTE_EXT
:
478 if (ctx
->Texture
.SharedPalette
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
481 ctx
->Texture
.SharedPalette
= state
;
483 case GL_STENCIL_TEST
:
484 if (state
&& ctx
->Visual
.StencilBits
==0) {
485 _mesa_warning(ctx
, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
488 if (ctx
->Stencil
.Enabled
==state
)
490 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
491 ctx
->Stencil
.Enabled
= state
;
492 ctx
->_TriangleCaps
^= DD_STENCIL
;
494 case GL_TEXTURE_1D
: {
495 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
496 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
497 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_1D
;
499 newenabled
|= TEXTURE0_1D
;
500 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
502 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
503 texUnit
->Enabled
= newenabled
;
506 case GL_TEXTURE_2D
: {
507 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
508 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
509 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_2D
;
511 newenabled
|= TEXTURE0_2D
;
512 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
514 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
515 texUnit
->Enabled
= newenabled
;
518 case GL_TEXTURE_3D
: {
519 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
520 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
521 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_3D
;
523 newenabled
|= TEXTURE0_3D
;
524 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
526 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
527 texUnit
->Enabled
= newenabled
;
530 case GL_TEXTURE_GEN_Q
: {
531 GLuint unit
= ctx
->Texture
.CurrentUnit
;
532 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
533 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
536 if (texUnit
->TexGenEnabled
== newenabled
)
538 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
539 texUnit
->TexGenEnabled
= newenabled
;
542 case GL_TEXTURE_GEN_R
: {
543 GLuint unit
= ctx
->Texture
.CurrentUnit
;
544 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
545 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
548 if (texUnit
->TexGenEnabled
== newenabled
)
550 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
551 texUnit
->TexGenEnabled
= newenabled
;
555 case GL_TEXTURE_GEN_S
: {
556 GLuint unit
= ctx
->Texture
.CurrentUnit
;
557 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
558 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
561 if (texUnit
->TexGenEnabled
== newenabled
)
563 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
564 texUnit
->TexGenEnabled
= newenabled
;
568 case GL_TEXTURE_GEN_T
: {
569 GLuint unit
= ctx
->Texture
.CurrentUnit
;
570 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
571 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
574 if (texUnit
->TexGenEnabled
== newenabled
)
576 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
577 texUnit
->TexGenEnabled
= newenabled
;
585 case GL_VERTEX_ARRAY
:
586 case GL_NORMAL_ARRAY
:
589 case GL_TEXTURE_COORD_ARRAY
:
590 case GL_EDGE_FLAG_ARRAY
:
591 case GL_FOG_COORDINATE_ARRAY_EXT
:
592 case GL_SECONDARY_COLOR_ARRAY_EXT
:
593 client_state( ctx
, cap
, state
);
596 /* GL_HP_occlusion_test */
597 case GL_OCCLUSION_TEST_HP
:
598 if (!ctx
->Extensions
.HP_occlusion_test
) {
599 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
602 if (ctx
->Depth
.OcclusionTest
== state
)
604 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
605 ctx
->Depth
.OcclusionTest
= state
;
607 ctx
->OcclusionResult
= ctx
->OcclusionResultSaved
;
609 ctx
->OcclusionResultSaved
= ctx
->OcclusionResult
;
612 /* GL_SGIS_pixel_texture */
613 case GL_PIXEL_TEXTURE_SGIS
:
614 if (!ctx
->Extensions
.SGIS_pixel_texture
) {
615 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
618 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
620 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
621 ctx
->Pixel
.PixelTextureEnabled
= state
;
624 /* GL_SGIX_pixel_texture */
625 case GL_PIXEL_TEX_GEN_SGIX
:
626 if (!ctx
->Extensions
.SGIX_pixel_texture
) {
627 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
630 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
632 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
633 ctx
->Pixel
.PixelTextureEnabled
= state
;
636 /* GL_SGI_color_table */
637 case GL_COLOR_TABLE_SGI
:
638 if (!ctx
->Extensions
.SGI_color_table
) {
639 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
642 if (ctx
->Pixel
.ColorTableEnabled
== state
)
644 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
645 ctx
->Pixel
.ColorTableEnabled
= state
;
647 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
648 if (!ctx
->Extensions
.SGI_color_table
) {
649 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
652 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
== state
)
654 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
655 ctx
->Pixel
.PostConvolutionColorTableEnabled
= state
;
657 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
658 if (!ctx
->Extensions
.SGI_color_table
) {
659 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
662 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
== state
)
664 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
665 ctx
->Pixel
.PostColorMatrixColorTableEnabled
= state
;
668 /* GL_EXT_convolution */
669 case GL_CONVOLUTION_1D
:
670 if (!ctx
->Extensions
.EXT_convolution
) {
671 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
674 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
676 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
677 ctx
->Pixel
.Convolution1DEnabled
= state
;
679 case GL_CONVOLUTION_2D
:
680 if (!ctx
->Extensions
.EXT_convolution
) {
681 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
684 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
686 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
687 ctx
->Pixel
.Convolution2DEnabled
= state
;
689 case GL_SEPARABLE_2D
:
690 if (!ctx
->Extensions
.EXT_convolution
) {
691 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
694 if (ctx
->Pixel
.Separable2DEnabled
== state
)
696 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
697 ctx
->Pixel
.Separable2DEnabled
= state
;
700 /* GL_ARB_texture_cube_map */
701 case GL_TEXTURE_CUBE_MAP_ARB
: {
702 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
703 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
704 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_CUBE
;
706 newenabled
|= TEXTURE0_CUBE
;
707 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
708 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
711 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
713 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
714 texUnit
->Enabled
= newenabled
;
717 /* GL_EXT_secondary_color */
718 case GL_COLOR_SUM_EXT
:
719 if (!ctx
->Extensions
.EXT_secondary_color
) {
720 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
723 if (ctx
->Fog
.ColorSumEnabled
== state
)
725 FLUSH_VERTICES(ctx
, _NEW_FOG
);
726 ctx
->Fog
.ColorSumEnabled
= state
;
727 ctx
->_TriangleCaps
^= DD_SEPERATE_SPECULAR
;
730 /* GL_MESA_sprite_point */
731 case GL_SPRITE_POINT_MESA
:
732 if (!ctx
->Extensions
.MESA_sprite_point
) {
733 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
736 if (ctx
->Point
.SpriteMode
== state
)
738 FLUSH_VERTICES(ctx
, _NEW_POINT
);
739 ctx
->Point
.SpriteMode
= state
;
743 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
747 if (ctx
->Driver
.Enable
) {
748 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
756 _mesa_Enable( GLenum cap
)
758 GET_CURRENT_CONTEXT(ctx
);
759 ASSERT_OUTSIDE_BEGIN_END(ctx
);
761 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
767 _mesa_Disable( GLenum cap
)
769 GET_CURRENT_CONTEXT(ctx
);
770 ASSERT_OUTSIDE_BEGIN_END(ctx
);
772 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
778 _mesa_IsEnabled( GLenum cap
)
780 GET_CURRENT_CONTEXT(ctx
);
783 return ctx
->Color
.AlphaEnabled
;
785 return ctx
->Eval
.AutoNormal
;
787 return ctx
->Color
.BlendEnabled
;
794 return ctx
->Transform
.ClipEnabled
[cap
-GL_CLIP_PLANE0
];
795 case GL_COLOR_MATERIAL
:
796 return ctx
->Light
.ColorMaterialEnabled
;
798 return ctx
->Polygon
.CullFlag
;
800 return ctx
->Depth
.Test
;
802 return ctx
->Color
.DitherFlag
;
804 return ctx
->Fog
.Enabled
;
806 if (ctx
->Extensions
.EXT_histogram
) {
807 return ctx
->Pixel
.HistogramEnabled
;
810 gl_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled");
814 return ctx
->Light
.Enabled
;
823 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
825 return ctx
->Line
.SmoothFlag
;
826 case GL_LINE_STIPPLE
:
827 return ctx
->Line
.StippleFlag
;
828 case GL_INDEX_LOGIC_OP
:
829 return ctx
->Color
.IndexLogicOpEnabled
;
830 case GL_COLOR_LOGIC_OP
:
831 return ctx
->Color
.ColorLogicOpEnabled
;
832 case GL_MAP1_COLOR_4
:
833 return ctx
->Eval
.Map1Color4
;
835 return ctx
->Eval
.Map1Index
;
837 return ctx
->Eval
.Map1Normal
;
838 case GL_MAP1_TEXTURE_COORD_1
:
839 return ctx
->Eval
.Map1TextureCoord1
;
840 case GL_MAP1_TEXTURE_COORD_2
:
841 return ctx
->Eval
.Map1TextureCoord2
;
842 case GL_MAP1_TEXTURE_COORD_3
:
843 return ctx
->Eval
.Map1TextureCoord3
;
844 case GL_MAP1_TEXTURE_COORD_4
:
845 return ctx
->Eval
.Map1TextureCoord4
;
846 case GL_MAP1_VERTEX_3
:
847 return ctx
->Eval
.Map1Vertex3
;
848 case GL_MAP1_VERTEX_4
:
849 return ctx
->Eval
.Map1Vertex4
;
850 case GL_MAP2_COLOR_4
:
851 return ctx
->Eval
.Map2Color4
;
853 return ctx
->Eval
.Map2Index
;
855 return ctx
->Eval
.Map2Normal
;
856 case GL_MAP2_TEXTURE_COORD_1
:
857 return ctx
->Eval
.Map2TextureCoord1
;
858 case GL_MAP2_TEXTURE_COORD_2
:
859 return ctx
->Eval
.Map2TextureCoord2
;
860 case GL_MAP2_TEXTURE_COORD_3
:
861 return ctx
->Eval
.Map2TextureCoord3
;
862 case GL_MAP2_TEXTURE_COORD_4
:
863 return ctx
->Eval
.Map2TextureCoord4
;
864 case GL_MAP2_VERTEX_3
:
865 return ctx
->Eval
.Map2Vertex3
;
866 case GL_MAP2_VERTEX_4
:
867 return ctx
->Eval
.Map2Vertex4
;
869 return ctx
->Pixel
.MinMaxEnabled
;
871 return ctx
->Transform
.Normalize
;
872 case GL_POINT_SMOOTH
:
873 return ctx
->Point
.SmoothFlag
;
874 case GL_POLYGON_SMOOTH
:
875 return ctx
->Polygon
.SmoothFlag
;
876 case GL_POLYGON_STIPPLE
:
877 return ctx
->Polygon
.StippleFlag
;
878 case GL_POLYGON_OFFSET_POINT
:
879 return ctx
->Polygon
.OffsetPoint
;
880 case GL_POLYGON_OFFSET_LINE
:
881 return ctx
->Polygon
.OffsetLine
;
882 case GL_POLYGON_OFFSET_FILL
:
883 /*case GL_POLYGON_OFFSET_EXT:*/
884 return ctx
->Polygon
.OffsetFill
;
885 case GL_RESCALE_NORMAL_EXT
:
886 return ctx
->Transform
.RescaleNormals
;
887 case GL_SCISSOR_TEST
:
888 return ctx
->Scissor
.Enabled
;
889 case GL_SHARED_TEXTURE_PALETTE_EXT
:
890 return ctx
->Texture
.SharedPalette
;
891 case GL_STENCIL_TEST
:
892 return ctx
->Stencil
.Enabled
;
895 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
896 return (texUnit
->Enabled
& TEXTURE0_1D
) ? GL_TRUE
: GL_FALSE
;
900 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
901 return (texUnit
->Enabled
& TEXTURE0_2D
) ? GL_TRUE
: GL_FALSE
;
905 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
906 return (texUnit
->Enabled
& TEXTURE0_3D
) ? GL_TRUE
: GL_FALSE
;
908 case GL_TEXTURE_GEN_Q
:
910 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
911 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
913 case GL_TEXTURE_GEN_R
:
915 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
916 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
918 case GL_TEXTURE_GEN_S
:
920 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
921 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
923 case GL_TEXTURE_GEN_T
:
925 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
926 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
932 case GL_VERTEX_ARRAY
:
933 return ctx
->Array
.Vertex
.Enabled
;
934 case GL_NORMAL_ARRAY
:
935 return ctx
->Array
.Normal
.Enabled
;
937 return ctx
->Array
.Color
.Enabled
;
939 return ctx
->Array
.Index
.Enabled
;
940 case GL_TEXTURE_COORD_ARRAY
:
941 return ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
942 case GL_EDGE_FLAG_ARRAY
:
943 return ctx
->Array
.EdgeFlag
.Enabled
;
945 /* GL_HP_occlusion_test */
946 case GL_OCCLUSION_TEST_HP
:
947 if (ctx
->Extensions
.HP_occlusion_test
) {
948 return ctx
->Depth
.OcclusionTest
;
951 gl_error( ctx
, GL_INVALID_ENUM
, "glIsEnabled" );
955 /* GL_SGIS_pixel_texture */
956 case GL_PIXEL_TEXTURE_SGIS
:
957 return ctx
->Pixel
.PixelTextureEnabled
;
959 /* GL_SGIX_pixel_texture */
960 case GL_PIXEL_TEX_GEN_SGIX
:
961 return ctx
->Pixel
.PixelTextureEnabled
;
963 /* GL_SGI_color_table */
964 case GL_COLOR_TABLE_SGI
:
965 return ctx
->Pixel
.ColorTableEnabled
;
966 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
967 return ctx
->Pixel
.PostConvolutionColorTableEnabled
;
968 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
969 return ctx
->Pixel
.PostColorMatrixColorTableEnabled
;
971 /* GL_EXT_convolution */
972 case GL_CONVOLUTION_1D
:
973 return ctx
->Pixel
.Convolution1DEnabled
;
974 case GL_CONVOLUTION_2D
:
975 return ctx
->Pixel
.Convolution2DEnabled
;
976 case GL_SEPARABLE_2D
:
977 return ctx
->Pixel
.Separable2DEnabled
;
979 /* GL_ARB_texture_cube_map */
980 case GL_TEXTURE_CUBE_MAP_ARB
:
981 if (ctx
->Extensions
.ARB_texture_cube_map
) {
982 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
983 return (texUnit
->Enabled
& TEXTURE0_CUBE
) ? GL_TRUE
: GL_FALSE
;
986 gl_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled");
990 /* GL_MESA_sprite_point */
991 case GL_SPRITE_POINT_MESA
:
992 return ctx
->Point
.SpriteMode
;
995 gl_error( ctx
, GL_INVALID_ENUM
, "glIsEnabled" );