removed Driver.UseGlobalTexturePalette()
[mesa.git] / src / mesa / main / enable.c
1 /* $Id: enable.c,v 1.11 2000/03/07 18:24:49 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
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
31 #include "glheader.h"
32 #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"
43 #endif
44
45
46
47 /*
48 * Perform glEnable and glDisable calls.
49 */
50 void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
51 {
52 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" );
53
54 if (MESA_VERBOSE & VERBOSE_API)
55 fprintf(stderr, "%s %s (newstate is %x)\n",
56 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;
64 ctx->NewState |= NEW_RASTER_OPS;
65 }
66 break;
67 case GL_AUTO_NORMAL:
68 ctx->Eval.AutoNormal = state;
69 break;
70 case GL_BLEND:
71 if (ctx->Color.BlendEnabled!=state) {
72 ctx->Color.BlendEnabled = state;
73 /* The following needed to accomodate 1.0 RGB logic op blending */
74 if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) {
75 ctx->Color.ColorLogicOpEnabled = GL_TRUE;
76 }
77 else {
78 ctx->Color.ColorLogicOpEnabled = GL_FALSE;
79 }
80 ctx->NewState |= NEW_RASTER_OPS;
81 }
82 break;
83 case GL_CLIP_PLANE0:
84 case GL_CLIP_PLANE1:
85 case GL_CLIP_PLANE2:
86 case GL_CLIP_PLANE3:
87 case GL_CLIP_PLANE4:
88 case GL_CLIP_PLANE5:
89 if (cap >= GL_CLIP_PLANE0 &&
90 cap <= GL_CLIP_PLANE5 &&
91 ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] != state)
92 {
93 GLuint p = cap-GL_CLIP_PLANE0;
94
95 ctx->Transform.ClipEnabled[p] = state;
96 ctx->NewState |= NEW_USER_CLIP;
97
98 if (state) {
99 ctx->Enabled |= ENABLE_USERCLIP;
100 ctx->Transform.AnyClip++;
101
102 if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) {
103 gl_matrix_analyze( &ctx->ProjectionMatrix );
104 }
105
106 gl_transform_vector( ctx->Transform.ClipUserPlane[p],
107 ctx->Transform.EyeUserPlane[p],
108 ctx->ProjectionMatrix.inv );
109 } else {
110 if (--ctx->Transform.AnyClip == 0)
111 ctx->Enabled &= ~ENABLE_USERCLIP;
112 }
113 }
114 break;
115 case GL_COLOR_MATERIAL:
116 if (ctx->Light.ColorMaterialEnabled!=state) {
117 ctx->Light.ColorMaterialEnabled = state;
118 ctx->NewState |= NEW_LIGHTING;
119 if (state)
120 gl_update_color_material( ctx, ctx->Current.ByteColor );
121 }
122 break;
123 case GL_CULL_FACE:
124 if (ctx->Polygon.CullFlag!=state) {
125 ctx->Polygon.CullFlag = state;
126 ctx->TriangleCaps ^= DD_TRI_CULL;
127 ctx->NewState |= NEW_POLYGON;
128 }
129 break;
130 case GL_DEPTH_TEST:
131 if (state && ctx->Visual->DepthBits==0) {
132 gl_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
133 return;
134 }
135 if (ctx->Depth.Test!=state) {
136 ctx->Depth.Test = state;
137 ctx->NewState |= NEW_RASTER_OPS;
138 }
139 break;
140 case GL_DITHER:
141 if (ctx->NoDither) {
142 /* MESA_NO_DITHER env var */
143 state = GL_FALSE;
144 }
145 if (ctx->Color.DitherFlag!=state) {
146 ctx->Color.DitherFlag = state;
147 ctx->NewState |= NEW_RASTER_OPS;
148 }
149 break;
150 case GL_FOG:
151 if (ctx->Fog.Enabled!=state) {
152 ctx->Fog.Enabled = state;
153 ctx->Enabled ^= ENABLE_FOG;
154 ctx->NewState |= NEW_FOG|NEW_RASTER_OPS;
155 }
156 break;
157 case GL_LIGHT0:
158 case GL_LIGHT1:
159 case GL_LIGHT2:
160 case GL_LIGHT3:
161 case GL_LIGHT4:
162 case GL_LIGHT5:
163 case GL_LIGHT6:
164 case GL_LIGHT7:
165 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state)
166 {
167 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
168
169 if (state) {
170 insert_at_tail(&ctx->Light.EnabledList,
171 &ctx->Light.Light[cap-GL_LIGHT0]);
172 if (ctx->Light.Enabled)
173 ctx->Enabled |= ENABLE_LIGHT;
174 } else {
175 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
176 if (is_empty_list(&ctx->Light.EnabledList))
177 ctx->Enabled &= ~ENABLE_LIGHT;
178 }
179
180 ctx->NewState |= NEW_LIGHTING;
181 }
182 break;
183 case GL_LIGHTING:
184 if (ctx->Light.Enabled!=state) {
185 ctx->Light.Enabled = state;
186 ctx->Enabled &= ~ENABLE_LIGHT;
187 if (state)
188 ctx->Enabled |= ENABLE_LIGHT;
189 ctx->NewState |= NEW_LIGHTING;
190 }
191 break;
192 case GL_LINE_SMOOTH:
193 if (ctx->Line.SmoothFlag!=state) {
194 ctx->Line.SmoothFlag = state;
195 ctx->NewState |= NEW_RASTER_OPS;
196 }
197 break;
198 case GL_LINE_STIPPLE:
199 if (ctx->Line.StippleFlag!=state) {
200 ctx->Line.StippleFlag = state;
201 ctx->TriangleCaps ^= DD_LINE_STIPPLE;
202 ctx->NewState |= NEW_RASTER_OPS;
203 }
204 break;
205 case GL_INDEX_LOGIC_OP:
206 if (ctx->Color.IndexLogicOpEnabled!=state) {
207 ctx->Color.IndexLogicOpEnabled = state;
208 ctx->NewState |= NEW_RASTER_OPS;
209 }
210 break;
211 case GL_COLOR_LOGIC_OP:
212 if (ctx->Color.ColorLogicOpEnabled!=state) {
213 ctx->Color.ColorLogicOpEnabled = state;
214 ctx->NewState |= NEW_RASTER_OPS;
215 }
216 break;
217 case GL_MAP1_COLOR_4:
218 ctx->Eval.Map1Color4 = state;
219 break;
220 case GL_MAP1_INDEX:
221 ctx->Eval.Map1Index = state;
222 break;
223 case GL_MAP1_NORMAL:
224 ctx->Eval.Map1Normal = state;
225 break;
226 case GL_MAP1_TEXTURE_COORD_1:
227 ctx->Eval.Map1TextureCoord1 = state;
228 break;
229 case GL_MAP1_TEXTURE_COORD_2:
230 ctx->Eval.Map1TextureCoord2 = state;
231 break;
232 case GL_MAP1_TEXTURE_COORD_3:
233 ctx->Eval.Map1TextureCoord3 = state;
234 break;
235 case GL_MAP1_TEXTURE_COORD_4:
236 ctx->Eval.Map1TextureCoord4 = state;
237 break;
238 case GL_MAP1_VERTEX_3:
239 ctx->Eval.Map1Vertex3 = state;
240 break;
241 case GL_MAP1_VERTEX_4:
242 ctx->Eval.Map1Vertex4 = state;
243 break;
244 case GL_MAP2_COLOR_4:
245 ctx->Eval.Map2Color4 = state;
246 break;
247 case GL_MAP2_INDEX:
248 ctx->Eval.Map2Index = state;
249 break;
250 case GL_MAP2_NORMAL:
251 ctx->Eval.Map2Normal = state;
252 break;
253 case GL_MAP2_TEXTURE_COORD_1:
254 ctx->Eval.Map2TextureCoord1 = state;
255 break;
256 case GL_MAP2_TEXTURE_COORD_2:
257 ctx->Eval.Map2TextureCoord2 = state;
258 break;
259 case GL_MAP2_TEXTURE_COORD_3:
260 ctx->Eval.Map2TextureCoord3 = state;
261 break;
262 case GL_MAP2_TEXTURE_COORD_4:
263 ctx->Eval.Map2TextureCoord4 = state;
264 break;
265 case GL_MAP2_VERTEX_3:
266 ctx->Eval.Map2Vertex3 = state;
267 break;
268 case GL_MAP2_VERTEX_4:
269 ctx->Eval.Map2Vertex4 = state;
270 break;
271 case GL_NORMALIZE:
272 if (ctx->Transform.Normalize != state) {
273 ctx->Transform.Normalize = state;
274 ctx->NewState |= NEW_NORMAL_TRANSFORM|NEW_LIGHTING;
275 ctx->Enabled ^= ENABLE_NORMALIZE;
276 }
277 break;
278 case GL_POINT_SMOOTH:
279 if (ctx->Point.SmoothFlag!=state) {
280 ctx->Point.SmoothFlag = state;
281 ctx->NewState |= NEW_RASTER_OPS;
282 }
283 break;
284 case GL_POLYGON_SMOOTH:
285 if (ctx->Polygon.SmoothFlag!=state) {
286 ctx->Polygon.SmoothFlag = state;
287 ctx->NewState |= NEW_RASTER_OPS;
288 }
289 break;
290 case GL_POLYGON_STIPPLE:
291 if (ctx->Polygon.StippleFlag!=state) {
292 ctx->Polygon.StippleFlag = state;
293 ctx->TriangleCaps ^= DD_TRI_STIPPLE;
294 ctx->NewState |= NEW_RASTER_OPS;
295 }
296 break;
297 case GL_POLYGON_OFFSET_POINT:
298 if (ctx->Polygon.OffsetPoint!=state) {
299 ctx->Polygon.OffsetPoint = state;
300 ctx->NewState |= NEW_POLYGON;
301 }
302 break;
303 case GL_POLYGON_OFFSET_LINE:
304 if (ctx->Polygon.OffsetLine!=state) {
305 ctx->Polygon.OffsetLine = state;
306 ctx->NewState |= NEW_POLYGON;
307 }
308 break;
309 case GL_POLYGON_OFFSET_FILL:
310 /*case GL_POLYGON_OFFSET_EXT:*/
311 if (ctx->Polygon.OffsetFill!=state) {
312 ctx->Polygon.OffsetFill = state;
313 ctx->NewState |= NEW_POLYGON;
314 }
315 break;
316 case GL_RESCALE_NORMAL_EXT:
317 if (ctx->Transform.RescaleNormals != state) {
318 ctx->Transform.RescaleNormals = state;
319 ctx->NewState |= NEW_NORMAL_TRANSFORM|NEW_LIGHTING;
320 ctx->Enabled ^= ENABLE_RESCALE;
321 }
322 break;
323 case GL_SCISSOR_TEST:
324 if (ctx->Scissor.Enabled!=state) {
325 ctx->Scissor.Enabled = state;
326 ctx->NewState |= NEW_RASTER_OPS;
327 }
328 break;
329 case GL_SHARED_TEXTURE_PALETTE_EXT:
330 ctx->Texture.SharedPalette = state;
331 break;
332 case GL_STENCIL_TEST:
333 if (state && ctx->Visual->StencilBits==0) {
334 gl_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
335 return;
336 }
337 if (ctx->Stencil.Enabled!=state) {
338 ctx->Stencil.Enabled = state;
339 ctx->NewState |= NEW_RASTER_OPS;
340 ctx->TriangleCaps ^= DD_STENCIL;
341 }
342 break;
343 case GL_TEXTURE_1D:
344 if (ctx->Visual->RGBAflag) {
345 const GLuint curr = ctx->Texture.CurrentUnit;
346 const GLuint flag = TEXTURE0_1D << (curr * 4);
347 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
348 ctx->NewState |= NEW_TEXTURE_ENABLE;
349 if (state) {
350 texUnit->Enabled |= TEXTURE0_1D;
351 ctx->Enabled |= flag;
352 }
353 else {
354 texUnit->Enabled &= ~TEXTURE0_1D;
355 ctx->Enabled &= ~flag;
356 }
357 }
358 break;
359 case GL_TEXTURE_2D:
360 if (ctx->Visual->RGBAflag) {
361 const GLuint curr = ctx->Texture.CurrentUnit;
362 const GLuint flag = TEXTURE0_2D << (curr * 4);
363 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
364 ctx->NewState |= NEW_TEXTURE_ENABLE;
365 if (state) {
366 texUnit->Enabled |= TEXTURE0_2D;
367 ctx->Enabled |= flag;
368 }
369 else {
370 texUnit->Enabled &= ~TEXTURE0_2D;
371 ctx->Enabled &= ~flag;
372 }
373 }
374 break;
375 case GL_TEXTURE_3D:
376 if (ctx->Visual->RGBAflag) {
377 const GLuint curr = ctx->Texture.CurrentUnit;
378 const GLuint flag = TEXTURE0_3D << (curr * 4);
379 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
380 ctx->NewState |= NEW_TEXTURE_ENABLE;
381 if (state) {
382 texUnit->Enabled |= TEXTURE0_3D;
383 ctx->Enabled |= flag;
384 }
385 else {
386 texUnit->Enabled &= ~TEXTURE0_3D;
387 ctx->Enabled &= ~flag;
388 }
389 }
390 break;
391 case GL_TEXTURE_GEN_Q:
392 {
393 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
394 if (state)
395 texUnit->TexGenEnabled |= Q_BIT;
396 else
397 texUnit->TexGenEnabled &= ~Q_BIT;
398 ctx->NewState |= NEW_TEXTURING;
399 }
400 break;
401 case GL_TEXTURE_GEN_R:
402 {
403 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
404 if (state)
405 texUnit->TexGenEnabled |= R_BIT;
406 else
407 texUnit->TexGenEnabled &= ~R_BIT;
408 ctx->NewState |= NEW_TEXTURING;
409 }
410 break;
411 case GL_TEXTURE_GEN_S:
412 {
413 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
414 if (state)
415 texUnit->TexGenEnabled |= S_BIT;
416 else
417 texUnit->TexGenEnabled &= ~S_BIT;
418 ctx->NewState |= NEW_TEXTURING;
419 }
420 break;
421 case GL_TEXTURE_GEN_T:
422 {
423 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
424 if (state)
425 texUnit->TexGenEnabled |= T_BIT;
426 else
427 texUnit->TexGenEnabled &= ~T_BIT;
428 ctx->NewState |= NEW_TEXTURING;
429 }
430 break;
431
432 /*
433 * CLIENT STATE!!!
434 */
435 case GL_VERTEX_ARRAY:
436 ctx->Array.Vertex.Enabled = state;
437 break;
438 case GL_NORMAL_ARRAY:
439 ctx->Array.Normal.Enabled = state;
440 break;
441 case GL_COLOR_ARRAY:
442 ctx->Array.Color.Enabled = state;
443 break;
444 case GL_INDEX_ARRAY:
445 ctx->Array.Index.Enabled = state;
446 break;
447 case GL_TEXTURE_COORD_ARRAY:
448 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
449 break;
450 case GL_EDGE_FLAG_ARRAY:
451 ctx->Array.EdgeFlag.Enabled = state;
452 break;
453
454 default:
455 if (state) {
456 gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
457 }
458 else {
459 gl_error( ctx, GL_INVALID_ENUM, "glDisable" );
460 }
461 return;
462 }
463
464 if (ctx->Driver.Enable) {
465 (*ctx->Driver.Enable)( ctx, cap, state );
466 }
467 }
468
469
470
471
472 void
473 _mesa_Enable( GLenum cap )
474 {
475 GET_CURRENT_CONTEXT(ctx);
476 _mesa_set_enable( ctx, cap, GL_TRUE );
477 }
478
479
480
481 void
482 _mesa_Disable( GLenum cap )
483 {
484 GET_CURRENT_CONTEXT(ctx);
485 _mesa_set_enable( ctx, cap, GL_FALSE );
486 }
487
488
489
490 GLboolean
491 _mesa_IsEnabled( GLenum cap )
492 {
493 GET_CURRENT_CONTEXT(ctx);
494 switch (cap) {
495 case GL_ALPHA_TEST:
496 return ctx->Color.AlphaEnabled;
497 case GL_AUTO_NORMAL:
498 return ctx->Eval.AutoNormal;
499 case GL_BLEND:
500 return ctx->Color.BlendEnabled;
501 case GL_CLIP_PLANE0:
502 case GL_CLIP_PLANE1:
503 case GL_CLIP_PLANE2:
504 case GL_CLIP_PLANE3:
505 case GL_CLIP_PLANE4:
506 case GL_CLIP_PLANE5:
507 return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
508 case GL_COLOR_MATERIAL:
509 return ctx->Light.ColorMaterialEnabled;
510 case GL_CULL_FACE:
511 return ctx->Polygon.CullFlag;
512 case GL_DEPTH_TEST:
513 return ctx->Depth.Test;
514 case GL_DITHER:
515 return ctx->Color.DitherFlag;
516 case GL_FOG:
517 return ctx->Fog.Enabled;
518 case GL_LIGHTING:
519 return ctx->Light.Enabled;
520 case GL_LIGHT0:
521 case GL_LIGHT1:
522 case GL_LIGHT2:
523 case GL_LIGHT3:
524 case GL_LIGHT4:
525 case GL_LIGHT5:
526 case GL_LIGHT6:
527 case GL_LIGHT7:
528 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
529 case GL_LINE_SMOOTH:
530 return ctx->Line.SmoothFlag;
531 case GL_LINE_STIPPLE:
532 return ctx->Line.StippleFlag;
533 case GL_INDEX_LOGIC_OP:
534 return ctx->Color.IndexLogicOpEnabled;
535 case GL_COLOR_LOGIC_OP:
536 return ctx->Color.ColorLogicOpEnabled;
537 case GL_MAP1_COLOR_4:
538 return ctx->Eval.Map1Color4;
539 case GL_MAP1_INDEX:
540 return ctx->Eval.Map1Index;
541 case GL_MAP1_NORMAL:
542 return ctx->Eval.Map1Normal;
543 case GL_MAP1_TEXTURE_COORD_1:
544 return ctx->Eval.Map1TextureCoord1;
545 case GL_MAP1_TEXTURE_COORD_2:
546 return ctx->Eval.Map1TextureCoord2;
547 case GL_MAP1_TEXTURE_COORD_3:
548 return ctx->Eval.Map1TextureCoord3;
549 case GL_MAP1_TEXTURE_COORD_4:
550 return ctx->Eval.Map1TextureCoord4;
551 case GL_MAP1_VERTEX_3:
552 return ctx->Eval.Map1Vertex3;
553 case GL_MAP1_VERTEX_4:
554 return ctx->Eval.Map1Vertex4;
555 case GL_MAP2_COLOR_4:
556 return ctx->Eval.Map2Color4;
557 case GL_MAP2_INDEX:
558 return ctx->Eval.Map2Index;
559 case GL_MAP2_NORMAL:
560 return ctx->Eval.Map2Normal;
561 case GL_MAP2_TEXTURE_COORD_1:
562 return ctx->Eval.Map2TextureCoord1;
563 case GL_MAP2_TEXTURE_COORD_2:
564 return ctx->Eval.Map2TextureCoord2;
565 case GL_MAP2_TEXTURE_COORD_3:
566 return ctx->Eval.Map2TextureCoord3;
567 case GL_MAP2_TEXTURE_COORD_4:
568 return ctx->Eval.Map2TextureCoord4;
569 case GL_MAP2_VERTEX_3:
570 return ctx->Eval.Map2Vertex3;
571 case GL_MAP2_VERTEX_4:
572 return ctx->Eval.Map2Vertex4;
573 case GL_NORMALIZE:
574 return ctx->Transform.Normalize;
575 case GL_POINT_SMOOTH:
576 return ctx->Point.SmoothFlag;
577 case GL_POLYGON_SMOOTH:
578 return ctx->Polygon.SmoothFlag;
579 case GL_POLYGON_STIPPLE:
580 return ctx->Polygon.StippleFlag;
581 case GL_POLYGON_OFFSET_POINT:
582 return ctx->Polygon.OffsetPoint;
583 case GL_POLYGON_OFFSET_LINE:
584 return ctx->Polygon.OffsetLine;
585 case GL_POLYGON_OFFSET_FILL:
586 /*case GL_POLYGON_OFFSET_EXT:*/
587 return ctx->Polygon.OffsetFill;
588 case GL_RESCALE_NORMAL_EXT:
589 return ctx->Transform.RescaleNormals;
590 case GL_SCISSOR_TEST:
591 return ctx->Scissor.Enabled;
592 case GL_SHARED_TEXTURE_PALETTE_EXT:
593 return ctx->Texture.SharedPalette;
594 case GL_STENCIL_TEST:
595 return ctx->Stencil.Enabled;
596 case GL_TEXTURE_1D:
597 {
598 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
599 return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
600 }
601 case GL_TEXTURE_2D:
602 {
603 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
604 return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
605 }
606 case GL_TEXTURE_3D:
607 {
608 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
609 return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
610 }
611 case GL_TEXTURE_GEN_Q:
612 {
613 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
614 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
615 }
616 case GL_TEXTURE_GEN_R:
617 {
618 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
619 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
620 }
621 case GL_TEXTURE_GEN_S:
622 {
623 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
624 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
625 }
626 case GL_TEXTURE_GEN_T:
627 {
628 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
629 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
630 }
631
632 /*
633 * CLIENT STATE!!!
634 */
635 case GL_VERTEX_ARRAY:
636 return ctx->Array.Vertex.Enabled;
637 case GL_NORMAL_ARRAY:
638 return ctx->Array.Normal.Enabled;
639 case GL_COLOR_ARRAY:
640 return ctx->Array.Color.Enabled;
641 case GL_INDEX_ARRAY:
642 return ctx->Array.Index.Enabled;
643 case GL_TEXTURE_COORD_ARRAY:
644 return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
645 case GL_EDGE_FLAG_ARRAY:
646 return ctx->Array.EdgeFlag.Enabled;
647 default:
648 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
649 return GL_FALSE;
650 }
651 }
652
653
654
655
656 static void
657 client_state( GLcontext *ctx, GLenum cap, GLboolean state )
658 {
659 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
660 (state
661 ? "glEnableClientState"
662 : "glDisableClientState") );
663
664 switch (cap) {
665 case GL_VERTEX_ARRAY:
666 ctx->Array.Vertex.Enabled = state;
667 break;
668 case GL_NORMAL_ARRAY:
669 ctx->Array.Normal.Enabled = state;
670 break;
671 case GL_COLOR_ARRAY:
672 ctx->Array.Color.Enabled = state;
673 break;
674 case GL_INDEX_ARRAY:
675 ctx->Array.Index.Enabled = state;
676 break;
677 case GL_TEXTURE_COORD_ARRAY:
678 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
679 break;
680 case GL_EDGE_FLAG_ARRAY:
681 ctx->Array.EdgeFlag.Enabled = state;
682 break;
683 default:
684 gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
685 }
686
687 ctx->NewState |= NEW_CLIENT_STATE;
688 }
689
690
691
692 void
693 _mesa_EnableClientState( GLenum cap )
694 {
695 GET_CURRENT_CONTEXT(ctx);
696 client_state( ctx, cap, GL_TRUE );
697 }
698
699
700
701 void
702 _mesa_DisableClientState( GLenum cap )
703 {
704 GET_CURRENT_CONTEXT(ctx);
705 client_state( ctx, cap, GL_FALSE );
706 }
707