1 /* $Id: enable.c,v 1.37 2000/12/26 05:09:28 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" );
93 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
94 ctx
->Array
.NewState
|= flag
;
98 ctx
->Array
._Enabled
|= flag
;
100 ctx
->Array
._Enabled
&= ~flag
;
102 if (ctx
->Driver
.Enable
) {
103 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
110 _mesa_EnableClientState( GLenum cap
)
112 GET_CURRENT_CONTEXT(ctx
);
113 ASSERT_OUTSIDE_BEGIN_END(ctx
);
114 client_state( ctx
, cap
, GL_TRUE
);
120 _mesa_DisableClientState( GLenum cap
)
122 GET_CURRENT_CONTEXT(ctx
);
123 ASSERT_OUTSIDE_BEGIN_END(ctx
);
124 client_state( ctx
, cap
, GL_FALSE
);
129 * Perform glEnable and glDisable calls.
131 void _mesa_set_enable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
133 if (MESA_VERBOSE
& VERBOSE_API
)
134 fprintf(stderr
, "%s %s (newstate is %x)\n",
135 state
? "glEnable" : "glDisable",
136 gl_lookup_enum_by_nr(cap
),
141 if (ctx
->Color
.AlphaEnabled
== state
)
143 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
144 ctx
->Color
.AlphaEnabled
= state
;
147 if (ctx
->Eval
.AutoNormal
== state
)
149 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
150 ctx
->Eval
.AutoNormal
= state
;
153 if (ctx
->Color
.BlendEnabled
== state
)
156 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
157 ctx
->Color
.BlendEnabled
= state
;
158 /* The following needed to accomodate 1.0 RGB logic op blending */
159 ctx
->Color
.ColorLogicOpEnabled
=
160 (ctx
->Color
.BlendEquation
== GL_LOGIC_OP
&& state
);
167 case GL_CLIP_PLANE5
: {
168 GLuint p
= cap
-GL_CLIP_PLANE0
;
170 if (ctx
->Transform
.ClipEnabled
[p
] == state
)
173 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
174 ctx
->Transform
.ClipEnabled
[p
] = state
;
177 ctx
->_Enabled
|= ENABLE_USERCLIP
;
178 ctx
->Transform
._AnyClip
++;
180 if (ctx
->ProjectionMatrix
.flags
& MAT_DIRTY
) {
181 _math_matrix_analyse( &ctx
->ProjectionMatrix
);
184 /* This derived state also calculated in clip.c and
185 * from gl_update_state() on changes to EyeUserPlane
186 * and ctx->ProjectionMatrix respectively.
188 gl_transform_vector( ctx
->Transform
._ClipUserPlane
[p
],
189 ctx
->Transform
.EyeUserPlane
[p
],
190 ctx
->ProjectionMatrix
.inv
);
192 if (--ctx
->Transform
._AnyClip
== 0)
193 ctx
->_Enabled
&= ~ENABLE_USERCLIP
;
197 case GL_COLOR_MATERIAL
:
198 if (ctx
->Light
.ColorMaterialEnabled
== state
)
200 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
201 ctx
->Light
.ColorMaterialEnabled
= state
;
203 FLUSH_CURRENT(ctx
, 0);
204 gl_update_color_material( ctx
, ctx
->Current
.Color
);
208 if (ctx
->Polygon
.CullFlag
== state
)
210 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
211 ctx
->Polygon
.CullFlag
= state
;
214 if (state
&& ctx
->Visual
.DepthBits
==0) {
215 _mesa_warning(ctx
,"glEnable(GL_DEPTH_TEST) but no depth buffer");
218 if (ctx
->Depth
.Test
==state
)
220 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
221 ctx
->Depth
.Test
= state
;
225 state
= GL_FALSE
; /* MESA_NO_DITHER env var */
227 if (ctx
->Color
.DitherFlag
==state
)
229 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
230 ctx
->Color
.DitherFlag
= state
;
233 if (ctx
->Fog
.Enabled
==state
)
235 FLUSH_VERTICES(ctx
, _NEW_FOG
);
236 ctx
->Fog
.Enabled
= state
;
237 ctx
->_Enabled
^= ENABLE_FOG
;
240 if (!ctx
->Extensions
.EXT_histogram
) {
241 gl_error(ctx
, GL_INVALID_ENUM
, "enable GL_HISTOGRAM");
244 if (ctx
->Pixel
.HistogramEnabled
== state
)
246 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
247 ctx
->Pixel
.HistogramEnabled
= state
;
257 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
259 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
260 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
262 insert_at_tail(&ctx
->Light
.EnabledList
,
263 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
266 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
270 if (ctx
->Light
.Enabled
== state
)
272 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
273 ctx
->Light
.Enabled
= state
;
274 ctx
->_Enabled
^= ENABLE_LIGHT
;
277 if (ctx
->Line
.SmoothFlag
== state
)
279 FLUSH_VERTICES(ctx
, _NEW_LINE
);
280 ctx
->Line
.SmoothFlag
= state
;
281 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
283 case GL_LINE_STIPPLE
:
284 if (ctx
->Line
.StippleFlag
== state
)
286 FLUSH_VERTICES(ctx
, _NEW_LINE
);
287 ctx
->Line
.StippleFlag
= state
;
288 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
290 case GL_INDEX_LOGIC_OP
:
291 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
293 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
294 ctx
->Color
.IndexLogicOpEnabled
= state
;
296 case GL_COLOR_LOGIC_OP
:
297 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
299 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
300 ctx
->Color
.ColorLogicOpEnabled
= state
;
302 case GL_MAP1_COLOR_4
:
303 if (ctx
->Eval
.Map1Color4
== state
)
305 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
306 ctx
->Eval
.Map1Color4
= state
;
309 if (ctx
->Eval
.Map1Index
== state
)
311 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
312 ctx
->Eval
.Map1Index
= state
;
315 if (ctx
->Eval
.Map1Normal
== state
)
317 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
318 ctx
->Eval
.Map1Normal
= state
;
320 case GL_MAP1_TEXTURE_COORD_1
:
321 if (ctx
->Eval
.Map1TextureCoord1
== state
)
323 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
324 ctx
->Eval
.Map1TextureCoord1
= state
;
326 case GL_MAP1_TEXTURE_COORD_2
:
327 if (ctx
->Eval
.Map1TextureCoord2
== state
)
329 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
330 ctx
->Eval
.Map1TextureCoord2
= state
;
332 case GL_MAP1_TEXTURE_COORD_3
:
333 if (ctx
->Eval
.Map1TextureCoord3
== state
)
335 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
336 ctx
->Eval
.Map1TextureCoord3
= state
;
338 case GL_MAP1_TEXTURE_COORD_4
:
339 if (ctx
->Eval
.Map1TextureCoord4
== state
)
341 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
342 ctx
->Eval
.Map1TextureCoord4
= state
;
344 case GL_MAP1_VERTEX_3
:
345 if (ctx
->Eval
.Map1Vertex3
== state
)
347 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
348 ctx
->Eval
.Map1Vertex3
= state
;
350 case GL_MAP1_VERTEX_4
:
351 if (ctx
->Eval
.Map1Vertex4
== state
)
353 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
354 ctx
->Eval
.Map1Vertex4
= state
;
356 case GL_MAP2_COLOR_4
:
357 if (ctx
->Eval
.Map2Color4
== state
)
359 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
360 ctx
->Eval
.Map2Color4
= state
;
363 if (ctx
->Eval
.Map2Index
== state
)
365 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
366 ctx
->Eval
.Map2Index
= state
;
369 if (ctx
->Eval
.Map2Normal
== state
)
371 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
372 ctx
->Eval
.Map2Normal
= state
;
374 case GL_MAP2_TEXTURE_COORD_1
:
375 if (ctx
->Eval
.Map2TextureCoord1
== state
)
377 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
378 ctx
->Eval
.Map2TextureCoord1
= state
;
380 case GL_MAP2_TEXTURE_COORD_2
:
381 if (ctx
->Eval
.Map2TextureCoord2
== state
)
383 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
384 ctx
->Eval
.Map2TextureCoord2
= state
;
386 case GL_MAP2_TEXTURE_COORD_3
:
387 if (ctx
->Eval
.Map2TextureCoord3
== state
)
389 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
390 ctx
->Eval
.Map2TextureCoord3
= state
;
392 case GL_MAP2_TEXTURE_COORD_4
:
393 if (ctx
->Eval
.Map2TextureCoord4
== state
)
395 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
396 ctx
->Eval
.Map2TextureCoord4
= state
;
398 case GL_MAP2_VERTEX_3
:
399 if (ctx
->Eval
.Map2Vertex3
== state
)
401 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
402 ctx
->Eval
.Map2Vertex3
= state
;
404 case GL_MAP2_VERTEX_4
:
405 if (ctx
->Eval
.Map2Vertex4
== state
)
407 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
408 ctx
->Eval
.Map2Vertex4
= state
;
411 if (ctx
->Pixel
.MinMaxEnabled
== state
)
413 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
414 ctx
->Pixel
.MinMaxEnabled
= state
;
417 if (ctx
->Transform
.Normalize
== state
)
419 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
420 ctx
->Transform
.Normalize
= state
;
421 ctx
->_Enabled
^= ENABLE_NORMALIZE
;
423 case GL_POINT_SMOOTH
:
424 if (ctx
->Point
.SmoothFlag
==state
)
426 FLUSH_VERTICES(ctx
, _NEW_POINT
);
427 ctx
->Point
.SmoothFlag
= state
;
428 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
430 case GL_POLYGON_SMOOTH
:
431 if (ctx
->Polygon
.SmoothFlag
==state
)
433 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
434 ctx
->Polygon
.SmoothFlag
= state
;
435 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
437 case GL_POLYGON_STIPPLE
:
438 if (ctx
->Polygon
.StippleFlag
==state
)
440 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
441 ctx
->Polygon
.StippleFlag
= state
;
442 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
444 case GL_POLYGON_OFFSET_POINT
:
445 if (ctx
->Polygon
.OffsetPoint
==state
)
447 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
448 ctx
->Polygon
.OffsetPoint
= state
;
450 case GL_POLYGON_OFFSET_LINE
:
451 if (ctx
->Polygon
.OffsetLine
==state
)
453 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
454 ctx
->Polygon
.OffsetLine
= state
;
456 case GL_POLYGON_OFFSET_FILL
:
457 /*case GL_POLYGON_OFFSET_EXT:*/
458 if (ctx
->Polygon
.OffsetFill
==state
)
460 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
461 ctx
->Polygon
.OffsetFill
= state
;
463 case GL_RESCALE_NORMAL_EXT
:
464 if (ctx
->Transform
.RescaleNormals
== state
)
466 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
467 ctx
->Transform
.RescaleNormals
= state
;
468 ctx
->_Enabled
^= ENABLE_RESCALE
;
470 case GL_SCISSOR_TEST
:
471 if (ctx
->Scissor
.Enabled
==state
)
473 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
474 ctx
->Scissor
.Enabled
= state
;
476 case GL_SHARED_TEXTURE_PALETTE_EXT
:
477 if (ctx
->Texture
.SharedPalette
== state
)
479 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
480 ctx
->Texture
.SharedPalette
= state
;
482 case GL_STENCIL_TEST
:
483 if (state
&& ctx
->Visual
.StencilBits
==0) {
484 _mesa_warning(ctx
, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
487 if (ctx
->Stencil
.Enabled
==state
)
489 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
490 ctx
->Stencil
.Enabled
= state
;
491 ctx
->_TriangleCaps
^= DD_STENCIL
;
493 case GL_TEXTURE_1D
: {
494 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
495 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
496 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_1D
;
498 newenabled
|= TEXTURE0_1D
;
499 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
501 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
502 texUnit
->Enabled
= newenabled
;
505 case GL_TEXTURE_2D
: {
506 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
507 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
508 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_2D
;
510 newenabled
|= TEXTURE0_2D
;
511 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
513 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
514 texUnit
->Enabled
= newenabled
;
517 case GL_TEXTURE_3D
: {
518 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
519 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
520 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_3D
;
522 newenabled
|= TEXTURE0_3D
;
523 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
525 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
526 texUnit
->Enabled
= newenabled
;
529 case GL_TEXTURE_GEN_Q
: {
530 GLuint unit
= ctx
->Texture
.CurrentUnit
;
531 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
532 GLuint newenabled
= texUnit
->TexGenEnabled
& ~Q_BIT
;
535 if (texUnit
->TexGenEnabled
== newenabled
)
537 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
538 texUnit
->TexGenEnabled
= newenabled
;
541 case GL_TEXTURE_GEN_R
: {
542 GLuint unit
= ctx
->Texture
.CurrentUnit
;
543 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
544 GLuint newenabled
= texUnit
->TexGenEnabled
& ~R_BIT
;
547 if (texUnit
->TexGenEnabled
== newenabled
)
549 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
550 texUnit
->TexGenEnabled
= newenabled
;
554 case GL_TEXTURE_GEN_S
: {
555 GLuint unit
= ctx
->Texture
.CurrentUnit
;
556 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
557 GLuint newenabled
= texUnit
->TexGenEnabled
& ~S_BIT
;
560 if (texUnit
->TexGenEnabled
== newenabled
)
562 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
563 texUnit
->TexGenEnabled
= newenabled
;
567 case GL_TEXTURE_GEN_T
: {
568 GLuint unit
= ctx
->Texture
.CurrentUnit
;
569 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
570 GLuint newenabled
= texUnit
->TexGenEnabled
& ~T_BIT
;
573 if (texUnit
->TexGenEnabled
== newenabled
)
575 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
576 texUnit
->TexGenEnabled
= newenabled
;
584 case GL_VERTEX_ARRAY
:
585 case GL_NORMAL_ARRAY
:
588 case GL_TEXTURE_COORD_ARRAY
:
589 case GL_EDGE_FLAG_ARRAY
:
590 case GL_FOG_COORDINATE_ARRAY_EXT
:
591 case GL_SECONDARY_COLOR_ARRAY_EXT
:
592 client_state( ctx
, cap
, state
);
595 /* GL_HP_occlusion_test */
596 case GL_OCCLUSION_TEST_HP
:
597 if (!ctx
->Extensions
.HP_occlusion_test
) {
598 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
601 if (ctx
->Depth
.OcclusionTest
== state
)
603 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
604 ctx
->Depth
.OcclusionTest
= state
;
606 ctx
->OcclusionResult
= ctx
->OcclusionResultSaved
;
608 ctx
->OcclusionResultSaved
= ctx
->OcclusionResult
;
611 /* GL_SGIS_pixel_texture */
612 case GL_PIXEL_TEXTURE_SGIS
:
613 if (!ctx
->Extensions
.SGIS_pixel_texture
) {
614 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
617 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
619 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
620 ctx
->Pixel
.PixelTextureEnabled
= state
;
623 /* GL_SGIX_pixel_texture */
624 case GL_PIXEL_TEX_GEN_SGIX
:
625 if (!ctx
->Extensions
.SGIX_pixel_texture
) {
626 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
629 if (ctx
->Pixel
.PixelTextureEnabled
== state
)
631 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
632 ctx
->Pixel
.PixelTextureEnabled
= state
;
635 /* GL_SGI_color_table */
636 case GL_COLOR_TABLE_SGI
:
637 if (!ctx
->Extensions
.SGI_color_table
) {
638 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
641 if (ctx
->Pixel
.ColorTableEnabled
== state
)
643 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
644 ctx
->Pixel
.ColorTableEnabled
= state
;
646 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
647 if (!ctx
->Extensions
.SGI_color_table
) {
648 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
651 if (ctx
->Pixel
.PostConvolutionColorTableEnabled
== state
)
653 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
654 ctx
->Pixel
.PostConvolutionColorTableEnabled
= state
;
656 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
657 if (!ctx
->Extensions
.SGI_color_table
) {
658 gl_error( ctx
, GL_INVALID_ENUM
, state
? "glEnable": "glDisable" );
661 if (ctx
->Pixel
.PostColorMatrixColorTableEnabled
== state
)
663 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
664 ctx
->Pixel
.PostColorMatrixColorTableEnabled
= state
;
667 /* GL_EXT_convolution */
668 case GL_CONVOLUTION_1D
:
669 if (!ctx
->Extensions
.EXT_convolution
) {
670 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
673 if (ctx
->Pixel
.Convolution1DEnabled
== state
)
675 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
676 ctx
->Pixel
.Convolution1DEnabled
= state
;
678 case GL_CONVOLUTION_2D
:
679 if (!ctx
->Extensions
.EXT_convolution
) {
680 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
683 if (ctx
->Pixel
.Convolution2DEnabled
== state
)
685 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
686 ctx
->Pixel
.Convolution2DEnabled
= state
;
688 case GL_SEPARABLE_2D
:
689 if (!ctx
->Extensions
.EXT_convolution
) {
690 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
693 if (ctx
->Pixel
.Separable2DEnabled
== state
)
695 FLUSH_VERTICES(ctx
, _NEW_PIXEL
);
696 ctx
->Pixel
.Separable2DEnabled
= state
;
699 /* GL_ARB_texture_cube_map */
700 case GL_TEXTURE_CUBE_MAP_ARB
: {
701 const GLuint curr
= ctx
->Texture
.CurrentUnit
;
702 struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[curr
];
703 GLuint newenabled
= texUnit
->Enabled
& ~TEXTURE0_CUBE
;
705 newenabled
|= TEXTURE0_CUBE
;
706 if (!ctx
->Extensions
.ARB_texture_cube_map
) {
707 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
710 if (!ctx
->Visual
.RGBAflag
|| texUnit
->Enabled
== newenabled
)
712 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
713 texUnit
->Enabled
= newenabled
;
716 /* GL_EXT_secondary_color */
717 case GL_COLOR_SUM_EXT
:
718 if (!ctx
->Extensions
.EXT_secondary_color
) {
719 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
722 if (ctx
->Fog
.ColorSumEnabled
== state
)
724 FLUSH_VERTICES(ctx
, _NEW_FOG
);
725 ctx
->Fog
.ColorSumEnabled
= state
;
726 ctx
->_TriangleCaps
^= DD_SEPERATE_SPECULAR
;
729 /* GL_MESA_sprite_point */
730 case GL_SPRITE_POINT_MESA
:
731 if (!ctx
->Extensions
.MESA_sprite_point
) {
732 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
735 if (ctx
->Point
.SpriteMode
== state
)
737 FLUSH_VERTICES(ctx
, _NEW_POINT
);
738 ctx
->Point
.SpriteMode
= state
;
742 gl_error(ctx
, GL_INVALID_ENUM
, state
? "glEnable" : "glDisable");
746 if (ctx
->Driver
.Enable
) {
747 (*ctx
->Driver
.Enable
)( ctx
, cap
, state
);
755 _mesa_Enable( GLenum cap
)
757 GET_CURRENT_CONTEXT(ctx
);
758 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
764 _mesa_Disable( GLenum cap
)
766 GET_CURRENT_CONTEXT(ctx
);
767 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
773 _mesa_IsEnabled( GLenum cap
)
775 GET_CURRENT_CONTEXT(ctx
);
778 return ctx
->Color
.AlphaEnabled
;
780 return ctx
->Eval
.AutoNormal
;
782 return ctx
->Color
.BlendEnabled
;
789 return ctx
->Transform
.ClipEnabled
[cap
-GL_CLIP_PLANE0
];
790 case GL_COLOR_MATERIAL
:
791 return ctx
->Light
.ColorMaterialEnabled
;
793 return ctx
->Polygon
.CullFlag
;
795 return ctx
->Depth
.Test
;
797 return ctx
->Color
.DitherFlag
;
799 return ctx
->Fog
.Enabled
;
801 if (ctx
->Extensions
.EXT_histogram
) {
802 return ctx
->Pixel
.HistogramEnabled
;
805 gl_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled");
809 return ctx
->Light
.Enabled
;
818 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
820 return ctx
->Line
.SmoothFlag
;
821 case GL_LINE_STIPPLE
:
822 return ctx
->Line
.StippleFlag
;
823 case GL_INDEX_LOGIC_OP
:
824 return ctx
->Color
.IndexLogicOpEnabled
;
825 case GL_COLOR_LOGIC_OP
:
826 return ctx
->Color
.ColorLogicOpEnabled
;
827 case GL_MAP1_COLOR_4
:
828 return ctx
->Eval
.Map1Color4
;
830 return ctx
->Eval
.Map1Index
;
832 return ctx
->Eval
.Map1Normal
;
833 case GL_MAP1_TEXTURE_COORD_1
:
834 return ctx
->Eval
.Map1TextureCoord1
;
835 case GL_MAP1_TEXTURE_COORD_2
:
836 return ctx
->Eval
.Map1TextureCoord2
;
837 case GL_MAP1_TEXTURE_COORD_3
:
838 return ctx
->Eval
.Map1TextureCoord3
;
839 case GL_MAP1_TEXTURE_COORD_4
:
840 return ctx
->Eval
.Map1TextureCoord4
;
841 case GL_MAP1_VERTEX_3
:
842 return ctx
->Eval
.Map1Vertex3
;
843 case GL_MAP1_VERTEX_4
:
844 return ctx
->Eval
.Map1Vertex4
;
845 case GL_MAP2_COLOR_4
:
846 return ctx
->Eval
.Map2Color4
;
848 return ctx
->Eval
.Map2Index
;
850 return ctx
->Eval
.Map2Normal
;
851 case GL_MAP2_TEXTURE_COORD_1
:
852 return ctx
->Eval
.Map2TextureCoord1
;
853 case GL_MAP2_TEXTURE_COORD_2
:
854 return ctx
->Eval
.Map2TextureCoord2
;
855 case GL_MAP2_TEXTURE_COORD_3
:
856 return ctx
->Eval
.Map2TextureCoord3
;
857 case GL_MAP2_TEXTURE_COORD_4
:
858 return ctx
->Eval
.Map2TextureCoord4
;
859 case GL_MAP2_VERTEX_3
:
860 return ctx
->Eval
.Map2Vertex3
;
861 case GL_MAP2_VERTEX_4
:
862 return ctx
->Eval
.Map2Vertex4
;
864 return ctx
->Pixel
.MinMaxEnabled
;
866 return ctx
->Transform
.Normalize
;
867 case GL_POINT_SMOOTH
:
868 return ctx
->Point
.SmoothFlag
;
869 case GL_POLYGON_SMOOTH
:
870 return ctx
->Polygon
.SmoothFlag
;
871 case GL_POLYGON_STIPPLE
:
872 return ctx
->Polygon
.StippleFlag
;
873 case GL_POLYGON_OFFSET_POINT
:
874 return ctx
->Polygon
.OffsetPoint
;
875 case GL_POLYGON_OFFSET_LINE
:
876 return ctx
->Polygon
.OffsetLine
;
877 case GL_POLYGON_OFFSET_FILL
:
878 /*case GL_POLYGON_OFFSET_EXT:*/
879 return ctx
->Polygon
.OffsetFill
;
880 case GL_RESCALE_NORMAL_EXT
:
881 return ctx
->Transform
.RescaleNormals
;
882 case GL_SCISSOR_TEST
:
883 return ctx
->Scissor
.Enabled
;
884 case GL_SHARED_TEXTURE_PALETTE_EXT
:
885 return ctx
->Texture
.SharedPalette
;
886 case GL_STENCIL_TEST
:
887 return ctx
->Stencil
.Enabled
;
890 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
891 return (texUnit
->Enabled
& TEXTURE0_1D
) ? GL_TRUE
: GL_FALSE
;
895 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
896 return (texUnit
->Enabled
& TEXTURE0_2D
) ? GL_TRUE
: GL_FALSE
;
900 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
901 return (texUnit
->Enabled
& TEXTURE0_3D
) ? GL_TRUE
: GL_FALSE
;
903 case GL_TEXTURE_GEN_Q
:
905 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
906 return (texUnit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
;
908 case GL_TEXTURE_GEN_R
:
910 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
911 return (texUnit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
;
913 case GL_TEXTURE_GEN_S
:
915 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
916 return (texUnit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
;
918 case GL_TEXTURE_GEN_T
:
920 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
921 return (texUnit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
;
927 case GL_VERTEX_ARRAY
:
928 return ctx
->Array
.Vertex
.Enabled
;
929 case GL_NORMAL_ARRAY
:
930 return ctx
->Array
.Normal
.Enabled
;
932 return ctx
->Array
.Color
.Enabled
;
934 return ctx
->Array
.Index
.Enabled
;
935 case GL_TEXTURE_COORD_ARRAY
:
936 return ctx
->Array
.TexCoord
[ctx
->Array
.ActiveTexture
].Enabled
;
937 case GL_EDGE_FLAG_ARRAY
:
938 return ctx
->Array
.EdgeFlag
.Enabled
;
940 /* GL_HP_occlusion_test */
941 case GL_OCCLUSION_TEST_HP
:
942 if (ctx
->Extensions
.HP_occlusion_test
) {
943 return ctx
->Depth
.OcclusionTest
;
946 gl_error( ctx
, GL_INVALID_ENUM
, "glIsEnabled" );
950 /* GL_SGIS_pixel_texture */
951 case GL_PIXEL_TEXTURE_SGIS
:
952 return ctx
->Pixel
.PixelTextureEnabled
;
954 /* GL_SGIX_pixel_texture */
955 case GL_PIXEL_TEX_GEN_SGIX
:
956 return ctx
->Pixel
.PixelTextureEnabled
;
958 /* GL_SGI_color_table */
959 case GL_COLOR_TABLE_SGI
:
960 return ctx
->Pixel
.ColorTableEnabled
;
961 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI
:
962 return ctx
->Pixel
.PostConvolutionColorTableEnabled
;
963 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI
:
964 return ctx
->Pixel
.PostColorMatrixColorTableEnabled
;
966 /* GL_EXT_convolution */
967 case GL_CONVOLUTION_1D
:
968 return ctx
->Pixel
.Convolution1DEnabled
;
969 case GL_CONVOLUTION_2D
:
970 return ctx
->Pixel
.Convolution2DEnabled
;
971 case GL_SEPARABLE_2D
:
972 return ctx
->Pixel
.Separable2DEnabled
;
974 /* GL_ARB_texture_cube_map */
975 case GL_TEXTURE_CUBE_MAP_ARB
:
976 if (ctx
->Extensions
.ARB_texture_cube_map
) {
977 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
978 return (texUnit
->Enabled
& TEXTURE0_CUBE
) ? GL_TRUE
: GL_FALSE
;
981 gl_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled");
985 /* GL_MESA_sprite_point */
986 case GL_SPRITE_POINT_MESA
:
987 return ctx
->Point
.SpriteMode
;
990 gl_error( ctx
, GL_INVALID_ENUM
, "glIsEnabled" );