move mesa32 over to new dir
[reactos.git] / reactos / lib / mesa32 / src / main / enable.c
1 /**
2 * \file enable.c
3 * Enable/disable/query GL capabilities.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 * Version: 6.1
9 *
10 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31 #include "glheader.h"
32 #include "context.h"
33 #include "enable.h"
34 #include "light.h"
35 #include "macros.h"
36 #include "simple_list.h"
37 #include "mtypes.h"
38 #include "enums.h"
39 #include "math/m_matrix.h"
40 #include "math/m_xform.h"
41
42
43
44 #define CHECK_EXTENSION(EXTNAME, CAP) \
45 if (!ctx->Extensions.EXTNAME) { \
46 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
47 state ? "Enable" : "Disable", CAP); \
48 return; \
49 }
50
51
52 static void
53 client_state( GLcontext *ctx, GLenum cap, GLboolean state )
54 {
55 GLuint flag;
56 GLuint *var;
57
58 switch (cap) {
59 case GL_VERTEX_ARRAY:
60 var = &ctx->Array.Vertex.Enabled;
61 flag = _NEW_ARRAY_VERTEX;
62 break;
63 case GL_NORMAL_ARRAY:
64 var = &ctx->Array.Normal.Enabled;
65 flag = _NEW_ARRAY_NORMAL;
66 break;
67 case GL_COLOR_ARRAY:
68 var = &ctx->Array.Color.Enabled;
69 flag = _NEW_ARRAY_COLOR0;
70 break;
71 case GL_INDEX_ARRAY:
72 var = &ctx->Array.Index.Enabled;
73 flag = _NEW_ARRAY_INDEX;
74 break;
75 case GL_TEXTURE_COORD_ARRAY:
76 var = &ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
77 flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture);
78 break;
79 case GL_EDGE_FLAG_ARRAY:
80 var = &ctx->Array.EdgeFlag.Enabled;
81 flag = _NEW_ARRAY_EDGEFLAG;
82 break;
83 case GL_FOG_COORDINATE_ARRAY_EXT:
84 var = &ctx->Array.FogCoord.Enabled;
85 flag = _NEW_ARRAY_FOGCOORD;
86 break;
87 case GL_SECONDARY_COLOR_ARRAY_EXT:
88 var = &ctx->Array.SecondaryColor.Enabled;
89 flag = _NEW_ARRAY_COLOR1;
90 break;
91
92 #if FEATURE_NV_vertex_program
93 case GL_VERTEX_ATTRIB_ARRAY0_NV:
94 case GL_VERTEX_ATTRIB_ARRAY1_NV:
95 case GL_VERTEX_ATTRIB_ARRAY2_NV:
96 case GL_VERTEX_ATTRIB_ARRAY3_NV:
97 case GL_VERTEX_ATTRIB_ARRAY4_NV:
98 case GL_VERTEX_ATTRIB_ARRAY5_NV:
99 case GL_VERTEX_ATTRIB_ARRAY6_NV:
100 case GL_VERTEX_ATTRIB_ARRAY7_NV:
101 case GL_VERTEX_ATTRIB_ARRAY8_NV:
102 case GL_VERTEX_ATTRIB_ARRAY9_NV:
103 case GL_VERTEX_ATTRIB_ARRAY10_NV:
104 case GL_VERTEX_ATTRIB_ARRAY11_NV:
105 case GL_VERTEX_ATTRIB_ARRAY12_NV:
106 case GL_VERTEX_ATTRIB_ARRAY13_NV:
107 case GL_VERTEX_ATTRIB_ARRAY14_NV:
108 case GL_VERTEX_ATTRIB_ARRAY15_NV:
109 CHECK_EXTENSION(NV_vertex_program, cap);
110 {
111 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
112 var = &ctx->Array.VertexAttrib[n].Enabled;
113 flag = _NEW_ARRAY_ATTRIB(n);
114 }
115 break;
116 #endif /* FEATURE_NV_vertex_program */
117
118 default:
119 _mesa_error( ctx, GL_INVALID_ENUM,
120 "glEnable/DisableClientState(0x%x)", cap);
121 return;
122 }
123
124 if (*var == state)
125 return;
126
127 FLUSH_VERTICES(ctx, _NEW_ARRAY);
128 ctx->Array.NewState |= flag;
129 *var = state;
130
131 if (state)
132 ctx->Array._Enabled |= flag;
133 else
134 ctx->Array._Enabled &= ~flag;
135
136 if (ctx->Driver.Enable) {
137 (*ctx->Driver.Enable)( ctx, cap, state );
138 }
139 }
140
141
142 /**
143 * Enable GL capability.
144 *
145 * \param cap capability.
146 *
147 * \sa glEnable().
148 *
149 * Get's the current context, assures that we're outside glBegin()/glEnd() and
150 * calls client_state().
151 */
152 void GLAPIENTRY
153 _mesa_EnableClientState( GLenum cap )
154 {
155 GET_CURRENT_CONTEXT(ctx);
156 ASSERT_OUTSIDE_BEGIN_END(ctx);
157 client_state( ctx, cap, GL_TRUE );
158 }
159
160
161 /**
162 * Disable GL capability.
163 *
164 * \param cap capability.
165 *
166 * \sa glDisable().
167 *
168 * Get's the current context, assures that we're outside glBegin()/glEnd() and
169 * calls client_state().
170 */
171 void GLAPIENTRY
172 _mesa_DisableClientState( GLenum cap )
173 {
174 GET_CURRENT_CONTEXT(ctx);
175 ASSERT_OUTSIDE_BEGIN_END(ctx);
176 client_state( ctx, cap, GL_FALSE );
177 }
178
179
180 #undef CHECK_EXTENSION
181 #define CHECK_EXTENSION(EXTNAME, CAP) \
182 if (!ctx->Extensions.EXTNAME) { \
183 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
184 state ? "Enable" : "Disable", CAP); \
185 return; \
186 }
187
188 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
189 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
190 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
191 state ? "Enable" : "Disable", CAP); \
192 return; \
193 }
194
195
196
197 /**
198 * Perform glEnable() and glDisable() calls.
199 *
200 * \param ctx GL context.
201 * \param cap capability.
202 * \param state whether to enable or disable the specified capability.
203 *
204 * Updates the current context and flushes the vertices as needed. For
205 * capabilities associated with extensions it verifies that those extensions
206 * are effectivly present before updating. Notifies the driver via
207 * dd_function_table::Enable.
208 */
209 void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
210 {
211 if (MESA_VERBOSE & VERBOSE_API)
212 _mesa_debug(ctx, "%s %s (newstate is %x)\n",
213 state ? "glEnable" : "glDisable",
214 _mesa_lookup_enum_by_nr(cap),
215 ctx->NewState);
216
217 switch (cap) {
218 case GL_ALPHA_TEST:
219 if (ctx->Color.AlphaEnabled == state)
220 return;
221 FLUSH_VERTICES(ctx, _NEW_COLOR);
222 ctx->Color.AlphaEnabled = state;
223 break;
224 case GL_AUTO_NORMAL:
225 if (ctx->Eval.AutoNormal == state)
226 return;
227 FLUSH_VERTICES(ctx, _NEW_EVAL);
228 ctx->Eval.AutoNormal = state;
229 break;
230 case GL_BLEND:
231 if (ctx->Color.BlendEnabled == state)
232 return;
233 FLUSH_VERTICES(ctx, _NEW_COLOR);
234 ctx->Color.BlendEnabled = state;
235 /* This is needed to support 1.1's RGB logic ops AND
236 * 1.0's blending logicops.
237 */
238 ctx->Color._LogicOpEnabled =
239 (ctx->Color.ColorLogicOpEnabled ||
240 (state && ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
241 break;
242 #if FEATURE_userclip
243 case GL_CLIP_PLANE0:
244 case GL_CLIP_PLANE1:
245 case GL_CLIP_PLANE2:
246 case GL_CLIP_PLANE3:
247 case GL_CLIP_PLANE4:
248 case GL_CLIP_PLANE5:
249 {
250 const GLuint p = cap - GL_CLIP_PLANE0;
251
252 if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p))
253 return;
254
255 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
256
257 if (state) {
258 ctx->Transform.ClipPlanesEnabled |= (1 << p);
259
260 if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
261 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
262
263 /* This derived state also calculated in clip.c and
264 * from _mesa_update_state() on changes to EyeUserPlane
265 * and ctx->ProjectionMatrix respectively.
266 */
267 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
268 ctx->Transform.EyeUserPlane[p],
269 ctx->ProjectionMatrixStack.Top->inv );
270 }
271 else {
272 ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
273 }
274 }
275 break;
276 #endif
277 case GL_COLOR_MATERIAL:
278 if (ctx->Light.ColorMaterialEnabled == state)
279 return;
280 FLUSH_VERTICES(ctx, _NEW_LIGHT);
281 FLUSH_CURRENT(ctx, 0);
282 ctx->Light.ColorMaterialEnabled = state;
283 if (state) {
284 _mesa_update_color_material( ctx,
285 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
286 }
287 break;
288 case GL_CULL_FACE:
289 if (ctx->Polygon.CullFlag == state)
290 return;
291 FLUSH_VERTICES(ctx, _NEW_POLYGON);
292 ctx->Polygon.CullFlag = state;
293 break;
294
295 case GL_CULL_VERTEX_EXT:
296 CHECK_EXTENSION(EXT_cull_vertex, cap);
297 if (ctx->Transform.CullVertexFlag == state)
298 return;
299 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
300 ctx->Transform.CullVertexFlag = state;
301 break;
302
303 case GL_DEPTH_TEST:
304 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
305 _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
306 return;
307 }
308 if (ctx->Depth.Test==state)
309 return;
310 FLUSH_VERTICES(ctx, _NEW_DEPTH);
311 ctx->Depth.Test = state;
312 break;
313 case GL_DITHER:
314 if (ctx->NoDither) {
315 state = GL_FALSE; /* MESA_NO_DITHER env var */
316 }
317 if (ctx->Color.DitherFlag==state)
318 return;
319 FLUSH_VERTICES(ctx, _NEW_COLOR);
320 ctx->Color.DitherFlag = state;
321 break;
322 case GL_FOG:
323 if (ctx->Fog.Enabled==state)
324 return;
325 FLUSH_VERTICES(ctx, _NEW_FOG);
326 ctx->Fog.Enabled = state;
327 break;
328 case GL_HISTOGRAM:
329 CHECK_EXTENSION(EXT_histogram, cap);
330 if (ctx->Pixel.HistogramEnabled == state)
331 return;
332 FLUSH_VERTICES(ctx, _NEW_PIXEL);
333 ctx->Pixel.HistogramEnabled = state;
334 break;
335 case GL_LIGHT0:
336 case GL_LIGHT1:
337 case GL_LIGHT2:
338 case GL_LIGHT3:
339 case GL_LIGHT4:
340 case GL_LIGHT5:
341 case GL_LIGHT6:
342 case GL_LIGHT7:
343 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
344 return;
345 FLUSH_VERTICES(ctx, _NEW_LIGHT);
346 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
347 if (state) {
348 insert_at_tail(&ctx->Light.EnabledList,
349 &ctx->Light.Light[cap-GL_LIGHT0]);
350 }
351 else {
352 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
353 }
354 break;
355 case GL_LIGHTING:
356 if (ctx->Light.Enabled == state)
357 return;
358 FLUSH_VERTICES(ctx, _NEW_LIGHT);
359 ctx->Light.Enabled = state;
360
361 if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
362 ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
363 else
364 ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
365
366 break;
367 case GL_LINE_SMOOTH:
368 if (ctx->Line.SmoothFlag == state)
369 return;
370 FLUSH_VERTICES(ctx, _NEW_LINE);
371 ctx->Line.SmoothFlag = state;
372 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
373 break;
374 case GL_LINE_STIPPLE:
375 if (ctx->Line.StippleFlag == state)
376 return;
377 FLUSH_VERTICES(ctx, _NEW_LINE);
378 ctx->Line.StippleFlag = state;
379 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
380 break;
381 case GL_INDEX_LOGIC_OP:
382 if (ctx->Color.IndexLogicOpEnabled == state)
383 return;
384 FLUSH_VERTICES(ctx, _NEW_COLOR);
385 ctx->Color.IndexLogicOpEnabled = state;
386 break;
387 case GL_COLOR_LOGIC_OP:
388 if (ctx->Color.ColorLogicOpEnabled == state)
389 return;
390 FLUSH_VERTICES(ctx, _NEW_COLOR);
391 ctx->Color.ColorLogicOpEnabled = state;
392 /* This is needed to support 1.1's RGB logic ops AND
393 * 1.0's blending logicops.
394 */
395 ctx->Color._LogicOpEnabled =
396 (state || (ctx->Color.BlendEnabled &&
397 ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
398 break;
399 case GL_MAP1_COLOR_4:
400 if (ctx->Eval.Map1Color4 == state)
401 return;
402 FLUSH_VERTICES(ctx, _NEW_EVAL);
403 ctx->Eval.Map1Color4 = state;
404 break;
405 case GL_MAP1_INDEX:
406 if (ctx->Eval.Map1Index == state)
407 return;
408 FLUSH_VERTICES(ctx, _NEW_EVAL);
409 ctx->Eval.Map1Index = state;
410 break;
411 case GL_MAP1_NORMAL:
412 if (ctx->Eval.Map1Normal == state)
413 return;
414 FLUSH_VERTICES(ctx, _NEW_EVAL);
415 ctx->Eval.Map1Normal = state;
416 break;
417 case GL_MAP1_TEXTURE_COORD_1:
418 if (ctx->Eval.Map1TextureCoord1 == state)
419 return;
420 FLUSH_VERTICES(ctx, _NEW_EVAL);
421 ctx->Eval.Map1TextureCoord1 = state;
422 break;
423 case GL_MAP1_TEXTURE_COORD_2:
424 if (ctx->Eval.Map1TextureCoord2 == state)
425 return;
426 FLUSH_VERTICES(ctx, _NEW_EVAL);
427 ctx->Eval.Map1TextureCoord2 = state;
428 break;
429 case GL_MAP1_TEXTURE_COORD_3:
430 if (ctx->Eval.Map1TextureCoord3 == state)
431 return;
432 FLUSH_VERTICES(ctx, _NEW_EVAL);
433 ctx->Eval.Map1TextureCoord3 = state;
434 break;
435 case GL_MAP1_TEXTURE_COORD_4:
436 if (ctx->Eval.Map1TextureCoord4 == state)
437 return;
438 FLUSH_VERTICES(ctx, _NEW_EVAL);
439 ctx->Eval.Map1TextureCoord4 = state;
440 break;
441 case GL_MAP1_VERTEX_3:
442 if (ctx->Eval.Map1Vertex3 == state)
443 return;
444 FLUSH_VERTICES(ctx, _NEW_EVAL);
445 ctx->Eval.Map1Vertex3 = state;
446 break;
447 case GL_MAP1_VERTEX_4:
448 if (ctx->Eval.Map1Vertex4 == state)
449 return;
450 FLUSH_VERTICES(ctx, _NEW_EVAL);
451 ctx->Eval.Map1Vertex4 = state;
452 break;
453 case GL_MAP2_COLOR_4:
454 if (ctx->Eval.Map2Color4 == state)
455 return;
456 FLUSH_VERTICES(ctx, _NEW_EVAL);
457 ctx->Eval.Map2Color4 = state;
458 break;
459 case GL_MAP2_INDEX:
460 if (ctx->Eval.Map2Index == state)
461 return;
462 FLUSH_VERTICES(ctx, _NEW_EVAL);
463 ctx->Eval.Map2Index = state;
464 break;
465 case GL_MAP2_NORMAL:
466 if (ctx->Eval.Map2Normal == state)
467 return;
468 FLUSH_VERTICES(ctx, _NEW_EVAL);
469 ctx->Eval.Map2Normal = state;
470 break;
471 case GL_MAP2_TEXTURE_COORD_1:
472 if (ctx->Eval.Map2TextureCoord1 == state)
473 return;
474 FLUSH_VERTICES(ctx, _NEW_EVAL);
475 ctx->Eval.Map2TextureCoord1 = state;
476 break;
477 case GL_MAP2_TEXTURE_COORD_2:
478 if (ctx->Eval.Map2TextureCoord2 == state)
479 return;
480 FLUSH_VERTICES(ctx, _NEW_EVAL);
481 ctx->Eval.Map2TextureCoord2 = state;
482 break;
483 case GL_MAP2_TEXTURE_COORD_3:
484 if (ctx->Eval.Map2TextureCoord3 == state)
485 return;
486 FLUSH_VERTICES(ctx, _NEW_EVAL);
487 ctx->Eval.Map2TextureCoord3 = state;
488 break;
489 case GL_MAP2_TEXTURE_COORD_4:
490 if (ctx->Eval.Map2TextureCoord4 == state)
491 return;
492 FLUSH_VERTICES(ctx, _NEW_EVAL);
493 ctx->Eval.Map2TextureCoord4 = state;
494 break;
495 case GL_MAP2_VERTEX_3:
496 if (ctx->Eval.Map2Vertex3 == state)
497 return;
498 FLUSH_VERTICES(ctx, _NEW_EVAL);
499 ctx->Eval.Map2Vertex3 = state;
500 break;
501 case GL_MAP2_VERTEX_4:
502 if (ctx->Eval.Map2Vertex4 == state)
503 return;
504 FLUSH_VERTICES(ctx, _NEW_EVAL);
505 ctx->Eval.Map2Vertex4 = state;
506 break;
507 case GL_MINMAX:
508 if (ctx->Pixel.MinMaxEnabled == state)
509 return;
510 FLUSH_VERTICES(ctx, _NEW_PIXEL);
511 ctx->Pixel.MinMaxEnabled = state;
512 break;
513 case GL_NORMALIZE:
514 if (ctx->Transform.Normalize == state)
515 return;
516 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
517 ctx->Transform.Normalize = state;
518 break;
519 case GL_POINT_SMOOTH:
520 if (ctx->Point.SmoothFlag==state)
521 return;
522 FLUSH_VERTICES(ctx, _NEW_POINT);
523 ctx->Point.SmoothFlag = state;
524 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
525 break;
526 case GL_POLYGON_SMOOTH:
527 if (ctx->Polygon.SmoothFlag==state)
528 return;
529 FLUSH_VERTICES(ctx, _NEW_POLYGON);
530 ctx->Polygon.SmoothFlag = state;
531 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
532 break;
533 case GL_POLYGON_STIPPLE:
534 if (ctx->Polygon.StippleFlag==state)
535 return;
536 FLUSH_VERTICES(ctx, _NEW_POLYGON);
537 ctx->Polygon.StippleFlag = state;
538 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
539 break;
540 case GL_POLYGON_OFFSET_POINT:
541 if (ctx->Polygon.OffsetPoint==state)
542 return;
543 FLUSH_VERTICES(ctx, _NEW_POLYGON);
544 ctx->Polygon.OffsetPoint = state;
545 break;
546 case GL_POLYGON_OFFSET_LINE:
547 if (ctx->Polygon.OffsetLine==state)
548 return;
549 FLUSH_VERTICES(ctx, _NEW_POLYGON);
550 ctx->Polygon.OffsetLine = state;
551 break;
552 case GL_POLYGON_OFFSET_FILL:
553 /*case GL_POLYGON_OFFSET_EXT:*/
554 if (ctx->Polygon.OffsetFill==state)
555 return;
556 FLUSH_VERTICES(ctx, _NEW_POLYGON);
557 ctx->Polygon.OffsetFill = state;
558 break;
559 case GL_RESCALE_NORMAL_EXT:
560 if (ctx->Transform.RescaleNormals == state)
561 return;
562 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
563 ctx->Transform.RescaleNormals = state;
564 break;
565 case GL_SCISSOR_TEST:
566 if (ctx->Scissor.Enabled==state)
567 return;
568 FLUSH_VERTICES(ctx, _NEW_SCISSOR);
569 ctx->Scissor.Enabled = state;
570 break;
571 case GL_SHARED_TEXTURE_PALETTE_EXT:
572 if (ctx->Texture.SharedPalette == state)
573 return;
574 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
575 ctx->Texture.SharedPalette = state;
576 break;
577 case GL_STENCIL_TEST:
578 if (state && ctx->DrawBuffer->Visual.stencilBits == 0) {
579 _mesa_warning(ctx,
580 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
581 return;
582 }
583 if (ctx->Stencil.Enabled==state)
584 return;
585 FLUSH_VERTICES(ctx, _NEW_STENCIL);
586 ctx->Stencil.Enabled = state;
587 break;
588 case GL_TEXTURE_1D: {
589 const GLuint curr = ctx->Texture.CurrentUnit;
590 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
591 GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT;
592 if (state)
593 newenabled |= TEXTURE_1D_BIT;
594 if (!ctx->DrawBuffer->Visual.rgbMode
595 || texUnit->Enabled == newenabled)
596 return;
597 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
598 texUnit->Enabled = newenabled;
599 break;
600 }
601 case GL_TEXTURE_2D: {
602 const GLuint curr = ctx->Texture.CurrentUnit;
603 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
604 GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT;
605 if (state)
606 newenabled |= TEXTURE_2D_BIT;
607 if (!ctx->DrawBuffer->Visual.rgbMode
608 || texUnit->Enabled == newenabled)
609 return;
610 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
611 texUnit->Enabled = newenabled;
612 break;
613 }
614 case GL_TEXTURE_3D: {
615 const GLuint curr = ctx->Texture.CurrentUnit;
616 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
617 GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT;
618 if (state)
619 newenabled |= TEXTURE_3D_BIT;
620 if (!ctx->DrawBuffer->Visual.rgbMode
621 || texUnit->Enabled == newenabled)
622 return;
623 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
624 texUnit->Enabled = newenabled;
625 break;
626 }
627 case GL_TEXTURE_GEN_Q: {
628 GLuint unit = ctx->Texture.CurrentUnit;
629 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
630 GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
631 if (state)
632 newenabled |= Q_BIT;
633 if (texUnit->TexGenEnabled == newenabled)
634 return;
635 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
636 texUnit->TexGenEnabled = newenabled;
637 break;
638 }
639 case GL_TEXTURE_GEN_R: {
640 GLuint unit = ctx->Texture.CurrentUnit;
641 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
642 GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
643 if (state)
644 newenabled |= R_BIT;
645 if (texUnit->TexGenEnabled == newenabled)
646 return;
647 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
648 texUnit->TexGenEnabled = newenabled;
649 break;
650 }
651 case GL_TEXTURE_GEN_S: {
652 GLuint unit = ctx->Texture.CurrentUnit;
653 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
654 GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
655 if (state)
656 newenabled |= S_BIT;
657 if (texUnit->TexGenEnabled == newenabled)
658 return;
659 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
660 texUnit->TexGenEnabled = newenabled;
661 break;
662 }
663 case GL_TEXTURE_GEN_T: {
664 GLuint unit = ctx->Texture.CurrentUnit;
665 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
666 GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
667 if (state)
668 newenabled |= T_BIT;
669 if (texUnit->TexGenEnabled == newenabled)
670 return;
671 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
672 texUnit->TexGenEnabled = newenabled;
673 break;
674 }
675
676 /*
677 * CLIENT STATE!!!
678 */
679 case GL_VERTEX_ARRAY:
680 case GL_NORMAL_ARRAY:
681 case GL_COLOR_ARRAY:
682 case GL_INDEX_ARRAY:
683 case GL_TEXTURE_COORD_ARRAY:
684 case GL_EDGE_FLAG_ARRAY:
685 case GL_FOG_COORDINATE_ARRAY_EXT:
686 case GL_SECONDARY_COLOR_ARRAY_EXT:
687 client_state( ctx, cap, state );
688 return;
689
690 /* GL_HP_occlusion_test */
691 case GL_OCCLUSION_TEST_HP:
692 CHECK_EXTENSION(HP_occlusion_test, cap);
693 if (ctx->Depth.OcclusionTest == state)
694 return;
695 FLUSH_VERTICES(ctx, _NEW_DEPTH);
696 ctx->Depth.OcclusionTest = state;
697 if (state)
698 ctx->OcclusionResult = ctx->OcclusionResultSaved;
699 else
700 ctx->OcclusionResultSaved = ctx->OcclusionResult;
701 break;
702
703 /* GL_SGIS_pixel_texture */
704 case GL_PIXEL_TEXTURE_SGIS:
705 CHECK_EXTENSION(SGIS_pixel_texture, cap);
706 if (ctx->Pixel.PixelTextureEnabled == state)
707 return;
708 FLUSH_VERTICES(ctx, _NEW_PIXEL);
709 ctx->Pixel.PixelTextureEnabled = state;
710 break;
711
712 /* GL_SGIX_pixel_texture */
713 case GL_PIXEL_TEX_GEN_SGIX:
714 CHECK_EXTENSION(SGIX_pixel_texture, cap);
715 if (ctx->Pixel.PixelTextureEnabled == state)
716 return;
717 FLUSH_VERTICES(ctx, _NEW_PIXEL);
718 ctx->Pixel.PixelTextureEnabled = state;
719 break;
720
721 /* GL_SGI_color_table */
722 case GL_COLOR_TABLE_SGI:
723 CHECK_EXTENSION(SGI_color_table, cap);
724 if (ctx->Pixel.ColorTableEnabled == state)
725 return;
726 FLUSH_VERTICES(ctx, _NEW_PIXEL);
727 ctx->Pixel.ColorTableEnabled = state;
728 break;
729 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
730 CHECK_EXTENSION(SGI_color_table, cap);
731 if (ctx->Pixel.PostConvolutionColorTableEnabled == state)
732 return;
733 FLUSH_VERTICES(ctx, _NEW_PIXEL);
734 ctx->Pixel.PostConvolutionColorTableEnabled = state;
735 break;
736 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
737 CHECK_EXTENSION(SGI_color_table, cap);
738 if (ctx->Pixel.PostColorMatrixColorTableEnabled == state)
739 return;
740 FLUSH_VERTICES(ctx, _NEW_PIXEL);
741 ctx->Pixel.PostColorMatrixColorTableEnabled = state;
742 break;
743 case GL_TEXTURE_COLOR_TABLE_SGI:
744 CHECK_EXTENSION(SGI_texture_color_table, cap);
745 if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state)
746 return;
747 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
748 ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state;
749 break;
750
751 /* GL_EXT_convolution */
752 case GL_CONVOLUTION_1D:
753 CHECK_EXTENSION(EXT_convolution, cap);
754 if (ctx->Pixel.Convolution1DEnabled == state)
755 return;
756 FLUSH_VERTICES(ctx, _NEW_PIXEL);
757 ctx->Pixel.Convolution1DEnabled = state;
758 break;
759 case GL_CONVOLUTION_2D:
760 CHECK_EXTENSION(EXT_convolution, cap);
761 if (ctx->Pixel.Convolution2DEnabled == state)
762 return;
763 FLUSH_VERTICES(ctx, _NEW_PIXEL);
764 ctx->Pixel.Convolution2DEnabled = state;
765 break;
766 case GL_SEPARABLE_2D:
767 CHECK_EXTENSION(EXT_convolution, cap);
768 if (ctx->Pixel.Separable2DEnabled == state)
769 return;
770 FLUSH_VERTICES(ctx, _NEW_PIXEL);
771 ctx->Pixel.Separable2DEnabled = state;
772 break;
773
774 /* GL_ARB_texture_cube_map */
775 case GL_TEXTURE_CUBE_MAP_ARB:
776 {
777 const GLuint curr = ctx->Texture.CurrentUnit;
778 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
779 GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT;
780 CHECK_EXTENSION(ARB_texture_cube_map, cap);
781 if (state)
782 newenabled |= TEXTURE_CUBE_BIT;
783 if (!ctx->DrawBuffer->Visual.rgbMode
784 || texUnit->Enabled == newenabled)
785 return;
786 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
787 texUnit->Enabled = newenabled;
788 }
789 break;
790
791 /* GL_EXT_secondary_color */
792 case GL_COLOR_SUM_EXT:
793 CHECK_EXTENSION(EXT_secondary_color, cap);
794 if (ctx->Fog.ColorSumEnabled == state)
795 return;
796 FLUSH_VERTICES(ctx, _NEW_FOG);
797 ctx->Fog.ColorSumEnabled = state;
798 break;
799
800 /* GL_ARB_multisample */
801 case GL_MULTISAMPLE_ARB:
802 CHECK_EXTENSION(ARB_multisample, cap);
803 if (ctx->Multisample.Enabled == state)
804 return;
805 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
806 ctx->Multisample.Enabled = state;
807 break;
808 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
809 CHECK_EXTENSION(ARB_multisample, cap);
810 if (ctx->Multisample.SampleAlphaToCoverage == state)
811 return;
812 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
813 ctx->Multisample.SampleAlphaToCoverage = state;
814 break;
815 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
816 CHECK_EXTENSION(ARB_multisample, cap);
817 if (ctx->Multisample.SampleAlphaToOne == state)
818 return;
819 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
820 ctx->Multisample.SampleAlphaToOne = state;
821 break;
822 case GL_SAMPLE_COVERAGE_ARB:
823 CHECK_EXTENSION(ARB_multisample, cap);
824 if (ctx->Multisample.SampleCoverage == state)
825 return;
826 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
827 ctx->Multisample.SampleCoverage = state;
828 break;
829 case GL_SAMPLE_COVERAGE_INVERT_ARB:
830 CHECK_EXTENSION(ARB_multisample, cap);
831 if (ctx->Multisample.SampleCoverageInvert == state)
832 return;
833 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
834 ctx->Multisample.SampleCoverageInvert = state;
835 break;
836
837 /* GL_IBM_rasterpos_clip */
838 case GL_RASTER_POSITION_UNCLIPPED_IBM:
839 CHECK_EXTENSION(IBM_rasterpos_clip, cap);
840 if (ctx->Transform.RasterPositionUnclipped == state)
841 return;
842 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
843 ctx->Transform.RasterPositionUnclipped = state;
844 break;
845
846 /* GL_NV_point_sprite */
847 case GL_POINT_SPRITE_NV:
848 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
849 if (ctx->Point.PointSprite == state)
850 return;
851 FLUSH_VERTICES(ctx, _NEW_POINT);
852 ctx->Point.PointSprite = state;
853 break;
854
855 #if FEATURE_NV_vertex_program
856 case GL_VERTEX_PROGRAM_NV:
857 CHECK_EXTENSION2(NV_vertex_program, ARB_vertex_program, cap);
858 if (ctx->VertexProgram.Enabled == state)
859 return;
860 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
861 ctx->VertexProgram.Enabled = state;
862 break;
863 case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
864 CHECK_EXTENSION2(NV_vertex_program, ARB_vertex_program, cap);
865 if (ctx->VertexProgram.PointSizeEnabled == state)
866 return;
867 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
868 ctx->VertexProgram.PointSizeEnabled = state;
869 break;
870 case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
871 CHECK_EXTENSION2(NV_vertex_program, ARB_vertex_program, cap);
872 if (ctx->VertexProgram.TwoSideEnabled == state)
873 return;
874 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
875 ctx->VertexProgram.TwoSideEnabled = state;
876 break;
877 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
878 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
879 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
880 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
881 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
882 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
883 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
884 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
885 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
886 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
887 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
888 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
889 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
890 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
891 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
892 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
893 CHECK_EXTENSION(NV_vertex_program, cap);
894 {
895 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
896 FLUSH_VERTICES(ctx, _NEW_EVAL);
897 ctx->Eval.Map1Attrib[map] = state;
898 }
899 break;
900 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
901 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
902 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
903 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
904 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
905 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
906 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
907 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
908 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
909 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
910 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
911 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
912 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
913 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
914 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
915 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
916 CHECK_EXTENSION(NV_vertex_program, cap);
917 {
918 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
919 FLUSH_VERTICES(ctx, _NEW_EVAL);
920 ctx->Eval.Map2Attrib[map] = state;
921 }
922 break;
923 #endif /* FEATURE_NV_vertex_program */
924
925 #if FEATURE_NV_fragment_program
926 case GL_FRAGMENT_PROGRAM_NV:
927 CHECK_EXTENSION(NV_fragment_program, cap);
928 if (ctx->FragmentProgram.Enabled == state)
929 return;
930 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
931 ctx->FragmentProgram.Enabled = state;
932 break;
933 #endif /* FEATURE_NV_fragment_program */
934
935 /* GL_NV_texture_rectangle */
936 case GL_TEXTURE_RECTANGLE_NV:
937 CHECK_EXTENSION(NV_texture_rectangle, cap);
938 {
939 const GLuint curr = ctx->Texture.CurrentUnit;
940 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
941 GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT;
942 CHECK_EXTENSION(NV_texture_rectangle, cap);
943 if (state)
944 newenabled |= TEXTURE_RECT_BIT;
945 if (!ctx->DrawBuffer->Visual.rgbMode
946 || texUnit->Enabled == newenabled)
947 return;
948 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
949 texUnit->Enabled = newenabled;
950 }
951 break;
952
953 /* GL_EXT_stencil_two_side */
954 case GL_STENCIL_TEST_TWO_SIDE_EXT:
955 CHECK_EXTENSION(EXT_stencil_two_side, cap);
956 if (ctx->Stencil.TestTwoSide == state)
957 return;
958 FLUSH_VERTICES(ctx, _NEW_STENCIL);
959 ctx->Stencil.TestTwoSide = state;
960 if (state) {
961 ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
962 } else {
963 ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL;
964 }
965 break;
966
967 #if FEATURE_ARB_fragment_program
968 case GL_FRAGMENT_PROGRAM_ARB:
969 CHECK_EXTENSION(ARB_fragment_program, cap);
970 if (ctx->FragmentProgram.Enabled == state)
971 return;
972 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
973 ctx->FragmentProgram.Enabled = state;
974 break;
975 #endif /* FEATURE_ARB_fragment_program */
976
977 /* GL_EXT_depth_bounds_test */
978 case GL_DEPTH_BOUNDS_TEST_EXT:
979 CHECK_EXTENSION(EXT_depth_bounds_test, cap);
980 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
981 _mesa_warning(ctx,
982 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
983 return;
984 }
985 if (ctx->Depth.BoundsTest == state)
986 return;
987 FLUSH_VERTICES(ctx, _NEW_DEPTH);
988 ctx->Depth.BoundsTest = state;
989 break;
990
991 /* GL_MESA_program_debug */
992 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
993 CHECK_EXTENSION(MESA_program_debug, cap);
994 ctx->FragmentProgram.CallbackEnabled = state;
995 break;
996 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
997 CHECK_EXTENSION(MESA_program_debug, cap);
998 ctx->VertexProgram.CallbackEnabled = state;
999 break;
1000
1001 #if FEATURE_ATI_fragment_shader
1002 case GL_FRAGMENT_SHADER_ATI:
1003 CHECK_EXTENSION(ATI_fragment_shader, cap);
1004 if (ctx->ATIFragmentShader.Enabled == state)
1005 return;
1006 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
1007 ctx->ATIFragmentShader.Enabled = state;
1008 break;
1009 #endif
1010 default:
1011 _mesa_error(ctx, GL_INVALID_ENUM,
1012 "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
1013 return;
1014 }
1015
1016 if (ctx->Driver.Enable) {
1017 (*ctx->Driver.Enable)( ctx, cap, state );
1018 }
1019 }
1020
1021
1022 /**
1023 * Enable GL capability.
1024 *
1025 * \param cap capability.
1026 *
1027 * \sa glEnable().
1028 *
1029 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1030 * calls _mesa_set_enable().
1031 */
1032 void GLAPIENTRY
1033 _mesa_Enable( GLenum cap )
1034 {
1035 GET_CURRENT_CONTEXT(ctx);
1036 ASSERT_OUTSIDE_BEGIN_END(ctx);
1037
1038 _mesa_set_enable( ctx, cap, GL_TRUE );
1039 }
1040
1041
1042 /**
1043 * Disable GL capability.
1044 *
1045 * \param cap capability.
1046 *
1047 * \sa glDisable().
1048 *
1049 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1050 * calls _mesa_set_enable().
1051 */
1052 void GLAPIENTRY
1053 _mesa_Disable( GLenum cap )
1054 {
1055 GET_CURRENT_CONTEXT(ctx);
1056 ASSERT_OUTSIDE_BEGIN_END(ctx);
1057
1058 _mesa_set_enable( ctx, cap, GL_FALSE );
1059 }
1060
1061
1062 #undef CHECK_EXTENSION
1063 #define CHECK_EXTENSION(EXTNAME) \
1064 if (!ctx->Extensions.EXTNAME) { \
1065 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1066 return GL_FALSE; \
1067 }
1068
1069
1070 /**
1071 * Test whether a capability is enabled.
1072 *
1073 * \param cap capability.
1074 *
1075 * Returns the state of the specified capability from the current GL context.
1076 * For the capabilities associated with extensions verifies that those
1077 * extensions are effectively present before reporting.
1078 */
1079 GLboolean GLAPIENTRY
1080 _mesa_IsEnabled( GLenum cap )
1081 {
1082 GET_CURRENT_CONTEXT(ctx);
1083 switch (cap) {
1084 case GL_ALPHA_TEST:
1085 return ctx->Color.AlphaEnabled;
1086 case GL_AUTO_NORMAL:
1087 return ctx->Eval.AutoNormal;
1088 case GL_BLEND:
1089 return ctx->Color.BlendEnabled;
1090 case GL_CLIP_PLANE0:
1091 case GL_CLIP_PLANE1:
1092 case GL_CLIP_PLANE2:
1093 case GL_CLIP_PLANE3:
1094 case GL_CLIP_PLANE4:
1095 case GL_CLIP_PLANE5:
1096 return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
1097 case GL_COLOR_MATERIAL:
1098 return ctx->Light.ColorMaterialEnabled;
1099 case GL_CULL_FACE:
1100 return ctx->Polygon.CullFlag;
1101 case GL_DEPTH_TEST:
1102 return ctx->Depth.Test;
1103 case GL_DITHER:
1104 return ctx->Color.DitherFlag;
1105 case GL_FOG:
1106 return ctx->Fog.Enabled;
1107 case GL_LIGHTING:
1108 return ctx->Light.Enabled;
1109 case GL_LIGHT0:
1110 case GL_LIGHT1:
1111 case GL_LIGHT2:
1112 case GL_LIGHT3:
1113 case GL_LIGHT4:
1114 case GL_LIGHT5:
1115 case GL_LIGHT6:
1116 case GL_LIGHT7:
1117 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
1118 case GL_LINE_SMOOTH:
1119 return ctx->Line.SmoothFlag;
1120 case GL_LINE_STIPPLE:
1121 return ctx->Line.StippleFlag;
1122 case GL_INDEX_LOGIC_OP:
1123 return ctx->Color.IndexLogicOpEnabled;
1124 case GL_COLOR_LOGIC_OP:
1125 return ctx->Color.ColorLogicOpEnabled;
1126 case GL_MAP1_COLOR_4:
1127 return ctx->Eval.Map1Color4;
1128 case GL_MAP1_INDEX:
1129 return ctx->Eval.Map1Index;
1130 case GL_MAP1_NORMAL:
1131 return ctx->Eval.Map1Normal;
1132 case GL_MAP1_TEXTURE_COORD_1:
1133 return ctx->Eval.Map1TextureCoord1;
1134 case GL_MAP1_TEXTURE_COORD_2:
1135 return ctx->Eval.Map1TextureCoord2;
1136 case GL_MAP1_TEXTURE_COORD_3:
1137 return ctx->Eval.Map1TextureCoord3;
1138 case GL_MAP1_TEXTURE_COORD_4:
1139 return ctx->Eval.Map1TextureCoord4;
1140 case GL_MAP1_VERTEX_3:
1141 return ctx->Eval.Map1Vertex3;
1142 case GL_MAP1_VERTEX_4:
1143 return ctx->Eval.Map1Vertex4;
1144 case GL_MAP2_COLOR_4:
1145 return ctx->Eval.Map2Color4;
1146 case GL_MAP2_INDEX:
1147 return ctx->Eval.Map2Index;
1148 case GL_MAP2_NORMAL:
1149 return ctx->Eval.Map2Normal;
1150 case GL_MAP2_TEXTURE_COORD_1:
1151 return ctx->Eval.Map2TextureCoord1;
1152 case GL_MAP2_TEXTURE_COORD_2:
1153 return ctx->Eval.Map2TextureCoord2;
1154 case GL_MAP2_TEXTURE_COORD_3:
1155 return ctx->Eval.Map2TextureCoord3;
1156 case GL_MAP2_TEXTURE_COORD_4:
1157 return ctx->Eval.Map2TextureCoord4;
1158 case GL_MAP2_VERTEX_3:
1159 return ctx->Eval.Map2Vertex3;
1160 case GL_MAP2_VERTEX_4:
1161 return ctx->Eval.Map2Vertex4;
1162 case GL_NORMALIZE:
1163 return ctx->Transform.Normalize;
1164 case GL_POINT_SMOOTH:
1165 return ctx->Point.SmoothFlag;
1166 case GL_POLYGON_SMOOTH:
1167 return ctx->Polygon.SmoothFlag;
1168 case GL_POLYGON_STIPPLE:
1169 return ctx->Polygon.StippleFlag;
1170 case GL_POLYGON_OFFSET_POINT:
1171 return ctx->Polygon.OffsetPoint;
1172 case GL_POLYGON_OFFSET_LINE:
1173 return ctx->Polygon.OffsetLine;
1174 case GL_POLYGON_OFFSET_FILL:
1175 /*case GL_POLYGON_OFFSET_EXT:*/
1176 return ctx->Polygon.OffsetFill;
1177 case GL_RESCALE_NORMAL_EXT:
1178 return ctx->Transform.RescaleNormals;
1179 case GL_SCISSOR_TEST:
1180 return ctx->Scissor.Enabled;
1181 case GL_SHARED_TEXTURE_PALETTE_EXT:
1182 return ctx->Texture.SharedPalette;
1183 case GL_STENCIL_TEST:
1184 return ctx->Stencil.Enabled;
1185 case GL_TEXTURE_1D:
1186 {
1187 const struct gl_texture_unit *texUnit;
1188 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1189 return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE;
1190 }
1191 case GL_TEXTURE_2D:
1192 {
1193 const struct gl_texture_unit *texUnit;
1194 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1195 return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE;
1196 }
1197 case GL_TEXTURE_3D:
1198 {
1199 const struct gl_texture_unit *texUnit;
1200 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1201 return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE;
1202 }
1203 case GL_TEXTURE_GEN_Q:
1204 {
1205 const struct gl_texture_unit *texUnit;
1206 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1207 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
1208 }
1209 case GL_TEXTURE_GEN_R:
1210 {
1211 const struct gl_texture_unit *texUnit;
1212 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1213 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
1214 }
1215 case GL_TEXTURE_GEN_S:
1216 {
1217 const struct gl_texture_unit *texUnit;
1218 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1219 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
1220 }
1221 case GL_TEXTURE_GEN_T:
1222 {
1223 const struct gl_texture_unit *texUnit;
1224 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1225 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
1226 }
1227
1228 /*
1229 * CLIENT STATE!!!
1230 */
1231 case GL_VERTEX_ARRAY:
1232 return (ctx->Array.Vertex.Enabled != 0);
1233 case GL_NORMAL_ARRAY:
1234 return (ctx->Array.Normal.Enabled != 0);
1235 case GL_COLOR_ARRAY:
1236 return (ctx->Array.Color.Enabled != 0);
1237 case GL_INDEX_ARRAY:
1238 return (ctx->Array.Index.Enabled != 0);
1239 case GL_TEXTURE_COORD_ARRAY:
1240 return (ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled != 0);
1241 case GL_EDGE_FLAG_ARRAY:
1242 return (ctx->Array.EdgeFlag.Enabled != 0);
1243 case GL_FOG_COORDINATE_ARRAY_EXT:
1244 CHECK_EXTENSION(EXT_fog_coord);
1245 return (ctx->Array.FogCoord.Enabled != 0);
1246 case GL_SECONDARY_COLOR_ARRAY_EXT:
1247 CHECK_EXTENSION(EXT_secondary_color);
1248 return (ctx->Array.SecondaryColor.Enabled != 0);
1249
1250 /* GL_EXT_histogram */
1251 case GL_HISTOGRAM:
1252 CHECK_EXTENSION(EXT_histogram);
1253 return ctx->Pixel.HistogramEnabled;
1254 case GL_MINMAX:
1255 CHECK_EXTENSION(EXT_histogram);
1256 return ctx->Pixel.MinMaxEnabled;
1257
1258 /* GL_HP_occlusion_test */
1259 case GL_OCCLUSION_TEST_HP:
1260 CHECK_EXTENSION(HP_occlusion_test);
1261 return ctx->Depth.OcclusionTest;
1262
1263 /* GL_SGIS_pixel_texture */
1264 case GL_PIXEL_TEXTURE_SGIS:
1265 CHECK_EXTENSION(SGIS_pixel_texture);
1266 return ctx->Pixel.PixelTextureEnabled;
1267
1268 /* GL_SGIX_pixel_texture */
1269 case GL_PIXEL_TEX_GEN_SGIX:
1270 CHECK_EXTENSION(SGIX_pixel_texture);
1271 return ctx->Pixel.PixelTextureEnabled;
1272
1273 /* GL_SGI_color_table */
1274 case GL_COLOR_TABLE_SGI:
1275 CHECK_EXTENSION(SGI_color_table);
1276 return ctx->Pixel.ColorTableEnabled;
1277 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
1278 CHECK_EXTENSION(SGI_color_table);
1279 return ctx->Pixel.PostConvolutionColorTableEnabled;
1280 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
1281 CHECK_EXTENSION(SGI_color_table);
1282 return ctx->Pixel.PostColorMatrixColorTableEnabled;
1283
1284 /* GL_SGI_texture_color_table */
1285 case GL_TEXTURE_COLOR_TABLE_SGI:
1286 CHECK_EXTENSION(SGI_texture_color_table);
1287 return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
1288
1289 /* GL_EXT_convolution */
1290 case GL_CONVOLUTION_1D:
1291 CHECK_EXTENSION(EXT_convolution);
1292 return ctx->Pixel.Convolution1DEnabled;
1293 case GL_CONVOLUTION_2D:
1294 CHECK_EXTENSION(EXT_convolution);
1295 return ctx->Pixel.Convolution2DEnabled;
1296 case GL_SEPARABLE_2D:
1297 CHECK_EXTENSION(EXT_convolution);
1298 return ctx->Pixel.Separable2DEnabled;
1299
1300 /* GL_ARB_texture_cube_map */
1301 case GL_TEXTURE_CUBE_MAP_ARB:
1302 CHECK_EXTENSION(ARB_texture_cube_map);
1303 {
1304 const struct gl_texture_unit *texUnit;
1305 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1306 return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE;
1307 }
1308
1309 /* GL_ARB_multisample */
1310 case GL_MULTISAMPLE_ARB:
1311 CHECK_EXTENSION(ARB_multisample);
1312 return ctx->Multisample.Enabled;
1313 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
1314 CHECK_EXTENSION(ARB_multisample);
1315 return ctx->Multisample.SampleAlphaToCoverage;
1316 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
1317 CHECK_EXTENSION(ARB_multisample);
1318 return ctx->Multisample.SampleAlphaToOne;
1319 case GL_SAMPLE_COVERAGE_ARB:
1320 CHECK_EXTENSION(ARB_multisample);
1321 return ctx->Multisample.SampleCoverage;
1322 case GL_SAMPLE_COVERAGE_INVERT_ARB:
1323 CHECK_EXTENSION(ARB_multisample);
1324 return ctx->Multisample.SampleCoverageInvert;
1325
1326 /* GL_IBM_rasterpos_clip */
1327 case GL_RASTER_POSITION_UNCLIPPED_IBM:
1328 CHECK_EXTENSION(IBM_rasterpos_clip);
1329 return ctx->Transform.RasterPositionUnclipped;
1330
1331 /* GL_NV_point_sprite */
1332 case GL_POINT_SPRITE_NV:
1333 return ctx->Point.PointSprite;
1334
1335 #if FEATURE_NV_vertex_program
1336 case GL_VERTEX_PROGRAM_NV:
1337 CHECK_EXTENSION(NV_vertex_program);
1338 return ctx->VertexProgram.Enabled;
1339 case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
1340 CHECK_EXTENSION(NV_vertex_program);
1341 return ctx->VertexProgram.PointSizeEnabled;
1342 case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
1343 CHECK_EXTENSION(NV_vertex_program);
1344 return ctx->VertexProgram.TwoSideEnabled;
1345 case GL_VERTEX_ATTRIB_ARRAY0_NV:
1346 case GL_VERTEX_ATTRIB_ARRAY1_NV:
1347 case GL_VERTEX_ATTRIB_ARRAY2_NV:
1348 case GL_VERTEX_ATTRIB_ARRAY3_NV:
1349 case GL_VERTEX_ATTRIB_ARRAY4_NV:
1350 case GL_VERTEX_ATTRIB_ARRAY5_NV:
1351 case GL_VERTEX_ATTRIB_ARRAY6_NV:
1352 case GL_VERTEX_ATTRIB_ARRAY7_NV:
1353 case GL_VERTEX_ATTRIB_ARRAY8_NV:
1354 case GL_VERTEX_ATTRIB_ARRAY9_NV:
1355 case GL_VERTEX_ATTRIB_ARRAY10_NV:
1356 case GL_VERTEX_ATTRIB_ARRAY11_NV:
1357 case GL_VERTEX_ATTRIB_ARRAY12_NV:
1358 case GL_VERTEX_ATTRIB_ARRAY13_NV:
1359 case GL_VERTEX_ATTRIB_ARRAY14_NV:
1360 case GL_VERTEX_ATTRIB_ARRAY15_NV:
1361 CHECK_EXTENSION(NV_vertex_program);
1362 {
1363 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
1364 return (ctx->Array.VertexAttrib[n].Enabled != 0);
1365 }
1366 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
1367 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
1368 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
1369 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
1370 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
1371 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
1372 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
1373 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
1374 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
1375 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
1376 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
1377 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
1378 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
1379 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
1380 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
1381 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
1382 CHECK_EXTENSION(NV_vertex_program);
1383 {
1384 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
1385 return ctx->Eval.Map1Attrib[map];
1386 }
1387 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
1388 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
1389 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
1390 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
1391 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
1392 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
1393 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
1394 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
1395 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
1396 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
1397 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
1398 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
1399 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
1400 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
1401 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
1402 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
1403 CHECK_EXTENSION(NV_vertex_program);
1404 {
1405 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
1406 return ctx->Eval.Map2Attrib[map];
1407 }
1408 #endif /* FEATURE_NV_vertex_program */
1409
1410 #if FEATURE_NV_fragment_program
1411 case GL_FRAGMENT_PROGRAM_NV:
1412 CHECK_EXTENSION(NV_fragment_program);
1413 return ctx->FragmentProgram.Enabled;
1414 #endif /* FEATURE_NV_fragment_program */
1415
1416 /* GL_NV_texture_rectangle */
1417 case GL_TEXTURE_RECTANGLE_NV:
1418 CHECK_EXTENSION(NV_texture_rectangle);
1419 {
1420 const struct gl_texture_unit *texUnit;
1421 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1422 return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE;
1423 }
1424
1425 /* GL_EXT_stencil_two_side */
1426 case GL_STENCIL_TEST_TWO_SIDE_EXT:
1427 CHECK_EXTENSION(EXT_stencil_two_side);
1428 return ctx->Stencil.TestTwoSide;
1429
1430 #if FEATURE_ARB_fragment_program
1431 case GL_FRAGMENT_PROGRAM_ARB:
1432 return ctx->FragmentProgram.Enabled;
1433 #endif /* FEATURE_ARB_fragment_program */
1434
1435 /* GL_EXT_depth_bounds_test */
1436 case GL_DEPTH_BOUNDS_TEST_EXT:
1437 CHECK_EXTENSION(EXT_depth_bounds_test);
1438 return ctx->Depth.BoundsTest;
1439
1440 /* GL_MESA_program_debug */
1441 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
1442 CHECK_EXTENSION(MESA_program_debug);
1443 return ctx->FragmentProgram.CallbackEnabled;
1444 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
1445 CHECK_EXTENSION(MESA_program_debug);
1446 return ctx->VertexProgram.CallbackEnabled;
1447 #if FEATURE_ATI_fragment_shader
1448 case GL_FRAGMENT_SHADER_ATI:
1449 CHECK_EXTENSION(ATI_fragment_shader);
1450 return ctx->ATIFragmentShader.Enabled;
1451 #endif /* FEATURE_ATI_fragment_shader */
1452 default:
1453 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
1454 return GL_FALSE;
1455 }
1456 }