added GL_SGIX/SGIS_pixel_texture
[mesa.git] / src / mesa / main / enable.c
1 /* $Id: enable.c,v 1.14 2000/04/07 16:27:26 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 /* GL_HP_occlusion_test */
455 case GL_OCCLUSION_TEST_HP:
456 if (ctx->Extensions.HaveHpOcclusionTest) {
457 ctx->Depth.OcclusionTest = state;
458 if (state)
459 ctx->OcclusionResult = ctx->OcclusionResultSaved;
460 else
461 ctx->OcclusionResultSaved = ctx->OcclusionResult;
462 ctx->NewState |= NEW_RASTER_OPS;
463 }
464 else {
465 gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
466 return;
467 }
468 break;
469
470 /* GL_SGIS_pixel_texture */
471 case GL_PIXEL_TEXTURE_SGIS:
472 ctx->Pixel.PixelTextureEnabled = state;
473 break;
474
475 /* GL_SGIX_pixel_texture */
476 case GL_PIXEL_TEX_GEN_SGIX:
477 ctx->Pixel.PixelTextureEnabled = state;
478 break;
479
480 default:
481 if (state) {
482 gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
483 }
484 else {
485 gl_error( ctx, GL_INVALID_ENUM, "glDisable" );
486 }
487 return;
488 }
489
490 if (ctx->Driver.Enable) {
491 (*ctx->Driver.Enable)( ctx, cap, state );
492 }
493 }
494
495
496
497
498 void
499 _mesa_Enable( GLenum cap )
500 {
501 GET_CURRENT_CONTEXT(ctx);
502 _mesa_set_enable( ctx, cap, GL_TRUE );
503 }
504
505
506
507 void
508 _mesa_Disable( GLenum cap )
509 {
510 GET_CURRENT_CONTEXT(ctx);
511 _mesa_set_enable( ctx, cap, GL_FALSE );
512 }
513
514
515
516 GLboolean
517 _mesa_IsEnabled( GLenum cap )
518 {
519 GET_CURRENT_CONTEXT(ctx);
520 switch (cap) {
521 case GL_ALPHA_TEST:
522 return ctx->Color.AlphaEnabled;
523 case GL_AUTO_NORMAL:
524 return ctx->Eval.AutoNormal;
525 case GL_BLEND:
526 return ctx->Color.BlendEnabled;
527 case GL_CLIP_PLANE0:
528 case GL_CLIP_PLANE1:
529 case GL_CLIP_PLANE2:
530 case GL_CLIP_PLANE3:
531 case GL_CLIP_PLANE4:
532 case GL_CLIP_PLANE5:
533 return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
534 case GL_COLOR_MATERIAL:
535 return ctx->Light.ColorMaterialEnabled;
536 case GL_CULL_FACE:
537 return ctx->Polygon.CullFlag;
538 case GL_DEPTH_TEST:
539 return ctx->Depth.Test;
540 case GL_DITHER:
541 return ctx->Color.DitherFlag;
542 case GL_FOG:
543 return ctx->Fog.Enabled;
544 case GL_LIGHTING:
545 return ctx->Light.Enabled;
546 case GL_LIGHT0:
547 case GL_LIGHT1:
548 case GL_LIGHT2:
549 case GL_LIGHT3:
550 case GL_LIGHT4:
551 case GL_LIGHT5:
552 case GL_LIGHT6:
553 case GL_LIGHT7:
554 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
555 case GL_LINE_SMOOTH:
556 return ctx->Line.SmoothFlag;
557 case GL_LINE_STIPPLE:
558 return ctx->Line.StippleFlag;
559 case GL_INDEX_LOGIC_OP:
560 return ctx->Color.IndexLogicOpEnabled;
561 case GL_COLOR_LOGIC_OP:
562 return ctx->Color.ColorLogicOpEnabled;
563 case GL_MAP1_COLOR_4:
564 return ctx->Eval.Map1Color4;
565 case GL_MAP1_INDEX:
566 return ctx->Eval.Map1Index;
567 case GL_MAP1_NORMAL:
568 return ctx->Eval.Map1Normal;
569 case GL_MAP1_TEXTURE_COORD_1:
570 return ctx->Eval.Map1TextureCoord1;
571 case GL_MAP1_TEXTURE_COORD_2:
572 return ctx->Eval.Map1TextureCoord2;
573 case GL_MAP1_TEXTURE_COORD_3:
574 return ctx->Eval.Map1TextureCoord3;
575 case GL_MAP1_TEXTURE_COORD_4:
576 return ctx->Eval.Map1TextureCoord4;
577 case GL_MAP1_VERTEX_3:
578 return ctx->Eval.Map1Vertex3;
579 case GL_MAP1_VERTEX_4:
580 return ctx->Eval.Map1Vertex4;
581 case GL_MAP2_COLOR_4:
582 return ctx->Eval.Map2Color4;
583 case GL_MAP2_INDEX:
584 return ctx->Eval.Map2Index;
585 case GL_MAP2_NORMAL:
586 return ctx->Eval.Map2Normal;
587 case GL_MAP2_TEXTURE_COORD_1:
588 return ctx->Eval.Map2TextureCoord1;
589 case GL_MAP2_TEXTURE_COORD_2:
590 return ctx->Eval.Map2TextureCoord2;
591 case GL_MAP2_TEXTURE_COORD_3:
592 return ctx->Eval.Map2TextureCoord3;
593 case GL_MAP2_TEXTURE_COORD_4:
594 return ctx->Eval.Map2TextureCoord4;
595 case GL_MAP2_VERTEX_3:
596 return ctx->Eval.Map2Vertex3;
597 case GL_MAP2_VERTEX_4:
598 return ctx->Eval.Map2Vertex4;
599 case GL_NORMALIZE:
600 return ctx->Transform.Normalize;
601 case GL_POINT_SMOOTH:
602 return ctx->Point.SmoothFlag;
603 case GL_POLYGON_SMOOTH:
604 return ctx->Polygon.SmoothFlag;
605 case GL_POLYGON_STIPPLE:
606 return ctx->Polygon.StippleFlag;
607 case GL_POLYGON_OFFSET_POINT:
608 return ctx->Polygon.OffsetPoint;
609 case GL_POLYGON_OFFSET_LINE:
610 return ctx->Polygon.OffsetLine;
611 case GL_POLYGON_OFFSET_FILL:
612 /*case GL_POLYGON_OFFSET_EXT:*/
613 return ctx->Polygon.OffsetFill;
614 case GL_RESCALE_NORMAL_EXT:
615 return ctx->Transform.RescaleNormals;
616 case GL_SCISSOR_TEST:
617 return ctx->Scissor.Enabled;
618 case GL_SHARED_TEXTURE_PALETTE_EXT:
619 return ctx->Texture.SharedPalette;
620 case GL_STENCIL_TEST:
621 return ctx->Stencil.Enabled;
622 case GL_TEXTURE_1D:
623 {
624 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
625 return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
626 }
627 case GL_TEXTURE_2D:
628 {
629 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
630 return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
631 }
632 case GL_TEXTURE_3D:
633 {
634 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
635 return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
636 }
637 case GL_TEXTURE_GEN_Q:
638 {
639 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
640 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
641 }
642 case GL_TEXTURE_GEN_R:
643 {
644 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
645 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
646 }
647 case GL_TEXTURE_GEN_S:
648 {
649 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
650 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
651 }
652 case GL_TEXTURE_GEN_T:
653 {
654 const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
655 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
656 }
657
658 /*
659 * CLIENT STATE!!!
660 */
661 case GL_VERTEX_ARRAY:
662 return ctx->Array.Vertex.Enabled;
663 case GL_NORMAL_ARRAY:
664 return ctx->Array.Normal.Enabled;
665 case GL_COLOR_ARRAY:
666 return ctx->Array.Color.Enabled;
667 case GL_INDEX_ARRAY:
668 return ctx->Array.Index.Enabled;
669 case GL_TEXTURE_COORD_ARRAY:
670 return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
671 case GL_EDGE_FLAG_ARRAY:
672 return ctx->Array.EdgeFlag.Enabled;
673
674 /* GL_HP_occlusion_test */
675 case GL_OCCLUSION_TEST_HP:
676 if (ctx->Extensions.HaveHpOcclusionTest) {
677 return ctx->Depth.OcclusionTest;
678 }
679 else {
680 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
681 return GL_FALSE;
682 }
683
684 /* GL_SGIS_pixel_texture */
685 case GL_PIXEL_TEXTURE_SGIS:
686 return ctx->Pixel.PixelTextureEnabled;
687 break;
688
689 /* GL_SGIX_pixel_texture */
690 case GL_PIXEL_TEX_GEN_SGIX:
691 return ctx->Pixel.PixelTextureEnabled;
692 break;
693
694 default:
695 gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
696 return GL_FALSE;
697 }
698 }
699
700
701
702
703 static void
704 client_state( GLcontext *ctx, GLenum cap, GLboolean state )
705 {
706 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
707 (state
708 ? "glEnableClientState"
709 : "glDisableClientState") );
710
711 switch (cap) {
712 case GL_VERTEX_ARRAY:
713 ctx->Array.Vertex.Enabled = state;
714 break;
715 case GL_NORMAL_ARRAY:
716 ctx->Array.Normal.Enabled = state;
717 break;
718 case GL_COLOR_ARRAY:
719 ctx->Array.Color.Enabled = state;
720 break;
721 case GL_INDEX_ARRAY:
722 ctx->Array.Index.Enabled = state;
723 break;
724 case GL_TEXTURE_COORD_ARRAY:
725 ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state;
726 break;
727 case GL_EDGE_FLAG_ARRAY:
728 ctx->Array.EdgeFlag.Enabled = state;
729 break;
730 default:
731 gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
732 }
733
734 ctx->NewState |= NEW_CLIENT_STATE;
735 }
736
737
738
739 void
740 _mesa_EnableClientState( GLenum cap )
741 {
742 GET_CURRENT_CONTEXT(ctx);
743 client_state( ctx, cap, GL_TRUE );
744 }
745
746
747
748 void
749 _mesa_DisableClientState( GLenum cap )
750 {
751 GET_CURRENT_CONTEXT(ctx);
752 client_state( ctx, cap, GL_FALSE );
753 }
754