blob: bbc5070d7582c1f0e7dc3b52b382fd7df4b70e49 [file] [log] [blame]
Brian Paul06d05af2000-12-08 00:20:15 +00001/* $Id: enable.c,v 1.36 2000/12/08 00:20:15 brianp 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) {
Keith Whitwellad2ac212000-11-24 10:25:05 +0000103 _math_matrix_analyse( &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;
jtgafb833d1999-08-19 00:55:39 +0000184 if (state) {
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000185 insert_at_tail(&ctx->Light.EnabledList,
jtgafb833d1999-08-19 00:55:39 +0000186 &ctx->Light.Light[cap-GL_LIGHT0]);
jtgafb833d1999-08-19 00:55:39 +0000187 }
Brian Paul72ef7532000-11-27 18:59:09 +0000188 else {
189 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
190 }
Keith Whitwella96308c2000-10-30 13:31:59 +0000191 ctx->NewState |= _NEW_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000192 }
193 break;
194 case GL_LIGHTING:
195 if (ctx->Light.Enabled!=state) {
196 ctx->Light.Enabled = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000197 ctx->_Enabled &= ~ENABLE_LIGHT;
Brian Paul2c318aa1999-10-20 22:16:45 +0000198 if (state)
Keith Whitwell14940c42000-11-05 18:40:57 +0000199 ctx->_Enabled |= ENABLE_LIGHT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000200 ctx->NewState |= _NEW_LIGHT;
jtgafb833d1999-08-19 00:55:39 +0000201 }
202 break;
203 case GL_LINE_SMOOTH:
204 if (ctx->Line.SmoothFlag!=state) {
205 ctx->Line.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000206 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000207 ctx->NewState |= _NEW_LINE;
jtgafb833d1999-08-19 00:55:39 +0000208 }
209 break;
210 case GL_LINE_STIPPLE:
211 if (ctx->Line.StippleFlag!=state) {
212 ctx->Line.StippleFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000213 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
Keith Whitwella96308c2000-10-30 13:31:59 +0000214 ctx->NewState |= _NEW_LINE;
jtgafb833d1999-08-19 00:55:39 +0000215 }
216 break;
217 case GL_INDEX_LOGIC_OP:
218 if (ctx->Color.IndexLogicOpEnabled!=state) {
219 ctx->Color.IndexLogicOpEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000220 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000221 }
222 break;
223 case GL_COLOR_LOGIC_OP:
224 if (ctx->Color.ColorLogicOpEnabled!=state) {
225 ctx->Color.ColorLogicOpEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000226 ctx->NewState |= _NEW_COLOR;
jtgafb833d1999-08-19 00:55:39 +0000227 }
228 break;
229 case GL_MAP1_COLOR_4:
230 ctx->Eval.Map1Color4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000231 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000232 break;
233 case GL_MAP1_INDEX:
234 ctx->Eval.Map1Index = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000235 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000236 break;
237 case GL_MAP1_NORMAL:
238 ctx->Eval.Map1Normal = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000239 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000240 break;
241 case GL_MAP1_TEXTURE_COORD_1:
242 ctx->Eval.Map1TextureCoord1 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000243 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000244 break;
245 case GL_MAP1_TEXTURE_COORD_2:
246 ctx->Eval.Map1TextureCoord2 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000247 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000248 break;
249 case GL_MAP1_TEXTURE_COORD_3:
250 ctx->Eval.Map1TextureCoord3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000251 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000252 break;
253 case GL_MAP1_TEXTURE_COORD_4:
254 ctx->Eval.Map1TextureCoord4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000255 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000256 break;
257 case GL_MAP1_VERTEX_3:
258 ctx->Eval.Map1Vertex3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000259 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000260 break;
261 case GL_MAP1_VERTEX_4:
262 ctx->Eval.Map1Vertex4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000263 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000264 break;
265 case GL_MAP2_COLOR_4:
266 ctx->Eval.Map2Color4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000267 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000268 break;
269 case GL_MAP2_INDEX:
270 ctx->Eval.Map2Index = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000271 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000272 break;
273 case GL_MAP2_NORMAL:
274 ctx->Eval.Map2Normal = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000275 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000276 break;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000277 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +0000278 ctx->Eval.Map2TextureCoord1 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000279 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000280 break;
281 case GL_MAP2_TEXTURE_COORD_2:
282 ctx->Eval.Map2TextureCoord2 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000283 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000284 break;
285 case GL_MAP2_TEXTURE_COORD_3:
286 ctx->Eval.Map2TextureCoord3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000287 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000288 break;
289 case GL_MAP2_TEXTURE_COORD_4:
290 ctx->Eval.Map2TextureCoord4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000291 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000292 break;
293 case GL_MAP2_VERTEX_3:
294 ctx->Eval.Map2Vertex3 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000295 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000296 break;
297 case GL_MAP2_VERTEX_4:
298 ctx->Eval.Map2Vertex4 = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000299 ctx->NewState |= _NEW_EVAL;
jtgafb833d1999-08-19 00:55:39 +0000300 break;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000301 case GL_MINMAX:
302 ctx->Pixel.MinMaxEnabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000303 ctx->NewState |= _NEW_PIXEL;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000304 break;
jtgafb833d1999-08-19 00:55:39 +0000305 case GL_NORMALIZE:
306 if (ctx->Transform.Normalize != state) {
307 ctx->Transform.Normalize = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000308 ctx->NewState |= _NEW_TRANSFORM;
Keith Whitwell14940c42000-11-05 18:40:57 +0000309 ctx->_Enabled ^= ENABLE_NORMALIZE;
jtgafb833d1999-08-19 00:55:39 +0000310 }
311 break;
312 case GL_POINT_SMOOTH:
313 if (ctx->Point.SmoothFlag!=state) {
314 ctx->Point.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000315 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000316 ctx->NewState |= _NEW_POINT;
jtgafb833d1999-08-19 00:55:39 +0000317 }
318 break;
319 case GL_POLYGON_SMOOTH:
320 if (ctx->Polygon.SmoothFlag!=state) {
321 ctx->Polygon.SmoothFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000322 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
Keith Whitwella96308c2000-10-30 13:31:59 +0000323 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000324 }
325 break;
326 case GL_POLYGON_STIPPLE:
327 if (ctx->Polygon.StippleFlag!=state) {
328 ctx->Polygon.StippleFlag = state;
Keith Whitwell14940c42000-11-05 18:40:57 +0000329 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
Keith Whitwella96308c2000-10-30 13:31:59 +0000330 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000331 }
332 break;
333 case GL_POLYGON_OFFSET_POINT:
334 if (ctx->Polygon.OffsetPoint!=state) {
335 ctx->Polygon.OffsetPoint = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000336 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000337 }
338 break;
339 case GL_POLYGON_OFFSET_LINE:
340 if (ctx->Polygon.OffsetLine!=state) {
341 ctx->Polygon.OffsetLine = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000342 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000343 }
344 break;
345 case GL_POLYGON_OFFSET_FILL:
346 /*case GL_POLYGON_OFFSET_EXT:*/
347 if (ctx->Polygon.OffsetFill!=state) {
348 ctx->Polygon.OffsetFill = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000349 ctx->NewState |= _NEW_POLYGON;
jtgafb833d1999-08-19 00:55:39 +0000350 }
351 break;
352 case GL_RESCALE_NORMAL_EXT:
353 if (ctx->Transform.RescaleNormals != state) {
354 ctx->Transform.RescaleNormals = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000355 ctx->NewState |= _NEW_TRANSFORM;
Keith Whitwell14940c42000-11-05 18:40:57 +0000356 ctx->_Enabled ^= ENABLE_RESCALE;
jtgafb833d1999-08-19 00:55:39 +0000357 }
358 break;
359 case GL_SCISSOR_TEST:
360 if (ctx->Scissor.Enabled!=state) {
361 ctx->Scissor.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000362 ctx->NewState |= _NEW_SCISSOR;
jtgafb833d1999-08-19 00:55:39 +0000363 }
364 break;
365 case GL_SHARED_TEXTURE_PALETTE_EXT:
366 ctx->Texture.SharedPalette = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000367 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000368 break;
369 case GL_STENCIL_TEST:
Brian Paulb1394fa2000-09-26 20:53:53 +0000370 if (state && ctx->Visual.StencilBits==0) {
371 _mesa_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
jtgafb833d1999-08-19 00:55:39 +0000372 return;
373 }
374 if (ctx->Stencil.Enabled!=state) {
375 ctx->Stencil.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000376 ctx->NewState |= _NEW_STENCIL;
Keith Whitwell14940c42000-11-05 18:40:57 +0000377 ctx->_TriangleCaps ^= DD_STENCIL;
jtgafb833d1999-08-19 00:55:39 +0000378 }
379 break;
380 case GL_TEXTURE_1D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000381 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000382 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000383 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000384 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000385 if (state) {
386 texUnit->Enabled |= TEXTURE0_1D;
jtgafb833d1999-08-19 00:55:39 +0000387 }
388 else {
389 texUnit->Enabled &= ~TEXTURE0_1D;
jtgafb833d1999-08-19 00:55:39 +0000390 }
391 }
392 break;
393 case GL_TEXTURE_2D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000394 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000395 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000396 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000397 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000398 if (state) {
399 texUnit->Enabled |= TEXTURE0_2D;
jtgafb833d1999-08-19 00:55:39 +0000400 }
401 else {
402 texUnit->Enabled &= ~TEXTURE0_2D;
jtgafb833d1999-08-19 00:55:39 +0000403 }
404 }
405 break;
406 case GL_TEXTURE_3D:
Brian Paulb1394fa2000-09-26 20:53:53 +0000407 if (ctx->Visual.RGBAflag) {
jtgafb833d1999-08-19 00:55:39 +0000408 const GLuint curr = ctx->Texture.CurrentUnit;
jtgafb833d1999-08-19 00:55:39 +0000409 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000410 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000411 if (state) {
412 texUnit->Enabled |= TEXTURE0_3D;
jtgafb833d1999-08-19 00:55:39 +0000413 }
414 else {
415 texUnit->Enabled &= ~TEXTURE0_3D;
jtgafb833d1999-08-19 00:55:39 +0000416 }
417 }
418 break;
419 case GL_TEXTURE_GEN_Q:
420 {
421 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
422 if (state)
423 texUnit->TexGenEnabled |= Q_BIT;
424 else
425 texUnit->TexGenEnabled &= ~Q_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000426 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000427 }
428 break;
429 case GL_TEXTURE_GEN_R:
430 {
431 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
432 if (state)
433 texUnit->TexGenEnabled |= R_BIT;
434 else
435 texUnit->TexGenEnabled &= ~R_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000436 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000437 }
438 break;
439 case GL_TEXTURE_GEN_S:
440 {
441 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
442 if (state)
443 texUnit->TexGenEnabled |= S_BIT;
444 else
445 texUnit->TexGenEnabled &= ~S_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000446 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000447 }
448 break;
449 case GL_TEXTURE_GEN_T:
450 {
451 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
452 if (state)
453 texUnit->TexGenEnabled |= T_BIT;
454 else
455 texUnit->TexGenEnabled &= ~T_BIT;
Keith Whitwella96308c2000-10-30 13:31:59 +0000456 ctx->NewState |= _NEW_TEXTURE;
jtgafb833d1999-08-19 00:55:39 +0000457 }
458 break;
459
460 /*
461 * CLIENT STATE!!!
462 */
463 case GL_VERTEX_ARRAY:
464 ctx->Array.Vertex.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000465 ctx->NewState |= _NEW_ARRAY;
466 break;
jtgafb833d1999-08-19 00:55:39 +0000467 case GL_NORMAL_ARRAY:
468 ctx->Array.Normal.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000469 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000470 break;
471 case GL_COLOR_ARRAY:
472 ctx->Array.Color.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000473 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000474 break;
475 case GL_INDEX_ARRAY:
476 ctx->Array.Index.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000477 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000478 break;
479 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000480 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000481 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000482 break;
483 case GL_EDGE_FLAG_ARRAY:
484 ctx->Array.EdgeFlag.Enabled = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000485 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000486 break;
487
Brian Paul1b2ff692000-03-11 23:23:26 +0000488 /* GL_HP_occlusion_test */
489 case GL_OCCLUSION_TEST_HP:
Keith Whitwella96308c2000-10-30 13:31:59 +0000490 if (ctx->Extensions.HP_occlusion_test) {
Brian Paul1b2ff692000-03-11 23:23:26 +0000491 ctx->Depth.OcclusionTest = state;
Keith Whitwella96308c2000-10-30 13:31:59 +0000492 ctx->NewState |= _NEW_DEPTH;
Brian Paul7e67fb42000-04-04 15:14:10 +0000493 if (state)
494 ctx->OcclusionResult = ctx->OcclusionResultSaved;
495 else
496 ctx->OcclusionResultSaved = ctx->OcclusionResult;
Brian Paul1b2ff692000-03-11 23:23:26 +0000497 }
498 else {
499 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
500 return;
501 }
502 break;
503
Brian Paul2b2e9252000-04-07 16:27:26 +0000504 /* GL_SGIS_pixel_texture */
505 case GL_PIXEL_TEXTURE_SGIS:
Brian Paul06d05af2000-12-08 00:20:15 +0000506 if (ctx->Extensions.SGIS_pixel_texture) {
507 ctx->Pixel.PixelTextureEnabled = state;
508 ctx->NewState |= _NEW_PIXEL;
509 }
510 else {
511 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
512 return;
513 }
Brian Paul2b2e9252000-04-07 16:27:26 +0000514 break;
515
516 /* GL_SGIX_pixel_texture */
517 case GL_PIXEL_TEX_GEN_SGIX:
Brian Paul06d05af2000-12-08 00:20:15 +0000518 if (ctx->Extensions.SGIX_pixel_texture) {
519 ctx->Pixel.PixelTextureEnabled = state;
520 ctx->NewState |= _NEW_PIXEL;
521 }
522 else {
523 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
524 return;
525 }
Brian Paul2b2e9252000-04-07 16:27:26 +0000526 break;
527
Brian Paul13811372000-04-12 00:27:37 +0000528 /* GL_SGI_color_table */
529 case GL_COLOR_TABLE_SGI:
Brian Paul06d05af2000-12-08 00:20:15 +0000530 if (ctx->Extensions.SGI_color_table) {
531 ctx->Pixel.ColorTableEnabled = state;
532 ctx->NewState |= _NEW_PIXEL;
533 }
534 else {
535 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
536 return;
537 }
Brian Paul13811372000-04-12 00:27:37 +0000538 break;
539 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul06d05af2000-12-08 00:20:15 +0000540 if (ctx->Extensions.SGI_color_table) {
541 ctx->Pixel.PostConvolutionColorTableEnabled = state;
542 ctx->NewState |= _NEW_PIXEL;
543 }
544 else {
545 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
546 return;
547 }
Brian Paul13811372000-04-12 00:27:37 +0000548 break;
549 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul06d05af2000-12-08 00:20:15 +0000550 if (ctx->Extensions.SGI_color_table) {
551 ctx->Pixel.PostColorMatrixColorTableEnabled = state;
552 ctx->NewState |= _NEW_PIXEL;
553 }
554 else {
555 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
556 return;
557 }
Brian Paul13811372000-04-12 00:27:37 +0000558 break;
559
Brian Paul82b02f02000-05-07 20:37:40 +0000560 /* GL_EXT_convolution */
561 case GL_CONVOLUTION_1D:
Brian Paul06d05af2000-12-08 00:20:15 +0000562 if (ctx->Extensions.EXT_convolution) {
563 ctx->Pixel.Convolution1DEnabled = state;
564 ctx->NewState |= _NEW_PIXEL;
565 }
566 else {
567 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
568 return;
569 }
Brian Paul82b02f02000-05-07 20:37:40 +0000570 break;
571 case GL_CONVOLUTION_2D:
Brian Paul06d05af2000-12-08 00:20:15 +0000572 if (ctx->Extensions.EXT_convolution) {
573 ctx->Pixel.Convolution2DEnabled = state;
574 ctx->NewState |= _NEW_PIXEL;
575 }
576 else {
577 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
578 return;
579 }
Brian Paul82b02f02000-05-07 20:37:40 +0000580 break;
581 case GL_SEPARABLE_2D:
Brian Paul06d05af2000-12-08 00:20:15 +0000582 if (ctx->Extensions.EXT_convolution) {
583 ctx->Pixel.Separable2DEnabled = state;
584 ctx->NewState |= _NEW_PIXEL;
585 }
586 else {
587 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
588 return;
589 }
Brian Paul82b02f02000-05-07 20:37:40 +0000590 break;
591
Brian Paul86fc3702000-05-22 16:33:20 +0000592 /* GL_ARB_texture_cube_map */
593 case GL_TEXTURE_CUBE_MAP_ARB:
Keith Whitwella96308c2000-10-30 13:31:59 +0000594 if (ctx->Extensions.ARB_texture_cube_map) {
Brian Paulb1394fa2000-09-26 20:53:53 +0000595 if (ctx->Visual.RGBAflag) {
Brian Paulfc4b4432000-05-23 15:17:12 +0000596 const GLuint curr = ctx->Texture.CurrentUnit;
Brian Paulfc4b4432000-05-23 15:17:12 +0000597 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Keith Whitwella96308c2000-10-30 13:31:59 +0000598 ctx->NewState |= _NEW_TEXTURE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000599 if (state) {
600 texUnit->Enabled |= TEXTURE0_CUBE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000601 }
602 else {
603 texUnit->Enabled &= ~TEXTURE0_CUBE;
Brian Paulfc4b4432000-05-23 15:17:12 +0000604 }
Brian Paul86fc3702000-05-22 16:33:20 +0000605 }
606 }
Brian Paulfc4b4432000-05-23 15:17:12 +0000607 else {
Brian Pauleb326f52000-10-21 01:29:12 +0000608 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
Brian Paulfc4b4432000-05-23 15:17:12 +0000609 return;
610 }
Brian Paul86fc3702000-05-22 16:33:20 +0000611 break;
Brian Paul86fc3702000-05-22 16:33:20 +0000612
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000613 /* GL_EXT_secondary_color */
614 case GL_COLOR_SUM_EXT:
Brian Paul06d05af2000-12-08 00:20:15 +0000615 if (ctx->Extensions.EXT_secondary_color) {
616 ctx->Fog.ColorSumEnabled = state;
617 if (state)
618 SET_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
619 else if (ctx->Light.Model.ColorControl == GL_SINGLE_COLOR)
620 CLEAR_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR);
621 ctx->NewState |= _NEW_FOG;
622 }
623 else {
624 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
625 return;
626 }
627 break;
628
629 /* GL_MESA_sprite_point */
630 case GL_SPRITE_POINT_MESA:
631 if (ctx->Extensions.MESA_sprite_point) {
632 ctx->Point.SpriteMode = state;
633 ctx->NewState |= _NEW_POINT;
634 }
635 else {
636 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
637 return;
638 }
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000639 break;
640
jtgafb833d1999-08-19 00:55:39 +0000641 default:
Brian Pauleb326f52000-10-21 01:29:12 +0000642 gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
jtgafb833d1999-08-19 00:55:39 +0000643 return;
644 }
645
646 if (ctx->Driver.Enable) {
647 (*ctx->Driver.Enable)( ctx, cap, state );
648 }
649}
650
651
652
653
Brian Paulfbd8f211999-11-11 01:22:25 +0000654void
655_mesa_Enable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000656{
Brian Paulfbd8f211999-11-11 01:22:25 +0000657 GET_CURRENT_CONTEXT(ctx);
658 _mesa_set_enable( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000659}
660
661
662
Brian Paulfbd8f211999-11-11 01:22:25 +0000663void
664_mesa_Disable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000665{
Brian Paulfbd8f211999-11-11 01:22:25 +0000666 GET_CURRENT_CONTEXT(ctx);
667 _mesa_set_enable( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000668}
669
670
671
Brian Paulfbd8f211999-11-11 01:22:25 +0000672GLboolean
673_mesa_IsEnabled( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000674{
Brian Paulfbd8f211999-11-11 01:22:25 +0000675 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000676 switch (cap) {
677 case GL_ALPHA_TEST:
678 return ctx->Color.AlphaEnabled;
679 case GL_AUTO_NORMAL:
680 return ctx->Eval.AutoNormal;
681 case GL_BLEND:
682 return ctx->Color.BlendEnabled;
683 case GL_CLIP_PLANE0:
684 case GL_CLIP_PLANE1:
685 case GL_CLIP_PLANE2:
686 case GL_CLIP_PLANE3:
687 case GL_CLIP_PLANE4:
688 case GL_CLIP_PLANE5:
689 return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
690 case GL_COLOR_MATERIAL:
691 return ctx->Light.ColorMaterialEnabled;
692 case GL_CULL_FACE:
693 return ctx->Polygon.CullFlag;
694 case GL_DEPTH_TEST:
695 return ctx->Depth.Test;
696 case GL_DITHER:
697 return ctx->Color.DitherFlag;
698 case GL_FOG:
699 return ctx->Fog.Enabled;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000700 case GL_HISTOGRAM:
Keith Whitwella96308c2000-10-30 13:31:59 +0000701 if (ctx->Extensions.EXT_histogram) {
Brian Paul8e053912000-08-30 18:21:06 +0000702 return ctx->Pixel.HistogramEnabled;
703 }
704 else {
705 gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
706 return GL_FALSE;
707 }
jtgafb833d1999-08-19 00:55:39 +0000708 case GL_LIGHTING:
709 return ctx->Light.Enabled;
710 case GL_LIGHT0:
711 case GL_LIGHT1:
712 case GL_LIGHT2:
713 case GL_LIGHT3:
714 case GL_LIGHT4:
715 case GL_LIGHT5:
716 case GL_LIGHT6:
717 case GL_LIGHT7:
718 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
719 case GL_LINE_SMOOTH:
720 return ctx->Line.SmoothFlag;
721 case GL_LINE_STIPPLE:
722 return ctx->Line.StippleFlag;
723 case GL_INDEX_LOGIC_OP:
724 return ctx->Color.IndexLogicOpEnabled;
725 case GL_COLOR_LOGIC_OP:
726 return ctx->Color.ColorLogicOpEnabled;
727 case GL_MAP1_COLOR_4:
728 return ctx->Eval.Map1Color4;
729 case GL_MAP1_INDEX:
730 return ctx->Eval.Map1Index;
731 case GL_MAP1_NORMAL:
732 return ctx->Eval.Map1Normal;
733 case GL_MAP1_TEXTURE_COORD_1:
734 return ctx->Eval.Map1TextureCoord1;
735 case GL_MAP1_TEXTURE_COORD_2:
736 return ctx->Eval.Map1TextureCoord2;
737 case GL_MAP1_TEXTURE_COORD_3:
738 return ctx->Eval.Map1TextureCoord3;
739 case GL_MAP1_TEXTURE_COORD_4:
740 return ctx->Eval.Map1TextureCoord4;
741 case GL_MAP1_VERTEX_3:
742 return ctx->Eval.Map1Vertex3;
743 case GL_MAP1_VERTEX_4:
744 return ctx->Eval.Map1Vertex4;
745 case GL_MAP2_COLOR_4:
746 return ctx->Eval.Map2Color4;
747 case GL_MAP2_INDEX:
748 return ctx->Eval.Map2Index;
749 case GL_MAP2_NORMAL:
750 return ctx->Eval.Map2Normal;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000751 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +0000752 return ctx->Eval.Map2TextureCoord1;
753 case GL_MAP2_TEXTURE_COORD_2:
754 return ctx->Eval.Map2TextureCoord2;
755 case GL_MAP2_TEXTURE_COORD_3:
756 return ctx->Eval.Map2TextureCoord3;
757 case GL_MAP2_TEXTURE_COORD_4:
758 return ctx->Eval.Map2TextureCoord4;
759 case GL_MAP2_VERTEX_3:
760 return ctx->Eval.Map2Vertex3;
761 case GL_MAP2_VERTEX_4:
762 return ctx->Eval.Map2Vertex4;
Brian Paul1a1cf7e2000-05-04 13:48:49 +0000763 case GL_MINMAX:
764 return ctx->Pixel.MinMaxEnabled;
jtgafb833d1999-08-19 00:55:39 +0000765 case GL_NORMALIZE:
766 return ctx->Transform.Normalize;
767 case GL_POINT_SMOOTH:
768 return ctx->Point.SmoothFlag;
769 case GL_POLYGON_SMOOTH:
770 return ctx->Polygon.SmoothFlag;
771 case GL_POLYGON_STIPPLE:
772 return ctx->Polygon.StippleFlag;
773 case GL_POLYGON_OFFSET_POINT:
774 return ctx->Polygon.OffsetPoint;
775 case GL_POLYGON_OFFSET_LINE:
776 return ctx->Polygon.OffsetLine;
777 case GL_POLYGON_OFFSET_FILL:
778 /*case GL_POLYGON_OFFSET_EXT:*/
779 return ctx->Polygon.OffsetFill;
780 case GL_RESCALE_NORMAL_EXT:
781 return ctx->Transform.RescaleNormals;
782 case GL_SCISSOR_TEST:
783 return ctx->Scissor.Enabled;
784 case GL_SHARED_TEXTURE_PALETTE_EXT:
785 return ctx->Texture.SharedPalette;
786 case GL_STENCIL_TEST:
787 return ctx->Stencil.Enabled;
788 case GL_TEXTURE_1D:
789 {
790 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
791 return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
792 }
793 case GL_TEXTURE_2D:
794 {
795 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
796 return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
797 }
798 case GL_TEXTURE_3D:
799 {
800 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul65b5e1e1999-08-19 13:24:27 +0000801 return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000802 }
803 case GL_TEXTURE_GEN_Q:
804 {
805 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
806 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
807 }
808 case GL_TEXTURE_GEN_R:
809 {
810 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
811 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
812 }
813 case GL_TEXTURE_GEN_S:
814 {
815 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
816 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
817 }
818 case GL_TEXTURE_GEN_T:
819 {
820 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
821 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
822 }
823
824 /*
825 * CLIENT STATE!!!
826 */
827 case GL_VERTEX_ARRAY:
828 return ctx->Array.Vertex.Enabled;
829 case GL_NORMAL_ARRAY:
830 return ctx->Array.Normal.Enabled;
831 case GL_COLOR_ARRAY:
832 return ctx->Array.Color.Enabled;
833 case GL_INDEX_ARRAY:
834 return ctx->Array.Index.Enabled;
835 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000836 return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
jtgafb833d1999-08-19 00:55:39 +0000837 case GL_EDGE_FLAG_ARRAY:
838 return ctx->Array.EdgeFlag.Enabled;
Brian Paul1b2ff692000-03-11 23:23:26 +0000839
840 /* GL_HP_occlusion_test */
841 case GL_OCCLUSION_TEST_HP:
Keith Whitwella96308c2000-10-30 13:31:59 +0000842 if (ctx->Extensions.HP_occlusion_test) {
Brian Paul1b2ff692000-03-11 23:23:26 +0000843 return ctx->Depth.OcclusionTest;
844 }
845 else {
846 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
847 return GL_FALSE;
848 }
849
Brian Paul2b2e9252000-04-07 16:27:26 +0000850 /* GL_SGIS_pixel_texture */
851 case GL_PIXEL_TEXTURE_SGIS:
852 return ctx->Pixel.PixelTextureEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +0000853
854 /* GL_SGIX_pixel_texture */
855 case GL_PIXEL_TEX_GEN_SGIX:
856 return ctx->Pixel.PixelTextureEnabled;
Brian Paul13811372000-04-12 00:27:37 +0000857
858 /* GL_SGI_color_table */
859 case GL_COLOR_TABLE_SGI:
860 return ctx->Pixel.ColorTableEnabled;
861 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
862 return ctx->Pixel.PostConvolutionColorTableEnabled;
863 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
864 return ctx->Pixel.PostColorMatrixColorTableEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +0000865
Brian Paul82b02f02000-05-07 20:37:40 +0000866 /* GL_EXT_convolution */
867 case GL_CONVOLUTION_1D:
868 return ctx->Pixel.Convolution1DEnabled;
869 case GL_CONVOLUTION_2D:
870 return ctx->Pixel.Convolution2DEnabled;
871 case GL_SEPARABLE_2D:
872 return ctx->Pixel.Separable2DEnabled;
873
Brian Paul86fc3702000-05-22 16:33:20 +0000874 /* GL_ARB_texture_cube_map */
875 case GL_TEXTURE_CUBE_MAP_ARB:
Keith Whitwella96308c2000-10-30 13:31:59 +0000876 if (ctx->Extensions.ARB_texture_cube_map) {
Brian Paulfc4b4432000-05-23 15:17:12 +0000877 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
878 return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
Brian Paul86fc3702000-05-22 16:33:20 +0000879 }
Brian Paulfc4b4432000-05-23 15:17:12 +0000880 else {
881 gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
882 return GL_FALSE;
883 }
Brian Paul86fc3702000-05-22 16:33:20 +0000884
Brian Paul06d05af2000-12-08 00:20:15 +0000885 /* GL_MESA_sprite_point */
886 case GL_SPRITE_POINT_MESA:
887 return ctx->Point.SpriteMode;
888
jtgafb833d1999-08-19 00:55:39 +0000889 default:
890 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
891 return GL_FALSE;
892 }
893}
894
895
896
897
Brian Paulfbd8f211999-11-11 01:22:25 +0000898static void
899client_state( GLcontext *ctx, GLenum cap, GLboolean state )
jtgafb833d1999-08-19 00:55:39 +0000900{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000901 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
902 (state
903 ? "glEnableClientState"
jtgafb833d1999-08-19 00:55:39 +0000904 : "glDisableClientState") );
905
906 switch (cap) {
907 case GL_VERTEX_ARRAY:
908 ctx->Array.Vertex.Enabled = state;
909 break;
910 case GL_NORMAL_ARRAY:
911 ctx->Array.Normal.Enabled = state;
912 break;
913 case GL_COLOR_ARRAY:
914 ctx->Array.Color.Enabled = state;
915 break;
916 case GL_INDEX_ARRAY:
917 ctx->Array.Index.Enabled = state;
918 break;
919 case GL_TEXTURE_COORD_ARRAY:
Brian Paul45224fa1999-09-07 22:31:30 +0000920 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
jtgafb833d1999-08-19 00:55:39 +0000921 break;
922 case GL_EDGE_FLAG_ARRAY:
923 ctx->Array.EdgeFlag.Enabled = state;
924 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000925 case GL_FOG_COORDINATE_ARRAY_EXT:
926 ctx->Array.FogCoord.Enabled = state;
927 break;
928 case GL_SECONDARY_COLOR_ARRAY_EXT:
929 ctx->Array.SecondaryColor.Enabled = state;
930 break;
jtgafb833d1999-08-19 00:55:39 +0000931 default:
932 gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
933 }
934
Keith Whitwella96308c2000-10-30 13:31:59 +0000935 ctx->NewState |= _NEW_ARRAY;
jtgafb833d1999-08-19 00:55:39 +0000936}
937
938
939
Brian Paulfbd8f211999-11-11 01:22:25 +0000940void
941_mesa_EnableClientState( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000942{
Brian Paulfbd8f211999-11-11 01:22:25 +0000943 GET_CURRENT_CONTEXT(ctx);
944 client_state( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000945}
946
947
948
Brian Paulfbd8f211999-11-11 01:22:25 +0000949void
950_mesa_DisableClientState( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000951{
Brian Paulfbd8f211999-11-11 01:22:25 +0000952 GET_CURRENT_CONTEXT(ctx);
953 client_state( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000954}
955