blob: 7ac2f79087b38f47682d9f0c7b9d9b6f7cc95047 [file] [log] [blame]
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001/* $Id: enable.c,v 1.33 2000/11/22 07:32:16 joukj Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Pauleb326f52000-10-21 01:29:12 +00005 * Version: 3.5
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00006 *
Brian Pauleb326f52000-10-21 01:29:12 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00008 *
jtgafb833d1999-08-19 00:55:39 +00009 * 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:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000015 *
jtgafb833d1999-08-19 00:55:39 +000016 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000018 *
jtgafb833d1999-08-19 00:55:39 +000019 * 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#ifdef PC_HEADER
29#include "all.h"
30#else
Brian Paulfbd8f211999-11-11 01:22:25 +000031#include "glheader.h"
jtgafb833d1999-08-19 00:55:39 +000032#include "context.h"
33#include "enable.h"
34#include "light.h"
35#include "macros.h"
jtgafb833d1999-08-19 00:55:39 +000036#include "mmath.h"
37#include "simple_list.h"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000038#include "mtypes.h"
jtgafb833d1999-08-19 00:55:39 +000039#include "enums.h"
Keith Whitwell23caf202000-11-16 21:05:34 +000040
41#include "math/m_matrix.h"
42#include "math/m_xform.h"
43
jtgafb833d1999-08-19 00:55:39 +000044#endif
45
46
47
48/*
49 * Perform glEnable and glDisable calls.
50 */
Brian Paulfbd8f211999-11-11 01:22:25 +000051void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
jtgafb833d1999-08-19 00:55:39 +000052{
53 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" );
54
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000055 if (MESA_VERBOSE & VERBOSE_API)
56 fprintf(stderr, "%s %s (newstate is %x)\n",
jtgafb833d1999-08-19 00:55:39 +000057 state ? "glEnable" : "glDisable",
58 gl_lookup_enum_by_nr(cap),
59 ctx->NewState);
60
61 switch (cap) {
62 case GL_ALPHA_TEST:
63 if (ctx->Color.AlphaEnabled!=state) {
64 ctx->Color.AlphaEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +000065 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +000066 }
67 break;
68 case GL_AUTO_NORMAL:
69 ctx->Eval.AutoNormal = state;
Keith Whitwella96308c2000-10-30 13:31:59 +000070 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +000071 break;
72 case GL_BLEND:
73 if (ctx->Color.BlendEnabled!=state) {
74 ctx->Color.BlendEnabled = state;
75 /* The following needed to accomodate 1.0 RGB logic op blending */
76 if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) {
77 ctx->Color.ColorLogicOpEnabled = GL_TRUE;
78 }
79 else {
80 ctx->Color.ColorLogicOpEnabled = GL_FALSE;
81 }
Keith Whitwella96308c2000-10-30 13:31:59 +000082 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +000083 }
84 break;
85 case GL_CLIP_PLANE0:
86 case GL_CLIP_PLANE1:
87 case GL_CLIP_PLANE2:
88 case GL_CLIP_PLANE3:
89 case GL_CLIP_PLANE4:
90 case GL_CLIP_PLANE5:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000091 if (ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] != state)
jtgafb833d1999-08-19 00:55:39 +000092 {
93 GLuint p = cap-GL_CLIP_PLANE0;
94
95 ctx->Transform.ClipEnabled[p] = state;
Keith Whitwella96308c2000-10-30 13:31:59 +000096 ctx->NewState |= _NEW_TRANSFORM;
jtgafb833d1999-08-19 00:55:39 +000097
98 if (state) {
Keith Whitwell14940c42000-11-05 18:40:57 +000099 ctx->_Enabled |= ENABLE_USERCLIP;
100 ctx->Transform._AnyClip++;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000101
Keith Whitwell23caf202000-11-16 21:05:34 +0000102 if (ctx->ProjectionMatrix.flags & MAT_DIRTY) {
103 _math_matrix_analyze( &ctx->ProjectionMatrix );
jtgafb833d1999-08-19 00:55:39 +0000104 }
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000105
Keith Whitwell23caf202000-11-16 21:05:34 +0000106 /* This derived state also calculated in clip.c and
107 * from gl_update_state() on changes to EyeUserPlane
108 * and ctx->ProjectionMatrix respectively.
109 */
Keith Whitwell14940c42000-11-05 18:40:57 +0000110 gl_transform_vector( ctx->Transform._ClipUserPlane[p],
jtgafb833d1999-08-19 00:55:39 +0000111 ctx->Transform.EyeUserPlane[p],
112 ctx->ProjectionMatrix.inv );
113 } else {
Keith Whitwell14940c42000-11-05 18:40:57 +0000114 if (--ctx->Transform._AnyClip == 0)
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000115 ctx->_Enabled &= ~ENABLE_USERCLIP;
116 }
jtgafb833d1999-08-19 00:55:39 +0000117 }
118 break;
119 case GL_COLOR_MATERIAL:
120 if (ctx->Light.ColorMaterialEnabled!=state) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000121 ctx->Light.ColorMaterialEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000122 ctx->NewState |= _NEW_LIGHT;
Keith Whitwell23caf202000-11-16 21:05:34 +0000123
124 if (state) {
125 FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
Brian Paul19300532000-10-29 19:02:23 +0000126 gl_update_color_material( ctx, ctx->Current.Color );
Keith Whitwell23caf202000-11-16 21:05:34 +0000127 }
jtgafb833d1999-08-19 00:55:39 +0000128 }
129 break;
130 case GL_CULL_FACE:
131 if (ctx->Polygon.CullFlag!=state) {
132 ctx->Polygon.CullFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000133/* ctx->_TriangleCaps ^= DD_TRI_CULL; */
Keith Whitwella96308c2000-10-30 13:31:59 +0000134 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000135 }
136 break;
137 case GL_DEPTH_TEST:
Brian Paulb1394fa2000-09-26 20:53:53 +0000138 if (state && ctx->Visual.DepthBits==0) {
139 _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
jtgafb833d1999-08-19 00:55:39 +0000140 return;
141 }
142 if (ctx->Depth.Test!=state) {
143 ctx->Depth.Test = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000144 ctx->NewState |= _NEW_DEPTH;
jtgafb833d1999-08-19 00:55:39 +0000145 }
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;
Keith Whitwella96308c2000-10-30 13:31:59 +0000154 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000155 }
156 break;
157 case GL_FOG:
158 if (ctx->Fog.Enabled!=state) {
159 ctx->Fog.Enabled = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000160 ctx->_Enabled ^= ENABLE_FOG;
Keith Whitwella96308c2000-10-30 13:31:59 +0000161 ctx->NewState |= _NEW_FOG;
jtgafb833d1999-08-19 00:55:39 +0000162 }
163 break;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000164 case GL_HISTOGRAM:
Keith Whitwella96308c2000-10-30 13:31:59 +0000165 if (ctx->Extensions.EXT_histogram) {
Brian Paul8e053912000-08-30 18:21:06 +0000166 ctx->Pixel.HistogramEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000167 ctx->NewState |= _NEW_PIXEL;
Brian Paul8e053912000-08-30 18:21:06 +0000168 }
169 else {
170 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
171 return;
172 }
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000173 break;
jtgafb833d1999-08-19 00:55:39 +0000174 case GL_LIGHT0:
175 case GL_LIGHT1:
176 case GL_LIGHT2:
177 case GL_LIGHT3:
178 case GL_LIGHT4:
179 case GL_LIGHT5:
180 case GL_LIGHT6:
181 case GL_LIGHT7:
Brian Paul8e053912000-08-30 18:21:06 +0000182 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state) {
jtgafb833d1999-08-19 00:55:39 +0000183 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
184
185 if (state) {
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000186 insert_at_tail(&ctx->Light.EnabledList,
jtgafb833d1999-08-19 00:55:39 +0000187 &ctx->Light.Light[cap-GL_LIGHT0]);
188 if (ctx->Light.Enabled)
Keith Whitwell14940c42000-11-05 18:40:57 +0000189 ctx->_Enabled |= ENABLE_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000190 } else {
191 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
192 if (is_empty_list(&ctx->Light.EnabledList))
Keith Whitwell14940c42000-11-05 18:40:57 +0000193 ctx->_Enabled &= ~ENABLE_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000194 }
195
Keith Whitwella96308c2000-10-30 13:31:59 +0000196 ctx->NewState |= _NEW_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000197 }
198 break;
199 case GL_LIGHTING:
200 if (ctx->Light.Enabled!=state) {
201 ctx->Light.Enabled = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000202 ctx->_Enabled &= ~ENABLE_LIGHT;
Brian Paul2c318aa1999-10-20 22:16:45 +0000203 if (state)
Keith Whitwell14940c42000-11-05 18:40:57 +0000204 ctx->_Enabled |= ENABLE_LIGHT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000205 ctx->NewState |= _NEW_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000206 }
207 break;
208 case GL_LINE_SMOOTH:
209 if (ctx->Line.SmoothFlag!=state) {
210 ctx->Line.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000211 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000212 ctx->NewState |= _NEW_LINE;
jtgafb833d1999-08-19 00:55:39 +0000213 }
214 break;
215 case GL_LINE_STIPPLE:
216 if (ctx->Line.StippleFlag!=state) {
217 ctx->Line.StippleFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000218 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
Keith Whitwella96308c2000-10-30 13:31:59 +0000219 ctx->NewState |= _NEW_LINE;
jtgafb833d1999-08-19 00:55:39 +0000220 }
221 break;
222 case GL_INDEX_LOGIC_OP:
223 if (ctx->Color.IndexLogicOpEnabled!=state) {
224 ctx->Color.IndexLogicOpEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000225 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000226 }
227 break;
228 case GL_COLOR_LOGIC_OP:
229 if (ctx->Color.ColorLogicOpEnabled!=state) {
230 ctx->Color.ColorLogicOpEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000231 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000232 }
233 break;
234 case GL_MAP1_COLOR_4:
235 ctx->Eval.Map1Color4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000236 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000237 break;
238 case GL_MAP1_INDEX:
239 ctx->Eval.Map1Index = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000240 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000241 break;
242 case GL_MAP1_NORMAL:
243 ctx->Eval.Map1Normal = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000244 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000245 break;
246 case GL_MAP1_TEXTURE_COORD_1:
247 ctx->Eval.Map1TextureCoord1 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000248 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000249 break;
250 case GL_MAP1_TEXTURE_COORD_2:
251 ctx->Eval.Map1TextureCoord2 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000252 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000253 break;
254 case GL_MAP1_TEXTURE_COORD_3:
255 ctx->Eval.Map1TextureCoord3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000256 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000257 break;
258 case GL_MAP1_TEXTURE_COORD_4:
259 ctx->Eval.Map1TextureCoord4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000260 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000261 break;
262 case GL_MAP1_VERTEX_3:
263 ctx->Eval.Map1Vertex3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000264 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000265 break;
266 case GL_MAP1_VERTEX_4:
267 ctx->Eval.Map1Vertex4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000268 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000269 break;
270 case GL_MAP2_COLOR_4:
271 ctx->Eval.Map2Color4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000272 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000273 break;
274 case GL_MAP2_INDEX:
275 ctx->Eval.Map2Index = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000276 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000277 break;
278 case GL_MAP2_NORMAL:
279 ctx->Eval.Map2Normal = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000280 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000281 break;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000282 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +0000283 ctx->Eval.Map2TextureCoord1 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000284 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000285 break;
286 case GL_MAP2_TEXTURE_COORD_2:
287 ctx->Eval.Map2TextureCoord2 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000288 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000289 break;
290 case GL_MAP2_TEXTURE_COORD_3:
291 ctx->Eval.Map2TextureCoord3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000292 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000293 break;
294 case GL_MAP2_TEXTURE_COORD_4:
295 ctx->Eval.Map2TextureCoord4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000296 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000297 break;
298 case GL_MAP2_VERTEX_3:
299 ctx->Eval.Map2Vertex3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000300 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000301 break;
302 case GL_MAP2_VERTEX_4:
303 ctx->Eval.Map2Vertex4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000304 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000305 break;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000306 case GL_MINMAX:
307 ctx->Pixel.MinMaxEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000308 ctx->NewState |= _NEW_PIXEL;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000309 break;
jtgafb833d1999-08-19 00:55:39 +0000310 case GL_NORMALIZE:
311 if (ctx->Transform.Normalize != state) {
312 ctx->Transform.Normalize = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000313 ctx->NewState |= _NEW_TRANSFORM;
Keith Whitwell14940c42000-11-05 18:40:57 +0000314 ctx->_Enabled ^= ENABLE_NORMALIZE;
jtgafb833d1999-08-19 00:55:39 +0000315 }
316 break;
317 case GL_POINT_SMOOTH:
318 if (ctx->Point.SmoothFlag!=state) {
319 ctx->Point.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000320 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000321 ctx->NewState |= _NEW_POINT;
jtgafb833d1999-08-19 00:55:39 +0000322 }
323 break;
324 case GL_POLYGON_SMOOTH:
325 if (ctx->Polygon.SmoothFlag!=state) {
326 ctx->Polygon.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000327 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000328 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000329 }
330 break;
331 case GL_POLYGON_STIPPLE:
332 if (ctx->Polygon.StippleFlag!=state) {
333 ctx->Polygon.StippleFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000334 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
Keith Whitwella96308c2000-10-30 13:31:59 +0000335 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000336 }
337 break;
338 case GL_POLYGON_OFFSET_POINT:
339 if (ctx->Polygon.OffsetPoint!=state) {
340 ctx->Polygon.OffsetPoint = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000341 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000342 }
343 break;
344 case GL_POLYGON_OFFSET_LINE:
345 if (ctx->Polygon.OffsetLine!=state) {
346 ctx->Polygon.OffsetLine = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000347 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000348 }
349 break;
350 case GL_POLYGON_OFFSET_FILL:
351 /*case GL_POLYGON_OFFSET_EXT:*/
352 if (ctx->Polygon.OffsetFill!=state) {
353 ctx->Polygon.OffsetFill = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000354 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000355 }
356 break;
357 case GL_RESCALE_NORMAL_EXT:
358 if (ctx->Transform.RescaleNormals != state) {
359 ctx->Transform.RescaleNormals = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000360 ctx->NewState |= _NEW_TRANSFORM;
Keith Whitwell14940c42000-11-05 18:40:57 +0000361 ctx->_Enabled ^= ENABLE_RESCALE;
jtgafb833d1999-08-19 00:55:39 +0000362 }
363 break;
364 case GL_SCISSOR_TEST:
365 if (ctx->Scissor.Enabled!=state) {
366 ctx->Scissor.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000367 ctx->NewState |= _NEW_SCISSOR;
jtgafb833d1999-08-19 00:55:39 +0000368 }
369 break;
370 case GL_SHARED_TEXTURE_PALETTE_EXT:
371 ctx->Texture.SharedPalette = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000372 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000373 break;
374 case GL_STENCIL_TEST:
Brian Paulb1394fa2000-09-26 20:53:53 +0000375 if (state && ctx->Visual.StencilBits==0) {
376 _mesa_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
jtgafb833d1999-08-19 00:55:39 +0000377 return;
378 }
379 if (ctx->Stencil.Enabled!=state) {
380 ctx->Stencil.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000381 ctx->NewState |= _NEW_STENCIL;
Keith Whitwell14940c42000-11-05 18:40:57 +0000382 ctx->_TriangleCaps ^= DD_STENCIL;
jtgafb833d1999-08-19 00:55:39 +0000383 }
384 break;
385 case GL_TEXTURE_1D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000386 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000387 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000388 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000389 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000390 if (state) {
391 texUnit->Enabled |= TEXTURE0_1D;
jtgafb833d1999-08-19 00:55:39 +0000392 }
393 else {
394 texUnit->Enabled &= ~TEXTURE0_1D;
jtgafb833d1999-08-19 00:55:39 +0000395 }
396 }
397 break;
398 case GL_TEXTURE_2D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000399 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000400 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000401 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000402 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000403 if (state) {
404 texUnit->Enabled |= TEXTURE0_2D;
jtgafb833d1999-08-19 00:55:39 +0000405 }
406 else {
407 texUnit->Enabled &= ~TEXTURE0_2D;
jtgafb833d1999-08-19 00:55:39 +0000408 }
409 }
410 break;
411 case GL_TEXTURE_3D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000412 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000413 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000414 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000415 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000416 if (state) {
417 texUnit->Enabled |= TEXTURE0_3D;
jtgafb833d1999-08-19 00:55:39 +0000418 }
419 else {
420 texUnit->Enabled &= ~TEXTURE0_3D;
jtgafb833d1999-08-19 00:55:39 +0000421 }
422 }
423 break;
424 case GL_TEXTURE_GEN_Q:
425 {
426 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
427 if (state)
428 texUnit->TexGenEnabled |= Q_BIT;
429 else
430 texUnit->TexGenEnabled &= ~Q_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000431 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000432 }
433 break;
434 case GL_TEXTURE_GEN_R:
435 {
436 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
437 if (state)
438 texUnit->TexGenEnabled |= R_BIT;
439 else
440 texUnit->TexGenEnabled &= ~R_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000441 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000442 }
443 break;
444 case GL_TEXTURE_GEN_S:
445 {
446 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
447 if (state)
448 texUnit->TexGenEnabled |= S_BIT;
449 else
450 texUnit->TexGenEnabled &= ~S_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000451 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000452 }
453 break;
454 case GL_TEXTURE_GEN_T:
455 {
456 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
457 if (state)
458 texUnit->TexGenEnabled |= T_BIT;
459 else
460 texUnit->TexGenEnabled &= ~T_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000461 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000462 }
463 break;
464
465 /*
466 * CLIENT STATE!!!
467 */
468 case GL_VERTEX_ARRAY:
469 ctx->Array.Vertex.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000470 ctx->NewState |= _NEW_ARRAY;
471 break;
jtgafb833d1999-08-19 00:55:39 +0000472 case GL_NORMAL_ARRAY:
473 ctx->Array.Normal.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000474 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000475 break;
476 case GL_COLOR_ARRAY:
477 ctx->Array.Color.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000478 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000479 break;
480 case GL_INDEX_ARRAY:
481 ctx->Array.Index.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000482 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000483 break;
484 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000485 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000486 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000487 break;
488 case GL_EDGE_FLAG_ARRAY:
489 ctx->Array.EdgeFlag.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000490 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000491 break;
492
Brian Paul1b2ff692000-03-11 23:23:26 +0000493 /* GL_HP_occlusion_test */
494 case GL_OCCLUSION_TEST_HP:
Keith Whitwella96308c2000-10-30 13:31:59 +0000495 if (ctx->Extensions.HP_occlusion_test) {
Brian Paul1b2ff692000-03-11 23:23:26 +0000496 ctx->Depth.OcclusionTest = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000497 ctx->NewState |= _NEW_DEPTH;
Brian Paul7e67fb42000-04-04 15:14:10 +0000498 if (state)
499 ctx->OcclusionResult = ctx->OcclusionResultSaved;
500 else
501 ctx->OcclusionResultSaved = ctx->OcclusionResult;
Brian Paul1b2ff692000-03-11 23:23:26 +0000502 }
503 else {
504 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
505 return;
506 }
507 break;
508
Brian Paul2b2e9252000-04-07 16:27:26 +0000509 /* GL_SGIS_pixel_texture */
510 case GL_PIXEL_TEXTURE_SGIS:
Brian Paulfa4525e2000-08-21 14:22:24 +0000511 /* XXX check for extension */
Brian Paul2b2e9252000-04-07 16:27:26 +0000512 ctx->Pixel.PixelTextureEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000513 ctx->NewState |= _NEW_PIXEL;
Brian Paul2b2e9252000-04-07 16:27:26 +0000514 break;
515
516 /* GL_SGIX_pixel_texture */
517 case GL_PIXEL_TEX_GEN_SGIX:
Brian Paulfa4525e2000-08-21 14:22:24 +0000518 /* XXX check for extension */
Brian Paul2b2e9252000-04-07 16:27:26 +0000519 ctx->Pixel.PixelTextureEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000520 ctx->NewState |= _NEW_PIXEL;
Brian Paul2b2e9252000-04-07 16:27:26 +0000521 break;
522
Brian Paul13811372000-04-12 00:27:37 +0000523 /* GL_SGI_color_table */
524 case GL_COLOR_TABLE_SGI:
Brian Paulfa4525e2000-08-21 14:22:24 +0000525 /* XXX check for extension */
Brian Paul13811372000-04-12 00:27:37 +0000526 ctx->Pixel.ColorTableEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000527 ctx->NewState |= _NEW_PIXEL;
Brian Paul13811372000-04-12 00:27:37 +0000528 break;
529 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
530 ctx->Pixel.PostConvolutionColorTableEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000531 ctx->NewState |= _NEW_PIXEL;
Brian Paul13811372000-04-12 00:27:37 +0000532 break;
533 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
534 ctx->Pixel.PostColorMatrixColorTableEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000535 ctx->NewState |= _NEW_PIXEL;
Brian Paul13811372000-04-12 00:27:37 +0000536 break;
537
Brian Paul82b02f02000-05-07 20:37:40 +0000538 /* GL_EXT_convolution */
539 case GL_CONVOLUTION_1D:
Brian Paulfa4525e2000-08-21 14:22:24 +0000540 /* XXX check for extension */
Brian Paul82b02f02000-05-07 20:37:40 +0000541 ctx->Pixel.Convolution1DEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000542 ctx->NewState |= _NEW_PIXEL;
Brian Paul82b02f02000-05-07 20:37:40 +0000543 break;
544 case GL_CONVOLUTION_2D:
545 ctx->Pixel.Convolution2DEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000546 ctx->NewState |= _NEW_PIXEL;
Brian Paul82b02f02000-05-07 20:37:40 +0000547 break;
548 case GL_SEPARABLE_2D:
549 ctx->Pixel.Separable2DEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000550 ctx->NewState |= _NEW_PIXEL;
Brian Paul82b02f02000-05-07 20:37:40 +0000551 break;
552
Brian Paul86fc3702000-05-22 16:33:20 +0000553 /* GL_ARB_texture_cube_map */
554 case GL_TEXTURE_CUBE_MAP_ARB:
Keith Whitwella96308c2000-10-30 13:31:59 +0000555 if (ctx->Extensions.ARB_texture_cube_map) {
Brian Paulb1394fa2000-09-26 20:53:53 +0000556 if (ctx->Visual.RGBAflag) {
Brian Paulfc4b4432000-05-23 15:17:12 +0000557 const GLuint curr = ctx->Texture.CurrentUnit;
Brian Paulfc4b4432000-05-23 15:17:12 +0000558 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000559 ctx->NewState |= _NEW_TEXTURE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000560 if (state) {
561 texUnit->Enabled |= TEXTURE0_CUBE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000562 }
563 else {
564 texUnit->Enabled &= ~TEXTURE0_CUBE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000565 }
Brian Paul86fc3702000-05-22 16:33:20 +0000566 }
567 }
Brian Paulfc4b4432000-05-23 15:17:12 +0000568 else {
Brian Pauleb326f52000-10-21 01:29:12 +0000569 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
Brian Paulfc4b4432000-05-23 15:17:12 +0000570 return;
571 }
Brian Paul86fc3702000-05-22 16:33:20 +0000572 break;
Brian Paul86fc3702000-05-22 16:33:20 +0000573
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000574 /* GL_EXT_secondary_color */
575 case GL_COLOR_SUM_EXT:
576 ctx->Fog.ColorSumEnabled = state;
577 if (state)
Keith Whitwell14940c42000-11-05 18:40:57 +0000578 SET_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000579 else if (ctx->Light.Model.ColorControl == GL_SINGLE_COLOR)
Keith Whitwell14940c42000-11-05 18:40:57 +0000580 CLEAR_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
Keith Whitwella96308c2000-10-30 13:31:59 +0000581 ctx->NewState |= _NEW_FOG;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000582 break;
583
jtgafb833d1999-08-19 00:55:39 +0000584 default:
Brian Pauleb326f52000-10-21 01:29:12 +0000585 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
jtgafb833d1999-08-19 00:55:39 +0000586 return;
587 }
588
589 if (ctx->Driver.Enable) {
590 (*ctx->Driver.Enable)( ctx, cap, state );
591 }
592}
593
594
595
596
Brian Paulfbd8f211999-11-11 01:22:25 +0000597void
598_mesa_Enable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000599{
Brian Paulfbd8f211999-11-11 01:22:25 +0000600 GET_CURRENT_CONTEXT(ctx);
601 _mesa_set_enable( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000602}
603
604
605
Brian Paulfbd8f211999-11-11 01:22:25 +0000606void
607_mesa_Disable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000608{
Brian Paulfbd8f211999-11-11 01:22:25 +0000609 GET_CURRENT_CONTEXT(ctx);
610 _mesa_set_enable( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000611}
612
613
614
Brian Paulfbd8f211999-11-11 01:22:25 +0000615GLboolean
616_mesa_IsEnabled( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000617{
Brian Paulfbd8f211999-11-11 01:22:25 +0000618 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000619 switch (cap) {
620 case GL_ALPHA_TEST:
621 return ctx->Color.AlphaEnabled;
622 case GL_AUTO_NORMAL:
623 return ctx->Eval.AutoNormal;
624 case GL_BLEND:
625 return ctx->Color.BlendEnabled;
626 case GL_CLIP_PLANE0:
627 case GL_CLIP_PLANE1:
628 case GL_CLIP_PLANE2:
629 case GL_CLIP_PLANE3:
630 case GL_CLIP_PLANE4:
631 case GL_CLIP_PLANE5:
632 return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
633 case GL_COLOR_MATERIAL:
634 return ctx->Light.ColorMaterialEnabled;
635 case GL_CULL_FACE:
636 return ctx->Polygon.CullFlag;
637 case GL_DEPTH_TEST:
638 return ctx->Depth.Test;
639 case GL_DITHER:
640 return ctx->Color.DitherFlag;
641 case GL_FOG:
642 return ctx->Fog.Enabled;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000643 case GL_HISTOGRAM:
Keith Whitwella96308c2000-10-30 13:31:59 +0000644 if (ctx->Extensions.EXT_histogram) {
Brian Paul8e053912000-08-30 18:21:06 +0000645 return ctx->Pixel.HistogramEnabled;
646 }
647 else {
648 gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
649 return GL_FALSE;
650 }
jtgafb833d1999-08-19 00:55:39 +0000651 case GL_LIGHTING:
652 return ctx->Light.Enabled;
653 case GL_LIGHT0:
654 case GL_LIGHT1:
655 case GL_LIGHT2:
656 case GL_LIGHT3:
657 case GL_LIGHT4:
658 case GL_LIGHT5:
659 case GL_LIGHT6:
660 case GL_LIGHT7:
661 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
662 case GL_LINE_SMOOTH:
663 return ctx->Line.SmoothFlag;
664 case GL_LINE_STIPPLE:
665 return ctx->Line.StippleFlag;
666 case GL_INDEX_LOGIC_OP:
667 return ctx->Color.IndexLogicOpEnabled;
668 case GL_COLOR_LOGIC_OP:
669 return ctx->Color.ColorLogicOpEnabled;
670 case GL_MAP1_COLOR_4:
671 return ctx->Eval.Map1Color4;
672 case GL_MAP1_INDEX:
673 return ctx->Eval.Map1Index;
674 case GL_MAP1_NORMAL:
675 return ctx->Eval.Map1Normal;
676 case GL_MAP1_TEXTURE_COORD_1:
677 return ctx->Eval.Map1TextureCoord1;
678 case GL_MAP1_TEXTURE_COORD_2:
679 return ctx->Eval.Map1TextureCoord2;
680 case GL_MAP1_TEXTURE_COORD_3:
681 return ctx->Eval.Map1TextureCoord3;
682 case GL_MAP1_TEXTURE_COORD_4:
683 return ctx->Eval.Map1TextureCoord4;
684 case GL_MAP1_VERTEX_3:
685 return ctx->Eval.Map1Vertex3;
686 case GL_MAP1_VERTEX_4:
687 return ctx->Eval.Map1Vertex4;
688 case GL_MAP2_COLOR_4:
689 return ctx->Eval.Map2Color4;
690 case GL_MAP2_INDEX:
691 return ctx->Eval.Map2Index;
692 case GL_MAP2_NORMAL:
693 return ctx->Eval.Map2Normal;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000694 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +0000695 return ctx->Eval.Map2TextureCoord1;
696 case GL_MAP2_TEXTURE_COORD_2:
697 return ctx->Eval.Map2TextureCoord2;
698 case GL_MAP2_TEXTURE_COORD_3:
699 return ctx->Eval.Map2TextureCoord3;
700 case GL_MAP2_TEXTURE_COORD_4:
701 return ctx->Eval.Map2TextureCoord4;
702 case GL_MAP2_VERTEX_3:
703 return ctx->Eval.Map2Vertex3;
704 case GL_MAP2_VERTEX_4:
705 return ctx->Eval.Map2Vertex4;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000706 case GL_MINMAX:
707 return ctx->Pixel.MinMaxEnabled;
jtgafb833d1999-08-19 00:55:39 +0000708 case GL_NORMALIZE:
709 return ctx->Transform.Normalize;
710 case GL_POINT_SMOOTH:
711 return ctx->Point.SmoothFlag;
712 case GL_POLYGON_SMOOTH:
713 return ctx->Polygon.SmoothFlag;
714 case GL_POLYGON_STIPPLE:
715 return ctx->Polygon.StippleFlag;
716 case GL_POLYGON_OFFSET_POINT:
717 return ctx->Polygon.OffsetPoint;
718 case GL_POLYGON_OFFSET_LINE:
719 return ctx->Polygon.OffsetLine;
720 case GL_POLYGON_OFFSET_FILL:
721 /*case GL_POLYGON_OFFSET_EXT:*/
722 return ctx->Polygon.OffsetFill;
723 case GL_RESCALE_NORMAL_EXT:
724 return ctx->Transform.RescaleNormals;
725 case GL_SCISSOR_TEST:
726 return ctx->Scissor.Enabled;
727 case GL_SHARED_TEXTURE_PALETTE_EXT:
728 return ctx->Texture.SharedPalette;
729 case GL_STENCIL_TEST:
730 return ctx->Stencil.Enabled;
731 case GL_TEXTURE_1D:
732 {
733 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
734 return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
735 }
736 case GL_TEXTURE_2D:
737 {
738 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
739 return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
740 }
741 case GL_TEXTURE_3D:
742 {
743 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul65b5e1e1999-08-19 13:24:27 +0000744 return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000745 }
746 case GL_TEXTURE_GEN_Q:
747 {
748 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
749 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
750 }
751 case GL_TEXTURE_GEN_R:
752 {
753 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
754 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
755 }
756 case GL_TEXTURE_GEN_S:
757 {
758 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
759 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
760 }
761 case GL_TEXTURE_GEN_T:
762 {
763 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
764 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
765 }
766
767 /*
768 * CLIENT STATE!!!
769 */
770 case GL_VERTEX_ARRAY:
771 return ctx->Array.Vertex.Enabled;
772 case GL_NORMAL_ARRAY:
773 return ctx->Array.Normal.Enabled;
774 case GL_COLOR_ARRAY:
775 return ctx->Array.Color.Enabled;
776 case GL_INDEX_ARRAY:
777 return ctx->Array.Index.Enabled;
778 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000779 return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
jtgafb833d1999-08-19 00:55:39 +0000780 case GL_EDGE_FLAG_ARRAY:
781 return ctx->Array.EdgeFlag.Enabled;
Brian Paul1b2ff692000-03-11 23:23:26 +0000782
783 /* GL_HP_occlusion_test */
784 case GL_OCCLUSION_TEST_HP:
Keith Whitwella96308c2000-10-30 13:31:59 +0000785 if (ctx->Extensions.HP_occlusion_test) {
Brian Paul1b2ff692000-03-11 23:23:26 +0000786 return ctx->Depth.OcclusionTest;
787 }
788 else {
789 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
790 return GL_FALSE;
791 }
792
Brian Paul2b2e9252000-04-07 16:27:26 +0000793 /* GL_SGIS_pixel_texture */
794 case GL_PIXEL_TEXTURE_SGIS:
795 return ctx->Pixel.PixelTextureEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +0000796
797 /* GL_SGIX_pixel_texture */
798 case GL_PIXEL_TEX_GEN_SGIX:
799 return ctx->Pixel.PixelTextureEnabled;
Brian Paul13811372000-04-12 00:27:37 +0000800
801 /* GL_SGI_color_table */
802 case GL_COLOR_TABLE_SGI:
803 return ctx->Pixel.ColorTableEnabled;
804 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
805 return ctx->Pixel.PostConvolutionColorTableEnabled;
806 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
807 return ctx->Pixel.PostColorMatrixColorTableEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +0000808
Brian Paul82b02f02000-05-07 20:37:40 +0000809 /* GL_EXT_convolution */
810 case GL_CONVOLUTION_1D:
811 return ctx->Pixel.Convolution1DEnabled;
812 case GL_CONVOLUTION_2D:
813 return ctx->Pixel.Convolution2DEnabled;
814 case GL_SEPARABLE_2D:
815 return ctx->Pixel.Separable2DEnabled;
816
Brian Paul86fc3702000-05-22 16:33:20 +0000817 /* GL_ARB_texture_cube_map */
818 case GL_TEXTURE_CUBE_MAP_ARB:
Keith Whitwella96308c2000-10-30 13:31:59 +0000819 if (ctx->Extensions.ARB_texture_cube_map) {
Brian Paulfc4b4432000-05-23 15:17:12 +0000820 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
821 return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
Brian Paul86fc3702000-05-22 16:33:20 +0000822 }
Brian Paulfc4b4432000-05-23 15:17:12 +0000823 else {
824 gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
825 return GL_FALSE;
826 }
Brian Paul86fc3702000-05-22 16:33:20 +0000827
jtgafb833d1999-08-19 00:55:39 +0000828 default:
829 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
830 return GL_FALSE;
831 }
832}
833
834
835
836
Brian Paulfbd8f211999-11-11 01:22:25 +0000837static void
838client_state( GLcontext *ctx, GLenum cap, GLboolean state )
jtgafb833d1999-08-19 00:55:39 +0000839{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000840 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
841 (state
842 ? "glEnableClientState"
jtgafb833d1999-08-19 00:55:39 +0000843 : "glDisableClientState") );
844
845 switch (cap) {
846 case GL_VERTEX_ARRAY:
847 ctx->Array.Vertex.Enabled = state;
848 break;
849 case GL_NORMAL_ARRAY:
850 ctx->Array.Normal.Enabled = state;
851 break;
852 case GL_COLOR_ARRAY:
853 ctx->Array.Color.Enabled = state;
854 break;
855 case GL_INDEX_ARRAY:
856 ctx->Array.Index.Enabled = state;
857 break;
858 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000859 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
jtgafb833d1999-08-19 00:55:39 +0000860 break;
861 case GL_EDGE_FLAG_ARRAY:
862 ctx->Array.EdgeFlag.Enabled = state;
863 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000864 case GL_FOG_COORDINATE_ARRAY_EXT:
865 ctx->Array.FogCoord.Enabled = state;
866 break;
867 case GL_SECONDARY_COLOR_ARRAY_EXT:
868 ctx->Array.SecondaryColor.Enabled = state;
869 break;
jtgafb833d1999-08-19 00:55:39 +0000870 default:
871 gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
872 }
873
Keith Whitwella96308c2000-10-30 13:31:59 +0000874 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000875}
876
877
878
Brian Paulfbd8f211999-11-11 01:22:25 +0000879void
880_mesa_EnableClientState( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000881{
Brian Paulfbd8f211999-11-11 01:22:25 +0000882 GET_CURRENT_CONTEXT(ctx);
883 client_state( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000884}
885
886
887
Brian Paulfbd8f211999-11-11 01:22:25 +0000888void
889_mesa_DisableClientState( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000890{
Brian Paulfbd8f211999-11-11 01:22:25 +0000891 GET_CURRENT_CONTEXT(ctx);
892 client_state( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000893}
894