enable.c revision 06ac59281bdad6679fb1941e31e3c4df1c12cede
1/* $Id: enable.c,v 1.9 1999/11/10 06:29:44 keithw Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version:  3.1
6 *
7 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27
28/* $XFree86: xc/lib/GL/mesa/src/enable.c,v 1.3 1999/04/04 00:20:23 dawes Exp $ */
29
30#ifdef PC_HEADER
31#include "all.h"
32#else
33#ifndef XFree86Server
34#include <stdio.h>
35#include <string.h>
36#else
37#include "GL/xf86glx.h"
38#endif
39#include "context.h"
40#include "enable.h"
41#include "light.h"
42#include "macros.h"
43#include "matrix.h"
44#include "mmath.h"
45#include "simple_list.h"
46#include "types.h"
47#include "vbfill.h"
48#include "xform.h"
49#include "enums.h"
50#endif
51
52
53
54/*
55 * Perform glEnable and glDisable calls.
56 */
57void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
58{
59   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" );
60
61   if (MESA_VERBOSE & VERBOSE_API)
62      fprintf(stderr, "%s %s (newstate is %x)\n",
63	      state ? "glEnable" : "glDisable",
64	      gl_lookup_enum_by_nr(cap),
65	      ctx->NewState);
66
67   switch (cap) {
68      case GL_ALPHA_TEST:
69         if (ctx->Color.AlphaEnabled!=state) {
70            ctx->Color.AlphaEnabled = state;
71            ctx->NewState |= NEW_RASTER_OPS;
72         }
73	 break;
74      case GL_AUTO_NORMAL:
75	 ctx->Eval.AutoNormal = state;
76	 break;
77      case GL_BLEND:
78         if (ctx->Color.BlendEnabled!=state) {
79            ctx->Color.BlendEnabled = state;
80            /* The following needed to accomodate 1.0 RGB logic op blending */
81            if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) {
82               ctx->Color.ColorLogicOpEnabled = GL_TRUE;
83            }
84            else {
85               ctx->Color.ColorLogicOpEnabled = GL_FALSE;
86            }
87            ctx->NewState |= NEW_RASTER_OPS;
88         }
89	 break;
90      case GL_CLIP_PLANE0:
91      case GL_CLIP_PLANE1:
92      case GL_CLIP_PLANE2:
93      case GL_CLIP_PLANE3:
94      case GL_CLIP_PLANE4:
95      case GL_CLIP_PLANE5:
96	 if (cap >= GL_CLIP_PLANE0 &&
97	     cap <= GL_CLIP_PLANE5 &&
98	     ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] != state)
99	 {
100	    GLuint p = cap-GL_CLIP_PLANE0;
101
102	    ctx->Transform.ClipEnabled[p] = state;
103	    ctx->NewState |= NEW_USER_CLIP;
104
105	    if (state) {
106	       ctx->Enabled |= ENABLE_USERCLIP;
107	       ctx->Transform.AnyClip++;
108
109	       if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) {
110		  gl_matrix_analyze( &ctx->ProjectionMatrix );
111	       }
112
113	       gl_transform_vector( ctx->Transform.ClipUserPlane[p],
114				    ctx->Transform.EyeUserPlane[p],
115				    ctx->ProjectionMatrix.inv );
116	    } else {
117	       if (--ctx->Transform.AnyClip == 0)
118		  ctx->Enabled &= ~ENABLE_USERCLIP;
119	    }
120	 }
121	 break;
122      case GL_COLOR_MATERIAL:
123         if (ctx->Light.ColorMaterialEnabled!=state) {
124            ctx->Light.ColorMaterialEnabled = state;
125	    ctx->NewState |= NEW_LIGHTING;
126	    if (state)
127	       gl_update_color_material( ctx, ctx->Current.ByteColor );
128         }
129	 break;
130      case GL_CULL_FACE:
131         if (ctx->Polygon.CullFlag!=state) {
132            ctx->Polygon.CullFlag = state;
133	    ctx->TriangleCaps ^= DD_TRI_CULL;
134            ctx->NewState |= NEW_POLYGON;
135         }
136	 break;
137      case GL_DEPTH_TEST:
138         if (state && ctx->Visual->DepthBits==0) {
139            gl_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
140            return;
141         }
142	 if (ctx->Depth.Test!=state) {
143            ctx->Depth.Test = state;
144            ctx->NewState |= NEW_RASTER_OPS;
145         }
146         break;
147      case GL_DITHER:
148         if (ctx->NoDither) {
149            /* MESA_NO_DITHER env var */
150            state = GL_FALSE;
151         }
152         if (ctx->Color.DitherFlag!=state) {
153            ctx->Color.DitherFlag = state;
154            ctx->NewState |= NEW_RASTER_OPS;
155         }
156	 break;
157      case GL_FOG:
158	 if (ctx->Fog.Enabled!=state) {
159            ctx->Fog.Enabled = state;
160	    ctx->Enabled ^= ENABLE_FOG;
161            ctx->NewState |= NEW_FOG|NEW_RASTER_OPS;
162         }
163	 break;
164      case GL_LIGHT0:
165      case GL_LIGHT1:
166      case GL_LIGHT2:
167      case GL_LIGHT3:
168      case GL_LIGHT4:
169      case GL_LIGHT5:
170      case GL_LIGHT6:
171      case GL_LIGHT7:
172	 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state)
173	 {
174	    ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
175
176	    if (state) {
177	       insert_at_tail(&ctx->Light.EnabledList,
178			      &ctx->Light.Light[cap-GL_LIGHT0]);
179	       if (ctx->Light.Enabled)
180		  ctx->Enabled |= ENABLE_LIGHT;
181	    } else {
182	       remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
183	       if (is_empty_list(&ctx->Light.EnabledList))
184		  ctx->Enabled &= ~ENABLE_LIGHT;
185	    }
186
187	    ctx->NewState |= NEW_LIGHTING;
188	 }
189         break;
190      case GL_LIGHTING:
191         if (ctx->Light.Enabled!=state) {
192            ctx->Light.Enabled = state;
193	    ctx->Enabled &= ~ENABLE_LIGHT;
194            if (state)
195	       ctx->Enabled |= ENABLE_LIGHT;
196            ctx->NewState |= NEW_LIGHTING;
197         }
198         break;
199      case GL_LINE_SMOOTH:
200	 if (ctx->Line.SmoothFlag!=state) {
201            ctx->Line.SmoothFlag = state;
202            ctx->NewState |= NEW_RASTER_OPS;
203         }
204	 break;
205      case GL_LINE_STIPPLE:
206	 if (ctx->Line.StippleFlag!=state) {
207            ctx->Line.StippleFlag = state;
208	    ctx->TriangleCaps ^= DD_LINE_STIPPLE;
209            ctx->NewState |= NEW_RASTER_OPS;
210         }
211	 break;
212      case GL_INDEX_LOGIC_OP:
213         if (ctx->Color.IndexLogicOpEnabled!=state) {
214	    ctx->Color.IndexLogicOpEnabled = state;
215            ctx->NewState |= NEW_RASTER_OPS;
216         }
217	 break;
218      case GL_COLOR_LOGIC_OP:
219         if (ctx->Color.ColorLogicOpEnabled!=state) {
220	    ctx->Color.ColorLogicOpEnabled = state;
221            ctx->NewState |= NEW_RASTER_OPS;
222         }
223	 break;
224      case GL_MAP1_COLOR_4:
225	 ctx->Eval.Map1Color4 = state;
226	 break;
227      case GL_MAP1_INDEX:
228	 ctx->Eval.Map1Index = state;
229	 break;
230      case GL_MAP1_NORMAL:
231	 ctx->Eval.Map1Normal = state;
232	 break;
233      case GL_MAP1_TEXTURE_COORD_1:
234	 ctx->Eval.Map1TextureCoord1 = state;
235	 break;
236      case GL_MAP1_TEXTURE_COORD_2:
237	 ctx->Eval.Map1TextureCoord2 = state;
238	 break;
239      case GL_MAP1_TEXTURE_COORD_3:
240	 ctx->Eval.Map1TextureCoord3 = state;
241	 break;
242      case GL_MAP1_TEXTURE_COORD_4:
243	 ctx->Eval.Map1TextureCoord4 = state;
244	 break;
245      case GL_MAP1_VERTEX_3:
246	 ctx->Eval.Map1Vertex3 = state;
247	 break;
248      case GL_MAP1_VERTEX_4:
249	 ctx->Eval.Map1Vertex4 = state;
250	 break;
251      case GL_MAP2_COLOR_4:
252	 ctx->Eval.Map2Color4 = state;
253	 break;
254      case GL_MAP2_INDEX:
255	 ctx->Eval.Map2Index = state;
256	 break;
257      case GL_MAP2_NORMAL:
258	 ctx->Eval.Map2Normal = state;
259	 break;
260      case GL_MAP2_TEXTURE_COORD_1:
261	 ctx->Eval.Map2TextureCoord1 = state;
262	 break;
263      case GL_MAP2_TEXTURE_COORD_2:
264	 ctx->Eval.Map2TextureCoord2 = state;
265	 break;
266      case GL_MAP2_TEXTURE_COORD_3:
267	 ctx->Eval.Map2TextureCoord3 = state;
268	 break;
269      case GL_MAP2_TEXTURE_COORD_4:
270	 ctx->Eval.Map2TextureCoord4 = state;
271	 break;
272      case GL_MAP2_VERTEX_3:
273	 ctx->Eval.Map2Vertex3 = state;
274	 break;
275      case GL_MAP2_VERTEX_4:
276	 ctx->Eval.Map2Vertex4 = state;
277	 break;
278      case GL_NORMALIZE:
279	 if (ctx->Transform.Normalize != state) {
280	    ctx->Transform.Normalize = state;
281	    ctx->NewState |= NEW_NORMAL_TRANSFORM|NEW_LIGHTING;
282	    ctx->Enabled ^= ENABLE_NORMALIZE;
283	 }
284	 break;
285      case GL_POINT_SMOOTH:
286	 if (ctx->Point.SmoothFlag!=state) {
287            ctx->Point.SmoothFlag = state;
288            ctx->NewState |= NEW_RASTER_OPS;
289         }
290	 break;
291      case GL_POLYGON_SMOOTH:
292	 if (ctx->Polygon.SmoothFlag!=state) {
293            ctx->Polygon.SmoothFlag = state;
294            ctx->NewState |= NEW_RASTER_OPS;
295         }
296	 break;
297      case GL_POLYGON_STIPPLE:
298	 if (ctx->Polygon.StippleFlag!=state) {
299            ctx->Polygon.StippleFlag = state;
300	    ctx->TriangleCaps ^= DD_TRI_STIPPLE;
301            ctx->NewState |= NEW_RASTER_OPS;
302         }
303	 break;
304      case GL_POLYGON_OFFSET_POINT:
305         if (ctx->Polygon.OffsetPoint!=state) {
306            ctx->Polygon.OffsetPoint = state;
307            ctx->NewState |= NEW_POLYGON;
308         }
309         break;
310      case GL_POLYGON_OFFSET_LINE:
311         if (ctx->Polygon.OffsetLine!=state) {
312            ctx->Polygon.OffsetLine = state;
313            ctx->NewState |= NEW_POLYGON;
314         }
315         break;
316      case GL_POLYGON_OFFSET_FILL:
317      /*case GL_POLYGON_OFFSET_EXT:*/
318         if (ctx->Polygon.OffsetFill!=state) {
319            ctx->Polygon.OffsetFill = state;
320            ctx->NewState |= NEW_POLYGON;
321         }
322         break;
323      case GL_RESCALE_NORMAL_EXT:
324	 if (ctx->Transform.RescaleNormals != state) {
325	    ctx->Transform.RescaleNormals = state;
326	    ctx->NewState |= NEW_NORMAL_TRANSFORM|NEW_LIGHTING;
327	    ctx->Enabled ^= ENABLE_RESCALE;
328	 }
329         break;
330      case GL_SCISSOR_TEST:
331         if (ctx->Scissor.Enabled!=state) {
332            ctx->Scissor.Enabled = state;
333            ctx->NewState |= NEW_RASTER_OPS;
334         }
335	 break;
336      case GL_SHARED_TEXTURE_PALETTE_EXT:
337         ctx->Texture.SharedPalette = state;
338         if (ctx->Driver.UseGlobalTexturePalette)
339            (*ctx->Driver.UseGlobalTexturePalette)( ctx, state );
340         break;
341      case GL_STENCIL_TEST:
342	 if (state && ctx->Visual->StencilBits==0) {
343            gl_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
344            return;
345	 }
346	 if (ctx->Stencil.Enabled!=state) {
347            ctx->Stencil.Enabled = state;
348            ctx->NewState |= NEW_RASTER_OPS;
349	    ctx->TriangleCaps ^= DD_STENCIL;
350         }
351	 break;
352      case GL_TEXTURE_1D:
353         if (ctx->Visual->RGBAflag) {
354	    const GLuint curr = ctx->Texture.CurrentUnit;
355	    const GLuint flag = TEXTURE0_1D << (curr * 4);
356            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
357	    ctx->NewState |= NEW_TEXTURE_ENABLE;
358            if (state) {
359	       texUnit->Enabled |= TEXTURE0_1D;
360	       ctx->Enabled |= flag;
361	    }
362            else {
363               texUnit->Enabled &= ~TEXTURE0_1D;
364               ctx->Enabled &= ~flag;
365            }
366         }
367         break;
368      case GL_TEXTURE_2D:
369         if (ctx->Visual->RGBAflag) {
370	    const GLuint curr = ctx->Texture.CurrentUnit;
371	    const GLuint flag = TEXTURE0_2D << (curr * 4);
372            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
373	    ctx->NewState |= NEW_TEXTURE_ENABLE;
374            if (state) {
375	       texUnit->Enabled |= TEXTURE0_2D;
376	       ctx->Enabled |= flag;
377	    }
378            else {
379               texUnit->Enabled &= ~TEXTURE0_2D;
380               ctx->Enabled &= ~flag;
381            }
382         }
383	 break;
384      case GL_TEXTURE_3D:
385         if (ctx->Visual->RGBAflag) {
386	    const GLuint curr = ctx->Texture.CurrentUnit;
387	    const GLuint flag = TEXTURE0_3D << (curr * 4);
388            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
389	    ctx->NewState |= NEW_TEXTURE_ENABLE;
390            if (state) {
391	       texUnit->Enabled |= TEXTURE0_3D;
392	       ctx->Enabled |= flag;
393	    }
394            else {
395               texUnit->Enabled &= ~TEXTURE0_3D;
396               ctx->Enabled &= ~flag;
397            }
398         }
399         break;
400      case GL_TEXTURE_GEN_Q:
401         {
402            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
403            if (state)
404               texUnit->TexGenEnabled |= Q_BIT;
405            else
406               texUnit->TexGenEnabled &= ~Q_BIT;
407            ctx->NewState |= NEW_TEXTURING;
408         }
409	 break;
410      case GL_TEXTURE_GEN_R:
411         {
412            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
413            if (state)
414               texUnit->TexGenEnabled |= R_BIT;
415            else
416               texUnit->TexGenEnabled &= ~R_BIT;
417            ctx->NewState |= NEW_TEXTURING;
418         }
419	 break;
420      case GL_TEXTURE_GEN_S:
421         {
422            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
423            if (state)
424               texUnit->TexGenEnabled |= S_BIT;
425            else
426               texUnit->TexGenEnabled &= ~S_BIT;
427            ctx->NewState |= NEW_TEXTURING;
428         }
429	 break;
430      case GL_TEXTURE_GEN_T:
431         {
432            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
433            if (state)
434               texUnit->TexGenEnabled |= T_BIT;
435            else
436               texUnit->TexGenEnabled &= ~T_BIT;
437            ctx->NewState |= NEW_TEXTURING;
438         }
439	 break;
440
441      /*
442       * CLIENT STATE!!!
443       */
444      case GL_VERTEX_ARRAY:
445         ctx->Array.Vertex.Enabled = state;
446         break;
447      case GL_NORMAL_ARRAY:
448         ctx->Array.Normal.Enabled = state;
449         break;
450      case GL_COLOR_ARRAY:
451         ctx->Array.Color.Enabled = state;
452         break;
453      case GL_INDEX_ARRAY:
454         ctx->Array.Index.Enabled = state;
455         break;
456      case GL_TEXTURE_COORD_ARRAY:
457         ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
458         break;
459      case GL_EDGE_FLAG_ARRAY:
460         ctx->Array.EdgeFlag.Enabled = state;
461         break;
462
463      default:
464	 if (state) {
465	    gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
466	 }
467	 else {
468	    gl_error( ctx, GL_INVALID_ENUM, "glDisable" );
469	 }
470         return;
471   }
472
473   if (ctx->Driver.Enable) {
474      (*ctx->Driver.Enable)( ctx, cap, state );
475   }
476}
477
478
479
480
481void gl_Enable( GLcontext* ctx, GLenum cap )
482{
483   gl_set_enable( ctx, cap, GL_TRUE );
484}
485
486
487
488void gl_Disable( GLcontext* ctx, GLenum cap )
489{
490   gl_set_enable( ctx, cap, GL_FALSE );
491}
492
493
494
495GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap )
496{
497   switch (cap) {
498      case GL_ALPHA_TEST:
499         return ctx->Color.AlphaEnabled;
500      case GL_AUTO_NORMAL:
501	 return ctx->Eval.AutoNormal;
502      case GL_BLEND:
503         return ctx->Color.BlendEnabled;
504      case GL_CLIP_PLANE0:
505      case GL_CLIP_PLANE1:
506      case GL_CLIP_PLANE2:
507      case GL_CLIP_PLANE3:
508      case GL_CLIP_PLANE4:
509      case GL_CLIP_PLANE5:
510	 return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
511      case GL_COLOR_MATERIAL:
512	 return ctx->Light.ColorMaterialEnabled;
513      case GL_CULL_FACE:
514         return ctx->Polygon.CullFlag;
515      case GL_DEPTH_TEST:
516         return ctx->Depth.Test;
517      case GL_DITHER:
518	 return ctx->Color.DitherFlag;
519      case GL_FOG:
520	 return ctx->Fog.Enabled;
521      case GL_LIGHTING:
522         return ctx->Light.Enabled;
523      case GL_LIGHT0:
524      case GL_LIGHT1:
525      case GL_LIGHT2:
526      case GL_LIGHT3:
527      case GL_LIGHT4:
528      case GL_LIGHT5:
529      case GL_LIGHT6:
530      case GL_LIGHT7:
531         return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
532      case GL_LINE_SMOOTH:
533	 return ctx->Line.SmoothFlag;
534      case GL_LINE_STIPPLE:
535	 return ctx->Line.StippleFlag;
536      case GL_INDEX_LOGIC_OP:
537	 return ctx->Color.IndexLogicOpEnabled;
538      case GL_COLOR_LOGIC_OP:
539	 return ctx->Color.ColorLogicOpEnabled;
540      case GL_MAP1_COLOR_4:
541	 return ctx->Eval.Map1Color4;
542      case GL_MAP1_INDEX:
543	 return ctx->Eval.Map1Index;
544      case GL_MAP1_NORMAL:
545	 return ctx->Eval.Map1Normal;
546      case GL_MAP1_TEXTURE_COORD_1:
547	 return ctx->Eval.Map1TextureCoord1;
548      case GL_MAP1_TEXTURE_COORD_2:
549	 return ctx->Eval.Map1TextureCoord2;
550      case GL_MAP1_TEXTURE_COORD_3:
551	 return ctx->Eval.Map1TextureCoord3;
552      case GL_MAP1_TEXTURE_COORD_4:
553	 return ctx->Eval.Map1TextureCoord4;
554      case GL_MAP1_VERTEX_3:
555	 return ctx->Eval.Map1Vertex3;
556      case GL_MAP1_VERTEX_4:
557	 return ctx->Eval.Map1Vertex4;
558      case GL_MAP2_COLOR_4:
559	 return ctx->Eval.Map2Color4;
560      case GL_MAP2_INDEX:
561	 return ctx->Eval.Map2Index;
562      case GL_MAP2_NORMAL:
563	 return ctx->Eval.Map2Normal;
564      case GL_MAP2_TEXTURE_COORD_1:
565	 return ctx->Eval.Map2TextureCoord1;
566      case GL_MAP2_TEXTURE_COORD_2:
567	 return ctx->Eval.Map2TextureCoord2;
568      case GL_MAP2_TEXTURE_COORD_3:
569	 return ctx->Eval.Map2TextureCoord3;
570      case GL_MAP2_TEXTURE_COORD_4:
571	 return ctx->Eval.Map2TextureCoord4;
572      case GL_MAP2_VERTEX_3:
573	 return ctx->Eval.Map2Vertex3;
574      case GL_MAP2_VERTEX_4:
575	 return ctx->Eval.Map2Vertex4;
576      case GL_NORMALIZE:
577	 return ctx->Transform.Normalize;
578      case GL_POINT_SMOOTH:
579	 return ctx->Point.SmoothFlag;
580      case GL_POLYGON_SMOOTH:
581	 return ctx->Polygon.SmoothFlag;
582      case GL_POLYGON_STIPPLE:
583	 return ctx->Polygon.StippleFlag;
584      case GL_POLYGON_OFFSET_POINT:
585	 return ctx->Polygon.OffsetPoint;
586      case GL_POLYGON_OFFSET_LINE:
587	 return ctx->Polygon.OffsetLine;
588      case GL_POLYGON_OFFSET_FILL:
589      /*case GL_POLYGON_OFFSET_EXT:*/
590	 return ctx->Polygon.OffsetFill;
591      case GL_RESCALE_NORMAL_EXT:
592         return ctx->Transform.RescaleNormals;
593      case GL_SCISSOR_TEST:
594	 return ctx->Scissor.Enabled;
595      case GL_SHARED_TEXTURE_PALETTE_EXT:
596         return ctx->Texture.SharedPalette;
597      case GL_STENCIL_TEST:
598	 return ctx->Stencil.Enabled;
599      case GL_TEXTURE_1D:
600         {
601            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
602            return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
603         }
604      case GL_TEXTURE_2D:
605         {
606            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
607            return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
608         }
609      case GL_TEXTURE_3D:
610         {
611            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
612            return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
613         }
614      case GL_TEXTURE_GEN_Q:
615         {
616            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
617            return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
618         }
619      case GL_TEXTURE_GEN_R:
620         {
621            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
622            return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
623         }
624      case GL_TEXTURE_GEN_S:
625         {
626            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
627            return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
628         }
629      case GL_TEXTURE_GEN_T:
630         {
631            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
632            return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
633         }
634
635      /*
636       * CLIENT STATE!!!
637       */
638      case GL_VERTEX_ARRAY:
639         return ctx->Array.Vertex.Enabled;
640      case GL_NORMAL_ARRAY:
641         return ctx->Array.Normal.Enabled;
642      case GL_COLOR_ARRAY:
643         return ctx->Array.Color.Enabled;
644      case GL_INDEX_ARRAY:
645         return ctx->Array.Index.Enabled;
646      case GL_TEXTURE_COORD_ARRAY:
647         return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
648      case GL_EDGE_FLAG_ARRAY:
649         return ctx->Array.EdgeFlag.Enabled;
650      default:
651	 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
652	 return GL_FALSE;
653   }
654}
655
656
657
658
659static void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state )
660{
661   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
662				       (state
663					? "glEnableClientState"
664					: "glDisableClientState") );
665
666   switch (cap) {
667      case GL_VERTEX_ARRAY:
668         ctx->Array.Vertex.Enabled = state;
669         break;
670      case GL_NORMAL_ARRAY:
671         ctx->Array.Normal.Enabled = state;
672         break;
673      case GL_COLOR_ARRAY:
674         ctx->Array.Color.Enabled = state;
675         break;
676      case GL_INDEX_ARRAY:
677         ctx->Array.Index.Enabled = state;
678         break;
679      case GL_TEXTURE_COORD_ARRAY:
680         ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
681         break;
682      case GL_EDGE_FLAG_ARRAY:
683         ctx->Array.EdgeFlag.Enabled = state;
684         break;
685      default:
686         gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
687   }
688
689   ctx->NewState |= NEW_CLIENT_STATE;
690}
691
692
693
694void gl_EnableClientState( GLcontext *ctx, GLenum cap )
695{
696   gl_client_state( ctx, cap, GL_TRUE );
697}
698
699
700
701void gl_DisableClientState( GLcontext *ctx, GLenum cap )
702{
703   gl_client_state( ctx, cap, GL_FALSE );
704}
705
706