enable.c revision 14940c4ffe066a8b85bc14274c19ad3d8e334d61
1c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch/* $Id: enable.c,v 1.31 2000/11/05 18:40:57 keithw Exp $ */
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch/*
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * Mesa 3-D graphics library
5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * Version:  3.5
6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *
7c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * Permission is hereby granted, free of charge, to any person obtaining a
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * copy of this software and associated documentation files (the "Software"),
11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * to deal in the Software without restriction, including without limitation
12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * and/or sell copies of the Software, and to permit persons to whom the
14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * Software is furnished to do so, subject to the following conditions:
15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *
16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * The above copyright notice and this permission notice shall be included
17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * in all copies or substantial portions of the Software.
18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *
19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch */
26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifdef PC_HEADER
29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "all.h"
30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#else
31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "glheader.h"
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "context.h"
33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "enable.h"
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "light.h"
35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "macros.h"
36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "matrix.h"
37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "mmath.h"
38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "simple_list.h"
39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "types.h"
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "vbfill.h"
41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "xform.h"
42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "enums.h"
43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif
44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch/*
48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch * Perform glEnable and glDisable calls.
49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch */
50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch{
52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" );
53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   if (MESA_VERBOSE & VERBOSE_API)
55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      fprintf(stderr, "%s %s (newstate is %x)\n",
56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	      state ? "glEnable" : "glDisable",
57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	      gl_lookup_enum_by_nr(cap),
58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	      ctx->NewState);
59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   switch (cap) {
61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_ALPHA_TEST:
62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Color.AlphaEnabled!=state) {
63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Color.AlphaEnabled = state;
64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_COLOR;
65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_AUTO_NORMAL:
68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.AutoNormal = state;
69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_BLEND:
72c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Color.BlendEnabled!=state) {
73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Color.BlendEnabled = state;
74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            /* The following needed to accomodate 1.0 RGB logic op blending */
75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) {
76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               ctx->Color.ColorLogicOpEnabled = GL_TRUE;
77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            }
78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else {
79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               ctx->Color.ColorLogicOpEnabled = GL_FALSE;
80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            }
81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_COLOR;
82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
84c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE0:
85c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE1:
86c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE2:
87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE3:
88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE4:
89c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE5:
90c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] != state)
91c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 {
92c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    GLuint p = cap-GL_CLIP_PLANE0;
93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
94c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->Transform.ClipEnabled[p] = state;
95c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_TRANSFORM;
96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    if (state) {
98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       ctx->_Enabled |= ENABLE_USERCLIP;
99c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       ctx->Transform._AnyClip++;
100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) {
102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch		  gl_matrix_analyze( &ctx->ProjectionMatrix );
103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       }
104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       gl_transform_vector( ctx->Transform._ClipUserPlane[p],
106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch				    ctx->Transform.EyeUserPlane[p],
107c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch				    ctx->ProjectionMatrix.inv );
108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    } else {
109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       if (--ctx->Transform._AnyClip == 0)
110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch		  ctx->_Enabled &= ~ENABLE_USERCLIP;
111c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    }
112c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 }
113c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
114c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_MATERIAL:
115c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Light.ColorMaterialEnabled!=state) {
116c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Light.ColorMaterialEnabled = state;
117c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_LIGHT;
118c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state)
119c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               gl_update_color_material( ctx, ctx->Current.Color );
120c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
121c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CULL_FACE:
123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Polygon.CullFlag!=state) {
124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Polygon.CullFlag = state;
125c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch/*  	    ctx->_TriangleCaps ^= DD_TRI_CULL; */
126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_POLYGON;
127c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_DEPTH_TEST:
130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (state && ctx->Visual.DepthBits==0) {
131c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
132c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return;
133c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
134c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Depth.Test!=state) {
135c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Depth.Test = state;
136c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_DEPTH;
137c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
138c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
139c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_DITHER:
140c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->NoDither) {
141c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            /* MESA_NO_DITHER env var */
142c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            state = GL_FALSE;
143c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
144c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Color.DitherFlag!=state) {
145c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Color.DitherFlag = state;
146c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_COLOR;
147c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
148c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
149c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_FOG:
150c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Fog.Enabled!=state) {
151c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Fog.Enabled = state;
152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_Enabled ^= ENABLE_FOG;
153c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_FOG;
154c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
155c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
156c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_HISTOGRAM:
157c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Extensions.EXT_histogram) {
158c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Pixel.HistogramEnabled = state;
159c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_PIXEL;
160c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
161c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         else {
162c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
163c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return;
164c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
165c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
166c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT0:
167c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT1:
168c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT2:
169c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT3:
170c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT4:
171c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT5:
172c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT6:
173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT7:
174c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state) {
175c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
176c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
177c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    if (state) {
178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       insert_at_tail(&ctx->Light.EnabledList,
179c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch			      &ctx->Light.Light[cap-GL_LIGHT0]);
180c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       if (ctx->Light.Enabled)
181c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch		  ctx->_Enabled |= ENABLE_LIGHT;
182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    } else {
183c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
184c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       if (is_empty_list(&ctx->Light.EnabledList))
185c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch		  ctx->_Enabled &= ~ENABLE_LIGHT;
186c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    }
187c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
188c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_LIGHT;
189c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 }
190c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
191c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHTING:
192c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Light.Enabled!=state) {
193c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Light.Enabled = state;
194c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_Enabled &= ~ENABLE_LIGHT;
195c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state)
196c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       ctx->_Enabled |= ENABLE_LIGHT;
197c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_LIGHT;
198c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
199c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
200c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LINE_SMOOTH:
201c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Line.SmoothFlag!=state) {
202c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Line.SmoothFlag = state;
203c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
204c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_LINE;
205c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
206c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
207c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LINE_STIPPLE:
208c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Line.StippleFlag!=state) {
209c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Line.StippleFlag = state;
210c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
211c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_LINE;
212c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
213c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
214c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_INDEX_LOGIC_OP:
215c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Color.IndexLogicOpEnabled!=state) {
216c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->Color.IndexLogicOpEnabled = state;
217c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_COLOR;
218c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
219c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
220c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_LOGIC_OP:
221c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Color.ColorLogicOpEnabled!=state) {
222c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->Color.ColorLogicOpEnabled = state;
223c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_COLOR;
224c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
225c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
226c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_COLOR_4:
227c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1Color4 = state;
228c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
229c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
230c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_INDEX:
231c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1Index = state;
232c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
233c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
234c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_NORMAL:
235c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1Normal = state;
236c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
237c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
238c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_1:
239c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1TextureCoord1 = state;
240c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
241c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
242c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_2:
243c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1TextureCoord2 = state;
244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
245c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
246c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_3:
247c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1TextureCoord3 = state;
248c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
249c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
250c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_4:
251c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1TextureCoord4 = state;
252c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
253c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
254c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_VERTEX_3:
255c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1Vertex3 = state;
256c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
257c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
258c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_VERTEX_4:
259c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map1Vertex4 = state;
260c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
261c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
262c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_COLOR_4:
263c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2Color4 = state;
264c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
265c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
266c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_INDEX:
267c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2Index = state;
268c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
269c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
270c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_NORMAL:
271c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2Normal = state;
272c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
273c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
274c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_1:
275c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2TextureCoord1 = state;
276c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
277c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
278c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_2:
279c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2TextureCoord2 = state;
280c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
281c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
282c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_3:
283c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2TextureCoord3 = state;
284c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
285c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
286c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_4:
287c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2TextureCoord4 = state;
288c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
289c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
290c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_VERTEX_3:
291c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2Vertex3 = state;
292c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
293c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
294c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_VERTEX_4:
295c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->Eval.Map2Vertex4 = state;
296c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_EVAL;
297c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
298c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MINMAX:
299c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.MinMaxEnabled = state;
300c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
301c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
302c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_NORMALIZE:
303c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Transform.Normalize != state) {
304c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->Transform.Normalize = state;
305c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_TRANSFORM;
306c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_Enabled ^= ENABLE_NORMALIZE;
307c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 }
308c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
309c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POINT_SMOOTH:
310c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Point.SmoothFlag!=state) {
311c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Point.SmoothFlag = state;
312c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
313c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_POINT;
314c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
315c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
316c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_SMOOTH:
317c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Polygon.SmoothFlag!=state) {
318c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Polygon.SmoothFlag = state;
319c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
320c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_POLYGON;
321c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
322c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
323c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_STIPPLE:
324c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Polygon.StippleFlag!=state) {
325c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Polygon.StippleFlag = state;
326c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
327c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_POLYGON;
328c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
329c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
330c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_OFFSET_POINT:
331c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Polygon.OffsetPoint!=state) {
332c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Polygon.OffsetPoint = state;
333c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_POLYGON;
334c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
335c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
336c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_OFFSET_LINE:
337c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Polygon.OffsetLine!=state) {
338c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Polygon.OffsetLine = state;
339c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_POLYGON;
340c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
341c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
342c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_OFFSET_FILL:
343c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /*case GL_POLYGON_OFFSET_EXT:*/
344c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Polygon.OffsetFill!=state) {
345c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Polygon.OffsetFill = state;
346c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_POLYGON;
347c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
348c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
349c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_RESCALE_NORMAL_EXT:
350c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Transform.RescaleNormals != state) {
351c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->Transform.RescaleNormals = state;
352c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_TRANSFORM;
353c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_Enabled ^= ENABLE_RESCALE;
354c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 }
355c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
356c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_SCISSOR_TEST:
357c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Scissor.Enabled!=state) {
358c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Scissor.Enabled = state;
359c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_SCISSOR;
360c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
361c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
362c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_SHARED_TEXTURE_PALETTE_EXT:
363c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Texture.SharedPalette = state;
364c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_TEXTURE;
365c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
366c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_STENCIL_TEST:
367c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (state && ctx->Visual.StencilBits==0) {
368c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            _mesa_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
369c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return;
370c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 }
371c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (ctx->Stencil.Enabled!=state) {
372c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Stencil.Enabled = state;
373c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_STENCIL;
374c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->_TriangleCaps ^= DD_STENCIL;
375c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
376c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
377c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_1D:
378c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Visual.RGBAflag) {
379c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    const GLuint curr = ctx->Texture.CurrentUnit;
380c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
381c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_TEXTURE;
382c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state) {
383c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       texUnit->Enabled |= TEXTURE0_1D;
384c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    }
385c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else {
386c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->Enabled &= ~TEXTURE0_1D;
387c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            }
388c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
389c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
390c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_2D:
391c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Visual.RGBAflag) {
392c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    const GLuint curr = ctx->Texture.CurrentUnit;
393c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
394c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_TEXTURE;
395c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state) {
396c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       texUnit->Enabled |= TEXTURE0_2D;
397c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    }
398c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else {
399c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->Enabled &= ~TEXTURE0_2D;
400c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            }
401c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
402c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
403c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_3D:
404c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Visual.RGBAflag) {
405c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    const GLuint curr = ctx->Texture.CurrentUnit;
406c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
407c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_TEXTURE;
408c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state) {
409c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	       texUnit->Enabled |= TEXTURE0_3D;
410c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    }
411c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else {
412c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->Enabled &= ~TEXTURE0_3D;
413c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            }
414c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
415c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
416c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_Q:
417c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
418c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
419c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state)
420c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled |= Q_BIT;
421c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else
422c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled &= ~Q_BIT;
423c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_TEXTURE;
424c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
425c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
426c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_R:
427c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
428c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
429c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state)
430c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled |= R_BIT;
431c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else
432c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled &= ~R_BIT;
433c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_TEXTURE;
434c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
435c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
436c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_S:
437c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
438c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
439c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state)
440c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled |= S_BIT;
441c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else
442c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled &= ~S_BIT;
443c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_TEXTURE;
444c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
445c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
446c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_T:
447c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
448c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
449c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state)
450c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled |= T_BIT;
451c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else
452c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               texUnit->TexGenEnabled &= ~T_BIT;
453c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->NewState |= _NEW_TEXTURE;
454c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
455c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
456c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
457c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /*
458c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch       * CLIENT STATE!!!
459c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch       */
460c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_VERTEX_ARRAY:
461c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Vertex.Enabled = state;
462c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_ARRAY;
463c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
464c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_NORMAL_ARRAY:
465c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Normal.Enabled = state;
466c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_ARRAY;
467c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
468c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_ARRAY:
469c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Color.Enabled = state;
470c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_ARRAY;
471c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
472c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_INDEX_ARRAY:
473c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Index.Enabled = state;
474c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_ARRAY;
475c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
476c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_COORD_ARRAY:
477c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
478c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_ARRAY;
479c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
480c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_EDGE_FLAG_ARRAY:
481c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.EdgeFlag.Enabled = state;
482c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_ARRAY;
483c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
484c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
485c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_HP_occlusion_test */
486c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_OCCLUSION_TEST_HP:
487c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Extensions.HP_occlusion_test) {
488c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            ctx->Depth.OcclusionTest = state;
489c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    ctx->NewState |= _NEW_DEPTH;
490c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (state)
491c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               ctx->OcclusionResult = ctx->OcclusionResultSaved;
492c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            else
493c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               ctx->OcclusionResultSaved = ctx->OcclusionResult;
494c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
495c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         else {
496c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
497c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return;
498c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
499c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
500c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
501c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_SGIS_pixel_texture */
502c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_PIXEL_TEXTURE_SGIS:
503c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         /* XXX check for extension */
504c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.PixelTextureEnabled = state;
505c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
506c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
507c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
508c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_SGIX_pixel_texture */
509c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_PIXEL_TEX_GEN_SGIX:
510c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         /* XXX check for extension */
511c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.PixelTextureEnabled = state;
512c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
513c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
514c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
515c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_SGI_color_table */
516c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_TABLE_SGI:
517c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         /* XXX check for extension */
518c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.ColorTableEnabled = state;
519c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
520c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
521c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
522c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.PostConvolutionColorTableEnabled = state;
523c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
524c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
525c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
526c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.PostColorMatrixColorTableEnabled = state;
527c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
528c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
529c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
530c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_EXT_convolution */
531c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CONVOLUTION_1D:
532c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         /* XXX check for extension */
533c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.Convolution1DEnabled = state;
534c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
535c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
536c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CONVOLUTION_2D:
537c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.Convolution2DEnabled = state;
538c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
539c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
540c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_SEPARABLE_2D:
541c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Pixel.Separable2DEnabled = state;
542c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_PIXEL;
543c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
544c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
545c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_ARB_texture_cube_map */
546c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_CUBE_MAP_ARB:
547c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Extensions.ARB_texture_cube_map) {
548c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            if (ctx->Visual.RGBAflag) {
549c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               const GLuint curr = ctx->Texture.CurrentUnit;
550c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
551c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               ctx->NewState |= _NEW_TEXTURE;
552c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               if (state) {
553c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                  texUnit->Enabled |= TEXTURE0_CUBE;
554c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               }
555c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               else {
556c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                  texUnit->Enabled &= ~TEXTURE0_CUBE;
557c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch               }
558c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            }
559c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
560c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         else {
561c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
562c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return;
563c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
564c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 break;
565c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
566c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_EXT_secondary_color */
567c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_SUM_EXT:
568c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Fog.ColorSumEnabled = state;
569c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 if (state)
570c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    SET_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
571c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 else if (ctx->Light.Model.ColorControl == GL_SINGLE_COLOR)
572c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	    CLEAR_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
573c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 ctx->NewState |= _NEW_FOG;
574c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
575c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
576c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      default:
577c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
578c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return;
579c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   }
580c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
581c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   if (ctx->Driver.Enable) {
582c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      (*ctx->Driver.Enable)( ctx, cap, state );
583c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   }
584c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
585c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
586c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
587c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
588c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
589c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid
590c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch_mesa_Enable( GLenum cap )
591c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch{
592c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   GET_CURRENT_CONTEXT(ctx);
593c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   _mesa_set_enable( ctx, cap, GL_TRUE );
594c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
595c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
596c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
597c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
598c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid
599c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch_mesa_Disable( GLenum cap )
600c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch{
601c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   GET_CURRENT_CONTEXT(ctx);
602c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   _mesa_set_enable( ctx, cap, GL_FALSE );
603c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
604c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
605c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
606c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
607c407dc5cd9bdc5668497f21b26b09d988ab439deBen MurdochGLboolean
608c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch_mesa_IsEnabled( GLenum cap )
609c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch{
610c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   GET_CURRENT_CONTEXT(ctx);
611c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   switch (cap) {
612c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_ALPHA_TEST:
613c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Color.AlphaEnabled;
614c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_AUTO_NORMAL:
615c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.AutoNormal;
616c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_BLEND:
617c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Color.BlendEnabled;
618c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE0:
619c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE1:
620c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE2:
621c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE3:
622c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE4:
623c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CLIP_PLANE5:
624c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
625c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_MATERIAL:
626c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Light.ColorMaterialEnabled;
627c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CULL_FACE:
628c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Polygon.CullFlag;
629c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_DEPTH_TEST:
630c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Depth.Test;
631c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_DITHER:
632c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Color.DitherFlag;
633c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_FOG:
634c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Fog.Enabled;
635c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_HISTOGRAM:
636c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Extensions.EXT_histogram) {
637c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return ctx->Pixel.HistogramEnabled;
638c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
639c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         else {
640c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
641c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return GL_FALSE;
642c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
643c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHTING:
644c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Light.Enabled;
645c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT0:
646c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT1:
647c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT2:
648c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT3:
649c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT4:
650c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT5:
651c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT6:
652c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LIGHT7:
653c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
654c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LINE_SMOOTH:
655c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Line.SmoothFlag;
656c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_LINE_STIPPLE:
657c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Line.StippleFlag;
658c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_INDEX_LOGIC_OP:
659c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Color.IndexLogicOpEnabled;
660c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_LOGIC_OP:
661c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Color.ColorLogicOpEnabled;
662c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_COLOR_4:
663c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1Color4;
664c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_INDEX:
665c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1Index;
666c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_NORMAL:
667c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1Normal;
668c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_1:
669c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1TextureCoord1;
670c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_2:
671c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1TextureCoord2;
672c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_3:
673c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1TextureCoord3;
674c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_TEXTURE_COORD_4:
675c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1TextureCoord4;
676c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_VERTEX_3:
677c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1Vertex3;
678c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP1_VERTEX_4:
679c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map1Vertex4;
680c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_COLOR_4:
681c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2Color4;
682c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_INDEX:
683c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2Index;
684c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_NORMAL:
685c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2Normal;
686c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_1:
687c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2TextureCoord1;
688c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_2:
689c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2TextureCoord2;
690c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_3:
691c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2TextureCoord3;
692c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_TEXTURE_COORD_4:
693c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2TextureCoord4;
694c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_VERTEX_3:
695c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2Vertex3;
696c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MAP2_VERTEX_4:
697c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Eval.Map2Vertex4;
698c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_MINMAX:
699c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.MinMaxEnabled;
700c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_NORMALIZE:
701c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Transform.Normalize;
702c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POINT_SMOOTH:
703c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Point.SmoothFlag;
704c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_SMOOTH:
705c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Polygon.SmoothFlag;
706c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_STIPPLE:
707c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Polygon.StippleFlag;
708c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_OFFSET_POINT:
709c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Polygon.OffsetPoint;
710c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_OFFSET_LINE:
711c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Polygon.OffsetLine;
712c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POLYGON_OFFSET_FILL:
713c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /*case GL_POLYGON_OFFSET_EXT:*/
714c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Polygon.OffsetFill;
715c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_RESCALE_NORMAL_EXT:
716c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Transform.RescaleNormals;
717c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_SCISSOR_TEST:
718c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Scissor.Enabled;
719c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_SHARED_TEXTURE_PALETTE_EXT:
720c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Texture.SharedPalette;
721c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_STENCIL_TEST:
722c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return ctx->Stencil.Enabled;
723c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_1D:
724c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
725c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
726c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
727c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
728c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_2D:
729c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
730c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
731c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
732c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
733c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_3D:
734c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
735c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
736c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
737c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
738c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_Q:
739c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
740c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
741c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
742c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
743c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_R:
744c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
745c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
746c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
747c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
748c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_S:
749c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
750c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
751c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
752c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
753c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_GEN_T:
754c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         {
755c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
756c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
757c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
758c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
759c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /*
760c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch       * CLIENT STATE!!!
761c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch       */
762c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_VERTEX_ARRAY:
763c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Array.Vertex.Enabled;
764c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_NORMAL_ARRAY:
765c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Array.Normal.Enabled;
766c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_ARRAY:
767c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Array.Color.Enabled;
768c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_INDEX_ARRAY:
769c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Array.Index.Enabled;
770c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_COORD_ARRAY:
771c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
772c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_EDGE_FLAG_ARRAY:
773c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Array.EdgeFlag.Enabled;
774c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
775c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_HP_occlusion_test */
776c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_OCCLUSION_TEST_HP:
777c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Extensions.HP_occlusion_test) {
778c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return ctx->Depth.OcclusionTest;
779c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
780c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         else {
781c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
782c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return GL_FALSE;
783c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
784c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
785c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_SGIS_pixel_texture */
786c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_PIXEL_TEXTURE_SGIS:
787c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.PixelTextureEnabled;
788c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
789c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_SGIX_pixel_texture */
790c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_PIXEL_TEX_GEN_SGIX:
791c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.PixelTextureEnabled;
792c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
793c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_SGI_color_table */
794c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_TABLE_SGI:
795c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.ColorTableEnabled;
796c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
797c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.PostConvolutionColorTableEnabled;
798c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
799c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.PostColorMatrixColorTableEnabled;
800c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
801c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_EXT_convolution */
802c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CONVOLUTION_1D:
803c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.Convolution1DEnabled;
804c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_CONVOLUTION_2D:
805c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.Convolution2DEnabled;
806c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_SEPARABLE_2D:
807c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         return ctx->Pixel.Separable2DEnabled;
808c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
809c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      /* GL_ARB_texture_cube_map */
810c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_CUBE_MAP_ARB:
811c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         if (ctx->Extensions.ARB_texture_cube_map) {
812c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
813c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
814c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
815c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         else {
816c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
817c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch            return GL_FALSE;
818c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         }
819c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
820c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      default:
821c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
822c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch	 return GL_FALSE;
823c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   }
824c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
825c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
826c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
827c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
828c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
829c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstatic void
830c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclient_state( GLcontext *ctx, GLenum cap, GLboolean state )
831c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch{
832c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
833c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch				       (state
834c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch					? "glEnableClientState"
835c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch					: "glDisableClientState") );
836c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
837c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   switch (cap) {
838c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_VERTEX_ARRAY:
839c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Vertex.Enabled = state;
840c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
841c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_NORMAL_ARRAY:
842c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Normal.Enabled = state;
843c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
844c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_COLOR_ARRAY:
845c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Color.Enabled = state;
846c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
847c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_INDEX_ARRAY:
848c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.Index.Enabled = state;
849c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
850c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_TEXTURE_COORD_ARRAY:
851c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
852c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
853c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_EDGE_FLAG_ARRAY:
854c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.EdgeFlag.Enabled = state;
855c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
856c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_FOG_COORDINATE_ARRAY_EXT:
857c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.FogCoord.Enabled = state;
858c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
859c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      case GL_SECONDARY_COLOR_ARRAY_EXT:
860c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         ctx->Array.SecondaryColor.Enabled = state;
861c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         break;
862c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch      default:
863c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch         gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
864c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   }
865c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
866c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   ctx->NewState |= _NEW_ARRAY;
867c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
868c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
869c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
870c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
871c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid
872c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch_mesa_EnableClientState( GLenum cap )
873c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch{
874c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   GET_CURRENT_CONTEXT(ctx);
875c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   client_state( ctx, cap, GL_TRUE );
876c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
877c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
878c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
879c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
880c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid
881c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch_mesa_DisableClientState( GLenum cap )
882c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch{
883c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   GET_CURRENT_CONTEXT(ctx);
884c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch   client_state( ctx, cap, GL_FALSE );
885c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}
886c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
887c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch