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