blob: 78c200dcae441d28b37d9231eea8da2f17d0a972 [file] [log] [blame]
Alan Hourihane68c48df2002-04-19 08:38:23 +00001/* $Id: enable.c,v 1.61 2002/04/19 08:38:23 alanh Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paul8e6d3052002-01-11 17:26:54 +00005 * Version: 4.1
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00006 *
Brian Paul8e6d3052002-01-11 17:26:54 +00007 * Copyright (C) 1999-2002 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#include "math/m_matrix.h"
41#include "math/m_xform.h"
jtgafb833d1999-08-19 00:55:39 +000042#endif
43
44
Brian Paul86b84272001-12-14 02:50:01 +000045#define CHECK_EXTENSION(EXTNAME) \
46 if (!ctx->Extensions.EXTNAME) { \
47 _mesa_error(ctx, GL_INVALID_ENUM, \
48 state ? "glEnableClientState": "glDisableClientState"); \
49 return; \
50 }
51
52
53
Keith Whitwellcab974c2000-12-26 05:09:27 +000054static void
55client_state( GLcontext *ctx, GLenum cap, GLboolean state )
56{
57 GLuint flag;
Brian Paul8e6d3052002-01-11 17:26:54 +000058 GLuint *var;
Keith Whitwellcab974c2000-12-26 05:09:27 +000059
60 switch (cap) {
Brian Paul86b84272001-12-14 02:50:01 +000061 case GL_VERTEX_ARRAY:
62 var = &ctx->Array.Vertex.Enabled;
63 flag = _NEW_ARRAY_VERTEX;
64 break;
65 case GL_NORMAL_ARRAY:
66 var = &ctx->Array.Normal.Enabled;
67 flag = _NEW_ARRAY_NORMAL;
68 break;
69 case GL_COLOR_ARRAY:
70 var = &ctx->Array.Color.Enabled;
71 flag = _NEW_ARRAY_COLOR0;
72 break;
73 case GL_INDEX_ARRAY:
74 var = &ctx->Array.Index.Enabled;
75 flag = _NEW_ARRAY_INDEX;
76 break;
77 case GL_TEXTURE_COORD_ARRAY:
78 var = &ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
79 flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture);
80 break;
81 case GL_EDGE_FLAG_ARRAY:
82 var = &ctx->Array.EdgeFlag.Enabled;
83 flag = _NEW_ARRAY_EDGEFLAG;
84 break;
85 case GL_FOG_COORDINATE_ARRAY_EXT:
86 var = &ctx->Array.FogCoord.Enabled;
87 flag = _NEW_ARRAY_FOGCOORD;
88 break;
89 case GL_SECONDARY_COLOR_ARRAY_EXT:
90 var = &ctx->Array.SecondaryColor.Enabled;
91 flag = _NEW_ARRAY_COLOR1;
92 break;
93
94 /* GL_NV_vertex_program */
95 case GL_VERTEX_ATTRIB_ARRAY0_NV:
96 case GL_VERTEX_ATTRIB_ARRAY1_NV:
97 case GL_VERTEX_ATTRIB_ARRAY2_NV:
98 case GL_VERTEX_ATTRIB_ARRAY3_NV:
99 case GL_VERTEX_ATTRIB_ARRAY4_NV:
100 case GL_VERTEX_ATTRIB_ARRAY5_NV:
101 case GL_VERTEX_ATTRIB_ARRAY6_NV:
102 case GL_VERTEX_ATTRIB_ARRAY7_NV:
103 case GL_VERTEX_ATTRIB_ARRAY8_NV:
104 case GL_VERTEX_ATTRIB_ARRAY9_NV:
105 case GL_VERTEX_ATTRIB_ARRAY10_NV:
106 case GL_VERTEX_ATTRIB_ARRAY11_NV:
107 case GL_VERTEX_ATTRIB_ARRAY12_NV:
108 case GL_VERTEX_ATTRIB_ARRAY13_NV:
109 case GL_VERTEX_ATTRIB_ARRAY14_NV:
110 case GL_VERTEX_ATTRIB_ARRAY15_NV:
111 CHECK_EXTENSION(NV_vertex_program);
112 {
113 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
114 var = &ctx->Array.VertexAttrib[n].Enabled;
115 flag = _NEW_ARRAY_VERT_ATTRIB0; /* XXX flag OK? */
116 }
117 break;
118 default:
119 _mesa_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
120 return;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000121 }
122
Alan Hourihane68c48df2002-04-19 08:38:23 +0000123 if (*var == state)
Keith Whitwellcab974c2000-12-26 05:09:27 +0000124 return;
125
126 FLUSH_VERTICES(ctx, _NEW_ARRAY);
127 ctx->Array.NewState |= flag;
128 *var = state;
129
Gareth Hughes22144ab2001-03-12 00:48:37 +0000130 if (state)
Keith Whitwellcab974c2000-12-26 05:09:27 +0000131 ctx->Array._Enabled |= flag;
132 else
133 ctx->Array._Enabled &= ~flag;
134
135 if (ctx->Driver.Enable) {
136 (*ctx->Driver.Enable)( ctx, cap, state );
137 }
138}
139
140
141
142void
143_mesa_EnableClientState( GLenum cap )
144{
145 GET_CURRENT_CONTEXT(ctx);
146 ASSERT_OUTSIDE_BEGIN_END(ctx);
147 client_state( ctx, cap, GL_TRUE );
148}
149
150
151
152void
153_mesa_DisableClientState( GLenum cap )
154{
155 GET_CURRENT_CONTEXT(ctx);
156 ASSERT_OUTSIDE_BEGIN_END(ctx);
157 client_state( ctx, cap, GL_FALSE );
158}
159
jtgafb833d1999-08-19 00:55:39 +0000160
Brian Paul86b84272001-12-14 02:50:01 +0000161#undef CHECK_EXTENSION
162#define CHECK_EXTENSION(EXTNAME) \
163 if (!ctx->Extensions.EXTNAME) { \
164 _mesa_error(ctx, GL_INVALID_ENUM, \
165 state ? "glEnable": "glDisable"); \
166 return; \
167 }
168
169
jtgafb833d1999-08-19 00:55:39 +0000170/*
171 * Perform glEnable and glDisable calls.
172 */
Brian Paulfbd8f211999-11-11 01:22:25 +0000173void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
jtgafb833d1999-08-19 00:55:39 +0000174{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000175 if (MESA_VERBOSE & VERBOSE_API)
176 fprintf(stderr, "%s %s (newstate is %x)\n",
jtgafb833d1999-08-19 00:55:39 +0000177 state ? "glEnable" : "glDisable",
Brian Paul08836342001-03-03 20:33:27 +0000178 _mesa_lookup_enum_by_nr(cap),
jtgafb833d1999-08-19 00:55:39 +0000179 ctx->NewState);
180
181 switch (cap) {
Brian Paul86b84272001-12-14 02:50:01 +0000182 case GL_ALPHA_TEST:
183 if (ctx->Color.AlphaEnabled == state)
184 return;
185 FLUSH_VERTICES(ctx, _NEW_COLOR);
186 ctx->Color.AlphaEnabled = state;
187 break;
188 case GL_AUTO_NORMAL:
189 if (ctx->Eval.AutoNormal == state)
190 return;
191 FLUSH_VERTICES(ctx, _NEW_EVAL);
192 ctx->Eval.AutoNormal = state;
193 break;
194 case GL_BLEND:
195 if (ctx->Color.BlendEnabled == state)
196 return;
197 FLUSH_VERTICES(ctx, _NEW_COLOR);
198 ctx->Color.BlendEnabled = state;
199 /* The following needed to accomodate 1.0 RGB logic op blending */
200 ctx->Color.ColorLogicOpEnabled =
201 (ctx->Color.BlendEquation == GL_LOGIC_OP && state);
202 break;
203 case GL_CLIP_PLANE0:
204 case GL_CLIP_PLANE1:
205 case GL_CLIP_PLANE2:
206 case GL_CLIP_PLANE3:
207 case GL_CLIP_PLANE4:
208 case GL_CLIP_PLANE5:
209 {
Brian Paul103bc0f2002-03-29 17:27:59 +0000210 const GLuint p = cap - GL_CLIP_PLANE0;
jtgafb833d1999-08-19 00:55:39 +0000211
Brian Pauldb07de02002-04-19 00:23:08 +0000212 if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p))
Brian Paul86b84272001-12-14 02:50:01 +0000213 return;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000214
Brian Paul86b84272001-12-14 02:50:01 +0000215 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
jtgafb833d1999-08-19 00:55:39 +0000216
Brian Paul86b84272001-12-14 02:50:01 +0000217 if (state) {
Brian Paul103bc0f2002-03-29 17:27:59 +0000218 ctx->Transform.ClipPlanesEnabled |= (1 << p);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000219
Brian Paul103bc0f2002-03-29 17:27:59 +0000220 if (ctx->ProjectionMatrixStack.Top->flags & MAT_DIRTY)
Brian Paul30f51ae2001-12-18 04:06:44 +0000221 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
Gareth Hughes22144ab2001-03-12 00:48:37 +0000222
Brian Paul86b84272001-12-14 02:50:01 +0000223 /* This derived state also calculated in clip.c and
224 * from _mesa_update_state() on changes to EyeUserPlane
225 * and ctx->ProjectionMatrix respectively.
226 */
227 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
228 ctx->Transform.EyeUserPlane[p],
Brian Paul30f51ae2001-12-18 04:06:44 +0000229 ctx->ProjectionMatrixStack.Top->inv );
Brian Paul86b84272001-12-14 02:50:01 +0000230 }
Brian Paulf66de792002-03-28 22:45:45 +0000231 else {
Brian Paul103bc0f2002-03-29 17:27:59 +0000232 ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
Brian Paulf66de792002-03-28 22:45:45 +0000233 }
Brian Paul86b84272001-12-14 02:50:01 +0000234 }
235 break;
236 case GL_COLOR_MATERIAL:
237 if (ctx->Light.ColorMaterialEnabled == state)
238 return;
239 FLUSH_VERTICES(ctx, _NEW_LIGHT);
240 ctx->Light.ColorMaterialEnabled = state;
241 if (state) {
242 FLUSH_CURRENT(ctx, 0);
243 _mesa_update_color_material( ctx,
244 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
245 }
246 break;
247 case GL_CULL_FACE:
248 if (ctx->Polygon.CullFlag == state)
249 return;
250 FLUSH_VERTICES(ctx, _NEW_POLYGON);
251 ctx->Polygon.CullFlag = state;
252 break;
253 case GL_DEPTH_TEST:
254 if (state && ctx->Visual.depthBits==0) {
255 _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
256 return;
257 }
258 if (ctx->Depth.Test==state)
259 return;
260 FLUSH_VERTICES(ctx, _NEW_DEPTH);
261 ctx->Depth.Test = state;
262 break;
263 case GL_DITHER:
264 if (ctx->NoDither) {
265 state = GL_FALSE; /* MESA_NO_DITHER env var */
266 }
267 if (ctx->Color.DitherFlag==state)
268 return;
269 FLUSH_VERTICES(ctx, _NEW_COLOR);
270 ctx->Color.DitherFlag = state;
271 break;
272 case GL_FOG:
273 if (ctx->Fog.Enabled==state)
274 return;
275 FLUSH_VERTICES(ctx, _NEW_FOG);
276 ctx->Fog.Enabled = state;
277 break;
278 case GL_HISTOGRAM:
279 CHECK_EXTENSION(EXT_histogram);
280 if (ctx->Pixel.HistogramEnabled == state)
281 return;
282 FLUSH_VERTICES(ctx, _NEW_PIXEL);
283 ctx->Pixel.HistogramEnabled = state;
284 break;
285 case GL_LIGHT0:
286 case GL_LIGHT1:
287 case GL_LIGHT2:
288 case GL_LIGHT3:
289 case GL_LIGHT4:
290 case GL_LIGHT5:
291 case GL_LIGHT6:
292 case GL_LIGHT7:
293 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
294 return;
295 FLUSH_VERTICES(ctx, _NEW_LIGHT);
296 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
297 if (state) {
298 insert_at_tail(&ctx->Light.EnabledList,
299 &ctx->Light.Light[cap-GL_LIGHT0]);
300 }
301 else {
302 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
303 }
304 break;
305 case GL_LIGHTING:
306 if (ctx->Light.Enabled == state)
307 return;
308 FLUSH_VERTICES(ctx, _NEW_LIGHT);
309 ctx->Light.Enabled = state;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000310
Keith Whitwell0cb28412002-02-13 00:53:19 +0000311 if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
312 ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
313 else
314 ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
315
Brian Paul86b84272001-12-14 02:50:01 +0000316 if ((ctx->Light.Enabled &&
317 ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
318 || ctx->Fog.ColorSumEnabled)
319 ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
320 else
321 ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
322
323 break;
324 case GL_LINE_SMOOTH:
325 if (ctx->Line.SmoothFlag == state)
326 return;
327 FLUSH_VERTICES(ctx, _NEW_LINE);
328 ctx->Line.SmoothFlag = state;
329 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
330 break;
331 case GL_LINE_STIPPLE:
332 if (ctx->Line.StippleFlag == state)
333 return;
334 FLUSH_VERTICES(ctx, _NEW_LINE);
335 ctx->Line.StippleFlag = state;
336 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
337 break;
338 case GL_INDEX_LOGIC_OP:
339 if (ctx->Color.IndexLogicOpEnabled == state)
340 return;
341 FLUSH_VERTICES(ctx, _NEW_COLOR);
342 ctx->Color.IndexLogicOpEnabled = state;
343 break;
344 case GL_COLOR_LOGIC_OP:
345 if (ctx->Color.ColorLogicOpEnabled == state)
346 return;
347 FLUSH_VERTICES(ctx, _NEW_COLOR);
348 ctx->Color.ColorLogicOpEnabled = state;
349 break;
350 case GL_MAP1_COLOR_4:
351 if (ctx->Eval.Map1Color4 == state)
352 return;
353 FLUSH_VERTICES(ctx, _NEW_EVAL);
354 ctx->Eval.Map1Color4 = state;
355 break;
356 case GL_MAP1_INDEX:
357 if (ctx->Eval.Map1Index == state)
358 return;
359 FLUSH_VERTICES(ctx, _NEW_EVAL);
360 ctx->Eval.Map1Index = state;
361 break;
362 case GL_MAP1_NORMAL:
363 if (ctx->Eval.Map1Normal == state)
364 return;
365 FLUSH_VERTICES(ctx, _NEW_EVAL);
366 ctx->Eval.Map1Normal = state;
367 break;
368 case GL_MAP1_TEXTURE_COORD_1:
369 if (ctx->Eval.Map1TextureCoord1 == state)
370 return;
371 FLUSH_VERTICES(ctx, _NEW_EVAL);
372 ctx->Eval.Map1TextureCoord1 = state;
373 break;
374 case GL_MAP1_TEXTURE_COORD_2:
375 if (ctx->Eval.Map1TextureCoord2 == state)
376 return;
377 FLUSH_VERTICES(ctx, _NEW_EVAL);
378 ctx->Eval.Map1TextureCoord2 = state;
379 break;
380 case GL_MAP1_TEXTURE_COORD_3:
381 if (ctx->Eval.Map1TextureCoord3 == state)
382 return;
383 FLUSH_VERTICES(ctx, _NEW_EVAL);
384 ctx->Eval.Map1TextureCoord3 = state;
385 break;
386 case GL_MAP1_TEXTURE_COORD_4:
387 if (ctx->Eval.Map1TextureCoord4 == state)
388 return;
389 FLUSH_VERTICES(ctx, _NEW_EVAL);
390 ctx->Eval.Map1TextureCoord4 = state;
391 break;
392 case GL_MAP1_VERTEX_3:
393 if (ctx->Eval.Map1Vertex3 == state)
394 return;
395 FLUSH_VERTICES(ctx, _NEW_EVAL);
396 ctx->Eval.Map1Vertex3 = state;
397 break;
398 case GL_MAP1_VERTEX_4:
399 if (ctx->Eval.Map1Vertex4 == state)
400 return;
401 FLUSH_VERTICES(ctx, _NEW_EVAL);
402 ctx->Eval.Map1Vertex4 = state;
403 break;
404 case GL_MAP2_COLOR_4:
405 if (ctx->Eval.Map2Color4 == state)
406 return;
407 FLUSH_VERTICES(ctx, _NEW_EVAL);
408 ctx->Eval.Map2Color4 = state;
409 break;
410 case GL_MAP2_INDEX:
411 if (ctx->Eval.Map2Index == state)
412 return;
413 FLUSH_VERTICES(ctx, _NEW_EVAL);
414 ctx->Eval.Map2Index = state;
415 break;
416 case GL_MAP2_NORMAL:
417 if (ctx->Eval.Map2Normal == state)
418 return;
419 FLUSH_VERTICES(ctx, _NEW_EVAL);
420 ctx->Eval.Map2Normal = state;
421 break;
422 case GL_MAP2_TEXTURE_COORD_1:
423 if (ctx->Eval.Map2TextureCoord1 == state)
424 return;
425 FLUSH_VERTICES(ctx, _NEW_EVAL);
426 ctx->Eval.Map2TextureCoord1 = state;
427 break;
428 case GL_MAP2_TEXTURE_COORD_2:
429 if (ctx->Eval.Map2TextureCoord2 == state)
430 return;
431 FLUSH_VERTICES(ctx, _NEW_EVAL);
432 ctx->Eval.Map2TextureCoord2 = state;
433 break;
434 case GL_MAP2_TEXTURE_COORD_3:
435 if (ctx->Eval.Map2TextureCoord3 == state)
436 return;
437 FLUSH_VERTICES(ctx, _NEW_EVAL);
438 ctx->Eval.Map2TextureCoord3 = state;
439 break;
440 case GL_MAP2_TEXTURE_COORD_4:
441 if (ctx->Eval.Map2TextureCoord4 == state)
442 return;
443 FLUSH_VERTICES(ctx, _NEW_EVAL);
444 ctx->Eval.Map2TextureCoord4 = state;
445 break;
446 case GL_MAP2_VERTEX_3:
447 if (ctx->Eval.Map2Vertex3 == state)
448 return;
449 FLUSH_VERTICES(ctx, _NEW_EVAL);
450 ctx->Eval.Map2Vertex3 = state;
451 break;
452 case GL_MAP2_VERTEX_4:
453 if (ctx->Eval.Map2Vertex4 == state)
454 return;
455 FLUSH_VERTICES(ctx, _NEW_EVAL);
456 ctx->Eval.Map2Vertex4 = state;
457 break;
458 case GL_MINMAX:
459 if (ctx->Pixel.MinMaxEnabled == state)
460 return;
461 FLUSH_VERTICES(ctx, _NEW_PIXEL);
462 ctx->Pixel.MinMaxEnabled = state;
463 break;
464 case GL_NORMALIZE:
465 if (ctx->Transform.Normalize == state)
466 return;
467 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
468 ctx->Transform.Normalize = state;
469 break;
470 case GL_POINT_SMOOTH:
471 if (ctx->Point.SmoothFlag==state)
472 return;
473 FLUSH_VERTICES(ctx, _NEW_POINT);
474 ctx->Point.SmoothFlag = state;
475 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
476 break;
477 case GL_POLYGON_SMOOTH:
478 if (ctx->Polygon.SmoothFlag==state)
479 return;
480 FLUSH_VERTICES(ctx, _NEW_POLYGON);
481 ctx->Polygon.SmoothFlag = state;
482 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
483 break;
484 case GL_POLYGON_STIPPLE:
485 if (ctx->Polygon.StippleFlag==state)
486 return;
487 FLUSH_VERTICES(ctx, _NEW_POLYGON);
488 ctx->Polygon.StippleFlag = state;
489 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
490 break;
491 case GL_POLYGON_OFFSET_POINT:
492 if (ctx->Polygon.OffsetPoint==state)
493 return;
494 FLUSH_VERTICES(ctx, _NEW_POLYGON);
495 ctx->Polygon.OffsetPoint = state;
496 break;
497 case GL_POLYGON_OFFSET_LINE:
498 if (ctx->Polygon.OffsetLine==state)
499 return;
500 FLUSH_VERTICES(ctx, _NEW_POLYGON);
501 ctx->Polygon.OffsetLine = state;
502 break;
503 case GL_POLYGON_OFFSET_FILL:
504 /*case GL_POLYGON_OFFSET_EXT:*/
505 if (ctx->Polygon.OffsetFill==state)
506 return;
507 FLUSH_VERTICES(ctx, _NEW_POLYGON);
508 ctx->Polygon.OffsetFill = state;
509 break;
510 case GL_RESCALE_NORMAL_EXT:
511 if (ctx->Transform.RescaleNormals == state)
512 return;
513 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
514 ctx->Transform.RescaleNormals = state;
515 break;
516 case GL_SCISSOR_TEST:
517 if (ctx->Scissor.Enabled==state)
518 return;
519 FLUSH_VERTICES(ctx, _NEW_SCISSOR);
520 ctx->Scissor.Enabled = state;
521 break;
522 case GL_SHARED_TEXTURE_PALETTE_EXT:
523 if (ctx->Texture.SharedPalette == state)
524 return;
525 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
526 ctx->Texture.SharedPalette = state;
527 break;
528 case GL_STENCIL_TEST:
529 if (state && ctx->Visual.stencilBits==0) {
530 _mesa_warning(ctx,
531 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
532 return;
533 }
534 if (ctx->Stencil.Enabled==state)
535 return;
536 FLUSH_VERTICES(ctx, _NEW_STENCIL);
537 ctx->Stencil.Enabled = state;
538 break;
539 case GL_TEXTURE_1D: {
540 const GLuint curr = ctx->Texture.CurrentUnit;
541 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
542 GLuint newenabled = texUnit->Enabled & ~TEXTURE0_1D;
543 if (state)
544 newenabled |= TEXTURE0_1D;
545 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
546 return;
547 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
548 texUnit->Enabled = newenabled;
549 break;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000550 }
Brian Paul86b84272001-12-14 02:50:01 +0000551 case GL_TEXTURE_2D: {
552 const GLuint curr = ctx->Texture.CurrentUnit;
553 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
554 GLuint newenabled = texUnit->Enabled & ~TEXTURE0_2D;
555 if (state)
556 newenabled |= TEXTURE0_2D;
557 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
558 return;
559 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
560 texUnit->Enabled = newenabled;
561 break;
562 }
563 case GL_TEXTURE_3D: {
564 const GLuint curr = ctx->Texture.CurrentUnit;
565 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
566 GLuint newenabled = texUnit->Enabled & ~TEXTURE0_3D;
567 if (state)
568 newenabled |= TEXTURE0_3D;
569 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
570 return;
571 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
572 texUnit->Enabled = newenabled;
573 break;
574 }
575 case GL_TEXTURE_GEN_Q: {
576 GLuint unit = ctx->Texture.CurrentUnit;
577 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
578 GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
579 if (state)
580 newenabled |= Q_BIT;
581 if (texUnit->TexGenEnabled == newenabled)
582 return;
583 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
584 texUnit->TexGenEnabled = newenabled;
585 break;
586 }
587 case GL_TEXTURE_GEN_R: {
588 GLuint unit = ctx->Texture.CurrentUnit;
589 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
590 GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
591 if (state)
592 newenabled |= R_BIT;
593 if (texUnit->TexGenEnabled == newenabled)
594 return;
595 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
596 texUnit->TexGenEnabled = newenabled;
597 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000598 }
599 break;
Brian Paul86b84272001-12-14 02:50:01 +0000600 case GL_TEXTURE_GEN_S: {
601 GLuint unit = ctx->Texture.CurrentUnit;
602 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
603 GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
604 if (state)
605 newenabled |= S_BIT;
606 if (texUnit->TexGenEnabled == newenabled)
607 return;
608 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
609 texUnit->TexGenEnabled = newenabled;
610 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000611 }
612 break;
Brian Paul86b84272001-12-14 02:50:01 +0000613 case GL_TEXTURE_GEN_T: {
614 GLuint unit = ctx->Texture.CurrentUnit;
615 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
616 GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
617 if (state)
618 newenabled |= T_BIT;
619 if (texUnit->TexGenEnabled == newenabled)
620 return;
621 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
622 texUnit->TexGenEnabled = newenabled;
623 break;
624 }
625 break;
Keith Whitwell46b09882001-02-16 18:14:41 +0000626
Brian Paul86b84272001-12-14 02:50:01 +0000627 /*
628 * CLIENT STATE!!!
629 */
630 case GL_VERTEX_ARRAY:
631 case GL_NORMAL_ARRAY:
632 case GL_COLOR_ARRAY:
633 case GL_INDEX_ARRAY:
634 case GL_TEXTURE_COORD_ARRAY:
635 case GL_EDGE_FLAG_ARRAY:
636 case GL_FOG_COORDINATE_ARRAY_EXT:
637 case GL_SECONDARY_COLOR_ARRAY_EXT:
638 client_state( ctx, cap, state );
639 return;
jtgafb833d1999-08-19 00:55:39 +0000640
Brian Paul1b2ff692000-03-11 23:23:26 +0000641 /* GL_HP_occlusion_test */
Brian Paul86b84272001-12-14 02:50:01 +0000642 case GL_OCCLUSION_TEST_HP:
643 CHECK_EXTENSION(HP_occlusion_test);
644 if (ctx->Depth.OcclusionTest == state)
645 return;
646 FLUSH_VERTICES(ctx, _NEW_DEPTH);
647 ctx->Depth.OcclusionTest = state;
648 if (state)
649 ctx->OcclusionResult = ctx->OcclusionResultSaved;
650 else
651 ctx->OcclusionResultSaved = ctx->OcclusionResult;
652 break;
Brian Paul1b2ff692000-03-11 23:23:26 +0000653
Brian Paul2b2e9252000-04-07 16:27:26 +0000654 /* GL_SGIS_pixel_texture */
Brian Paul86b84272001-12-14 02:50:01 +0000655 case GL_PIXEL_TEXTURE_SGIS:
656 CHECK_EXTENSION(SGIS_pixel_texture);
657 if (ctx->Pixel.PixelTextureEnabled == state)
658 return;
659 FLUSH_VERTICES(ctx, _NEW_PIXEL);
660 ctx->Pixel.PixelTextureEnabled = state;
661 break;
Brian Paul2b2e9252000-04-07 16:27:26 +0000662
663 /* GL_SGIX_pixel_texture */
Brian Paul86b84272001-12-14 02:50:01 +0000664 case GL_PIXEL_TEX_GEN_SGIX:
665 CHECK_EXTENSION(SGIX_pixel_texture);
666 if (ctx->Pixel.PixelTextureEnabled == state)
667 return;
668 FLUSH_VERTICES(ctx, _NEW_PIXEL);
669 ctx->Pixel.PixelTextureEnabled = state;
670 break;
Brian Paul2b2e9252000-04-07 16:27:26 +0000671
Brian Paul13811372000-04-12 00:27:37 +0000672 /* GL_SGI_color_table */
Brian Paul86b84272001-12-14 02:50:01 +0000673 case GL_COLOR_TABLE_SGI:
674 CHECK_EXTENSION(SGI_color_table);
675 if (ctx->Pixel.ColorTableEnabled == state)
676 return;
677 FLUSH_VERTICES(ctx, _NEW_PIXEL);
678 ctx->Pixel.ColorTableEnabled = state;
679 break;
680 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
681 CHECK_EXTENSION(SGI_color_table);
682 if (ctx->Pixel.PostConvolutionColorTableEnabled == state)
683 return;
684 FLUSH_VERTICES(ctx, _NEW_PIXEL);
685 ctx->Pixel.PostConvolutionColorTableEnabled = state;
686 break;
687 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
688 CHECK_EXTENSION(SGI_color_table);
689 if (ctx->Pixel.PostColorMatrixColorTableEnabled == state)
690 return;
691 FLUSH_VERTICES(ctx, _NEW_PIXEL);
692 ctx->Pixel.PostColorMatrixColorTableEnabled = state;
693 break;
Brian Paul13811372000-04-12 00:27:37 +0000694
Brian Paul82b02f02000-05-07 20:37:40 +0000695 /* GL_EXT_convolution */
Brian Paul86b84272001-12-14 02:50:01 +0000696 case GL_CONVOLUTION_1D:
697 CHECK_EXTENSION(EXT_convolution);
698 if (ctx->Pixel.Convolution1DEnabled == state)
699 return;
700 FLUSH_VERTICES(ctx, _NEW_PIXEL);
701 ctx->Pixel.Convolution1DEnabled = state;
702 break;
703 case GL_CONVOLUTION_2D:
704 CHECK_EXTENSION(EXT_convolution);
705 if (ctx->Pixel.Convolution2DEnabled == state)
706 return;
707 FLUSH_VERTICES(ctx, _NEW_PIXEL);
708 ctx->Pixel.Convolution2DEnabled = state;
709 break;
710 case GL_SEPARABLE_2D:
711 CHECK_EXTENSION(EXT_convolution);
712 if (ctx->Pixel.Separable2DEnabled == state)
713 return;
714 FLUSH_VERTICES(ctx, _NEW_PIXEL);
715 ctx->Pixel.Separable2DEnabled = state;
716 break;
Brian Paul82b02f02000-05-07 20:37:40 +0000717
Brian Paul86fc3702000-05-22 16:33:20 +0000718 /* GL_ARB_texture_cube_map */
Brian Paul86b84272001-12-14 02:50:01 +0000719 case GL_TEXTURE_CUBE_MAP_ARB:
720 {
721 const GLuint curr = ctx->Texture.CurrentUnit;
722 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
723 GLuint newenabled = texUnit->Enabled & ~TEXTURE0_CUBE;
724 CHECK_EXTENSION(ARB_texture_cube_map);
725 if (state)
726 newenabled |= TEXTURE0_CUBE;
727 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
728 return;
729 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
730 texUnit->Enabled = newenabled;
731 }
732 break;
733
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000734 /* GL_EXT_secondary_color */
Brian Paul86b84272001-12-14 02:50:01 +0000735 case GL_COLOR_SUM_EXT:
736 CHECK_EXTENSION(EXT_secondary_color);
737 if (ctx->Fog.ColorSumEnabled == state)
738 return;
739 FLUSH_VERTICES(ctx, _NEW_FOG);
740 ctx->Fog.ColorSumEnabled = state;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000741
Brian Paul86b84272001-12-14 02:50:01 +0000742 if ((ctx->Light.Enabled &&
743 ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
744 || ctx->Fog.ColorSumEnabled)
745 ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
746 else
747 ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
Keith Whitwell46b09882001-02-16 18:14:41 +0000748
Brian Paul86b84272001-12-14 02:50:01 +0000749 break;
Brian Paul06d05af2000-12-08 00:20:15 +0000750
Brian Paul736fcbe2001-05-29 15:23:48 +0000751 /* GL_ARB_multisample */
Brian Paul86b84272001-12-14 02:50:01 +0000752 case GL_MULTISAMPLE_ARB:
753 CHECK_EXTENSION(ARB_multisample);
754 if (ctx->Multisample.Enabled == state)
755 return;
756 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
757 ctx->Multisample.Enabled = state;
758 break;
759 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
760 CHECK_EXTENSION(ARB_multisample);
761 if (ctx->Multisample.SampleAlphaToCoverage == state)
762 return;
763 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
764 ctx->Multisample.SampleAlphaToCoverage = state;
765 break;
766 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
767 CHECK_EXTENSION(ARB_multisample);
768 if (ctx->Multisample.SampleAlphaToOne == state)
769 return;
770 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
771 ctx->Multisample.SampleAlphaToOne = state;
772 break;
773 case GL_SAMPLE_COVERAGE_ARB:
774 CHECK_EXTENSION(ARB_multisample);
775 if (ctx->Multisample.SampleCoverage == state)
776 return;
777 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
778 ctx->Multisample.SampleCoverage = state;
779 break;
780 case GL_SAMPLE_COVERAGE_INVERT_ARB:
781 CHECK_EXTENSION(ARB_multisample);
782 if (ctx->Multisample.SampleCoverageInvert == state)
783 return;
784 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
785 ctx->Multisample.SampleCoverageInvert = state;
786 break;
Brian Paul8c2f6c52001-06-26 01:32:48 +0000787
788 /* GL_IBM_rasterpos_clip */
Brian Paul86b84272001-12-14 02:50:01 +0000789 case GL_RASTER_POSITION_UNCLIPPED_IBM:
790 CHECK_EXTENSION(IBM_rasterpos_clip);
791 if (ctx->Transform.RasterPositionUnclipped == state)
792 return;
793 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
794 ctx->Transform.RasterPositionUnclipped = state;
795 break;
Brian Paul736fcbe2001-05-29 15:23:48 +0000796
Brian Paul06d05af2000-12-08 00:20:15 +0000797 /* GL_MESA_sprite_point */
Brian Paul86b84272001-12-14 02:50:01 +0000798 case GL_SPRITE_POINT_MESA:
799 CHECK_EXTENSION(MESA_sprite_point);
800 if (ctx->Point.SpriteMode == state)
801 return;
802 FLUSH_VERTICES(ctx, _NEW_POINT);
803 ctx->Point.SpriteMode = state;
804 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000805
Brian Paul86b84272001-12-14 02:50:01 +0000806 /* GL_NV_vertex_program */
807 case GL_VERTEX_PROGRAM_NV:
808 CHECK_EXTENSION(NV_vertex_program);
809 if (ctx->VertexProgram.Enabled == state)
810 return;
Brian Paul571a1ac2002-01-06 20:39:03 +0000811 FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_PROGRAM); /* XXX OK? */
Brian Paul86b84272001-12-14 02:50:01 +0000812 ctx->VertexProgram.Enabled = state;
813 break;
814 case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
815 CHECK_EXTENSION(NV_vertex_program);
816 if (ctx->VertexProgram.PointSizeEnabled == state)
817 return;
Brian Paul571a1ac2002-01-06 20:39:03 +0000818 FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_PROGRAM);
Brian Paul86b84272001-12-14 02:50:01 +0000819 ctx->VertexProgram.PointSizeEnabled = state;
820 break;
821 case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
822 CHECK_EXTENSION(NV_vertex_program);
823 if (ctx->VertexProgram.TwoSideEnabled == state)
824 return;
Brian Paul571a1ac2002-01-06 20:39:03 +0000825 FLUSH_VERTICES(ctx, _NEW_PROGRAM); /* XXX OK? */
Brian Paul86b84272001-12-14 02:50:01 +0000826 ctx->VertexProgram.TwoSideEnabled = state;
827 break;
828 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
829 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
830 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
831 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
832 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
833 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
834 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
835 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
836 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
837 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
838 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
839 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
840 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
841 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
842 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
843 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
844 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +0000845 {
846 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
847 FLUSH_VERTICES(ctx, _NEW_EVAL);
848 ctx->Eval.Map1Attrib[map] = state;
849 }
Brian Paul86b84272001-12-14 02:50:01 +0000850 break;
851 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
852 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
853 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
854 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
855 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
856 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
857 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
858 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
859 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
860 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
861 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
862 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
863 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
864 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
865 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
866 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
867 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +0000868 {
869 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
870 FLUSH_VERTICES(ctx, _NEW_EVAL);
871 ctx->Eval.Map2Attrib[map] = state;
872 }
Brian Paul86b84272001-12-14 02:50:01 +0000873 break;
874
875 default:
876 _mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
877 return;
jtgafb833d1999-08-19 00:55:39 +0000878 }
879
880 if (ctx->Driver.Enable) {
881 (*ctx->Driver.Enable)( ctx, cap, state );
882 }
883}
884
885
Brian Paulfbd8f211999-11-11 01:22:25 +0000886void
887_mesa_Enable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000888{
Brian Paulfbd8f211999-11-11 01:22:25 +0000889 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +0000890 ASSERT_OUTSIDE_BEGIN_END(ctx);
891
Brian Paulfbd8f211999-11-11 01:22:25 +0000892 _mesa_set_enable( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000893}
894
895
Brian Paulfbd8f211999-11-11 01:22:25 +0000896void
897_mesa_Disable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000898{
Brian Paulfbd8f211999-11-11 01:22:25 +0000899 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +0000900 ASSERT_OUTSIDE_BEGIN_END(ctx);
901
Brian Paulfbd8f211999-11-11 01:22:25 +0000902 _mesa_set_enable( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000903}
904
905
Brian Paul86b84272001-12-14 02:50:01 +0000906#undef CHECK_EXTENSION
907#define CHECK_EXTENSION(EXTNAME) \
908 if (!ctx->Extensions.EXTNAME) { \
909 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
910 return GL_FALSE; \
911 }
912
jtgafb833d1999-08-19 00:55:39 +0000913
Brian Paulfbd8f211999-11-11 01:22:25 +0000914GLboolean
915_mesa_IsEnabled( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000916{
Brian Paulfbd8f211999-11-11 01:22:25 +0000917 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000918 switch (cap) {
919 case GL_ALPHA_TEST:
920 return ctx->Color.AlphaEnabled;
921 case GL_AUTO_NORMAL:
922 return ctx->Eval.AutoNormal;
923 case GL_BLEND:
924 return ctx->Color.BlendEnabled;
925 case GL_CLIP_PLANE0:
926 case GL_CLIP_PLANE1:
927 case GL_CLIP_PLANE2:
928 case GL_CLIP_PLANE3:
929 case GL_CLIP_PLANE4:
930 case GL_CLIP_PLANE5:
Brian Paul103bc0f2002-03-29 17:27:59 +0000931 return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
jtgafb833d1999-08-19 00:55:39 +0000932 case GL_COLOR_MATERIAL:
933 return ctx->Light.ColorMaterialEnabled;
934 case GL_CULL_FACE:
935 return ctx->Polygon.CullFlag;
936 case GL_DEPTH_TEST:
937 return ctx->Depth.Test;
938 case GL_DITHER:
939 return ctx->Color.DitherFlag;
940 case GL_FOG:
941 return ctx->Fog.Enabled;
942 case GL_LIGHTING:
943 return ctx->Light.Enabled;
944 case GL_LIGHT0:
945 case GL_LIGHT1:
946 case GL_LIGHT2:
947 case GL_LIGHT3:
948 case GL_LIGHT4:
949 case GL_LIGHT5:
950 case GL_LIGHT6:
951 case GL_LIGHT7:
952 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
953 case GL_LINE_SMOOTH:
954 return ctx->Line.SmoothFlag;
955 case GL_LINE_STIPPLE:
956 return ctx->Line.StippleFlag;
957 case GL_INDEX_LOGIC_OP:
958 return ctx->Color.IndexLogicOpEnabled;
959 case GL_COLOR_LOGIC_OP:
960 return ctx->Color.ColorLogicOpEnabled;
961 case GL_MAP1_COLOR_4:
962 return ctx->Eval.Map1Color4;
963 case GL_MAP1_INDEX:
964 return ctx->Eval.Map1Index;
965 case GL_MAP1_NORMAL:
966 return ctx->Eval.Map1Normal;
967 case GL_MAP1_TEXTURE_COORD_1:
968 return ctx->Eval.Map1TextureCoord1;
969 case GL_MAP1_TEXTURE_COORD_2:
970 return ctx->Eval.Map1TextureCoord2;
971 case GL_MAP1_TEXTURE_COORD_3:
972 return ctx->Eval.Map1TextureCoord3;
973 case GL_MAP1_TEXTURE_COORD_4:
974 return ctx->Eval.Map1TextureCoord4;
975 case GL_MAP1_VERTEX_3:
976 return ctx->Eval.Map1Vertex3;
977 case GL_MAP1_VERTEX_4:
978 return ctx->Eval.Map1Vertex4;
979 case GL_MAP2_COLOR_4:
980 return ctx->Eval.Map2Color4;
981 case GL_MAP2_INDEX:
982 return ctx->Eval.Map2Index;
983 case GL_MAP2_NORMAL:
984 return ctx->Eval.Map2Normal;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000985 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +0000986 return ctx->Eval.Map2TextureCoord1;
987 case GL_MAP2_TEXTURE_COORD_2:
988 return ctx->Eval.Map2TextureCoord2;
989 case GL_MAP2_TEXTURE_COORD_3:
990 return ctx->Eval.Map2TextureCoord3;
991 case GL_MAP2_TEXTURE_COORD_4:
992 return ctx->Eval.Map2TextureCoord4;
993 case GL_MAP2_VERTEX_3:
994 return ctx->Eval.Map2Vertex3;
995 case GL_MAP2_VERTEX_4:
996 return ctx->Eval.Map2Vertex4;
997 case GL_NORMALIZE:
998 return ctx->Transform.Normalize;
999 case GL_POINT_SMOOTH:
1000 return ctx->Point.SmoothFlag;
1001 case GL_POLYGON_SMOOTH:
1002 return ctx->Polygon.SmoothFlag;
1003 case GL_POLYGON_STIPPLE:
1004 return ctx->Polygon.StippleFlag;
1005 case GL_POLYGON_OFFSET_POINT:
1006 return ctx->Polygon.OffsetPoint;
1007 case GL_POLYGON_OFFSET_LINE:
1008 return ctx->Polygon.OffsetLine;
1009 case GL_POLYGON_OFFSET_FILL:
1010 /*case GL_POLYGON_OFFSET_EXT:*/
1011 return ctx->Polygon.OffsetFill;
1012 case GL_RESCALE_NORMAL_EXT:
1013 return ctx->Transform.RescaleNormals;
1014 case GL_SCISSOR_TEST:
1015 return ctx->Scissor.Enabled;
1016 case GL_SHARED_TEXTURE_PALETTE_EXT:
1017 return ctx->Texture.SharedPalette;
1018 case GL_STENCIL_TEST:
1019 return ctx->Stencil.Enabled;
1020 case GL_TEXTURE_1D:
1021 {
Brian Paul86b84272001-12-14 02:50:01 +00001022 const struct gl_texture_unit *texUnit;
1023 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001024 return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
1025 }
1026 case GL_TEXTURE_2D:
1027 {
Brian Paul86b84272001-12-14 02:50:01 +00001028 const struct gl_texture_unit *texUnit;
1029 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001030 return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
1031 }
1032 case GL_TEXTURE_3D:
1033 {
Brian Paul86b84272001-12-14 02:50:01 +00001034 const struct gl_texture_unit *texUnit;
1035 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul65b5e1e1999-08-19 13:24:27 +00001036 return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001037 }
1038 case GL_TEXTURE_GEN_Q:
1039 {
Brian Paul86b84272001-12-14 02:50:01 +00001040 const struct gl_texture_unit *texUnit;
1041 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001042 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
1043 }
1044 case GL_TEXTURE_GEN_R:
1045 {
Brian Paul86b84272001-12-14 02:50:01 +00001046 const struct gl_texture_unit *texUnit;
1047 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001048 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
1049 }
1050 case GL_TEXTURE_GEN_S:
1051 {
Brian Paul86b84272001-12-14 02:50:01 +00001052 const struct gl_texture_unit *texUnit;
1053 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001054 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
1055 }
1056 case GL_TEXTURE_GEN_T:
1057 {
Brian Paul86b84272001-12-14 02:50:01 +00001058 const struct gl_texture_unit *texUnit;
1059 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001060 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
1061 }
1062
1063 /*
1064 * CLIENT STATE!!!
1065 */
1066 case GL_VERTEX_ARRAY:
Brian Paul8e6d3052002-01-11 17:26:54 +00001067 return (ctx->Array.Vertex.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001068 case GL_NORMAL_ARRAY:
Brian Paul8e6d3052002-01-11 17:26:54 +00001069 return (ctx->Array.Normal.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001070 case GL_COLOR_ARRAY:
Brian Paul8e6d3052002-01-11 17:26:54 +00001071 return (ctx->Array.Color.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001072 case GL_INDEX_ARRAY:
Brian Paul8e6d3052002-01-11 17:26:54 +00001073 return (ctx->Array.Index.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001074 case GL_TEXTURE_COORD_ARRAY:
Brian Paul8e6d3052002-01-11 17:26:54 +00001075 return (ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001076 case GL_EDGE_FLAG_ARRAY:
Brian Paul8e6d3052002-01-11 17:26:54 +00001077 return (ctx->Array.EdgeFlag.Enabled != 0);
Brian Paul6ee7a022002-01-22 18:40:46 +00001078 case GL_FOG_COORDINATE_ARRAY_EXT:
1079 CHECK_EXTENSION(EXT_fog_coord);
1080 return (ctx->Array.FogCoord.Enabled != 0);
1081 case GL_SECONDARY_COLOR_ARRAY_EXT:
1082 CHECK_EXTENSION(EXT_secondary_color);
1083 return (ctx->Array.SecondaryColor.Enabled != 0);
Brian Paul1b2ff692000-03-11 23:23:26 +00001084
Brian Paul86b84272001-12-14 02:50:01 +00001085 /* GL_EXT_histogram */
1086 case GL_HISTOGRAM:
1087 CHECK_EXTENSION(EXT_histogram);
1088 return ctx->Pixel.HistogramEnabled;
1089 case GL_MINMAX:
1090 CHECK_EXTENSION(EXT_histogram);
1091 return ctx->Pixel.MinMaxEnabled;
1092
Brian Paul1b2ff692000-03-11 23:23:26 +00001093 /* GL_HP_occlusion_test */
1094 case GL_OCCLUSION_TEST_HP:
Brian Paul86b84272001-12-14 02:50:01 +00001095 CHECK_EXTENSION(HP_occlusion_test);
1096 return ctx->Depth.OcclusionTest;
Brian Paul1b2ff692000-03-11 23:23:26 +00001097
Brian Paul2b2e9252000-04-07 16:27:26 +00001098 /* GL_SGIS_pixel_texture */
1099 case GL_PIXEL_TEXTURE_SGIS:
Brian Paul86b84272001-12-14 02:50:01 +00001100 CHECK_EXTENSION(SGIS_pixel_texture);
Brian Paul2b2e9252000-04-07 16:27:26 +00001101 return ctx->Pixel.PixelTextureEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +00001102
1103 /* GL_SGIX_pixel_texture */
1104 case GL_PIXEL_TEX_GEN_SGIX:
Brian Paul86b84272001-12-14 02:50:01 +00001105 CHECK_EXTENSION(SGIX_pixel_texture);
Brian Paul2b2e9252000-04-07 16:27:26 +00001106 return ctx->Pixel.PixelTextureEnabled;
Brian Paul13811372000-04-12 00:27:37 +00001107
1108 /* GL_SGI_color_table */
1109 case GL_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001110 CHECK_EXTENSION(SGI_color_table);
Brian Paul13811372000-04-12 00:27:37 +00001111 return ctx->Pixel.ColorTableEnabled;
1112 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001113 CHECK_EXTENSION(SGI_color_table);
Brian Paul13811372000-04-12 00:27:37 +00001114 return ctx->Pixel.PostConvolutionColorTableEnabled;
1115 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001116 CHECK_EXTENSION(SGI_color_table);
Brian Paul13811372000-04-12 00:27:37 +00001117 return ctx->Pixel.PostColorMatrixColorTableEnabled;
Brian Paul2b2e9252000-04-07 16:27:26 +00001118
Brian Paul82b02f02000-05-07 20:37:40 +00001119 /* GL_EXT_convolution */
1120 case GL_CONVOLUTION_1D:
Brian Paul86b84272001-12-14 02:50:01 +00001121 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001122 return ctx->Pixel.Convolution1DEnabled;
1123 case GL_CONVOLUTION_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001124 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001125 return ctx->Pixel.Convolution2DEnabled;
1126 case GL_SEPARABLE_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001127 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001128 return ctx->Pixel.Separable2DEnabled;
1129
Brian Paul86fc3702000-05-22 16:33:20 +00001130 /* GL_ARB_texture_cube_map */
1131 case GL_TEXTURE_CUBE_MAP_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001132 CHECK_EXTENSION(ARB_texture_cube_map);
1133 {
1134 const struct gl_texture_unit *texUnit;
1135 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paulfc4b4432000-05-23 15:17:12 +00001136 return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
Brian Paul86fc3702000-05-22 16:33:20 +00001137 }
Brian Paul86fc3702000-05-22 16:33:20 +00001138
Brian Paul736fcbe2001-05-29 15:23:48 +00001139 /* GL_ARB_multisample */
1140 case GL_MULTISAMPLE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001141 CHECK_EXTENSION(ARB_multisample);
1142 return ctx->Multisample.Enabled;
Brian Paul736fcbe2001-05-29 15:23:48 +00001143 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001144 CHECK_EXTENSION(ARB_multisample);
1145 return ctx->Multisample.SampleAlphaToCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001146 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001147 CHECK_EXTENSION(ARB_multisample);
1148 return ctx->Multisample.SampleAlphaToOne;
Brian Paul736fcbe2001-05-29 15:23:48 +00001149 case GL_SAMPLE_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001150 CHECK_EXTENSION(ARB_multisample);
1151 return ctx->Multisample.SampleCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001152 case GL_SAMPLE_COVERAGE_INVERT_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001153 CHECK_EXTENSION(ARB_multisample);
1154 return ctx->Multisample.SampleCoverageInvert;
Brian Paul736fcbe2001-05-29 15:23:48 +00001155
Brian Paul8c2f6c52001-06-26 01:32:48 +00001156 /* GL_IBM_rasterpos_clip */
1157 case GL_RASTER_POSITION_UNCLIPPED_IBM:
Brian Paul86b84272001-12-14 02:50:01 +00001158 CHECK_EXTENSION(IBM_rasterpos_clip);
1159 return ctx->Transform.RasterPositionUnclipped;
Brian Paul8c2f6c52001-06-26 01:32:48 +00001160
Brian Paul06d05af2000-12-08 00:20:15 +00001161 /* GL_MESA_sprite_point */
1162 case GL_SPRITE_POINT_MESA:
1163 return ctx->Point.SpriteMode;
1164
Brian Paul86b84272001-12-14 02:50:01 +00001165 /* GL_NV_vertex_program */
1166 case GL_VERTEX_PROGRAM_NV:
1167 CHECK_EXTENSION(NV_vertex_program);
1168 return ctx->VertexProgram.Enabled;
1169 case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
1170 CHECK_EXTENSION(NV_vertex_program);
1171 return ctx->VertexProgram.PointSizeEnabled;
1172 case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
1173 CHECK_EXTENSION(NV_vertex_program);
1174 return ctx->VertexProgram.TwoSideEnabled;
1175 case GL_VERTEX_ATTRIB_ARRAY0_NV:
1176 case GL_VERTEX_ATTRIB_ARRAY1_NV:
1177 case GL_VERTEX_ATTRIB_ARRAY2_NV:
1178 case GL_VERTEX_ATTRIB_ARRAY3_NV:
1179 case GL_VERTEX_ATTRIB_ARRAY4_NV:
1180 case GL_VERTEX_ATTRIB_ARRAY5_NV:
1181 case GL_VERTEX_ATTRIB_ARRAY6_NV:
1182 case GL_VERTEX_ATTRIB_ARRAY7_NV:
1183 case GL_VERTEX_ATTRIB_ARRAY8_NV:
1184 case GL_VERTEX_ATTRIB_ARRAY9_NV:
1185 case GL_VERTEX_ATTRIB_ARRAY10_NV:
1186 case GL_VERTEX_ATTRIB_ARRAY11_NV:
1187 case GL_VERTEX_ATTRIB_ARRAY12_NV:
1188 case GL_VERTEX_ATTRIB_ARRAY13_NV:
1189 case GL_VERTEX_ATTRIB_ARRAY14_NV:
1190 case GL_VERTEX_ATTRIB_ARRAY15_NV:
1191 CHECK_EXTENSION(NV_vertex_program);
1192 {
1193 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
Brian Paul8e6d3052002-01-11 17:26:54 +00001194 return (ctx->Array.VertexAttrib[n].Enabled != 0);
Brian Paul86b84272001-12-14 02:50:01 +00001195 }
1196 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
1197 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
1198 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
1199 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
1200 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
1201 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
1202 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
1203 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
1204 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
1205 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
1206 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
1207 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
1208 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
1209 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
1210 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
1211 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
1212 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001213 {
1214 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
1215 return ctx->Eval.Map1Attrib[map];
1216 }
Brian Paul86b84272001-12-14 02:50:01 +00001217 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
1218 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
1219 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
1220 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
1221 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
1222 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
1223 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
1224 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
1225 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
1226 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
1227 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
1228 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
1229 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
1230 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
1231 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
1232 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
1233 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001234 {
1235 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
1236 return ctx->Eval.Map2Attrib[map];
1237 }
Brian Paul86b84272001-12-14 02:50:01 +00001238
jtgafb833d1999-08-19 00:55:39 +00001239 default:
Brian Paul08836342001-03-03 20:33:27 +00001240 _mesa_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
jtgafb833d1999-08-19 00:55:39 +00001241 return GL_FALSE;
1242 }
1243}