Some initial RGB and RGBA floating point texture formats.
[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 break;
357 case GL_LINE_SMOOTH:
358 if (ctx->Line.SmoothFlag == state)
359 return;
360 FLUSH_VERTICES(ctx, _NEW_LINE);
361 ctx->Line.SmoothFlag = state;
362 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
363 break;
364 case GL_LINE_STIPPLE:
365 if (ctx->Line.StippleFlag == state)
366 return;
367 FLUSH_VERTICES(ctx, _NEW_LINE);
368 ctx->Line.StippleFlag = state;
369 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
370 break;
371 case GL_INDEX_LOGIC_OP:
372 if (ctx->Color.IndexLogicOpEnabled == state)
373 return;
374 FLUSH_VERTICES(ctx, _NEW_COLOR);
375 ctx->Color.IndexLogicOpEnabled = state;
376 break;
377 case GL_COLOR_LOGIC_OP:
378 if (ctx->Color.ColorLogicOpEnabled == state)
379 return;
380 FLUSH_VERTICES(ctx, _NEW_COLOR);
381 ctx->Color.ColorLogicOpEnabled = state;
382 /* This is needed to support 1.1's RGB logic ops AND
383 * 1.0's blending logicops.
384 */
385 ctx->Color._LogicOpEnabled =
386 (state || (ctx->Color.BlendEnabled &&
387 ctx->Color.BlendEquation == GL_LOGIC_OP));
388 break;
389 case GL_MAP1_COLOR_4:
390 if (ctx->Eval.Map1Color4 == state)
391 return;
392 FLUSH_VERTICES(ctx, _NEW_EVAL);
393 ctx->Eval.Map1Color4 = state;
394 break;
395 case GL_MAP1_INDEX:
396 if (ctx->Eval.Map1Index == state)
397 return;
398 FLUSH_VERTICES(ctx, _NEW_EVAL);
399 ctx->Eval.Map1Index = state;
400 break;
401 case GL_MAP1_NORMAL:
402 if (ctx->Eval.Map1Normal == state)
403 return;
404 FLUSH_VERTICES(ctx, _NEW_EVAL);
405 ctx->Eval.Map1Normal = state;
406 break;
407 case GL_MAP1_TEXTURE_COORD_1:
408 if (ctx->Eval.Map1TextureCoord1 == state)
409 return;
410 FLUSH_VERTICES(ctx, _NEW_EVAL);
411 ctx->Eval.Map1TextureCoord1 = state;
412 break;
413 case GL_MAP1_TEXTURE_COORD_2:
414 if (ctx->Eval.Map1TextureCoord2 == state)
415 return;
416 FLUSH_VERTICES(ctx, _NEW_EVAL);
417 ctx->Eval.Map1TextureCoord2 = state;
418 break;
419 case GL_MAP1_TEXTURE_COORD_3:
420 if (ctx->Eval.Map1TextureCoord3 == state)
421 return;
422 FLUSH_VERTICES(ctx, _NEW_EVAL);
423 ctx->Eval.Map1TextureCoord3 = state;
424 break;
425 case GL_MAP1_TEXTURE_COORD_4:
426 if (ctx->Eval.Map1TextureCoord4 == state)
427 return;
428 FLUSH_VERTICES(ctx, _NEW_EVAL);
429 ctx->Eval.Map1TextureCoord4 = state;
430 break;
431 case GL_MAP1_VERTEX_3:
432 if (ctx->Eval.Map1Vertex3 == state)
433 return;
434 FLUSH_VERTICES(ctx, _NEW_EVAL);
435 ctx->Eval.Map1Vertex3 = state;
436 break;
437 case GL_MAP1_VERTEX_4:
438 if (ctx->Eval.Map1Vertex4 == state)
439 return;
440 FLUSH_VERTICES(ctx, _NEW_EVAL);
441 ctx->Eval.Map1Vertex4 = state;
442 break;
443 case GL_MAP2_COLOR_4:
444 if (ctx->Eval.Map2Color4 == state)
445 return;
446 FLUSH_VERTICES(ctx, _NEW_EVAL);
447 ctx->Eval.Map2Color4 = state;
448 break;
449 case GL_MAP2_INDEX:
450 if (ctx->Eval.Map2Index == state)
451 return;
452 FLUSH_VERTICES(ctx, _NEW_EVAL);
453 ctx->Eval.Map2Index = state;
454 break;
455 case GL_MAP2_NORMAL:
456 if (ctx->Eval.Map2Normal == state)
457 return;
458 FLUSH_VERTICES(ctx, _NEW_EVAL);
459 ctx->Eval.Map2Normal = state;
460 break;
461 case GL_MAP2_TEXTURE_COORD_1:
462 if (ctx->Eval.Map2TextureCoord1 == state)
463 return;
464 FLUSH_VERTICES(ctx, _NEW_EVAL);
465 ctx->Eval.Map2TextureCoord1 = state;
466 break;
467 case GL_MAP2_TEXTURE_COORD_2:
468 if (ctx->Eval.Map2TextureCoord2 == state)
469 return;
470 FLUSH_VERTICES(ctx, _NEW_EVAL);
471 ctx->Eval.Map2TextureCoord2 = state;
472 break;
473 case GL_MAP2_TEXTURE_COORD_3:
474 if (ctx->Eval.Map2TextureCoord3 == state)
475 return;
476 FLUSH_VERTICES(ctx, _NEW_EVAL);
477 ctx->Eval.Map2TextureCoord3 = state;
478 break;
479 case GL_MAP2_TEXTURE_COORD_4:
480 if (ctx->Eval.Map2TextureCoord4 == state)
481 return;
482 FLUSH_VERTICES(ctx, _NEW_EVAL);
483 ctx->Eval.Map2TextureCoord4 = state;
484 break;
485 case GL_MAP2_VERTEX_3:
486 if (ctx->Eval.Map2Vertex3 == state)
487 return;
488 FLUSH_VERTICES(ctx, _NEW_EVAL);
489 ctx->Eval.Map2Vertex3 = state;
490 break;
491 case GL_MAP2_VERTEX_4:
492 if (ctx->Eval.Map2Vertex4 == state)
493 return;
494 FLUSH_VERTICES(ctx, _NEW_EVAL);
495 ctx->Eval.Map2Vertex4 = state;
496 break;
497 case GL_MINMAX:
498 if (ctx->Pixel.MinMaxEnabled == state)
499 return;
500 FLUSH_VERTICES(ctx, _NEW_PIXEL);
501 ctx->Pixel.MinMaxEnabled = state;
502 break;
503 case GL_NORMALIZE:
504 if (ctx->Transform.Normalize == state)
505 return;
506 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
507 ctx->Transform.Normalize = state;
508 break;
509 case GL_POINT_SMOOTH:
510 if (ctx->Point.SmoothFlag==state)
511 return;
512 FLUSH_VERTICES(ctx, _NEW_POINT);
513 ctx->Point.SmoothFlag = state;
514 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
515 break;
516 case GL_POLYGON_SMOOTH:
517 if (ctx->Polygon.SmoothFlag==state)
518 return;
519 FLUSH_VERTICES(ctx, _NEW_POLYGON);
520 ctx->Polygon.SmoothFlag = state;
521 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
522 break;
523 case GL_POLYGON_STIPPLE:
524 if (ctx->Polygon.StippleFlag==state)
525 return;
526 FLUSH_VERTICES(ctx, _NEW_POLYGON);
527 ctx->Polygon.StippleFlag = state;
528 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
529 break;
530 case GL_POLYGON_OFFSET_POINT:
531 if (ctx->Polygon.OffsetPoint==state)
532 return;
533 FLUSH_VERTICES(ctx, _NEW_POLYGON);
534 ctx->Polygon.OffsetPoint = state;
535 break;
536 case GL_POLYGON_OFFSET_LINE:
537 if (ctx->Polygon.OffsetLine==state)
538 return;
539 FLUSH_VERTICES(ctx, _NEW_POLYGON);
540 ctx->Polygon.OffsetLine = state;
541 break;
542 case GL_POLYGON_OFFSET_FILL:
543 /*case GL_POLYGON_OFFSET_EXT:*/
544 if (ctx->Polygon.OffsetFill==state)
545 return;
546 FLUSH_VERTICES(ctx, _NEW_POLYGON);
547 ctx->Polygon.OffsetFill = state;
548 break;
549 case GL_RESCALE_NORMAL_EXT:
550 if (ctx->Transform.RescaleNormals == state)
551 return;
552 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
553 ctx->Transform.RescaleNormals = state;
554 break;
555 case GL_SCISSOR_TEST:
556 if (ctx->Scissor.Enabled==state)
557 return;
558 FLUSH_VERTICES(ctx, _NEW_SCISSOR);
559 ctx->Scissor.Enabled = state;
560 break;
561 case GL_SHARED_TEXTURE_PALETTE_EXT:
562 if (ctx->Texture.SharedPalette == state)
563 return;
564 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
565 ctx->Texture.SharedPalette = state;
566 break;
567 case GL_STENCIL_TEST:
568 if (state && ctx->Visual.stencilBits==0) {
569 _mesa_warning(ctx,
570 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
571 return;
572 }
573 if (ctx->Stencil.Enabled==state)
574 return;
575 FLUSH_VERTICES(ctx, _NEW_STENCIL);
576 ctx->Stencil.Enabled = state;
577 break;
578 case GL_TEXTURE_1D: {
579 const GLuint curr = ctx->Texture.CurrentUnit;
580 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
581 GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT;
582 if (state)
583 newenabled |= TEXTURE_1D_BIT;
584 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
585 return;
586 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
587 texUnit->Enabled = newenabled;
588 break;
589 }
590 case GL_TEXTURE_2D: {
591 const GLuint curr = ctx->Texture.CurrentUnit;
592 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
593 GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT;
594 if (state)
595 newenabled |= TEXTURE_2D_BIT;
596 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
597 return;
598 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
599 texUnit->Enabled = newenabled;
600 break;
601 }
602 case GL_TEXTURE_3D: {
603 const GLuint curr = ctx->Texture.CurrentUnit;
604 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
605 GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT;
606 if (state)
607 newenabled |= TEXTURE_3D_BIT;
608 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
609 return;
610 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
611 texUnit->Enabled = newenabled;
612 break;
613 }
614 case GL_TEXTURE_GEN_Q: {
615 GLuint unit = ctx->Texture.CurrentUnit;
616 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
617 GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
618 if (state)
619 newenabled |= Q_BIT;
620 if (texUnit->TexGenEnabled == newenabled)
621 return;
622 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
623 texUnit->TexGenEnabled = newenabled;
624 break;
625 }
626 case GL_TEXTURE_GEN_R: {
627 GLuint unit = ctx->Texture.CurrentUnit;
628 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
629 GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
630 if (state)
631 newenabled |= R_BIT;
632 if (texUnit->TexGenEnabled == newenabled)
633 return;
634 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
635 texUnit->TexGenEnabled = newenabled;
636 break;
637 }
638 break;
639 case GL_TEXTURE_GEN_S: {
640 GLuint unit = ctx->Texture.CurrentUnit;
641 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
642 GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
643 if (state)
644 newenabled |= S_BIT;
645 if (texUnit->TexGenEnabled == newenabled)
646 return;
647 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
648 texUnit->TexGenEnabled = newenabled;
649 break;
650 }
651 break;
652 case GL_TEXTURE_GEN_T: {
653 GLuint unit = ctx->Texture.CurrentUnit;
654 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
655 GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
656 if (state)
657 newenabled |= T_BIT;
658 if (texUnit->TexGenEnabled == newenabled)
659 return;
660 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
661 texUnit->TexGenEnabled = newenabled;
662 break;
663 }
664 break;
665
666 /*
667 * CLIENT STATE!!!
668 */
669 case GL_VERTEX_ARRAY:
670 case GL_NORMAL_ARRAY:
671 case GL_COLOR_ARRAY:
672 case GL_INDEX_ARRAY:
673 case GL_TEXTURE_COORD_ARRAY:
674 case GL_EDGE_FLAG_ARRAY:
675 case GL_FOG_COORDINATE_ARRAY_EXT:
676 case GL_SECONDARY_COLOR_ARRAY_EXT:
677 client_state( ctx, cap, state );
678 return;
679
680 /* GL_HP_occlusion_test */
681 case GL_OCCLUSION_TEST_HP:
682 CHECK_EXTENSION(HP_occlusion_test, cap);
683 if (ctx->Depth.OcclusionTest == state)
684 return;
685 FLUSH_VERTICES(ctx, _NEW_DEPTH);
686 ctx->Depth.OcclusionTest = state;
687 if (state)
688 ctx->OcclusionResult = ctx->OcclusionResultSaved;
689 else
690 ctx->OcclusionResultSaved = ctx->OcclusionResult;
691 break;
692
693 /* GL_SGIS_pixel_texture */
694 case GL_PIXEL_TEXTURE_SGIS:
695 CHECK_EXTENSION(SGIS_pixel_texture, cap);
696 if (ctx->Pixel.PixelTextureEnabled == state)
697 return;
698 FLUSH_VERTICES(ctx, _NEW_PIXEL);
699 ctx->Pixel.PixelTextureEnabled = state;
700 break;
701
702 /* GL_SGIX_pixel_texture */
703 case GL_PIXEL_TEX_GEN_SGIX:
704 CHECK_EXTENSION(SGIX_pixel_texture, cap);
705 if (ctx->Pixel.PixelTextureEnabled == state)
706 return;
707 FLUSH_VERTICES(ctx, _NEW_PIXEL);
708 ctx->Pixel.PixelTextureEnabled = state;
709 break;
710
711 /* GL_SGI_color_table */
712 case GL_COLOR_TABLE_SGI:
713 CHECK_EXTENSION(SGI_color_table, cap);
714 if (ctx->Pixel.ColorTableEnabled == state)
715 return;
716 FLUSH_VERTICES(ctx, _NEW_PIXEL);
717 ctx->Pixel.ColorTableEnabled = state;
718 break;
719 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
720 CHECK_EXTENSION(SGI_color_table, cap);
721 if (ctx->Pixel.PostConvolutionColorTableEnabled == state)
722 return;
723 FLUSH_VERTICES(ctx, _NEW_PIXEL);
724 ctx->Pixel.PostConvolutionColorTableEnabled = state;
725 break;
726 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
727 CHECK_EXTENSION(SGI_color_table, cap);
728 if (ctx->Pixel.PostColorMatrixColorTableEnabled == state)
729 return;
730 FLUSH_VERTICES(ctx, _NEW_PIXEL);
731 ctx->Pixel.PostColorMatrixColorTableEnabled = state;
732 break;
733 case GL_TEXTURE_COLOR_TABLE_SGI:
734 CHECK_EXTENSION(SGI_texture_color_table, cap);
735 if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state)
736 return;
737 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
738 ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state;
739 break;
740
741 /* GL_EXT_convolution */
742 case GL_CONVOLUTION_1D:
743 CHECK_EXTENSION(EXT_convolution, cap);
744 if (ctx->Pixel.Convolution1DEnabled == state)
745 return;
746 FLUSH_VERTICES(ctx, _NEW_PIXEL);
747 ctx->Pixel.Convolution1DEnabled = state;
748 break;
749 case GL_CONVOLUTION_2D:
750 CHECK_EXTENSION(EXT_convolution, cap);
751 if (ctx->Pixel.Convolution2DEnabled == state)
752 return;
753 FLUSH_VERTICES(ctx, _NEW_PIXEL);
754 ctx->Pixel.Convolution2DEnabled = state;
755 break;
756 case GL_SEPARABLE_2D:
757 CHECK_EXTENSION(EXT_convolution, cap);
758 if (ctx->Pixel.Separable2DEnabled == state)
759 return;
760 FLUSH_VERTICES(ctx, _NEW_PIXEL);
761 ctx->Pixel.Separable2DEnabled = state;
762 break;
763
764 /* GL_ARB_texture_cube_map */
765 case GL_TEXTURE_CUBE_MAP_ARB:
766 {
767 const GLuint curr = ctx->Texture.CurrentUnit;
768 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
769 GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT;
770 CHECK_EXTENSION(ARB_texture_cube_map, cap);
771 if (state)
772 newenabled |= TEXTURE_CUBE_BIT;
773 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
774 return;
775 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
776 texUnit->Enabled = newenabled;
777 }
778 break;
779
780 /* GL_EXT_secondary_color */
781 case GL_COLOR_SUM_EXT:
782 CHECK_EXTENSION(EXT_secondary_color, cap);
783 if (ctx->Fog.ColorSumEnabled == state)
784 return;
785 FLUSH_VERTICES(ctx, _NEW_FOG);
786 ctx->Fog.ColorSumEnabled = state;
787 break;
788
789 /* GL_ARB_multisample */
790 case GL_MULTISAMPLE_ARB:
791 CHECK_EXTENSION(ARB_multisample, cap);
792 if (ctx->Multisample.Enabled == state)
793 return;
794 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
795 ctx->Multisample.Enabled = state;
796 break;
797 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
798 CHECK_EXTENSION(ARB_multisample, cap);
799 if (ctx->Multisample.SampleAlphaToCoverage == state)
800 return;
801 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
802 ctx->Multisample.SampleAlphaToCoverage = state;
803 break;
804 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
805 CHECK_EXTENSION(ARB_multisample, cap);
806 if (ctx->Multisample.SampleAlphaToOne == state)
807 return;
808 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
809 ctx->Multisample.SampleAlphaToOne = state;
810 break;
811 case GL_SAMPLE_COVERAGE_ARB:
812 CHECK_EXTENSION(ARB_multisample, cap);
813 if (ctx->Multisample.SampleCoverage == state)
814 return;
815 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
816 ctx->Multisample.SampleCoverage = state;
817 break;
818 case GL_SAMPLE_COVERAGE_INVERT_ARB:
819 CHECK_EXTENSION(ARB_multisample, cap);
820 if (ctx->Multisample.SampleCoverageInvert == state)
821 return;
822 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
823 ctx->Multisample.SampleCoverageInvert = state;
824 break;
825
826 /* GL_IBM_rasterpos_clip */
827 case GL_RASTER_POSITION_UNCLIPPED_IBM:
828 CHECK_EXTENSION(IBM_rasterpos_clip, cap);
829 if (ctx->Transform.RasterPositionUnclipped == state)
830 return;
831 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
832 ctx->Transform.RasterPositionUnclipped = state;
833 break;
834
835 /* GL_NV_point_sprite */
836 case GL_POINT_SPRITE_NV:
837 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
838 if (ctx->Point.PointSprite == state)
839 return;
840 FLUSH_VERTICES(ctx, _NEW_POINT);
841 ctx->Point.PointSprite = state;
842 break;
843
844 #if FEATURE_NV_vertex_program
845 case GL_VERTEX_PROGRAM_NV:
846 CHECK_EXTENSION(NV_vertex_program, cap);
847 if (ctx->VertexProgram.Enabled == state)
848 return;
849 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
850 ctx->VertexProgram.Enabled = state;
851 break;
852 case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
853 CHECK_EXTENSION(NV_vertex_program, cap);
854 if (ctx->VertexProgram.PointSizeEnabled == state)
855 return;
856 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
857 ctx->VertexProgram.PointSizeEnabled = state;
858 break;
859 case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
860 CHECK_EXTENSION(NV_vertex_program, cap);
861 if (ctx->VertexProgram.TwoSideEnabled == state)
862 return;
863 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
864 ctx->VertexProgram.TwoSideEnabled = state;
865 break;
866 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
867 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
868 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
869 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
870 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
871 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
872 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
873 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
874 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
875 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
876 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
877 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
878 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
879 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
880 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
881 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
882 CHECK_EXTENSION(NV_vertex_program, cap);
883 {
884 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
885 FLUSH_VERTICES(ctx, _NEW_EVAL);
886 ctx->Eval.Map1Attrib[map] = state;
887 }
888 break;
889 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
890 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
891 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
892 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
893 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
894 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
895 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
896 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
897 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
898 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
899 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
900 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
901 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
902 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
903 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
904 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
905 CHECK_EXTENSION(NV_vertex_program, cap);
906 {
907 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
908 FLUSH_VERTICES(ctx, _NEW_EVAL);
909 ctx->Eval.Map2Attrib[map] = state;
910 }
911 break;
912 #endif /* FEATURE_NV_vertex_program */
913
914 #if FEATURE_NV_fragment_program
915 case GL_FRAGMENT_PROGRAM_NV:
916 CHECK_EXTENSION(NV_fragment_program, cap);
917 if (ctx->FragmentProgram.Enabled == state)
918 return;
919 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
920 ctx->FragmentProgram.Enabled = state;
921 break;
922 #endif /* FEATURE_NV_fragment_program */
923
924 /* GL_NV_texture_rectangle */
925 case GL_TEXTURE_RECTANGLE_NV:
926 CHECK_EXTENSION(NV_texture_rectangle, cap);
927 {
928 const GLuint curr = ctx->Texture.CurrentUnit;
929 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
930 GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT;
931 CHECK_EXTENSION(NV_texture_rectangle, cap);
932 if (state)
933 newenabled |= TEXTURE_RECT_BIT;
934 if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
935 return;
936 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
937 texUnit->Enabled = newenabled;
938 }
939 break;
940
941 /* GL_EXT_stencil_two_side */
942 case GL_STENCIL_TEST_TWO_SIDE_EXT:
943 CHECK_EXTENSION(EXT_stencil_two_side, cap);
944 if (ctx->Stencil.TestTwoSide == state)
945 return;
946 FLUSH_VERTICES(ctx, _NEW_STENCIL);
947 ctx->Stencil.TestTwoSide = state;
948 break;
949
950 #if FEATURE_ARB_fragment_program
951 case GL_FRAGMENT_PROGRAM_ARB:
952 CHECK_EXTENSION(ARB_fragment_program, cap);
953 if (ctx->FragmentProgram.Enabled == state)
954 return;
955 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
956 ctx->FragmentProgram.Enabled = state;
957 break;
958 #endif /* FEATURE_ARB_fragment_program */
959
960 /* GL_EXT_depth_bounds_test */
961 case GL_DEPTH_BOUNDS_TEST_EXT:
962 CHECK_EXTENSION(EXT_depth_bounds_test, cap);
963 if (state && ctx->Visual.depthBits==0) {
964 _mesa_warning(ctx,
965 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
966 return;
967 }
968 if (ctx->Depth.BoundsTest == state)
969 return;
970 FLUSH_VERTICES(ctx, _NEW_DEPTH);
971 ctx->Depth.BoundsTest = state;
972 break;
973
974 /* GL_MESA_program_debug */
975 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
976 CHECK_EXTENSION(MESA_program_debug, cap);
977 ctx->FragmentProgram.CallbackEnabled = state;
978 break;
979 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
980 CHECK_EXTENSION(MESA_program_debug, cap);
981 ctx->VertexProgram.CallbackEnabled = state;
982 break;
983
984 default:
985 _mesa_error(ctx, GL_INVALID_ENUM,
986 "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
987 return;
988 }
989
990 if (ctx->Driver.Enable) {
991 (*ctx->Driver.Enable)( ctx, cap, state );
992 }
993 }
994
995
996 /**
997 * Enable GL capability.
998 *
999 * \param cap capability.
1000 *
1001 * \sa glEnable().
1002 *
1003 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1004 * calls _mesa_set_enable().
1005 */
1006 void GLAPIENTRY
1007 _mesa_Enable( GLenum cap )
1008 {
1009 GET_CURRENT_CONTEXT(ctx);
1010 ASSERT_OUTSIDE_BEGIN_END(ctx);
1011
1012 _mesa_set_enable( ctx, cap, GL_TRUE );
1013 }
1014
1015
1016 /**
1017 * Disable GL capability.
1018 *
1019 * \param cap capability.
1020 *
1021 * \sa glDisable().
1022 *
1023 * Get's the current context, assures that we're outside glBegin()/glEnd() and
1024 * calls _mesa_set_enable().
1025 */
1026 void GLAPIENTRY
1027 _mesa_Disable( GLenum cap )
1028 {
1029 GET_CURRENT_CONTEXT(ctx);
1030 ASSERT_OUTSIDE_BEGIN_END(ctx);
1031
1032 _mesa_set_enable( ctx, cap, GL_FALSE );
1033 }
1034
1035
1036 #undef CHECK_EXTENSION
1037 #define CHECK_EXTENSION(EXTNAME) \
1038 if (!ctx->Extensions.EXTNAME) { \
1039 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1040 return GL_FALSE; \
1041 }
1042
1043
1044 /**
1045 * Test whether a capability is enabled.
1046 *
1047 * \param cap capability.
1048 *
1049 * Returns the state of the specified capability from the current GL context.
1050 * For the capabilities associated with extensions verifies that those
1051 * extensions are effectively present before reporting.
1052 */
1053 GLboolean GLAPIENTRY
1054 _mesa_IsEnabled( GLenum cap )
1055 {
1056 GET_CURRENT_CONTEXT(ctx);
1057 switch (cap) {
1058 case GL_ALPHA_TEST:
1059 return ctx->Color.AlphaEnabled;
1060 case GL_AUTO_NORMAL:
1061 return ctx->Eval.AutoNormal;
1062 case GL_BLEND:
1063 return ctx->Color.BlendEnabled;
1064 case GL_CLIP_PLANE0:
1065 case GL_CLIP_PLANE1:
1066 case GL_CLIP_PLANE2:
1067 case GL_CLIP_PLANE3:
1068 case GL_CLIP_PLANE4:
1069 case GL_CLIP_PLANE5:
1070 return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
1071 case GL_COLOR_MATERIAL:
1072 return ctx->Light.ColorMaterialEnabled;
1073 case GL_CULL_FACE:
1074 return ctx->Polygon.CullFlag;
1075 case GL_DEPTH_TEST:
1076 return ctx->Depth.Test;
1077 case GL_DITHER:
1078 return ctx->Color.DitherFlag;
1079 case GL_FOG:
1080 return ctx->Fog.Enabled;
1081 case GL_LIGHTING:
1082 return ctx->Light.Enabled;
1083 case GL_LIGHT0:
1084 case GL_LIGHT1:
1085 case GL_LIGHT2:
1086 case GL_LIGHT3:
1087 case GL_LIGHT4:
1088 case GL_LIGHT5:
1089 case GL_LIGHT6:
1090 case GL_LIGHT7:
1091 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
1092 case GL_LINE_SMOOTH:
1093 return ctx->Line.SmoothFlag;
1094 case GL_LINE_STIPPLE:
1095 return ctx->Line.StippleFlag;
1096 case GL_INDEX_LOGIC_OP:
1097 return ctx->Color.IndexLogicOpEnabled;
1098 case GL_COLOR_LOGIC_OP:
1099 return ctx->Color.ColorLogicOpEnabled;
1100 case GL_MAP1_COLOR_4:
1101 return ctx->Eval.Map1Color4;
1102 case GL_MAP1_INDEX:
1103 return ctx->Eval.Map1Index;
1104 case GL_MAP1_NORMAL:
1105 return ctx->Eval.Map1Normal;
1106 case GL_MAP1_TEXTURE_COORD_1:
1107 return ctx->Eval.Map1TextureCoord1;
1108 case GL_MAP1_TEXTURE_COORD_2:
1109 return ctx->Eval.Map1TextureCoord2;
1110 case GL_MAP1_TEXTURE_COORD_3:
1111 return ctx->Eval.Map1TextureCoord3;
1112 case GL_MAP1_TEXTURE_COORD_4:
1113 return ctx->Eval.Map1TextureCoord4;
1114 case GL_MAP1_VERTEX_3:
1115 return ctx->Eval.Map1Vertex3;
1116 case GL_MAP1_VERTEX_4:
1117 return ctx->Eval.Map1Vertex4;
1118 case GL_MAP2_COLOR_4:
1119 return ctx->Eval.Map2Color4;
1120 case GL_MAP2_INDEX:
1121 return ctx->Eval.Map2Index;
1122 case GL_MAP2_NORMAL:
1123 return ctx->Eval.Map2Normal;
1124 case GL_MAP2_TEXTURE_COORD_1:
1125 return ctx->Eval.Map2TextureCoord1;
1126 case GL_MAP2_TEXTURE_COORD_2:
1127 return ctx->Eval.Map2TextureCoord2;
1128 case GL_MAP2_TEXTURE_COORD_3:
1129 return ctx->Eval.Map2TextureCoord3;
1130 case GL_MAP2_TEXTURE_COORD_4:
1131 return ctx->Eval.Map2TextureCoord4;
1132 case GL_MAP2_VERTEX_3:
1133 return ctx->Eval.Map2Vertex3;
1134 case GL_MAP2_VERTEX_4:
1135 return ctx->Eval.Map2Vertex4;
1136 case GL_NORMALIZE:
1137 return ctx->Transform.Normalize;
1138 case GL_POINT_SMOOTH:
1139 return ctx->Point.SmoothFlag;
1140 case GL_POLYGON_SMOOTH:
1141 return ctx->Polygon.SmoothFlag;
1142 case GL_POLYGON_STIPPLE:
1143 return ctx->Polygon.StippleFlag;
1144 case GL_POLYGON_OFFSET_POINT:
1145 return ctx->Polygon.OffsetPoint;
1146 case GL_POLYGON_OFFSET_LINE:
1147 return ctx->Polygon.OffsetLine;
1148 case GL_POLYGON_OFFSET_FILL:
1149 /*case GL_POLYGON_OFFSET_EXT:*/
1150 return ctx->Polygon.OffsetFill;
1151 case GL_RESCALE_NORMAL_EXT:
1152 return ctx->Transform.RescaleNormals;
1153 case GL_SCISSOR_TEST:
1154 return ctx->Scissor.Enabled;
1155 case GL_SHARED_TEXTURE_PALETTE_EXT:
1156 return ctx->Texture.SharedPalette;
1157 case GL_STENCIL_TEST:
1158 return ctx->Stencil.Enabled;
1159 case GL_TEXTURE_1D:
1160 {
1161 const struct gl_texture_unit *texUnit;
1162 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1163 return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE;
1164 }
1165 case GL_TEXTURE_2D:
1166 {
1167 const struct gl_texture_unit *texUnit;
1168 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1169 return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE;
1170 }
1171 case GL_TEXTURE_3D:
1172 {
1173 const struct gl_texture_unit *texUnit;
1174 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1175 return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE;
1176 }
1177 case GL_TEXTURE_GEN_Q:
1178 {
1179 const struct gl_texture_unit *texUnit;
1180 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1181 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
1182 }
1183 case GL_TEXTURE_GEN_R:
1184 {
1185 const struct gl_texture_unit *texUnit;
1186 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1187 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
1188 }
1189 case GL_TEXTURE_GEN_S:
1190 {
1191 const struct gl_texture_unit *texUnit;
1192 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1193 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
1194 }
1195 case GL_TEXTURE_GEN_T:
1196 {
1197 const struct gl_texture_unit *texUnit;
1198 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1199 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
1200 }
1201
1202 /*
1203 * CLIENT STATE!!!
1204 */
1205 case GL_VERTEX_ARRAY:
1206 return (ctx->Array.Vertex.Enabled != 0);
1207 case GL_NORMAL_ARRAY:
1208 return (ctx->Array.Normal.Enabled != 0);
1209 case GL_COLOR_ARRAY:
1210 return (ctx->Array.Color.Enabled != 0);
1211 case GL_INDEX_ARRAY:
1212 return (ctx->Array.Index.Enabled != 0);
1213 case GL_TEXTURE_COORD_ARRAY:
1214 return (ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled != 0);
1215 case GL_EDGE_FLAG_ARRAY:
1216 return (ctx->Array.EdgeFlag.Enabled != 0);
1217 case GL_FOG_COORDINATE_ARRAY_EXT:
1218 CHECK_EXTENSION(EXT_fog_coord);
1219 return (ctx->Array.FogCoord.Enabled != 0);
1220 case GL_SECONDARY_COLOR_ARRAY_EXT:
1221 CHECK_EXTENSION(EXT_secondary_color);
1222 return (ctx->Array.SecondaryColor.Enabled != 0);
1223
1224 /* GL_EXT_histogram */
1225 case GL_HISTOGRAM:
1226 CHECK_EXTENSION(EXT_histogram);
1227 return ctx->Pixel.HistogramEnabled;
1228 case GL_MINMAX:
1229 CHECK_EXTENSION(EXT_histogram);
1230 return ctx->Pixel.MinMaxEnabled;
1231
1232 /* GL_HP_occlusion_test */
1233 case GL_OCCLUSION_TEST_HP:
1234 CHECK_EXTENSION(HP_occlusion_test);
1235 return ctx->Depth.OcclusionTest;
1236
1237 /* GL_SGIS_pixel_texture */
1238 case GL_PIXEL_TEXTURE_SGIS:
1239 CHECK_EXTENSION(SGIS_pixel_texture);
1240 return ctx->Pixel.PixelTextureEnabled;
1241
1242 /* GL_SGIX_pixel_texture */
1243 case GL_PIXEL_TEX_GEN_SGIX:
1244 CHECK_EXTENSION(SGIX_pixel_texture);
1245 return ctx->Pixel.PixelTextureEnabled;
1246
1247 /* GL_SGI_color_table */
1248 case GL_COLOR_TABLE_SGI:
1249 CHECK_EXTENSION(SGI_color_table);
1250 return ctx->Pixel.ColorTableEnabled;
1251 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
1252 CHECK_EXTENSION(SGI_color_table);
1253 return ctx->Pixel.PostConvolutionColorTableEnabled;
1254 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
1255 CHECK_EXTENSION(SGI_color_table);
1256 return ctx->Pixel.PostColorMatrixColorTableEnabled;
1257
1258 /* GL_SGI_texture_color_table */
1259 case GL_TEXTURE_COLOR_TABLE_SGI:
1260 CHECK_EXTENSION(SGI_texture_color_table);
1261 return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
1262
1263 /* GL_EXT_convolution */
1264 case GL_CONVOLUTION_1D:
1265 CHECK_EXTENSION(EXT_convolution);
1266 return ctx->Pixel.Convolution1DEnabled;
1267 case GL_CONVOLUTION_2D:
1268 CHECK_EXTENSION(EXT_convolution);
1269 return ctx->Pixel.Convolution2DEnabled;
1270 case GL_SEPARABLE_2D:
1271 CHECK_EXTENSION(EXT_convolution);
1272 return ctx->Pixel.Separable2DEnabled;
1273
1274 /* GL_ARB_texture_cube_map */
1275 case GL_TEXTURE_CUBE_MAP_ARB:
1276 CHECK_EXTENSION(ARB_texture_cube_map);
1277 {
1278 const struct gl_texture_unit *texUnit;
1279 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1280 return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE;
1281 }
1282
1283 /* GL_ARB_multisample */
1284 case GL_MULTISAMPLE_ARB:
1285 CHECK_EXTENSION(ARB_multisample);
1286 return ctx->Multisample.Enabled;
1287 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
1288 CHECK_EXTENSION(ARB_multisample);
1289 return ctx->Multisample.SampleAlphaToCoverage;
1290 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
1291 CHECK_EXTENSION(ARB_multisample);
1292 return ctx->Multisample.SampleAlphaToOne;
1293 case GL_SAMPLE_COVERAGE_ARB:
1294 CHECK_EXTENSION(ARB_multisample);
1295 return ctx->Multisample.SampleCoverage;
1296 case GL_SAMPLE_COVERAGE_INVERT_ARB:
1297 CHECK_EXTENSION(ARB_multisample);
1298 return ctx->Multisample.SampleCoverageInvert;
1299
1300 /* GL_IBM_rasterpos_clip */
1301 case GL_RASTER_POSITION_UNCLIPPED_IBM:
1302 CHECK_EXTENSION(IBM_rasterpos_clip);
1303 return ctx->Transform.RasterPositionUnclipped;
1304
1305 /* GL_NV_point_sprite */
1306 case GL_POINT_SPRITE_NV:
1307 return ctx->Point.PointSprite;
1308
1309 #if FEATURE_NV_vertex_program
1310 case GL_VERTEX_PROGRAM_NV:
1311 CHECK_EXTENSION(NV_vertex_program);
1312 return ctx->VertexProgram.Enabled;
1313 case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
1314 CHECK_EXTENSION(NV_vertex_program);
1315 return ctx->VertexProgram.PointSizeEnabled;
1316 case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
1317 CHECK_EXTENSION(NV_vertex_program);
1318 return ctx->VertexProgram.TwoSideEnabled;
1319 case GL_VERTEX_ATTRIB_ARRAY0_NV:
1320 case GL_VERTEX_ATTRIB_ARRAY1_NV:
1321 case GL_VERTEX_ATTRIB_ARRAY2_NV:
1322 case GL_VERTEX_ATTRIB_ARRAY3_NV:
1323 case GL_VERTEX_ATTRIB_ARRAY4_NV:
1324 case GL_VERTEX_ATTRIB_ARRAY5_NV:
1325 case GL_VERTEX_ATTRIB_ARRAY6_NV:
1326 case GL_VERTEX_ATTRIB_ARRAY7_NV:
1327 case GL_VERTEX_ATTRIB_ARRAY8_NV:
1328 case GL_VERTEX_ATTRIB_ARRAY9_NV:
1329 case GL_VERTEX_ATTRIB_ARRAY10_NV:
1330 case GL_VERTEX_ATTRIB_ARRAY11_NV:
1331 case GL_VERTEX_ATTRIB_ARRAY12_NV:
1332 case GL_VERTEX_ATTRIB_ARRAY13_NV:
1333 case GL_VERTEX_ATTRIB_ARRAY14_NV:
1334 case GL_VERTEX_ATTRIB_ARRAY15_NV:
1335 CHECK_EXTENSION(NV_vertex_program);
1336 {
1337 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
1338 return (ctx->Array.VertexAttrib[n].Enabled != 0);
1339 }
1340 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
1341 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
1342 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
1343 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
1344 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
1345 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
1346 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
1347 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
1348 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
1349 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
1350 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
1351 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
1352 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
1353 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
1354 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
1355 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
1356 CHECK_EXTENSION(NV_vertex_program);
1357 {
1358 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
1359 return ctx->Eval.Map1Attrib[map];
1360 }
1361 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
1362 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
1363 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
1364 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
1365 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
1366 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
1367 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
1368 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
1369 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
1370 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
1371 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
1372 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
1373 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
1374 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
1375 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
1376 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
1377 CHECK_EXTENSION(NV_vertex_program);
1378 {
1379 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
1380 return ctx->Eval.Map2Attrib[map];
1381 }
1382 #endif /* FEATURE_NV_vertex_program */
1383
1384 #if FEATURE_NV_fragment_program
1385 case GL_FRAGMENT_PROGRAM_NV:
1386 CHECK_EXTENSION(NV_fragment_program);
1387 return ctx->FragmentProgram.Enabled;
1388 #endif /* FEATURE_NV_fragment_program */
1389
1390 /* GL_NV_texture_rectangle */
1391 case GL_TEXTURE_RECTANGLE_NV:
1392 CHECK_EXTENSION(NV_texture_rectangle);
1393 {
1394 const struct gl_texture_unit *texUnit;
1395 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1396 return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE;
1397 }
1398
1399 /* GL_EXT_stencil_two_side */
1400 case GL_STENCIL_TEST_TWO_SIDE_EXT:
1401 CHECK_EXTENSION(EXT_stencil_two_side);
1402 return ctx->Stencil.TestTwoSide;
1403
1404 #if FEATURE_ARB_fragment_program
1405 case GL_FRAGMENT_PROGRAM_ARB:
1406 return ctx->FragmentProgram.Enabled;
1407 #endif /* FEATURE_ARB_fragment_program */
1408
1409 /* GL_EXT_depth_bounds_test */
1410 case GL_DEPTH_BOUNDS_TEST_EXT:
1411 CHECK_EXTENSION(EXT_depth_bounds_test);
1412 return ctx->Depth.BoundsTest;
1413
1414 /* GL_MESA_program_debug */
1415 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
1416 CHECK_EXTENSION(MESA_program_debug);
1417 return ctx->FragmentProgram.CallbackEnabled;
1418 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
1419 CHECK_EXTENSION(MESA_program_debug);
1420 return ctx->VertexProgram.CallbackEnabled;
1421
1422 default:
1423 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
1424 return GL_FALSE;
1425 }
1426 }