blob: 3d21f95bea1ff152bf2c14f7af05eb1a38e9ee16 [file] [log] [blame]
Keith Whitwell14940c42000-11-05 18:40:57 +00001/* $Id: enable.c,v 1.31 2000/11/05 18:40:57 keithw 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
jtgafb833d1999-08-19 00:55:39 +00006 *
Brian Pauleb326f52000-10-21 01:29:12 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
jtgafb833d1999-08-19 00:55:39 +00008 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28#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"
36#include "matrix.h"
37#include "mmath.h"
38#include "simple_list.h"
39#include "types.h"
40#include "vbfill.h"
41#include "xform.h"
42#include "enums.h"
jtgafb833d1999-08-19 00:55:39 +000043#endif
44
45
46
47/*
48 * Perform glEnable and glDisable calls.
49 */
Brian Paulfbd8f211999-11-11 01:22:25 +000050void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
jtgafb833d1999-08-19 00:55:39 +000051{
52 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" );
53
54 if (MESA_VERBOSE & VERBOSE_API)
Keith Whitwell2be79c11999-08-26 14:50:49 +000055 fprintf(stderr, "%s %s (newstate is %x)\n",
jtgafb833d1999-08-19 00:55:39 +000056 state ? "glEnable" : "glDisable",
57 gl_lookup_enum_by_nr(cap),
58 ctx->NewState);
59
60 switch (cap) {
61 case GL_ALPHA_TEST:
62 if (ctx->Color.AlphaEnabled!=state) {
63 ctx->Color.AlphaEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +000064 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +000065 }
66 break;
67 case GL_AUTO_NORMAL:
68 ctx->Eval.AutoNormal = state;
Keith Whitwella96308c2000-10-30 13:31:59 +000069 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +000070 break;
71 case GL_BLEND:
72 if (ctx->Color.BlendEnabled!=state) {
73 ctx->Color.BlendEnabled = state;
74 /* The following needed to accomodate 1.0 RGB logic op blending */
75 if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) {
76 ctx->Color.ColorLogicOpEnabled = GL_TRUE;
77 }
78 else {
79 ctx->Color.ColorLogicOpEnabled = GL_FALSE;
80 }
Keith Whitwella96308c2000-10-30 13:31:59 +000081 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +000082 }
83 break;
84 case GL_CLIP_PLANE0:
85 case GL_CLIP_PLANE1:
86 case GL_CLIP_PLANE2:
87 case GL_CLIP_PLANE3:
88 case GL_CLIP_PLANE4:
89 case GL_CLIP_PLANE5:
Keith Whitwella96308c2000-10-30 13:31:59 +000090 if (ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] != state)
jtgafb833d1999-08-19 00:55:39 +000091 {
92 GLuint p = cap-GL_CLIP_PLANE0;
93
94 ctx->Transform.ClipEnabled[p] = state;
Keith Whitwella96308c2000-10-30 13:31:59 +000095 ctx->NewState |= _NEW_TRANSFORM;
jtgafb833d1999-08-19 00:55:39 +000096
97 if (state) {
Keith Whitwell14940c42000-11-05 18:40:57 +000098 ctx->_Enabled |= ENABLE_USERCLIP;
99 ctx->Transform._AnyClip++;
jtgafb833d1999-08-19 00:55:39 +0000100
101 if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) {
102 gl_matrix_analyze( &ctx->ProjectionMatrix );
103 }
104
Keith Whitwell14940c42000-11-05 18:40:57 +0000105 gl_transform_vector( ctx->Transform._ClipUserPlane[p],
jtgafb833d1999-08-19 00:55:39 +0000106 ctx->Transform.EyeUserPlane[p],
107 ctx->ProjectionMatrix.inv );
108 } else {
Keith Whitwell14940c42000-11-05 18:40:57 +0000109 if (--ctx->Transform._AnyClip == 0)
110 ctx->_Enabled &= ~ENABLE_USERCLIP;
jtgafb833d1999-08-19 00:55:39 +0000111 }
112 }
113 break;
114 case GL_COLOR_MATERIAL:
115 if (ctx->Light.ColorMaterialEnabled!=state) {
116 ctx->Light.ColorMaterialEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000117 ctx->NewState |= _NEW_LIGHT;
Brian Paulfbd8f211999-11-11 01:22:25 +0000118 if (state)
Brian Paul19300532000-10-29 19:02:23 +0000119 gl_update_color_material( ctx, ctx->Current.Color );
jtgafb833d1999-08-19 00:55:39 +0000120 }
121 break;
122 case GL_CULL_FACE:
123 if (ctx->Polygon.CullFlag!=state) {
124 ctx->Polygon.CullFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000125/* ctx->_TriangleCaps ^= DD_TRI_CULL; */
Keith Whitwella96308c2000-10-30 13:31:59 +0000126 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000127 }
128 break;
129 case GL_DEPTH_TEST:
Brian Paulb1394fa2000-09-26 20:53:53 +0000130 if (state && ctx->Visual.DepthBits==0) {
131 _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
jtgafb833d1999-08-19 00:55:39 +0000132 return;
133 }
134 if (ctx->Depth.Test!=state) {
135 ctx->Depth.Test = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000136 ctx->NewState |= _NEW_DEPTH;
jtgafb833d1999-08-19 00:55:39 +0000137 }
138 break;
139 case GL_DITHER:
140 if (ctx->NoDither) {
141 /* MESA_NO_DITHER env var */
142 state = GL_FALSE;
143 }
144 if (ctx->Color.DitherFlag!=state) {
145 ctx->Color.DitherFlag = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000146 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000147 }
148 break;
149 case GL_FOG:
150 if (ctx->Fog.Enabled!=state) {
151 ctx->Fog.Enabled = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000152 ctx->_Enabled ^= ENABLE_FOG;
Keith Whitwella96308c2000-10-30 13:31:59 +0000153 ctx->NewState |= _NEW_FOG;
jtgafb833d1999-08-19 00:55:39 +0000154 }
155 break;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000156 case GL_HISTOGRAM:
Keith Whitwella96308c2000-10-30 13:31:59 +0000157 if (ctx->Extensions.EXT_histogram) {
Brian Paul8e053912000-08-30 18:21:06 +0000158 ctx->Pixel.HistogramEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000159 ctx->NewState |= _NEW_PIXEL;
Brian Paul8e053912000-08-30 18:21:06 +0000160 }
161 else {
162 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
163 return;
164 }
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000165 break;
jtgafb833d1999-08-19 00:55:39 +0000166 case GL_LIGHT0:
167 case GL_LIGHT1:
168 case GL_LIGHT2:
169 case GL_LIGHT3:
170 case GL_LIGHT4:
171 case GL_LIGHT5:
172 case GL_LIGHT6:
173 case GL_LIGHT7:
Brian Paul8e053912000-08-30 18:21:06 +0000174 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state) {
jtgafb833d1999-08-19 00:55:39 +0000175 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
176
177 if (state) {
178 insert_at_tail(&ctx->Light.EnabledList,
179 &ctx->Light.Light[cap-GL_LIGHT0]);
180 if (ctx->Light.Enabled)
Keith Whitwell14940c42000-11-05 18:40:57 +0000181 ctx->_Enabled |= ENABLE_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000182 } else {
183 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
184 if (is_empty_list(&ctx->Light.EnabledList))
Keith Whitwell14940c42000-11-05 18:40:57 +0000185 ctx->_Enabled &= ~ENABLE_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000186 }
187
Keith Whitwella96308c2000-10-30 13:31:59 +0000188 ctx->NewState |= _NEW_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000189 }
190 break;
191 case GL_LIGHTING:
192 if (ctx->Light.Enabled!=state) {
193 ctx->Light.Enabled = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000194 ctx->_Enabled &= ~ENABLE_LIGHT;
Brian Paul2c318aa1999-10-20 22:16:45 +0000195 if (state)
Keith Whitwell14940c42000-11-05 18:40:57 +0000196 ctx->_Enabled |= ENABLE_LIGHT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000197 ctx->NewState |= _NEW_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000198 }
199 break;
200 case GL_LINE_SMOOTH:
201 if (ctx->Line.SmoothFlag!=state) {
202 ctx->Line.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000203 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000204 ctx->NewState |= _NEW_LINE;
jtgafb833d1999-08-19 00:55:39 +0000205 }
206 break;
207 case GL_LINE_STIPPLE:
208 if (ctx->Line.StippleFlag!=state) {
209 ctx->Line.StippleFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000210 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
Keith Whitwella96308c2000-10-30 13:31:59 +0000211 ctx->NewState |= _NEW_LINE;
jtgafb833d1999-08-19 00:55:39 +0000212 }
213 break;
214 case GL_INDEX_LOGIC_OP:
215 if (ctx->Color.IndexLogicOpEnabled!=state) {
216 ctx->Color.IndexLogicOpEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000217 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000218 }
219 break;
220 case GL_COLOR_LOGIC_OP:
221 if (ctx->Color.ColorLogicOpEnabled!=state) {
222 ctx->Color.ColorLogicOpEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000223 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000224 }
225 break;
226 case GL_MAP1_COLOR_4:
227 ctx->Eval.Map1Color4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000228 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000229 break;
230 case GL_MAP1_INDEX:
231 ctx->Eval.Map1Index = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000232 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000233 break;
234 case GL_MAP1_NORMAL:
235 ctx->Eval.Map1Normal = 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_TEXTURE_COORD_1:
239 ctx->Eval.Map1TextureCoord1 = 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_TEXTURE_COORD_2:
243 ctx->Eval.Map1TextureCoord2 = 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_3:
247 ctx->Eval.Map1TextureCoord3 = 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_4:
251 ctx->Eval.Map1TextureCoord4 = 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_VERTEX_3:
255 ctx->Eval.Map1Vertex3 = 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_VERTEX_4:
259 ctx->Eval.Map1Vertex4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000260 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000261 break;
262 case GL_MAP2_COLOR_4:
263 ctx->Eval.Map2Color4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000264 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000265 break;
266 case GL_MAP2_INDEX:
267 ctx->Eval.Map2Index = 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_NORMAL:
271 ctx->Eval.Map2Normal = 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_TEXTURE_COORD_1:
275 ctx->Eval.Map2TextureCoord1 = 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_TEXTURE_COORD_2:
279 ctx->Eval.Map2TextureCoord2 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000280 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000281 break;
282 case GL_MAP2_TEXTURE_COORD_3:
283 ctx->Eval.Map2TextureCoord3 = 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_4:
287 ctx->Eval.Map2TextureCoord4 = 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_VERTEX_3:
291 ctx->Eval.Map2Vertex3 = 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_VERTEX_4:
295 ctx->Eval.Map2Vertex4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000296 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000297 break;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000298 case GL_MINMAX:
299 ctx->Pixel.MinMaxEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000300 ctx->NewState |= _NEW_PIXEL;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000301 break;
jtgafb833d1999-08-19 00:55:39 +0000302 case GL_NORMALIZE:
303 if (ctx->Transform.Normalize != state) {
304 ctx->Transform.Normalize = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000305 ctx->NewState |= _NEW_TRANSFORM;
Keith Whitwell14940c42000-11-05 18:40:57 +0000306 ctx->_Enabled ^= ENABLE_NORMALIZE;
jtgafb833d1999-08-19 00:55:39 +0000307 }
308 break;
309 case GL_POINT_SMOOTH:
310 if (ctx->Point.SmoothFlag!=state) {
311 ctx->Point.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000312 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000313 ctx->NewState |= _NEW_POINT;
jtgafb833d1999-08-19 00:55:39 +0000314 }
315 break;
316 case GL_POLYGON_SMOOTH:
317 if (ctx->Polygon.SmoothFlag!=state) {
318 ctx->Polygon.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000319 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000320 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000321 }
322 break;
323 case GL_POLYGON_STIPPLE:
324 if (ctx->Polygon.StippleFlag!=state) {
325 ctx->Polygon.StippleFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000326 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
Keith Whitwella96308c2000-10-30 13:31:59 +0000327 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000328 }
329 break;
330 case GL_POLYGON_OFFSET_POINT:
331 if (ctx->Polygon.OffsetPoint!=state) {
332 ctx->Polygon.OffsetPoint = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000333 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000334 }
335 break;
336 case GL_POLYGON_OFFSET_LINE:
337 if (ctx->Polygon.OffsetLine!=state) {
338 ctx->Polygon.OffsetLine = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000339 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000340 }
341 break;
342 case GL_POLYGON_OFFSET_FILL:
343 /*case GL_POLYGON_OFFSET_EXT:*/
344 if (ctx->Polygon.OffsetFill!=state) {
345 ctx->Polygon.OffsetFill = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000346 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000347 }
348 break;
349 case GL_RESCALE_NORMAL_EXT:
350 if (ctx->Transform.RescaleNormals != state) {
351 ctx->Transform.RescaleNormals = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000352 ctx->NewState |= _NEW_TRANSFORM;
Keith Whitwell14940c42000-11-05 18:40:57 +0000353 ctx->_Enabled ^= ENABLE_RESCALE;
jtgafb833d1999-08-19 00:55:39 +0000354 }
355 break;
356 case GL_SCISSOR_TEST:
357 if (ctx->Scissor.Enabled!=state) {
358 ctx->Scissor.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000359 ctx->NewState |= _NEW_SCISSOR;
jtgafb833d1999-08-19 00:55:39 +0000360 }
361 break;
362 case GL_SHARED_TEXTURE_PALETTE_EXT:
363 ctx->Texture.SharedPalette = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000364 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000365 break;
366 case GL_STENCIL_TEST:
Brian Paulb1394fa2000-09-26 20:53:53 +0000367 if (state && ctx->Visual.StencilBits==0) {
368 _mesa_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
jtgafb833d1999-08-19 00:55:39 +0000369 return;
370 }
371 if (ctx->Stencil.Enabled!=state) {
372 ctx->Stencil.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000373 ctx->NewState |= _NEW_STENCIL;
Keith Whitwell14940c42000-11-05 18:40:57 +0000374 ctx->_TriangleCaps ^= DD_STENCIL;
jtgafb833d1999-08-19 00:55:39 +0000375 }
376 break;
377 case GL_TEXTURE_1D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000378 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000379 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000380 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000381 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000382 if (state) {
383 texUnit->Enabled |= TEXTURE0_1D;
jtgafb833d1999-08-19 00:55:39 +0000384 }
385 else {
386 texUnit->Enabled &= ~TEXTURE0_1D;
jtgafb833d1999-08-19 00:55:39 +0000387 }
388 }
389 break;
390 case GL_TEXTURE_2D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000391 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000392 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000393 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000394 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000395 if (state) {
396 texUnit->Enabled |= TEXTURE0_2D;
jtgafb833d1999-08-19 00:55:39 +0000397 }
398 else {
399 texUnit->Enabled &= ~TEXTURE0_2D;
jtgafb833d1999-08-19 00:55:39 +0000400 }
401 }
402 break;
403 case GL_TEXTURE_3D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000404 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000405 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000406 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000407 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000408 if (state) {
409 texUnit->Enabled |= TEXTURE0_3D;
jtgafb833d1999-08-19 00:55:39 +0000410 }
411 else {
412 texUnit->Enabled &= ~TEXTURE0_3D;
jtgafb833d1999-08-19 00:55:39 +0000413 }
414 }
415 break;
416 case GL_TEXTURE_GEN_Q:
417 {
418 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
419 if (state)
420 texUnit->TexGenEnabled |= Q_BIT;
421 else
422 texUnit->TexGenEnabled &= ~Q_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000423 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000424 }
425 break;
426 case GL_TEXTURE_GEN_R:
427 {
428 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
429 if (state)
430 texUnit->TexGenEnabled |= R_BIT;
431 else
432 texUnit->TexGenEnabled &= ~R_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000433 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000434 }
435 break;
436 case GL_TEXTURE_GEN_S:
437 {
438 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
439 if (state)
440 texUnit->TexGenEnabled |= S_BIT;
441 else
442 texUnit->TexGenEnabled &= ~S_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000443 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000444 }
445 break;
446 case GL_TEXTURE_GEN_T:
447 {
448 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
449 if (state)
450 texUnit->TexGenEnabled |= T_BIT;
451 else
452 texUnit->TexGenEnabled &= ~T_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000453 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000454 }
455 break;
456
457 /*
458 * CLIENT STATE!!!
459 */
460 case GL_VERTEX_ARRAY:
461 ctx->Array.Vertex.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000462 ctx->NewState |= _NEW_ARRAY;
463 break;
jtgafb833d1999-08-19 00:55:39 +0000464 case GL_NORMAL_ARRAY:
465 ctx->Array.Normal.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000466 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000467 break;
468 case GL_COLOR_ARRAY:
469 ctx->Array.Color.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000470 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000471 break;
472 case GL_INDEX_ARRAY:
473 ctx->Array.Index.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_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000477 ctx->Array.TexCoord[ctx->Array.ActiveTexture].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_EDGE_FLAG_ARRAY:
481 ctx->Array.EdgeFlag.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000482 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000483 break;
484
Brian Paul1b2ff692000-03-11 23:23:26 +0000485 /* GL_HP_occlusion_test */
486 case GL_OCCLUSION_TEST_HP:
Keith Whitwella96308c2000-10-30 13:31:59 +0000487 if (ctx->Extensions.HP_occlusion_test) {
Brian Paul1b2ff692000-03-11 23:23:26 +0000488 ctx->Depth.OcclusionTest = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000489 ctx->NewState |= _NEW_DEPTH;
Brian Paul7e67fb42000-04-04 15:14:10 +0000490 if (state)
491 ctx->OcclusionResult = ctx->OcclusionResultSaved;
492 else
493 ctx->OcclusionResultSaved = ctx->OcclusionResult;
Brian Paul1b2ff692000-03-11 23:23:26 +0000494 }
495 else {
496 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
497 return;
498 }
499 break;
500
Brian Paul2b2e9252000-04-07 16:27:26 +0000501 /* GL_SGIS_pixel_texture */
502 case GL_PIXEL_TEXTURE_SGIS:
Brian Paulfa4525e2000-08-21 14:22:24 +0000503 /* XXX check for extension */
Brian Paul2b2e9252000-04-07 16:27:26 +0000504 ctx->Pixel.PixelTextureEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000505 ctx->NewState |= _NEW_PIXEL;
Brian Paul2b2e9252000-04-07 16:27:26 +0000506 break;
507
508 /* GL_SGIX_pixel_texture */
509 case GL_PIXEL_TEX_GEN_SGIX:
Brian Paulfa4525e2000-08-21 14:22:24 +0000510 /* XXX check for extension */
Brian Paul2b2e9252000-04-07 16:27:26 +0000511 ctx->Pixel.PixelTextureEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000512 ctx->NewState |= _NEW_PIXEL;
Brian Paul2b2e9252000-04-07 16:27:26 +0000513 break;
514
Brian Paul13811372000-04-12 00:27:37 +0000515 /* GL_SGI_color_table */
516 case GL_COLOR_TABLE_SGI:
Brian Paulfa4525e2000-08-21 14:22:24 +0000517 /* XXX check for extension */
Brian Paul13811372000-04-12 00:27:37 +0000518 ctx->Pixel.ColorTableEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000519 ctx->NewState |= _NEW_PIXEL;
Brian Paul13811372000-04-12 00:27:37 +0000520 break;
521 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
522 ctx->Pixel.PostConvolutionColorTableEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000523 ctx->NewState |= _NEW_PIXEL;
Brian Paul13811372000-04-12 00:27:37 +0000524 break;
525 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
526 ctx->Pixel.PostColorMatrixColorTableEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000527 ctx->NewState |= _NEW_PIXEL;
Brian Paul13811372000-04-12 00:27:37 +0000528 break;
529
Brian Paul82b02f02000-05-07 20:37:40 +0000530 /* GL_EXT_convolution */
531 case GL_CONVOLUTION_1D:
Brian Paulfa4525e2000-08-21 14:22:24 +0000532 /* XXX check for extension */
Brian Paul82b02f02000-05-07 20:37:40 +0000533 ctx->Pixel.Convolution1DEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000534 ctx->NewState |= _NEW_PIXEL;
Brian Paul82b02f02000-05-07 20:37:40 +0000535 break;
536 case GL_CONVOLUTION_2D:
537 ctx->Pixel.Convolution2DEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000538 ctx->NewState |= _NEW_PIXEL;
Brian Paul82b02f02000-05-07 20:37:40 +0000539 break;
540 case GL_SEPARABLE_2D:
541 ctx->Pixel.Separable2DEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000542 ctx->NewState |= _NEW_PIXEL;
Brian Paul82b02f02000-05-07 20:37:40 +0000543 break;
544
Brian Paul86fc3702000-05-22 16:33:20 +0000545 /* GL_ARB_texture_cube_map */
546 case GL_TEXTURE_CUBE_MAP_ARB:
Keith Whitwella96308c2000-10-30 13:31:59 +0000547 if (ctx->Extensions.ARB_texture_cube_map) {
Brian Paulb1394fa2000-09-26 20:53:53 +0000548 if (ctx->Visual.RGBAflag) {
Brian Paulfc4b4432000-05-23 15:17:12 +0000549 const GLuint curr = ctx->Texture.CurrentUnit;
Brian Paulfc4b4432000-05-23 15:17:12 +0000550 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000551 ctx->NewState |= _NEW_TEXTURE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000552 if (state) {
553 texUnit->Enabled |= TEXTURE0_CUBE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000554 }
555 else {
556 texUnit->Enabled &= ~TEXTURE0_CUBE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000557 }
Brian Paul86fc3702000-05-22 16:33:20 +0000558 }
559 }
Brian Paulfc4b4432000-05-23 15:17:12 +0000560 else {
Brian Pauleb326f52000-10-21 01:29:12 +0000561 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
Brian Paulfc4b4432000-05-23 15:17:12 +0000562 return;
563 }
Brian Paul86fc3702000-05-22 16:33:20 +0000564 break;
Brian Paul86fc3702000-05-22 16:33:20 +0000565
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000566 /* GL_EXT_secondary_color */
567 case GL_COLOR_SUM_EXT:
568 ctx->Fog.ColorSumEnabled = state;
569 if (state)
Keith Whitwell14940c42000-11-05 18:40:57 +0000570 SET_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000571 else if (ctx->Light.Model.ColorControl == GL_SINGLE_COLOR)
Keith Whitwell14940c42000-11-05 18:40:57 +0000572 CLEAR_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
Keith Whitwella96308c2000-10-30 13:31:59 +0000573 ctx->NewState |= _NEW_FOG;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000574 break;
575
jtgafb833d1999-08-19 00:55:39 +0000576 default:
Brian Pauleb326f52000-10-21 01:29:12 +0000577 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
jtgafb833d1999-08-19 00:55:39 +0000578 return;
579 }
580
581 if (ctx->Driver.Enable) {
582 (*ctx->Driver.Enable)( ctx, cap, state );
583 }
584}
585
586
587
588
Brian Paulfbd8f211999-11-11 01:22:25 +0000589void
590_mesa_Enable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000591{
Brian Paulfbd8f211999-11-11 01:22:25 +0000592 GET_CURRENT_CONTEXT(ctx);
593 _mesa_set_enable( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000594}
595
596
597
Brian Paulfbd8f211999-11-11 01:22:25 +0000598void
599_mesa_Disable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000600{
Brian Paulfbd8f211999-11-11 01:22:25 +0000601 GET_CURRENT_CONTEXT(ctx);
602 _mesa_set_enable( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000603}
604
605
606
Brian Paulfbd8f211999-11-11 01:22:25 +0000607GLboolean
608_mesa_IsEnabled( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000609{
Brian Paulfbd8f211999-11-11 01:22:25 +0000610 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000611 switch (cap) {
612 case GL_ALPHA_TEST:
613 return ctx->Color.AlphaEnabled;
614 case GL_AUTO_NORMAL:
615 return ctx->Eval.AutoNormal;
616 case GL_BLEND:
617 return ctx->Color.BlendEnabled;
618 case GL_CLIP_PLANE0:
619 case GL_CLIP_PLANE1:
620 case GL_CLIP_PLANE2:
621 case GL_CLIP_PLANE3:
622 case GL_CLIP_PLANE4:
623 case GL_CLIP_PLANE5:
624 return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
625 case GL_COLOR_MATERIAL:
626 return ctx->Light.ColorMaterialEnabled;
627 case GL_CULL_FACE:
628 return ctx->Polygon.CullFlag;
629 case GL_DEPTH_TEST:
630 return ctx->Depth.Test;
631 case GL_DITHER:
632 return ctx->Color.DitherFlag;
633 case GL_FOG:
634 return ctx->Fog.Enabled;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000635 case GL_HISTOGRAM:
Keith Whitwella96308c2000-10-30 13:31:59 +0000636 if (ctx->Extensions.EXT_histogram) {
Brian Paul8e053912000-08-30 18:21:06 +0000637 return ctx->Pixel.HistogramEnabled;
638 }
639 else {
640 gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
641 return GL_FALSE;
642 }
jtgafb833d1999-08-19 00:55:39 +0000643 case GL_LIGHTING:
644 return ctx->Light.Enabled;
645 case GL_LIGHT0:
646 case GL_LIGHT1:
647 case GL_LIGHT2:
648 case GL_LIGHT3:
649 case GL_LIGHT4:
650 case GL_LIGHT5:
651 case GL_LIGHT6:
652 case GL_LIGHT7:
653 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
654 case GL_LINE_SMOOTH:
655 return ctx->Line.SmoothFlag;
656 case GL_LINE_STIPPLE:
657 return ctx->Line.StippleFlag;
658 case GL_INDEX_LOGIC_OP:
659 return ctx->Color.IndexLogicOpEnabled;
660 case GL_COLOR_LOGIC_OP:
661 return ctx->Color.ColorLogicOpEnabled;
662 case GL_MAP1_COLOR_4:
663 return ctx->Eval.Map1Color4;
664 case GL_MAP1_INDEX:
665 return ctx->Eval.Map1Index;
666 case GL_MAP1_NORMAL:
667 return ctx->Eval.Map1Normal;
668 case GL_MAP1_TEXTURE_COORD_1:
669 return ctx->Eval.Map1TextureCoord1;
670 case GL_MAP1_TEXTURE_COORD_2:
671 return ctx->Eval.Map1TextureCoord2;
672 case GL_MAP1_TEXTURE_COORD_3:
673 return ctx->Eval.Map1TextureCoord3;
674 case GL_MAP1_TEXTURE_COORD_4:
675 return ctx->Eval.Map1TextureCoord4;
676 case GL_MAP1_VERTEX_3:
677 return ctx->Eval.Map1Vertex3;
678 case GL_MAP1_VERTEX_4:
679 return ctx->Eval.Map1Vertex4;
680 case GL_MAP2_COLOR_4:
681 return ctx->Eval.Map2Color4;
682 case GL_MAP2_INDEX:
683 return ctx->Eval.Map2Index;
684 case GL_MAP2_NORMAL:
685 return ctx->Eval.Map2Normal;
686 case GL_MAP2_TEXTURE_COORD_1:
687 return ctx->Eval.Map2TextureCoord1;
688 case GL_MAP2_TEXTURE_COORD_2:
689 return ctx->Eval.Map2TextureCoord2;
690 case GL_MAP2_TEXTURE_COORD_3:
691 return ctx->Eval.Map2TextureCoord3;
692 case GL_MAP2_TEXTURE_COORD_4:
693 return ctx->Eval.Map2TextureCoord4;
694 case GL_MAP2_VERTEX_3:
695 return ctx->Eval.Map2Vertex3;
696 case GL_MAP2_VERTEX_4:
697 return ctx->Eval.Map2Vertex4;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000698 case GL_MINMAX:
699 return ctx->Pixel.MinMaxEnabled;
jtgafb833d1999-08-19 00:55:39 +0000700 case GL_NORMALIZE:
701 return ctx->Transform.Normalize;
702 case GL_POINT_SMOOTH:
703 return ctx->Point.SmoothFlag;
704 case GL_POLYGON_SMOOTH:
705 return ctx->Polygon.SmoothFlag;
706 case GL_POLYGON_STIPPLE:
707 return ctx->Polygon.StippleFlag;
708 case GL_POLYGON_OFFSET_POINT:
709 return ctx->Polygon.OffsetPoint;
710 case GL_POLYGON_OFFSET_LINE:
711 return ctx->Polygon.OffsetLine;
712 case GL_POLYGON_OFFSET_FILL:
713 /*case GL_POLYGON_OFFSET_EXT:*/
714 return ctx->Polygon.OffsetFill;
715 case GL_RESCALE_NORMAL_EXT:
716 return ctx->Transform.RescaleNormals;
717 case GL_SCISSOR_TEST:
718 return ctx->Scissor.Enabled;
719 case GL_SHARED_TEXTURE_PALETTE_EXT:
720 return ctx->Texture.SharedPalette;
721 case GL_STENCIL_TEST:
722 return ctx->Stencil.Enabled;
723 case GL_TEXTURE_1D:
724 {
725 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
726 return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
727 }
728 case GL_TEXTURE_2D:
729 {
730 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
731 return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
732 }
733 case GL_TEXTURE_3D:
734 {
735 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul65b5e1e1999-08-19 13:24:27 +0000736 return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000737 }
738 case GL_TEXTURE_GEN_Q:
739 {
740 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
741 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
742 }
743 case GL_TEXTURE_GEN_R:
744 {
745 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
746 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
747 }
748 case GL_TEXTURE_GEN_S:
749 {
750 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
751 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
752 }
753 case GL_TEXTURE_GEN_T:
754 {
755 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
756 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
757 }
758
759 /*
760 * CLIENT STATE!!!
761 */
762 case GL_VERTEX_ARRAY:
763 return ctx->Array.Vertex.Enabled;
764 case GL_NORMAL_ARRAY:
765 return ctx->Array.Normal.Enabled;
766 case GL_COLOR_ARRAY:
767 return ctx->Array.Color.Enabled;
768 case GL_INDEX_ARRAY:
769 return ctx->Array.Index.Enabled;
770 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000771 return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
jtgafb833d1999-08-19 00:55:39 +0000772 case GL_EDGE_FLAG_ARRAY:
773 return ctx->Array.EdgeFlag.Enabled;
Brian Paul1b2ff692000-03-11 23:23:26 +0000774
775 /* GL_HP_occlusion_test */
776 case GL_OCCLUSION_TEST_HP:
Keith Whitwella96308c2000-10-30 13:31:59 +0000777 if (ctx->Extensions.HP_occlusion_test) {
Brian Paul1b2ff692000-03-11 23:23:26 +0000778 return ctx->Depth.OcclusionTest;
779 }
780 else {
781 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
782 return GL_FALSE;
783 }
784
Brian Paul2b2e9252000-04-07 16:27:26 +0000785 /* GL_SGIS_pixel_texture */
786 case GL_PIXEL_TEXTURE_SGIS:
787 return ctx->Pixel.PixelTextureEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +0000788
789 /* GL_SGIX_pixel_texture */
790 case GL_PIXEL_TEX_GEN_SGIX:
791 return ctx->Pixel.PixelTextureEnabled;
Brian Paul13811372000-04-12 00:27:37 +0000792
793 /* GL_SGI_color_table */
794 case GL_COLOR_TABLE_SGI:
795 return ctx->Pixel.ColorTableEnabled;
796 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
797 return ctx->Pixel.PostConvolutionColorTableEnabled;
798 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
799 return ctx->Pixel.PostColorMatrixColorTableEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +0000800
Brian Paul82b02f02000-05-07 20:37:40 +0000801 /* GL_EXT_convolution */
802 case GL_CONVOLUTION_1D:
803 return ctx->Pixel.Convolution1DEnabled;
804 case GL_CONVOLUTION_2D:
805 return ctx->Pixel.Convolution2DEnabled;
806 case GL_SEPARABLE_2D:
807 return ctx->Pixel.Separable2DEnabled;
808
Brian Paul86fc3702000-05-22 16:33:20 +0000809 /* GL_ARB_texture_cube_map */
810 case GL_TEXTURE_CUBE_MAP_ARB:
Keith Whitwella96308c2000-10-30 13:31:59 +0000811 if (ctx->Extensions.ARB_texture_cube_map) {
Brian Paulfc4b4432000-05-23 15:17:12 +0000812 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
813 return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
Brian Paul86fc3702000-05-22 16:33:20 +0000814 }
Brian Paulfc4b4432000-05-23 15:17:12 +0000815 else {
816 gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
817 return GL_FALSE;
818 }
Brian Paul86fc3702000-05-22 16:33:20 +0000819
jtgafb833d1999-08-19 00:55:39 +0000820 default:
821 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
822 return GL_FALSE;
823 }
824}
825
826
827
828
Brian Paulfbd8f211999-11-11 01:22:25 +0000829static void
830client_state( GLcontext *ctx, GLenum cap, GLboolean state )
jtgafb833d1999-08-19 00:55:39 +0000831{
832 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
833 (state
834 ? "glEnableClientState"
835 : "glDisableClientState") );
836
837 switch (cap) {
838 case GL_VERTEX_ARRAY:
839 ctx->Array.Vertex.Enabled = state;
840 break;
841 case GL_NORMAL_ARRAY:
842 ctx->Array.Normal.Enabled = state;
843 break;
844 case GL_COLOR_ARRAY:
845 ctx->Array.Color.Enabled = state;
846 break;
847 case GL_INDEX_ARRAY:
848 ctx->Array.Index.Enabled = state;
849 break;
850 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000851 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
jtgafb833d1999-08-19 00:55:39 +0000852 break;
853 case GL_EDGE_FLAG_ARRAY:
854 ctx->Array.EdgeFlag.Enabled = state;
855 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000856 case GL_FOG_COORDINATE_ARRAY_EXT:
857 ctx->Array.FogCoord.Enabled = state;
858 break;
859 case GL_SECONDARY_COLOR_ARRAY_EXT:
860 ctx->Array.SecondaryColor.Enabled = state;
861 break;
jtgafb833d1999-08-19 00:55:39 +0000862 default:
863 gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
864 }
865
Keith Whitwella96308c2000-10-30 13:31:59 +0000866 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000867}
868
869
870
Brian Paulfbd8f211999-11-11 01:22:25 +0000871void
872_mesa_EnableClientState( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000873{
Brian Paulfbd8f211999-11-11 01:22:25 +0000874 GET_CURRENT_CONTEXT(ctx);
875 client_state( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000876}
877
878
879
Brian Paulfbd8f211999-11-11 01:22:25 +0000880void
881_mesa_DisableClientState( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000882{
Brian Paulfbd8f211999-11-11 01:22:25 +0000883 GET_CURRENT_CONTEXT(ctx);
884 client_state( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000885}
886