mesa: remove FEATURE_point_size_array define.
[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 *
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 */
28
29
30 #include "glheader.h"
31 #include "clip.h"
32 #include "context.h"
33 #include "enable.h"
34 #include "light.h"
35 #include "simple_list.h"
36 #include "mfeatures.h"
37 #include "mtypes.h"
38 #include "enums.h"
39 #include "api_arrayelt.h"
40 #include "texstate.h"
41 #include "drivers/common/meta.h"
42
43
44
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
48 }
49
50
51 /**
52 * Helper to enable/disable client-side state.
53 */
54 static void
55 client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
56 {
57 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
58 GLbitfield64 flag;
59 GLboolean *var;
60
61 switch (cap) {
62 case GL_VERTEX_ARRAY:
63 var = &arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled;
64 flag = VERT_BIT_POS;
65 break;
66 case GL_NORMAL_ARRAY:
67 var = &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
68 flag = VERT_BIT_NORMAL;
69 break;
70 case GL_COLOR_ARRAY:
71 var = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
72 flag = VERT_BIT_COLOR0;
73 break;
74 case GL_INDEX_ARRAY:
75 var = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
76 flag = VERT_BIT_COLOR_INDEX;
77 break;
78 case GL_TEXTURE_COORD_ARRAY:
79 var = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
80 flag = VERT_BIT_TEX(ctx->Array.ActiveTexture);
81 break;
82 case GL_EDGE_FLAG_ARRAY:
83 var = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
84 flag = VERT_BIT_EDGEFLAG;
85 break;
86 case GL_FOG_COORDINATE_ARRAY_EXT:
87 var = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
88 flag = VERT_BIT_FOG;
89 break;
90 case GL_SECONDARY_COLOR_ARRAY_EXT:
91 var = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
92 flag = VERT_BIT_COLOR1;
93 break;
94
95 case GL_POINT_SIZE_ARRAY_OES:
96 var = &arrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
97 flag = VERT_BIT_POINT_SIZE;
98 break;
99
100 #if FEATURE_NV_vertex_program
101 case GL_VERTEX_ATTRIB_ARRAY0_NV:
102 case GL_VERTEX_ATTRIB_ARRAY1_NV:
103 case GL_VERTEX_ATTRIB_ARRAY2_NV:
104 case GL_VERTEX_ATTRIB_ARRAY3_NV:
105 case GL_VERTEX_ATTRIB_ARRAY4_NV:
106 case GL_VERTEX_ATTRIB_ARRAY5_NV:
107 case GL_VERTEX_ATTRIB_ARRAY6_NV:
108 case GL_VERTEX_ATTRIB_ARRAY7_NV:
109 case GL_VERTEX_ATTRIB_ARRAY8_NV:
110 case GL_VERTEX_ATTRIB_ARRAY9_NV:
111 case GL_VERTEX_ATTRIB_ARRAY10_NV:
112 case GL_VERTEX_ATTRIB_ARRAY11_NV:
113 case GL_VERTEX_ATTRIB_ARRAY12_NV:
114 case GL_VERTEX_ATTRIB_ARRAY13_NV:
115 case GL_VERTEX_ATTRIB_ARRAY14_NV:
116 case GL_VERTEX_ATTRIB_ARRAY15_NV:
117 CHECK_EXTENSION(NV_vertex_program, cap);
118 {
119 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
120 ASSERT(VERT_ATTRIB_GENERIC(n) < Elements(arrayObj->VertexAttrib));
121 var = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(n)].Enabled;
122 flag = VERT_BIT_GENERIC(n);
123 }
124 break;
125 #endif /* FEATURE_NV_vertex_program */
126
127 /* GL_NV_primitive_restart */
128 case GL_PRIMITIVE_RESTART_NV:
129 if (!ctx->Extensions.NV_primitive_restart) {
130 goto invalid_enum_error;
131 }
132 var = &ctx->Array.PrimitiveRestart;
133 flag = 0;
134 break;
135
136 default:
137 goto invalid_enum_error;
138 }
139
140 if (*var == state)
141 return;
142
143 FLUSH_VERTICES(ctx, _NEW_ARRAY);
144
145 _ae_invalidate_state(ctx, _NEW_ARRAY);
146
147 *var = state;
148
149 if (state)
150 arrayObj->_Enabled |= flag;
151 else
152 arrayObj->_Enabled &= ~flag;
153
154 arrayObj->NewArrays |= flag;
155
156 if (ctx->Driver.Enable) {
157 ctx->Driver.Enable( ctx, cap, state );
158 }
159
160 return;
161
162 invalid_enum_error:
163 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(%s)",
164 state ? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap));
165 }
166
167
168 /**
169 * Enable GL capability.
170 * \param cap state to enable/disable.
171 *
172 * Get's the current context, assures that we're outside glBegin()/glEnd() and
173 * calls client_state().
174 */
175 void GLAPIENTRY
176 _mesa_EnableClientState( GLenum cap )
177 {
178 GET_CURRENT_CONTEXT(ctx);
179 ASSERT_OUTSIDE_BEGIN_END(ctx);
180 client_state( ctx, cap, GL_TRUE );
181 }
182
183
184 /**
185 * Disable GL capability.
186 * \param cap state to enable/disable.
187 *
188 * Get's the current context, assures that we're outside glBegin()/glEnd() and
189 * calls client_state().
190 */
191 void GLAPIENTRY
192 _mesa_DisableClientState( GLenum cap )
193 {
194 GET_CURRENT_CONTEXT(ctx);
195 ASSERT_OUTSIDE_BEGIN_END(ctx);
196 client_state( ctx, cap, GL_FALSE );
197 }
198
199
200 #undef CHECK_EXTENSION
201 #define CHECK_EXTENSION(EXTNAME, CAP) \
202 if (!ctx->Extensions.EXTNAME) { \
203 goto invalid_enum_error; \
204 }
205
206 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
207 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
208 goto invalid_enum_error; \
209 }
210
211 /**
212 * Return pointer to current texture unit for setting/getting coordinate
213 * state.
214 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
215 * texture unit is higher than the number of supported coordinate units.
216 */
217 static struct gl_texture_unit *
218 get_texcoord_unit(struct gl_context *ctx)
219 {
220 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
221 _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)");
222 return NULL;
223 }
224 else {
225 return &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
226 }
227 }
228
229
230 /**
231 * Helper function to enable or disable a texture target.
232 * \param bit one of the TEXTURE_x_BIT values
233 * \return GL_TRUE if state is changing or GL_FALSE if no change
234 */
235 static GLboolean
236 enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
237 {
238 struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
239 const GLbitfield newenabled = state
240 ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit);
241
242 if (texUnit->Enabled == newenabled)
243 return GL_FALSE;
244
245 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
246 texUnit->Enabled = newenabled;
247 return GL_TRUE;
248 }
249
250
251 /**
252 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
253 * whether the API supports it (GLES doesn't).
254 */
255 void
256 _mesa_set_multisample(struct gl_context *ctx, GLboolean state)
257 {
258 if (ctx->Multisample.Enabled == state)
259 return;
260 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
261 ctx->Multisample.Enabled = state;
262
263 if (ctx->Driver.Enable) {
264 ctx->Driver.Enable(ctx, GL_MULTISAMPLE, state);
265 }
266 }
267
268 /**
269 * Helper function to enable or disable state.
270 *
271 * \param ctx GL context.
272 * \param cap the state to enable/disable
273 * \param state whether to enable or disable the specified capability.
274 *
275 * Updates the current context and flushes the vertices as needed. For
276 * capabilities associated with extensions it verifies that those extensions
277 * are effectivly present before updating. Notifies the driver via
278 * dd_function_table::Enable.
279 */
280 void
281 _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
282 {
283 if (MESA_VERBOSE & VERBOSE_API)
284 _mesa_debug(ctx, "%s %s (newstate is %x)\n",
285 state ? "glEnable" : "glDisable",
286 _mesa_lookup_enum_by_nr(cap),
287 ctx->NewState);
288
289 switch (cap) {
290 case GL_ALPHA_TEST:
291 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
292 goto invalid_enum_error;
293 if (ctx->Color.AlphaEnabled == state)
294 return;
295 FLUSH_VERTICES(ctx, _NEW_COLOR);
296 ctx->Color.AlphaEnabled = state;
297 break;
298 case GL_AUTO_NORMAL:
299 if (ctx->API != API_OPENGL)
300 goto invalid_enum_error;
301 if (ctx->Eval.AutoNormal == state)
302 return;
303 FLUSH_VERTICES(ctx, _NEW_EVAL);
304 ctx->Eval.AutoNormal = state;
305 break;
306 case GL_BLEND:
307 {
308 GLbitfield newEnabled =
309 state * ((1 << ctx->Const.MaxDrawBuffers) - 1);
310 if (newEnabled != ctx->Color.BlendEnabled) {
311 FLUSH_VERTICES(ctx, _NEW_COLOR);
312 ctx->Color.BlendEnabled = newEnabled;
313 }
314 }
315 break;
316 case GL_CLIP_DISTANCE0:
317 case GL_CLIP_DISTANCE1:
318 case GL_CLIP_DISTANCE2:
319 case GL_CLIP_DISTANCE3:
320 case GL_CLIP_DISTANCE4:
321 case GL_CLIP_DISTANCE5:
322 case GL_CLIP_DISTANCE6:
323 case GL_CLIP_DISTANCE7:
324 {
325 const GLuint p = cap - GL_CLIP_DISTANCE0;
326
327 if (p >= ctx->Const.MaxClipPlanes)
328 goto invalid_enum_error;
329
330 if ((ctx->Transform.ClipPlanesEnabled & (1 << p))
331 == ((GLuint) state << p))
332 return;
333
334 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
335
336 if (state) {
337 ctx->Transform.ClipPlanesEnabled |= (1 << p);
338 _mesa_update_clip_plane(ctx, p);
339 }
340 else {
341 ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
342 }
343 }
344 break;
345 case GL_COLOR_MATERIAL:
346 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
347 goto invalid_enum_error;
348 if (ctx->Light.ColorMaterialEnabled == state)
349 return;
350 FLUSH_VERTICES(ctx, _NEW_LIGHT);
351 FLUSH_CURRENT(ctx, 0);
352 ctx->Light.ColorMaterialEnabled = state;
353 if (state) {
354 _mesa_update_color_material( ctx,
355 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
356 }
357 break;
358 case GL_CULL_FACE:
359 if (ctx->Polygon.CullFlag == state)
360 return;
361 FLUSH_VERTICES(ctx, _NEW_POLYGON);
362 ctx->Polygon.CullFlag = state;
363 break;
364 case GL_DEPTH_TEST:
365 if (ctx->Depth.Test == state)
366 return;
367 FLUSH_VERTICES(ctx, _NEW_DEPTH);
368 ctx->Depth.Test = state;
369 break;
370 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB:
371 if (!_mesa_is_desktop_gl(ctx))
372 goto invalid_enum_error;
373 ctx->Debug.SyncOutput = state;
374 break;
375 case GL_DITHER:
376 if (ctx->Color.DitherFlag == state)
377 return;
378 FLUSH_VERTICES(ctx, _NEW_COLOR);
379 ctx->Color.DitherFlag = state;
380 break;
381 case GL_FOG:
382 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
383 goto invalid_enum_error;
384 if (ctx->Fog.Enabled == state)
385 return;
386 FLUSH_VERTICES(ctx, _NEW_FOG);
387 ctx->Fog.Enabled = state;
388 break;
389 case GL_LIGHT0:
390 case GL_LIGHT1:
391 case GL_LIGHT2:
392 case GL_LIGHT3:
393 case GL_LIGHT4:
394 case GL_LIGHT5:
395 case GL_LIGHT6:
396 case GL_LIGHT7:
397 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
398 goto invalid_enum_error;
399 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
400 return;
401 FLUSH_VERTICES(ctx, _NEW_LIGHT);
402 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
403 if (state) {
404 insert_at_tail(&ctx->Light.EnabledList,
405 &ctx->Light.Light[cap-GL_LIGHT0]);
406 }
407 else {
408 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
409 }
410 break;
411 case GL_LIGHTING:
412 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
413 goto invalid_enum_error;
414 if (ctx->Light.Enabled == state)
415 return;
416 FLUSH_VERTICES(ctx, _NEW_LIGHT);
417 ctx->Light.Enabled = state;
418 if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
419 ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
420 else
421 ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
422 break;
423 case GL_LINE_SMOOTH:
424 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
425 goto invalid_enum_error;
426 if (ctx->Line.SmoothFlag == state)
427 return;
428 FLUSH_VERTICES(ctx, _NEW_LINE);
429 ctx->Line.SmoothFlag = state;
430 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
431 break;
432 case GL_LINE_STIPPLE:
433 if (ctx->API != API_OPENGL)
434 goto invalid_enum_error;
435 if (ctx->Line.StippleFlag == state)
436 return;
437 FLUSH_VERTICES(ctx, _NEW_LINE);
438 ctx->Line.StippleFlag = state;
439 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
440 break;
441 case GL_INDEX_LOGIC_OP:
442 if (ctx->API != API_OPENGL)
443 goto invalid_enum_error;
444 if (ctx->Color.IndexLogicOpEnabled == state)
445 return;
446 FLUSH_VERTICES(ctx, _NEW_COLOR);
447 ctx->Color.IndexLogicOpEnabled = state;
448 break;
449 case GL_COLOR_LOGIC_OP:
450 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
451 goto invalid_enum_error;
452 if (ctx->Color.ColorLogicOpEnabled == state)
453 return;
454 FLUSH_VERTICES(ctx, _NEW_COLOR);
455 ctx->Color.ColorLogicOpEnabled = state;
456 break;
457 case GL_MAP1_COLOR_4:
458 if (ctx->API != API_OPENGL)
459 goto invalid_enum_error;
460 if (ctx->Eval.Map1Color4 == state)
461 return;
462 FLUSH_VERTICES(ctx, _NEW_EVAL);
463 ctx->Eval.Map1Color4 = state;
464 break;
465 case GL_MAP1_INDEX:
466 if (ctx->API != API_OPENGL)
467 goto invalid_enum_error;
468 if (ctx->Eval.Map1Index == state)
469 return;
470 FLUSH_VERTICES(ctx, _NEW_EVAL);
471 ctx->Eval.Map1Index = state;
472 break;
473 case GL_MAP1_NORMAL:
474 if (ctx->API != API_OPENGL)
475 goto invalid_enum_error;
476 if (ctx->Eval.Map1Normal == state)
477 return;
478 FLUSH_VERTICES(ctx, _NEW_EVAL);
479 ctx->Eval.Map1Normal = state;
480 break;
481 case GL_MAP1_TEXTURE_COORD_1:
482 if (ctx->API != API_OPENGL)
483 goto invalid_enum_error;
484 if (ctx->Eval.Map1TextureCoord1 == state)
485 return;
486 FLUSH_VERTICES(ctx, _NEW_EVAL);
487 ctx->Eval.Map1TextureCoord1 = state;
488 break;
489 case GL_MAP1_TEXTURE_COORD_2:
490 if (ctx->API != API_OPENGL)
491 goto invalid_enum_error;
492 if (ctx->Eval.Map1TextureCoord2 == state)
493 return;
494 FLUSH_VERTICES(ctx, _NEW_EVAL);
495 ctx->Eval.Map1TextureCoord2 = state;
496 break;
497 case GL_MAP1_TEXTURE_COORD_3:
498 if (ctx->API != API_OPENGL)
499 goto invalid_enum_error;
500 if (ctx->Eval.Map1TextureCoord3 == state)
501 return;
502 FLUSH_VERTICES(ctx, _NEW_EVAL);
503 ctx->Eval.Map1TextureCoord3 = state;
504 break;
505 case GL_MAP1_TEXTURE_COORD_4:
506 if (ctx->API != API_OPENGL)
507 goto invalid_enum_error;
508 if (ctx->Eval.Map1TextureCoord4 == state)
509 return;
510 FLUSH_VERTICES(ctx, _NEW_EVAL);
511 ctx->Eval.Map1TextureCoord4 = state;
512 break;
513 case GL_MAP1_VERTEX_3:
514 if (ctx->API != API_OPENGL)
515 goto invalid_enum_error;
516 if (ctx->Eval.Map1Vertex3 == state)
517 return;
518 FLUSH_VERTICES(ctx, _NEW_EVAL);
519 ctx->Eval.Map1Vertex3 = state;
520 break;
521 case GL_MAP1_VERTEX_4:
522 if (ctx->API != API_OPENGL)
523 goto invalid_enum_error;
524 if (ctx->Eval.Map1Vertex4 == state)
525 return;
526 FLUSH_VERTICES(ctx, _NEW_EVAL);
527 ctx->Eval.Map1Vertex4 = state;
528 break;
529 case GL_MAP2_COLOR_4:
530 if (ctx->API != API_OPENGL)
531 goto invalid_enum_error;
532 if (ctx->Eval.Map2Color4 == state)
533 return;
534 FLUSH_VERTICES(ctx, _NEW_EVAL);
535 ctx->Eval.Map2Color4 = state;
536 break;
537 case GL_MAP2_INDEX:
538 if (ctx->API != API_OPENGL)
539 goto invalid_enum_error;
540 if (ctx->Eval.Map2Index == state)
541 return;
542 FLUSH_VERTICES(ctx, _NEW_EVAL);
543 ctx->Eval.Map2Index = state;
544 break;
545 case GL_MAP2_NORMAL:
546 if (ctx->API != API_OPENGL)
547 goto invalid_enum_error;
548 if (ctx->Eval.Map2Normal == state)
549 return;
550 FLUSH_VERTICES(ctx, _NEW_EVAL);
551 ctx->Eval.Map2Normal = state;
552 break;
553 case GL_MAP2_TEXTURE_COORD_1:
554 if (ctx->API != API_OPENGL)
555 goto invalid_enum_error;
556 if (ctx->Eval.Map2TextureCoord1 == state)
557 return;
558 FLUSH_VERTICES(ctx, _NEW_EVAL);
559 ctx->Eval.Map2TextureCoord1 = state;
560 break;
561 case GL_MAP2_TEXTURE_COORD_2:
562 if (ctx->API != API_OPENGL)
563 goto invalid_enum_error;
564 if (ctx->Eval.Map2TextureCoord2 == state)
565 return;
566 FLUSH_VERTICES(ctx, _NEW_EVAL);
567 ctx->Eval.Map2TextureCoord2 = state;
568 break;
569 case GL_MAP2_TEXTURE_COORD_3:
570 if (ctx->API != API_OPENGL)
571 goto invalid_enum_error;
572 if (ctx->Eval.Map2TextureCoord3 == state)
573 return;
574 FLUSH_VERTICES(ctx, _NEW_EVAL);
575 ctx->Eval.Map2TextureCoord3 = state;
576 break;
577 case GL_MAP2_TEXTURE_COORD_4:
578 if (ctx->API != API_OPENGL)
579 goto invalid_enum_error;
580 if (ctx->Eval.Map2TextureCoord4 == state)
581 return;
582 FLUSH_VERTICES(ctx, _NEW_EVAL);
583 ctx->Eval.Map2TextureCoord4 = state;
584 break;
585 case GL_MAP2_VERTEX_3:
586 if (ctx->API != API_OPENGL)
587 goto invalid_enum_error;
588 if (ctx->Eval.Map2Vertex3 == state)
589 return;
590 FLUSH_VERTICES(ctx, _NEW_EVAL);
591 ctx->Eval.Map2Vertex3 = state;
592 break;
593 case GL_MAP2_VERTEX_4:
594 if (ctx->API != API_OPENGL)
595 goto invalid_enum_error;
596 if (ctx->Eval.Map2Vertex4 == state)
597 return;
598 FLUSH_VERTICES(ctx, _NEW_EVAL);
599 ctx->Eval.Map2Vertex4 = state;
600 break;
601 case GL_NORMALIZE:
602 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
603 goto invalid_enum_error;
604 if (ctx->Transform.Normalize == state)
605 return;
606 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
607 ctx->Transform.Normalize = state;
608 break;
609 case GL_POINT_SMOOTH:
610 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
611 goto invalid_enum_error;
612 if (ctx->Point.SmoothFlag == state)
613 return;
614 FLUSH_VERTICES(ctx, _NEW_POINT);
615 ctx->Point.SmoothFlag = state;
616 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
617 break;
618 case GL_POLYGON_SMOOTH:
619 if (!_mesa_is_desktop_gl(ctx))
620 goto invalid_enum_error;
621 if (ctx->Polygon.SmoothFlag == state)
622 return;
623 FLUSH_VERTICES(ctx, _NEW_POLYGON);
624 ctx->Polygon.SmoothFlag = state;
625 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
626 break;
627 case GL_POLYGON_STIPPLE:
628 if (ctx->API != API_OPENGL)
629 goto invalid_enum_error;
630 if (ctx->Polygon.StippleFlag == state)
631 return;
632 FLUSH_VERTICES(ctx, _NEW_POLYGON);
633 ctx->Polygon.StippleFlag = state;
634 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
635 break;
636 case GL_POLYGON_OFFSET_POINT:
637 if (!_mesa_is_desktop_gl(ctx))
638 goto invalid_enum_error;
639 if (ctx->Polygon.OffsetPoint == state)
640 return;
641 FLUSH_VERTICES(ctx, _NEW_POLYGON);
642 ctx->Polygon.OffsetPoint = state;
643 break;
644 case GL_POLYGON_OFFSET_LINE:
645 if (!_mesa_is_desktop_gl(ctx))
646 goto invalid_enum_error;
647 if (ctx->Polygon.OffsetLine == state)
648 return;
649 FLUSH_VERTICES(ctx, _NEW_POLYGON);
650 ctx->Polygon.OffsetLine = state;
651 break;
652 case GL_POLYGON_OFFSET_FILL:
653 if (ctx->Polygon.OffsetFill == state)
654 return;
655 FLUSH_VERTICES(ctx, _NEW_POLYGON);
656 ctx->Polygon.OffsetFill = state;
657 break;
658 case GL_RESCALE_NORMAL_EXT:
659 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
660 goto invalid_enum_error;
661 if (ctx->Transform.RescaleNormals == state)
662 return;
663 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
664 ctx->Transform.RescaleNormals = state;
665 break;
666 case GL_SCISSOR_TEST:
667 if (ctx->Scissor.Enabled == state)
668 return;
669 FLUSH_VERTICES(ctx, _NEW_SCISSOR);
670 ctx->Scissor.Enabled = state;
671 break;
672 case GL_STENCIL_TEST:
673 if (ctx->Stencil.Enabled == state)
674 return;
675 FLUSH_VERTICES(ctx, _NEW_STENCIL);
676 ctx->Stencil.Enabled = state;
677 break;
678 case GL_TEXTURE_1D:
679 if (ctx->API != API_OPENGL)
680 goto invalid_enum_error;
681 if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) {
682 return;
683 }
684 break;
685 case GL_TEXTURE_2D:
686 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
687 goto invalid_enum_error;
688 if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) {
689 return;
690 }
691 break;
692 case GL_TEXTURE_3D:
693 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
694 goto invalid_enum_error;
695 if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) {
696 return;
697 }
698 break;
699 case GL_TEXTURE_GEN_S:
700 case GL_TEXTURE_GEN_T:
701 case GL_TEXTURE_GEN_R:
702 case GL_TEXTURE_GEN_Q:
703 {
704 struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
705
706 if (ctx->API != API_OPENGL)
707 goto invalid_enum_error;
708
709 if (texUnit) {
710 GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S);
711 GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit;
712 if (state)
713 newenabled |= coordBit;
714 if (texUnit->TexGenEnabled == newenabled)
715 return;
716 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
717 texUnit->TexGenEnabled = newenabled;
718 }
719 }
720 break;
721
722 #if FEATURE_ES1
723 case GL_TEXTURE_GEN_STR_OES:
724 /* disable S, T, and R at the same time */
725 {
726 struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
727
728 if (ctx->API != API_OPENGLES)
729 goto invalid_enum_error;
730
731 if (texUnit) {
732 GLuint newenabled =
733 texUnit->TexGenEnabled & ~STR_BITS;
734 if (state)
735 newenabled |= STR_BITS;
736 if (texUnit->TexGenEnabled == newenabled)
737 return;
738 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
739 texUnit->TexGenEnabled = newenabled;
740 }
741 }
742 break;
743 #endif
744
745 /* client-side state */
746 case GL_VERTEX_ARRAY:
747 case GL_NORMAL_ARRAY:
748 case GL_COLOR_ARRAY:
749 case GL_INDEX_ARRAY:
750 case GL_TEXTURE_COORD_ARRAY:
751 case GL_EDGE_FLAG_ARRAY:
752 case GL_FOG_COORDINATE_ARRAY_EXT:
753 case GL_SECONDARY_COLOR_ARRAY_EXT:
754 case GL_POINT_SIZE_ARRAY_OES:
755 client_state( ctx, cap, state );
756 return;
757
758 /* GL_ARB_texture_cube_map */
759 case GL_TEXTURE_CUBE_MAP_ARB:
760 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
761 goto invalid_enum_error;
762 CHECK_EXTENSION(ARB_texture_cube_map, cap);
763 if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) {
764 return;
765 }
766 break;
767
768 /* GL_EXT_secondary_color */
769 case GL_COLOR_SUM_EXT:
770 if (ctx->API != API_OPENGL)
771 goto invalid_enum_error;
772 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap);
773 if (ctx->Fog.ColorSumEnabled == state)
774 return;
775 FLUSH_VERTICES(ctx, _NEW_FOG);
776 ctx->Fog.ColorSumEnabled = state;
777 break;
778
779 /* GL_ARB_multisample */
780 case GL_MULTISAMPLE_ARB:
781 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
782 goto invalid_enum_error;
783 _mesa_set_multisample(ctx, state);
784 return;
785 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
786 if (ctx->Multisample.SampleAlphaToCoverage == state)
787 return;
788 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
789 ctx->Multisample.SampleAlphaToCoverage = state;
790 break;
791 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
792 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
793 goto invalid_enum_error;
794 if (ctx->Multisample.SampleAlphaToOne == state)
795 return;
796 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
797 ctx->Multisample.SampleAlphaToOne = state;
798 break;
799 case GL_SAMPLE_COVERAGE_ARB:
800 if (ctx->Multisample.SampleCoverage == state)
801 return;
802 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
803 ctx->Multisample.SampleCoverage = state;
804 break;
805 case GL_SAMPLE_COVERAGE_INVERT_ARB:
806 if (!_mesa_is_desktop_gl(ctx))
807 goto invalid_enum_error;
808 if (ctx->Multisample.SampleCoverageInvert == state)
809 return;
810 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
811 ctx->Multisample.SampleCoverageInvert = state;
812 break;
813
814 /* GL_IBM_rasterpos_clip */
815 case GL_RASTER_POSITION_UNCLIPPED_IBM:
816 if (ctx->API != API_OPENGL)
817 goto invalid_enum_error;
818 CHECK_EXTENSION(IBM_rasterpos_clip, cap);
819 if (ctx->Transform.RasterPositionUnclipped == state)
820 return;
821 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
822 ctx->Transform.RasterPositionUnclipped = state;
823 break;
824
825 /* GL_NV_point_sprite */
826 case GL_POINT_SPRITE_NV:
827 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
828 goto invalid_enum_error;
829 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
830 if (ctx->Point.PointSprite == state)
831 return;
832 FLUSH_VERTICES(ctx, _NEW_POINT);
833 ctx->Point.PointSprite = state;
834 break;
835
836 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
837 case GL_VERTEX_PROGRAM_ARB:
838 if (ctx->API != API_OPENGL)
839 goto invalid_enum_error;
840 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
841 if (ctx->VertexProgram.Enabled == state)
842 return;
843 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
844 ctx->VertexProgram.Enabled = state;
845 break;
846 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
847 /* This was added with ARB_vertex_program, but it is also used with
848 * GLSL vertex shaders on desktop.
849 */
850 if (!_mesa_is_desktop_gl(ctx))
851 goto invalid_enum_error;
852 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
853 if (ctx->VertexProgram.PointSizeEnabled == state)
854 return;
855 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
856 ctx->VertexProgram.PointSizeEnabled = state;
857 break;
858 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
859 if (ctx->API != API_OPENGL)
860 goto invalid_enum_error;
861 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
862 if (ctx->VertexProgram.TwoSideEnabled == state)
863 return;
864 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
865 ctx->VertexProgram.TwoSideEnabled = state;
866 break;
867 #endif
868 #if FEATURE_NV_vertex_program
869 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
870 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
871 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
872 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
873 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
874 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
875 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
876 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
877 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
878 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
879 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
880 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
881 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
882 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
883 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
884 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
885 if (ctx->API != API_OPENGL)
886 goto invalid_enum_error;
887 CHECK_EXTENSION(NV_vertex_program, cap);
888 {
889 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
890 FLUSH_VERTICES(ctx, _NEW_EVAL);
891 ctx->Eval.Map1Attrib[map] = state;
892 }
893 break;
894 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
895 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
896 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
897 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
898 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
899 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
900 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
901 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
902 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
903 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
904 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
905 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
906 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
907 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
908 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
909 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
910 if (ctx->API != API_OPENGL)
911 goto invalid_enum_error;
912 CHECK_EXTENSION(NV_vertex_program, cap);
913 {
914 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
915 FLUSH_VERTICES(ctx, _NEW_EVAL);
916 ctx->Eval.Map2Attrib[map] = state;
917 }
918 break;
919 #endif /* FEATURE_NV_vertex_program */
920
921 #if FEATURE_NV_fragment_program
922 case GL_FRAGMENT_PROGRAM_NV:
923 if (ctx->API != API_OPENGL)
924 goto invalid_enum_error;
925 CHECK_EXTENSION(NV_fragment_program, cap);
926 if (ctx->FragmentProgram.Enabled == state)
927 return;
928 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
929 ctx->FragmentProgram.Enabled = state;
930 break;
931 #endif /* FEATURE_NV_fragment_program */
932
933 /* GL_NV_texture_rectangle */
934 case GL_TEXTURE_RECTANGLE_NV:
935 if (ctx->API != API_OPENGL)
936 goto invalid_enum_error;
937 CHECK_EXTENSION(NV_texture_rectangle, cap);
938 if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) {
939 return;
940 }
941 break;
942
943 /* GL_EXT_stencil_two_side */
944 case GL_STENCIL_TEST_TWO_SIDE_EXT:
945 if (ctx->API != API_OPENGL)
946 goto invalid_enum_error;
947 CHECK_EXTENSION(EXT_stencil_two_side, cap);
948 if (ctx->Stencil.TestTwoSide == state)
949 return;
950 FLUSH_VERTICES(ctx, _NEW_STENCIL);
951 ctx->Stencil.TestTwoSide = state;
952 if (state) {
953 ctx->Stencil._BackFace = 2;
954 } else {
955 ctx->Stencil._BackFace = 1;
956 }
957 break;
958
959 #if FEATURE_ARB_fragment_program
960 case GL_FRAGMENT_PROGRAM_ARB:
961 if (ctx->API != API_OPENGL)
962 goto invalid_enum_error;
963 CHECK_EXTENSION(ARB_fragment_program, cap);
964 if (ctx->FragmentProgram.Enabled == state)
965 return;
966 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
967 ctx->FragmentProgram.Enabled = state;
968 break;
969 #endif /* FEATURE_ARB_fragment_program */
970
971 /* GL_EXT_depth_bounds_test */
972 case GL_DEPTH_BOUNDS_TEST_EXT:
973 if (!_mesa_is_desktop_gl(ctx))
974 goto invalid_enum_error;
975 CHECK_EXTENSION(EXT_depth_bounds_test, cap);
976 if (ctx->Depth.BoundsTest == state)
977 return;
978 FLUSH_VERTICES(ctx, _NEW_DEPTH);
979 ctx->Depth.BoundsTest = state;
980 break;
981
982 case GL_DEPTH_CLAMP:
983 if (!_mesa_is_desktop_gl(ctx))
984 goto invalid_enum_error;
985 CHECK_EXTENSION(ARB_depth_clamp, cap);
986 if (ctx->Transform.DepthClamp == state)
987 return;
988 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
989 ctx->Transform.DepthClamp = state;
990 break;
991
992 #if FEATURE_ATI_fragment_shader
993 case GL_FRAGMENT_SHADER_ATI:
994 if (ctx->API != API_OPENGL)
995 goto invalid_enum_error;
996 CHECK_EXTENSION(ATI_fragment_shader, cap);
997 if (ctx->ATIFragmentShader.Enabled == state)
998 return;
999 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
1000 ctx->ATIFragmentShader.Enabled = state;
1001 break;
1002 #endif
1003
1004 /* GL_MESA_texture_array */
1005 case GL_TEXTURE_1D_ARRAY_EXT:
1006 if (ctx->API != API_OPENGL)
1007 goto invalid_enum_error;
1008 CHECK_EXTENSION(MESA_texture_array, cap);
1009 if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) {
1010 return;
1011 }
1012 break;
1013
1014 case GL_TEXTURE_2D_ARRAY_EXT:
1015 if (ctx->API != API_OPENGL)
1016 goto invalid_enum_error;
1017 CHECK_EXTENSION(MESA_texture_array, cap);
1018 if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) {
1019 return;
1020 }
1021 break;
1022
1023 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1024 if (!_mesa_is_desktop_gl(ctx))
1025 goto invalid_enum_error;
1026 CHECK_EXTENSION(ARB_seamless_cube_map, cap);
1027 if (ctx->Texture.CubeMapSeamless != state) {
1028 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
1029 ctx->Texture.CubeMapSeamless = state;
1030 }
1031 break;
1032
1033 #if FEATURE_EXT_transform_feedback
1034 case GL_RASTERIZER_DISCARD:
1035 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1036 goto invalid_enum_error;
1037 CHECK_EXTENSION(EXT_transform_feedback, cap);
1038 if (ctx->RasterDiscard != state) {
1039 FLUSH_VERTICES(ctx, _NEW_RASTERIZER_DISCARD);
1040 ctx->RasterDiscard = state;
1041 }
1042 break;
1043 #endif
1044
1045 /* GL 3.1 primitive restart. Note: this enum is different from
1046 * GL_PRIMITIVE_RESTART_NV (which is client state).
1047 */
1048 case GL_PRIMITIVE_RESTART:
1049 if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) {
1050 goto invalid_enum_error;
1051 }
1052 if (ctx->Array.PrimitiveRestart != state) {
1053 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
1054 ctx->Array.PrimitiveRestart = state;
1055 }
1056 break;
1057
1058 /* GL3.0 - GL_framebuffer_sRGB */
1059 case GL_FRAMEBUFFER_SRGB_EXT:
1060 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1061 goto invalid_enum_error;
1062 CHECK_EXTENSION(EXT_framebuffer_sRGB, cap);
1063 FLUSH_VERTICES(ctx, _NEW_BUFFERS);
1064 ctx->Color.sRGBEnabled = state;
1065 break;
1066
1067 /* GL_OES_EGL_image_external */
1068 case GL_TEXTURE_EXTERNAL_OES:
1069 if (!_mesa_is_gles(ctx))
1070 goto invalid_enum_error;
1071 CHECK_EXTENSION(OES_EGL_image_external, cap);
1072 if (!enable_texture(ctx, state, TEXTURE_EXTERNAL_BIT)) {
1073 return;
1074 }
1075 break;
1076
1077 default:
1078 goto invalid_enum_error;
1079 }
1080
1081 if (ctx->Driver.Enable) {
1082 ctx->Driver.Enable( ctx, cap, state );
1083 }
1084
1085 return;
1086
1087 invalid_enum_error:
1088 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(%s)",
1089 state ? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap));
1090 }
1091
1092
1093 /**
1094 * Enable GL capability. Called by glEnable()
1095 * \param cap state to enable.
1096 */
1097 void GLAPIENTRY
1098 _mesa_Enable( GLenum cap )
1099 {
1100 GET_CURRENT_CONTEXT(ctx);
1101 ASSERT_OUTSIDE_BEGIN_END(ctx);
1102
1103 _mesa_set_enable( ctx, cap, GL_TRUE );
1104 }
1105
1106
1107 /**
1108 * Disable GL capability. Called by glDisable()
1109 * \param cap state to disable.
1110 */
1111 void GLAPIENTRY
1112 _mesa_Disable( GLenum cap )
1113 {
1114 GET_CURRENT_CONTEXT(ctx);
1115 ASSERT_OUTSIDE_BEGIN_END(ctx);
1116
1117 _mesa_set_enable( ctx, cap, GL_FALSE );
1118 }
1119
1120
1121
1122 /**
1123 * Enable/disable an indexed state var.
1124 */
1125 void
1126 _mesa_set_enablei(struct gl_context *ctx, GLenum cap,
1127 GLuint index, GLboolean state)
1128 {
1129 ASSERT(state == 0 || state == 1);
1130 switch (cap) {
1131 case GL_BLEND:
1132 if (!ctx->Extensions.EXT_draw_buffers2) {
1133 goto invalid_enum_error;
1134 }
1135 if (index >= ctx->Const.MaxDrawBuffers) {
1136 _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)",
1137 state ? "glEnableIndexed" : "glDisableIndexed", index);
1138 return;
1139 }
1140 if (((ctx->Color.BlendEnabled >> index) & 1) != state) {
1141 FLUSH_VERTICES(ctx, _NEW_COLOR);
1142 if (state)
1143 ctx->Color.BlendEnabled |= (1 << index);
1144 else
1145 ctx->Color.BlendEnabled &= ~(1 << index);
1146 }
1147 break;
1148 default:
1149 goto invalid_enum_error;
1150 }
1151 return;
1152
1153 invalid_enum_error:
1154 _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)",
1155 state ? "glEnablei" : "glDisablei",
1156 _mesa_lookup_enum_by_nr(cap));
1157 }
1158
1159
1160 void GLAPIENTRY
1161 _mesa_DisableIndexed( GLenum cap, GLuint index )
1162 {
1163 GET_CURRENT_CONTEXT(ctx);
1164 ASSERT_OUTSIDE_BEGIN_END(ctx);
1165 _mesa_set_enablei(ctx, cap, index, GL_FALSE);
1166 }
1167
1168
1169 void GLAPIENTRY
1170 _mesa_EnableIndexed( GLenum cap, GLuint index )
1171 {
1172 GET_CURRENT_CONTEXT(ctx);
1173 ASSERT_OUTSIDE_BEGIN_END(ctx);
1174 _mesa_set_enablei(ctx, cap, index, GL_TRUE);
1175 }
1176
1177
1178 GLboolean GLAPIENTRY
1179 _mesa_IsEnabledIndexed( GLenum cap, GLuint index )
1180 {
1181 GET_CURRENT_CONTEXT(ctx);
1182 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
1183 switch (cap) {
1184 case GL_BLEND:
1185 if (index >= ctx->Const.MaxDrawBuffers) {
1186 _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)",
1187 index);
1188 return GL_FALSE;
1189 }
1190 return (ctx->Color.BlendEnabled >> index) & 1;
1191 default:
1192 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)",
1193 _mesa_lookup_enum_by_nr(cap));
1194 return GL_FALSE;
1195 }
1196 }
1197
1198
1199
1200
1201 #undef CHECK_EXTENSION
1202 #define CHECK_EXTENSION(EXTNAME) \
1203 if (!ctx->Extensions.EXTNAME) { \
1204 goto invalid_enum_error; \
1205 }
1206
1207 #undef CHECK_EXTENSION2
1208 #define CHECK_EXTENSION2(EXT1, EXT2) \
1209 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1210 goto invalid_enum_error; \
1211 }
1212
1213
1214 /**
1215 * Helper function to determine whether a texture target is enabled.
1216 */
1217 static GLboolean
1218 is_texture_enabled(struct gl_context *ctx, GLbitfield bit)
1219 {
1220 const struct gl_texture_unit *const texUnit =
1221 &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1222 return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
1223 }
1224
1225
1226 /**
1227 * Return simple enable/disable state.
1228 *
1229 * \param cap state variable to query.
1230 *
1231 * Returns the state of the specified capability from the current GL context.
1232 * For the capabilities associated with extensions verifies that those
1233 * extensions are effectively present before reporting.
1234 */
1235 GLboolean GLAPIENTRY
1236 _mesa_IsEnabled( GLenum cap )
1237 {
1238 GET_CURRENT_CONTEXT(ctx);
1239 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
1240
1241 switch (cap) {
1242 case GL_ALPHA_TEST:
1243 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1244 goto invalid_enum_error;
1245 return ctx->Color.AlphaEnabled;
1246 case GL_AUTO_NORMAL:
1247 if (ctx->API != API_OPENGL)
1248 goto invalid_enum_error;
1249 return ctx->Eval.AutoNormal;
1250 case GL_BLEND:
1251 return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */
1252 case GL_CLIP_DISTANCE0:
1253 case GL_CLIP_DISTANCE1:
1254 case GL_CLIP_DISTANCE2:
1255 case GL_CLIP_DISTANCE3:
1256 case GL_CLIP_DISTANCE4:
1257 case GL_CLIP_DISTANCE5:
1258 case GL_CLIP_DISTANCE6:
1259 case GL_CLIP_DISTANCE7: {
1260 const GLuint p = cap - GL_CLIP_DISTANCE0;
1261
1262 if (p >= ctx->Const.MaxClipPlanes)
1263 goto invalid_enum_error;
1264
1265 return (ctx->Transform.ClipPlanesEnabled >> p) & 1;
1266 }
1267 case GL_COLOR_MATERIAL:
1268 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1269 goto invalid_enum_error;
1270 return ctx->Light.ColorMaterialEnabled;
1271 case GL_CULL_FACE:
1272 return ctx->Polygon.CullFlag;
1273 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB:
1274 if (!_mesa_is_desktop_gl(ctx))
1275 goto invalid_enum_error;
1276 return ctx->Debug.SyncOutput;
1277 case GL_DEPTH_TEST:
1278 return ctx->Depth.Test;
1279 case GL_DITHER:
1280 return ctx->Color.DitherFlag;
1281 case GL_FOG:
1282 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1283 goto invalid_enum_error;
1284 return ctx->Fog.Enabled;
1285 case GL_LIGHTING:
1286 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1287 goto invalid_enum_error;
1288 return ctx->Light.Enabled;
1289 case GL_LIGHT0:
1290 case GL_LIGHT1:
1291 case GL_LIGHT2:
1292 case GL_LIGHT3:
1293 case GL_LIGHT4:
1294 case GL_LIGHT5:
1295 case GL_LIGHT6:
1296 case GL_LIGHT7:
1297 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1298 goto invalid_enum_error;
1299 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
1300 case GL_LINE_SMOOTH:
1301 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1302 goto invalid_enum_error;
1303 return ctx->Line.SmoothFlag;
1304 case GL_LINE_STIPPLE:
1305 if (ctx->API != API_OPENGL)
1306 goto invalid_enum_error;
1307 return ctx->Line.StippleFlag;
1308 case GL_INDEX_LOGIC_OP:
1309 if (ctx->API != API_OPENGL)
1310 goto invalid_enum_error;
1311 return ctx->Color.IndexLogicOpEnabled;
1312 case GL_COLOR_LOGIC_OP:
1313 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1314 goto invalid_enum_error;
1315 return ctx->Color.ColorLogicOpEnabled;
1316 case GL_MAP1_COLOR_4:
1317 if (ctx->API != API_OPENGL)
1318 goto invalid_enum_error;
1319 return ctx->Eval.Map1Color4;
1320 case GL_MAP1_INDEX:
1321 if (ctx->API != API_OPENGL)
1322 goto invalid_enum_error;
1323 return ctx->Eval.Map1Index;
1324 case GL_MAP1_NORMAL:
1325 if (ctx->API != API_OPENGL)
1326 goto invalid_enum_error;
1327 return ctx->Eval.Map1Normal;
1328 case GL_MAP1_TEXTURE_COORD_1:
1329 if (ctx->API != API_OPENGL)
1330 goto invalid_enum_error;
1331 return ctx->Eval.Map1TextureCoord1;
1332 case GL_MAP1_TEXTURE_COORD_2:
1333 if (ctx->API != API_OPENGL)
1334 goto invalid_enum_error;
1335 return ctx->Eval.Map1TextureCoord2;
1336 case GL_MAP1_TEXTURE_COORD_3:
1337 if (ctx->API != API_OPENGL)
1338 goto invalid_enum_error;
1339 return ctx->Eval.Map1TextureCoord3;
1340 case GL_MAP1_TEXTURE_COORD_4:
1341 if (ctx->API != API_OPENGL)
1342 goto invalid_enum_error;
1343 return ctx->Eval.Map1TextureCoord4;
1344 case GL_MAP1_VERTEX_3:
1345 if (ctx->API != API_OPENGL)
1346 goto invalid_enum_error;
1347 return ctx->Eval.Map1Vertex3;
1348 case GL_MAP1_VERTEX_4:
1349 if (ctx->API != API_OPENGL)
1350 goto invalid_enum_error;
1351 return ctx->Eval.Map1Vertex4;
1352 case GL_MAP2_COLOR_4:
1353 if (ctx->API != API_OPENGL)
1354 goto invalid_enum_error;
1355 return ctx->Eval.Map2Color4;
1356 case GL_MAP2_INDEX:
1357 if (ctx->API != API_OPENGL)
1358 goto invalid_enum_error;
1359 return ctx->Eval.Map2Index;
1360 case GL_MAP2_NORMAL:
1361 if (ctx->API != API_OPENGL)
1362 goto invalid_enum_error;
1363 return ctx->Eval.Map2Normal;
1364 case GL_MAP2_TEXTURE_COORD_1:
1365 if (ctx->API != API_OPENGL)
1366 goto invalid_enum_error;
1367 return ctx->Eval.Map2TextureCoord1;
1368 case GL_MAP2_TEXTURE_COORD_2:
1369 if (ctx->API != API_OPENGL)
1370 goto invalid_enum_error;
1371 return ctx->Eval.Map2TextureCoord2;
1372 case GL_MAP2_TEXTURE_COORD_3:
1373 if (ctx->API != API_OPENGL)
1374 goto invalid_enum_error;
1375 return ctx->Eval.Map2TextureCoord3;
1376 case GL_MAP2_TEXTURE_COORD_4:
1377 if (ctx->API != API_OPENGL)
1378 goto invalid_enum_error;
1379 return ctx->Eval.Map2TextureCoord4;
1380 case GL_MAP2_VERTEX_3:
1381 if (ctx->API != API_OPENGL)
1382 goto invalid_enum_error;
1383 return ctx->Eval.Map2Vertex3;
1384 case GL_MAP2_VERTEX_4:
1385 if (ctx->API != API_OPENGL)
1386 goto invalid_enum_error;
1387 return ctx->Eval.Map2Vertex4;
1388 case GL_NORMALIZE:
1389 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1390 goto invalid_enum_error;
1391 return ctx->Transform.Normalize;
1392 case GL_POINT_SMOOTH:
1393 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1394 goto invalid_enum_error;
1395 return ctx->Point.SmoothFlag;
1396 case GL_POLYGON_SMOOTH:
1397 if (!_mesa_is_desktop_gl(ctx))
1398 goto invalid_enum_error;
1399 return ctx->Polygon.SmoothFlag;
1400 case GL_POLYGON_STIPPLE:
1401 if (ctx->API != API_OPENGL)
1402 goto invalid_enum_error;
1403 return ctx->Polygon.StippleFlag;
1404 case GL_POLYGON_OFFSET_POINT:
1405 if (!_mesa_is_desktop_gl(ctx))
1406 goto invalid_enum_error;
1407 return ctx->Polygon.OffsetPoint;
1408 case GL_POLYGON_OFFSET_LINE:
1409 if (!_mesa_is_desktop_gl(ctx))
1410 goto invalid_enum_error;
1411 return ctx->Polygon.OffsetLine;
1412 case GL_POLYGON_OFFSET_FILL:
1413 return ctx->Polygon.OffsetFill;
1414 case GL_RESCALE_NORMAL_EXT:
1415 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1416 goto invalid_enum_error;
1417 return ctx->Transform.RescaleNormals;
1418 case GL_SCISSOR_TEST:
1419 return ctx->Scissor.Enabled;
1420 case GL_STENCIL_TEST:
1421 return ctx->Stencil.Enabled;
1422 case GL_TEXTURE_1D:
1423 if (ctx->API != API_OPENGL)
1424 goto invalid_enum_error;
1425 return is_texture_enabled(ctx, TEXTURE_1D_BIT);
1426 case GL_TEXTURE_2D:
1427 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1428 goto invalid_enum_error;
1429 return is_texture_enabled(ctx, TEXTURE_2D_BIT);
1430 case GL_TEXTURE_3D:
1431 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1432 goto invalid_enum_error;
1433 return is_texture_enabled(ctx, TEXTURE_3D_BIT);
1434 case GL_TEXTURE_GEN_S:
1435 case GL_TEXTURE_GEN_T:
1436 case GL_TEXTURE_GEN_R:
1437 case GL_TEXTURE_GEN_Q:
1438 {
1439 const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
1440
1441 if (ctx->API != API_OPENGL)
1442 goto invalid_enum_error;
1443
1444 if (texUnit) {
1445 GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S);
1446 return (texUnit->TexGenEnabled & coordBit) ? GL_TRUE : GL_FALSE;
1447 }
1448 }
1449 return GL_FALSE;
1450 #if FEATURE_ES1
1451 case GL_TEXTURE_GEN_STR_OES:
1452 {
1453 const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
1454
1455 if (ctx->API != API_OPENGLES)
1456 goto invalid_enum_error;
1457
1458 if (texUnit) {
1459 return (texUnit->TexGenEnabled & STR_BITS) == STR_BITS
1460 ? GL_TRUE : GL_FALSE;
1461 }
1462 }
1463 #endif
1464
1465 /* client-side state */
1466 case GL_VERTEX_ARRAY:
1467 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1468 goto invalid_enum_error;
1469 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled != 0);
1470 case GL_NORMAL_ARRAY:
1471 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1472 goto invalid_enum_error;
1473 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled != 0);
1474 case GL_COLOR_ARRAY:
1475 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1476 goto invalid_enum_error;
1477 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled != 0);
1478 case GL_INDEX_ARRAY:
1479 if (ctx->API != API_OPENGL)
1480 goto invalid_enum_error;
1481 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled != 0);
1482 case GL_TEXTURE_COORD_ARRAY:
1483 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1484 goto invalid_enum_error;
1485 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]
1486 .Enabled != 0);
1487 case GL_EDGE_FLAG_ARRAY:
1488 if (ctx->API != API_OPENGL)
1489 goto invalid_enum_error;
1490 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled != 0);
1491 case GL_FOG_COORDINATE_ARRAY_EXT:
1492 if (ctx->API != API_OPENGL)
1493 goto invalid_enum_error;
1494 CHECK_EXTENSION(EXT_fog_coord);
1495 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled != 0);
1496 case GL_SECONDARY_COLOR_ARRAY_EXT:
1497 if (ctx->API != API_OPENGL)
1498 goto invalid_enum_error;
1499 CHECK_EXTENSION(EXT_secondary_color);
1500 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled != 0);
1501 #if FEATURE_ES
1502 case GL_POINT_SIZE_ARRAY_OES:
1503 if (ctx->API != API_OPENGLES)
1504 goto invalid_enum_error;
1505 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled != 0);
1506 #endif
1507
1508 /* GL_ARB_texture_cube_map */
1509 case GL_TEXTURE_CUBE_MAP_ARB:
1510 CHECK_EXTENSION(ARB_texture_cube_map);
1511 return is_texture_enabled(ctx, TEXTURE_CUBE_BIT);
1512
1513 /* GL_EXT_secondary_color */
1514 case GL_COLOR_SUM_EXT:
1515 if (ctx->API != API_OPENGL)
1516 goto invalid_enum_error;
1517 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program);
1518 return ctx->Fog.ColorSumEnabled;
1519
1520 /* GL_ARB_multisample */
1521 case GL_MULTISAMPLE_ARB:
1522 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1523 goto invalid_enum_error;
1524 return ctx->Multisample.Enabled;
1525 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
1526 return ctx->Multisample.SampleAlphaToCoverage;
1527 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
1528 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
1529 goto invalid_enum_error;
1530 return ctx->Multisample.SampleAlphaToOne;
1531 case GL_SAMPLE_COVERAGE_ARB:
1532 return ctx->Multisample.SampleCoverage;
1533 case GL_SAMPLE_COVERAGE_INVERT_ARB:
1534 if (!_mesa_is_desktop_gl(ctx))
1535 goto invalid_enum_error;
1536 return ctx->Multisample.SampleCoverageInvert;
1537
1538 /* GL_IBM_rasterpos_clip */
1539 case GL_RASTER_POSITION_UNCLIPPED_IBM:
1540 if (ctx->API != API_OPENGL)
1541 goto invalid_enum_error;
1542 CHECK_EXTENSION(IBM_rasterpos_clip);
1543 return ctx->Transform.RasterPositionUnclipped;
1544
1545 /* GL_NV_point_sprite */
1546 case GL_POINT_SPRITE_NV:
1547 if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES)
1548 goto invalid_enum_error;
1549 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite)
1550 return ctx->Point.PointSprite;
1551
1552 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1553 case GL_VERTEX_PROGRAM_ARB:
1554 if (ctx->API != API_OPENGL)
1555 goto invalid_enum_error;
1556 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
1557 return ctx->VertexProgram.Enabled;
1558 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
1559 /* This was added with ARB_vertex_program, but it is also used with
1560 * GLSL vertex shaders on desktop.
1561 */
1562 if (!_mesa_is_desktop_gl(ctx))
1563 goto invalid_enum_error;
1564 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
1565 return ctx->VertexProgram.PointSizeEnabled;
1566 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
1567 if (ctx->API != API_OPENGL)
1568 goto invalid_enum_error;
1569 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
1570 return ctx->VertexProgram.TwoSideEnabled;
1571 #endif
1572 #if FEATURE_NV_vertex_program
1573 case GL_VERTEX_ATTRIB_ARRAY0_NV:
1574 case GL_VERTEX_ATTRIB_ARRAY1_NV:
1575 case GL_VERTEX_ATTRIB_ARRAY2_NV:
1576 case GL_VERTEX_ATTRIB_ARRAY3_NV:
1577 case GL_VERTEX_ATTRIB_ARRAY4_NV:
1578 case GL_VERTEX_ATTRIB_ARRAY5_NV:
1579 case GL_VERTEX_ATTRIB_ARRAY6_NV:
1580 case GL_VERTEX_ATTRIB_ARRAY7_NV:
1581 case GL_VERTEX_ATTRIB_ARRAY8_NV:
1582 case GL_VERTEX_ATTRIB_ARRAY9_NV:
1583 case GL_VERTEX_ATTRIB_ARRAY10_NV:
1584 case GL_VERTEX_ATTRIB_ARRAY11_NV:
1585 case GL_VERTEX_ATTRIB_ARRAY12_NV:
1586 case GL_VERTEX_ATTRIB_ARRAY13_NV:
1587 case GL_VERTEX_ATTRIB_ARRAY14_NV:
1588 case GL_VERTEX_ATTRIB_ARRAY15_NV:
1589 if (ctx->API != API_OPENGL)
1590 goto invalid_enum_error;
1591 CHECK_EXTENSION(NV_vertex_program);
1592 {
1593 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
1594 ASSERT(VERT_ATTRIB_GENERIC(n) < Elements(ctx->Array.ArrayObj->VertexAttrib));
1595 return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(n)].Enabled != 0);
1596 }
1597 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
1598 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
1599 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
1600 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
1601 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
1602 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
1603 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
1604 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
1605 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
1606 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
1607 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
1608 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
1609 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
1610 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
1611 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
1612 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
1613 if (ctx->API != API_OPENGL)
1614 goto invalid_enum_error;
1615 CHECK_EXTENSION(NV_vertex_program);
1616 {
1617 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
1618 return ctx->Eval.Map1Attrib[map];
1619 }
1620 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
1621 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
1622 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
1623 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
1624 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
1625 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
1626 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
1627 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
1628 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
1629 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
1630 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
1631 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
1632 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
1633 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
1634 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
1635 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
1636 if (ctx->API != API_OPENGL)
1637 goto invalid_enum_error;
1638 CHECK_EXTENSION(NV_vertex_program);
1639 {
1640 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
1641 return ctx->Eval.Map2Attrib[map];
1642 }
1643 #endif /* FEATURE_NV_vertex_program */
1644
1645 #if FEATURE_NV_fragment_program
1646 case GL_FRAGMENT_PROGRAM_NV:
1647 if (ctx->API != API_OPENGL)
1648 goto invalid_enum_error;
1649 CHECK_EXTENSION(NV_fragment_program);
1650 return ctx->FragmentProgram.Enabled;
1651 #endif /* FEATURE_NV_fragment_program */
1652
1653 /* GL_NV_texture_rectangle */
1654 case GL_TEXTURE_RECTANGLE_NV:
1655 if (ctx->API != API_OPENGL)
1656 goto invalid_enum_error;
1657 CHECK_EXTENSION(NV_texture_rectangle);
1658 return is_texture_enabled(ctx, TEXTURE_RECT_BIT);
1659
1660 /* GL_EXT_stencil_two_side */
1661 case GL_STENCIL_TEST_TWO_SIDE_EXT:
1662 if (ctx->API != API_OPENGL)
1663 goto invalid_enum_error;
1664 CHECK_EXTENSION(EXT_stencil_two_side);
1665 return ctx->Stencil.TestTwoSide;
1666
1667 #if FEATURE_ARB_fragment_program
1668 case GL_FRAGMENT_PROGRAM_ARB:
1669 if (ctx->API != API_OPENGL)
1670 goto invalid_enum_error;
1671 return ctx->FragmentProgram.Enabled;
1672 #endif /* FEATURE_ARB_fragment_program */
1673
1674 /* GL_EXT_depth_bounds_test */
1675 case GL_DEPTH_BOUNDS_TEST_EXT:
1676 if (!_mesa_is_desktop_gl(ctx))
1677 goto invalid_enum_error;
1678 CHECK_EXTENSION(EXT_depth_bounds_test);
1679 return ctx->Depth.BoundsTest;
1680
1681 /* GL_ARB_depth_clamp */
1682 case GL_DEPTH_CLAMP:
1683 if (!_mesa_is_desktop_gl(ctx))
1684 goto invalid_enum_error;
1685 CHECK_EXTENSION(ARB_depth_clamp);
1686 return ctx->Transform.DepthClamp;
1687
1688 #if FEATURE_ATI_fragment_shader
1689 case GL_FRAGMENT_SHADER_ATI:
1690 if (ctx->API != API_OPENGL)
1691 goto invalid_enum_error;
1692 CHECK_EXTENSION(ATI_fragment_shader);
1693 return ctx->ATIFragmentShader.Enabled;
1694 #endif /* FEATURE_ATI_fragment_shader */
1695
1696 case GL_TEXTURE_CUBE_MAP_SEAMLESS:
1697 if (!_mesa_is_desktop_gl(ctx))
1698 goto invalid_enum_error;
1699 CHECK_EXTENSION(ARB_seamless_cube_map);
1700 return ctx->Texture.CubeMapSeamless;
1701
1702 #if FEATURE_EXT_transform_feedback
1703 case GL_RASTERIZER_DISCARD:
1704 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1705 goto invalid_enum_error;
1706 CHECK_EXTENSION(EXT_transform_feedback);
1707 return ctx->RasterDiscard;
1708 #endif
1709
1710 /* GL_NV_primitive_restart */
1711 case GL_PRIMITIVE_RESTART_NV:
1712 if (ctx->API != API_OPENGL || !ctx->Extensions.NV_primitive_restart) {
1713 goto invalid_enum_error;
1714 }
1715 return ctx->Array.PrimitiveRestart;
1716
1717 /* GL 3.1 primitive restart */
1718 case GL_PRIMITIVE_RESTART:
1719 if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 31) {
1720 goto invalid_enum_error;
1721 }
1722 return ctx->Array.PrimitiveRestart;
1723
1724 /* GL3.0 - GL_framebuffer_sRGB */
1725 case GL_FRAMEBUFFER_SRGB_EXT:
1726 if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
1727 goto invalid_enum_error;
1728 CHECK_EXTENSION(EXT_framebuffer_sRGB);
1729 return ctx->Color.sRGBEnabled;
1730
1731 /* GL_OES_EGL_image_external */
1732 case GL_TEXTURE_EXTERNAL_OES:
1733 if (!_mesa_is_gles(ctx))
1734 goto invalid_enum_error;
1735 CHECK_EXTENSION(OES_EGL_image_external);
1736 return is_texture_enabled(ctx, TEXTURE_EXTERNAL_BIT);
1737
1738 default:
1739 goto invalid_enum_error;
1740 }
1741
1742 return GL_FALSE;
1743
1744 invalid_enum_error:
1745 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(%s)",
1746 _mesa_lookup_enum_by_nr(cap));
1747 return GL_FALSE;
1748 }