3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
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:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
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.
35 #include "simple_list.h"
36 #include "mfeatures.h"
39 #include "api_arrayelt.h"
41 #include "drivers/common/meta.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
52 * Helper to enable/disable client-side state.
55 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
57 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
63 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
67 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
68 flag
= VERT_BIT_NORMAL
;
71 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
72 flag
= VERT_BIT_COLOR0
;
75 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
76 flag
= VERT_BIT_COLOR_INDEX
;
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
);
82 case GL_EDGE_FLAG_ARRAY
:
83 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
84 flag
= VERT_BIT_EDGEFLAG
;
86 case GL_FOG_COORDINATE_ARRAY_EXT
:
87 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
90 case GL_SECONDARY_COLOR_ARRAY_EXT
:
91 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
92 flag
= VERT_BIT_COLOR1
;
95 #if FEATURE_point_size_array
96 case GL_POINT_SIZE_ARRAY_OES
:
97 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
98 flag
= VERT_BIT_POINT_SIZE
;
102 #if FEATURE_NV_vertex_program
103 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
104 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
105 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
106 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
107 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
108 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
109 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
110 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
111 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
112 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
113 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
114 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
115 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
116 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
117 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
118 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
119 CHECK_EXTENSION(NV_vertex_program
, cap
);
121 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
122 ASSERT(VERT_ATTRIB_GENERIC(n
) < Elements(arrayObj
->VertexAttrib
));
123 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(n
)].Enabled
;
124 flag
= VERT_BIT_GENERIC(n
);
127 #endif /* FEATURE_NV_vertex_program */
129 /* GL_NV_primitive_restart */
130 case GL_PRIMITIVE_RESTART_NV
:
131 if (!ctx
->Extensions
.NV_primitive_restart
) {
132 goto invalid_enum_error
;
134 var
= &ctx
->Array
.PrimitiveRestart
;
139 goto invalid_enum_error
;
145 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
147 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
152 arrayObj
->_Enabled
|= flag
;
154 arrayObj
->_Enabled
&= ~flag
;
156 arrayObj
->NewArrays
|= flag
;
158 if (ctx
->Driver
.Enable
) {
159 ctx
->Driver
.Enable( ctx
, cap
, state
);
165 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
166 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
171 * Enable GL capability.
172 * \param cap state to enable/disable.
174 * Get's the current context, assures that we're outside glBegin()/glEnd() and
175 * calls client_state().
178 _mesa_EnableClientState( GLenum cap
)
180 GET_CURRENT_CONTEXT(ctx
);
181 ASSERT_OUTSIDE_BEGIN_END(ctx
);
182 client_state( ctx
, cap
, GL_TRUE
);
187 * Disable GL capability.
188 * \param cap state to enable/disable.
190 * Get's the current context, assures that we're outside glBegin()/glEnd() and
191 * calls client_state().
194 _mesa_DisableClientState( GLenum cap
)
196 GET_CURRENT_CONTEXT(ctx
);
197 ASSERT_OUTSIDE_BEGIN_END(ctx
);
198 client_state( ctx
, cap
, GL_FALSE
);
202 #undef CHECK_EXTENSION
203 #define CHECK_EXTENSION(EXTNAME, CAP) \
204 if (!ctx->Extensions.EXTNAME) { \
205 goto invalid_enum_error; \
208 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
209 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
210 goto invalid_enum_error; \
214 * Return pointer to current texture unit for setting/getting coordinate
216 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
217 * texture unit is higher than the number of supported coordinate units.
219 static struct gl_texture_unit
*
220 get_texcoord_unit(struct gl_context
*ctx
)
222 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
223 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
227 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
233 * Helper function to enable or disable a texture target.
234 * \param bit one of the TEXTURE_x_BIT values
235 * \return GL_TRUE if state is changing or GL_FALSE if no change
238 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
240 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
241 const GLbitfield newenabled
= state
242 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
244 if (texUnit
->Enabled
== newenabled
)
247 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
248 texUnit
->Enabled
= newenabled
;
254 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
255 * whether the API supports it (GLES doesn't).
258 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
260 if (ctx
->Multisample
.Enabled
== state
)
262 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
263 ctx
->Multisample
.Enabled
= state
;
265 if (ctx
->Driver
.Enable
) {
266 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
271 * Helper function to enable or disable state.
273 * \param ctx GL context.
274 * \param cap the state to enable/disable
275 * \param state whether to enable or disable the specified capability.
277 * Updates the current context and flushes the vertices as needed. For
278 * capabilities associated with extensions it verifies that those extensions
279 * are effectivly present before updating. Notifies the driver via
280 * dd_function_table::Enable.
283 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
285 if (MESA_VERBOSE
& VERBOSE_API
)
286 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
287 state
? "glEnable" : "glDisable",
288 _mesa_lookup_enum_by_nr(cap
),
293 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
294 goto invalid_enum_error
;
295 if (ctx
->Color
.AlphaEnabled
== state
)
297 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
298 ctx
->Color
.AlphaEnabled
= state
;
301 if (ctx
->API
!= API_OPENGL
)
302 goto invalid_enum_error
;
303 if (ctx
->Eval
.AutoNormal
== state
)
305 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
306 ctx
->Eval
.AutoNormal
= state
;
310 GLbitfield newEnabled
=
311 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
312 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
313 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
314 ctx
->Color
.BlendEnabled
= newEnabled
;
319 case GL_CLIP_DISTANCE0
:
320 case GL_CLIP_DISTANCE1
:
321 case GL_CLIP_DISTANCE2
:
322 case GL_CLIP_DISTANCE3
:
323 case GL_CLIP_DISTANCE4
:
324 case GL_CLIP_DISTANCE5
:
325 case GL_CLIP_DISTANCE6
:
326 case GL_CLIP_DISTANCE7
:
328 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
330 if (p
>= ctx
->Const
.MaxClipPlanes
)
331 goto invalid_enum_error
;
333 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
334 == ((GLuint
) state
<< p
))
337 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
340 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
341 _mesa_update_clip_plane(ctx
, p
);
344 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
349 case GL_COLOR_MATERIAL
:
350 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
351 goto invalid_enum_error
;
352 if (ctx
->Light
.ColorMaterialEnabled
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
355 FLUSH_CURRENT(ctx
, 0);
356 ctx
->Light
.ColorMaterialEnabled
= state
;
358 _mesa_update_color_material( ctx
,
359 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
363 if (ctx
->Polygon
.CullFlag
== state
)
365 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
366 ctx
->Polygon
.CullFlag
= state
;
369 if (ctx
->Depth
.Test
== state
)
371 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
372 ctx
->Depth
.Test
= state
;
374 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
375 if (!_mesa_is_desktop_gl(ctx
))
376 goto invalid_enum_error
;
377 ctx
->Debug
.SyncOutput
= state
;
380 if (ctx
->Color
.DitherFlag
== state
)
382 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
383 ctx
->Color
.DitherFlag
= state
;
386 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
387 goto invalid_enum_error
;
388 if (ctx
->Fog
.Enabled
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_FOG
);
391 ctx
->Fog
.Enabled
= state
;
401 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
402 goto invalid_enum_error
;
403 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
405 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
406 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
408 insert_at_tail(&ctx
->Light
.EnabledList
,
409 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
412 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
416 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
417 goto invalid_enum_error
;
418 if (ctx
->Light
.Enabled
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
421 ctx
->Light
.Enabled
= state
;
422 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
423 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
425 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
428 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
429 goto invalid_enum_error
;
430 if (ctx
->Line
.SmoothFlag
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_LINE
);
433 ctx
->Line
.SmoothFlag
= state
;
434 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
436 case GL_LINE_STIPPLE
:
437 if (ctx
->API
!= API_OPENGL
)
438 goto invalid_enum_error
;
439 if (ctx
->Line
.StippleFlag
== state
)
441 FLUSH_VERTICES(ctx
, _NEW_LINE
);
442 ctx
->Line
.StippleFlag
= state
;
443 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
445 case GL_INDEX_LOGIC_OP
:
446 if (ctx
->API
!= API_OPENGL
)
447 goto invalid_enum_error
;
448 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
451 ctx
->Color
.IndexLogicOpEnabled
= state
;
453 case GL_COLOR_LOGIC_OP
:
454 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
455 goto invalid_enum_error
;
456 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
459 ctx
->Color
.ColorLogicOpEnabled
= state
;
461 case GL_MAP1_COLOR_4
:
462 if (ctx
->API
!= API_OPENGL
)
463 goto invalid_enum_error
;
464 if (ctx
->Eval
.Map1Color4
== state
)
466 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
467 ctx
->Eval
.Map1Color4
= state
;
470 if (ctx
->API
!= API_OPENGL
)
471 goto invalid_enum_error
;
472 if (ctx
->Eval
.Map1Index
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map1Index
= state
;
478 if (ctx
->API
!= API_OPENGL
)
479 goto invalid_enum_error
;
480 if (ctx
->Eval
.Map1Normal
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map1Normal
= state
;
485 case GL_MAP1_TEXTURE_COORD_1
:
486 if (ctx
->API
!= API_OPENGL
)
487 goto invalid_enum_error
;
488 if (ctx
->Eval
.Map1TextureCoord1
== state
)
490 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
491 ctx
->Eval
.Map1TextureCoord1
= state
;
493 case GL_MAP1_TEXTURE_COORD_2
:
494 if (ctx
->API
!= API_OPENGL
)
495 goto invalid_enum_error
;
496 if (ctx
->Eval
.Map1TextureCoord2
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map1TextureCoord2
= state
;
501 case GL_MAP1_TEXTURE_COORD_3
:
502 if (ctx
->API
!= API_OPENGL
)
503 goto invalid_enum_error
;
504 if (ctx
->Eval
.Map1TextureCoord3
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map1TextureCoord3
= state
;
509 case GL_MAP1_TEXTURE_COORD_4
:
510 if (ctx
->API
!= API_OPENGL
)
511 goto invalid_enum_error
;
512 if (ctx
->Eval
.Map1TextureCoord4
== state
)
514 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
515 ctx
->Eval
.Map1TextureCoord4
= state
;
517 case GL_MAP1_VERTEX_3
:
518 if (ctx
->API
!= API_OPENGL
)
519 goto invalid_enum_error
;
520 if (ctx
->Eval
.Map1Vertex3
== state
)
522 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
523 ctx
->Eval
.Map1Vertex3
= state
;
525 case GL_MAP1_VERTEX_4
:
526 if (ctx
->API
!= API_OPENGL
)
527 goto invalid_enum_error
;
528 if (ctx
->Eval
.Map1Vertex4
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
531 ctx
->Eval
.Map1Vertex4
= state
;
533 case GL_MAP2_COLOR_4
:
534 if (ctx
->API
!= API_OPENGL
)
535 goto invalid_enum_error
;
536 if (ctx
->Eval
.Map2Color4
== state
)
538 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
539 ctx
->Eval
.Map2Color4
= state
;
542 if (ctx
->API
!= API_OPENGL
)
543 goto invalid_enum_error
;
544 if (ctx
->Eval
.Map2Index
== state
)
546 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
547 ctx
->Eval
.Map2Index
= state
;
550 if (ctx
->API
!= API_OPENGL
)
551 goto invalid_enum_error
;
552 if (ctx
->Eval
.Map2Normal
== state
)
554 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
555 ctx
->Eval
.Map2Normal
= state
;
557 case GL_MAP2_TEXTURE_COORD_1
:
558 if (ctx
->API
!= API_OPENGL
)
559 goto invalid_enum_error
;
560 if (ctx
->Eval
.Map2TextureCoord1
== state
)
562 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
563 ctx
->Eval
.Map2TextureCoord1
= state
;
565 case GL_MAP2_TEXTURE_COORD_2
:
566 if (ctx
->API
!= API_OPENGL
)
567 goto invalid_enum_error
;
568 if (ctx
->Eval
.Map2TextureCoord2
== state
)
570 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
571 ctx
->Eval
.Map2TextureCoord2
= state
;
573 case GL_MAP2_TEXTURE_COORD_3
:
574 if (ctx
->API
!= API_OPENGL
)
575 goto invalid_enum_error
;
576 if (ctx
->Eval
.Map2TextureCoord3
== state
)
578 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
579 ctx
->Eval
.Map2TextureCoord3
= state
;
581 case GL_MAP2_TEXTURE_COORD_4
:
582 if (ctx
->API
!= API_OPENGL
)
583 goto invalid_enum_error
;
584 if (ctx
->Eval
.Map2TextureCoord4
== state
)
586 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
587 ctx
->Eval
.Map2TextureCoord4
= state
;
589 case GL_MAP2_VERTEX_3
:
590 if (ctx
->API
!= API_OPENGL
)
591 goto invalid_enum_error
;
592 if (ctx
->Eval
.Map2Vertex3
== state
)
594 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
595 ctx
->Eval
.Map2Vertex3
= state
;
597 case GL_MAP2_VERTEX_4
:
598 if (ctx
->API
!= API_OPENGL
)
599 goto invalid_enum_error
;
600 if (ctx
->Eval
.Map2Vertex4
== state
)
602 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
603 ctx
->Eval
.Map2Vertex4
= state
;
606 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
607 goto invalid_enum_error
;
608 if (ctx
->Transform
.Normalize
== state
)
610 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
611 ctx
->Transform
.Normalize
= state
;
613 case GL_POINT_SMOOTH
:
614 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
615 goto invalid_enum_error
;
616 if (ctx
->Point
.SmoothFlag
== state
)
618 FLUSH_VERTICES(ctx
, _NEW_POINT
);
619 ctx
->Point
.SmoothFlag
= state
;
620 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
622 case GL_POLYGON_SMOOTH
:
623 if (!_mesa_is_desktop_gl(ctx
))
624 goto invalid_enum_error
;
625 if (ctx
->Polygon
.SmoothFlag
== state
)
627 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
628 ctx
->Polygon
.SmoothFlag
= state
;
629 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
631 case GL_POLYGON_STIPPLE
:
632 if (ctx
->API
!= API_OPENGL
)
633 goto invalid_enum_error
;
634 if (ctx
->Polygon
.StippleFlag
== state
)
636 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
637 ctx
->Polygon
.StippleFlag
= state
;
638 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
640 case GL_POLYGON_OFFSET_POINT
:
641 if (!_mesa_is_desktop_gl(ctx
))
642 goto invalid_enum_error
;
643 if (ctx
->Polygon
.OffsetPoint
== state
)
645 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
646 ctx
->Polygon
.OffsetPoint
= state
;
648 case GL_POLYGON_OFFSET_LINE
:
649 if (!_mesa_is_desktop_gl(ctx
))
650 goto invalid_enum_error
;
651 if (ctx
->Polygon
.OffsetLine
== state
)
653 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
654 ctx
->Polygon
.OffsetLine
= state
;
656 case GL_POLYGON_OFFSET_FILL
:
657 if (ctx
->Polygon
.OffsetFill
== state
)
659 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
660 ctx
->Polygon
.OffsetFill
= state
;
662 case GL_RESCALE_NORMAL_EXT
:
663 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
664 goto invalid_enum_error
;
665 if (ctx
->Transform
.RescaleNormals
== state
)
667 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
668 ctx
->Transform
.RescaleNormals
= state
;
670 case GL_SCISSOR_TEST
:
671 if (ctx
->Scissor
.Enabled
== state
)
673 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
674 ctx
->Scissor
.Enabled
= state
;
676 case GL_STENCIL_TEST
:
677 if (ctx
->Stencil
.Enabled
== state
)
679 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
680 ctx
->Stencil
.Enabled
= state
;
683 if (ctx
->API
!= API_OPENGL
)
684 goto invalid_enum_error
;
685 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
690 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
691 goto invalid_enum_error
;
692 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
697 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
698 goto invalid_enum_error
;
699 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
703 case GL_TEXTURE_GEN_S
:
704 case GL_TEXTURE_GEN_T
:
705 case GL_TEXTURE_GEN_R
:
706 case GL_TEXTURE_GEN_Q
:
708 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
710 if (ctx
->API
!= API_OPENGL
)
711 goto invalid_enum_error
;
714 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
715 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
717 newenabled
|= coordBit
;
718 if (texUnit
->TexGenEnabled
== newenabled
)
720 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
721 texUnit
->TexGenEnabled
= newenabled
;
727 case GL_TEXTURE_GEN_STR_OES
:
728 /* disable S, T, and R at the same time */
730 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
732 if (ctx
->API
!= API_OPENGLES
)
733 goto invalid_enum_error
;
737 texUnit
->TexGenEnabled
& ~STR_BITS
;
739 newenabled
|= STR_BITS
;
740 if (texUnit
->TexGenEnabled
== newenabled
)
742 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
743 texUnit
->TexGenEnabled
= newenabled
;
749 /* client-side state */
750 case GL_VERTEX_ARRAY
:
751 case GL_NORMAL_ARRAY
:
754 case GL_TEXTURE_COORD_ARRAY
:
755 case GL_EDGE_FLAG_ARRAY
:
756 case GL_FOG_COORDINATE_ARRAY_EXT
:
757 case GL_SECONDARY_COLOR_ARRAY_EXT
:
758 case GL_POINT_SIZE_ARRAY_OES
:
759 client_state( ctx
, cap
, state
);
762 /* GL_ARB_texture_cube_map */
763 case GL_TEXTURE_CUBE_MAP_ARB
:
764 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
765 goto invalid_enum_error
;
766 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
767 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
772 /* GL_EXT_secondary_color */
773 case GL_COLOR_SUM_EXT
:
774 if (ctx
->API
!= API_OPENGL
)
775 goto invalid_enum_error
;
776 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
777 if (ctx
->Fog
.ColorSumEnabled
== state
)
779 FLUSH_VERTICES(ctx
, _NEW_FOG
);
780 ctx
->Fog
.ColorSumEnabled
= state
;
783 /* GL_ARB_multisample */
784 case GL_MULTISAMPLE_ARB
:
785 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
786 goto invalid_enum_error
;
787 _mesa_set_multisample(ctx
, state
);
789 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
790 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
792 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
793 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
795 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
796 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
797 goto invalid_enum_error
;
798 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
800 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
801 ctx
->Multisample
.SampleAlphaToOne
= state
;
803 case GL_SAMPLE_COVERAGE_ARB
:
804 if (ctx
->Multisample
.SampleCoverage
== state
)
806 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
807 ctx
->Multisample
.SampleCoverage
= state
;
809 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
810 if (!_mesa_is_desktop_gl(ctx
))
811 goto invalid_enum_error
;
812 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
814 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
815 ctx
->Multisample
.SampleCoverageInvert
= state
;
818 /* GL_IBM_rasterpos_clip */
819 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
820 if (ctx
->API
!= API_OPENGL
)
821 goto invalid_enum_error
;
822 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
823 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
825 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
826 ctx
->Transform
.RasterPositionUnclipped
= state
;
829 /* GL_NV_point_sprite */
830 case GL_POINT_SPRITE_NV
:
831 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
832 goto invalid_enum_error
;
833 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
834 if (ctx
->Point
.PointSprite
== state
)
836 FLUSH_VERTICES(ctx
, _NEW_POINT
);
837 ctx
->Point
.PointSprite
= state
;
840 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
841 case GL_VERTEX_PROGRAM_ARB
:
842 if (ctx
->API
!= API_OPENGL
)
843 goto invalid_enum_error
;
844 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
845 if (ctx
->VertexProgram
.Enabled
== state
)
847 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
848 ctx
->VertexProgram
.Enabled
= state
;
850 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
851 /* This was added with ARB_vertex_program, but it is also used with
852 * GLSL vertex shaders on desktop.
854 if (!_mesa_is_desktop_gl(ctx
))
855 goto invalid_enum_error
;
856 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
857 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
859 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
860 ctx
->VertexProgram
.PointSizeEnabled
= state
;
862 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
863 if (ctx
->API
!= API_OPENGL
)
864 goto invalid_enum_error
;
865 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
, cap
);
866 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
868 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
869 ctx
->VertexProgram
.TwoSideEnabled
= state
;
872 #if FEATURE_NV_vertex_program
873 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
874 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
875 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
876 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
877 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
878 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
879 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
880 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
881 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
882 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
883 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
884 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
885 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
886 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
887 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
888 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
889 if (ctx
->API
!= API_OPENGL
)
890 goto invalid_enum_error
;
891 CHECK_EXTENSION(NV_vertex_program
, cap
);
893 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
894 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
895 ctx
->Eval
.Map1Attrib
[map
] = state
;
898 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
899 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
900 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
901 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
902 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
903 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
904 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
905 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
906 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
907 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
908 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
909 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
910 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
911 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
912 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
913 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
914 if (ctx
->API
!= API_OPENGL
)
915 goto invalid_enum_error
;
916 CHECK_EXTENSION(NV_vertex_program
, cap
);
918 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
919 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
920 ctx
->Eval
.Map2Attrib
[map
] = state
;
923 #endif /* FEATURE_NV_vertex_program */
925 #if FEATURE_NV_fragment_program
926 case GL_FRAGMENT_PROGRAM_NV
:
927 if (ctx
->API
!= API_OPENGL
)
928 goto invalid_enum_error
;
929 CHECK_EXTENSION(NV_fragment_program
, cap
);
930 if (ctx
->FragmentProgram
.Enabled
== state
)
932 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
933 ctx
->FragmentProgram
.Enabled
= state
;
935 #endif /* FEATURE_NV_fragment_program */
937 /* GL_NV_texture_rectangle */
938 case GL_TEXTURE_RECTANGLE_NV
:
939 if (ctx
->API
!= API_OPENGL
)
940 goto invalid_enum_error
;
941 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
942 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
947 /* GL_EXT_stencil_two_side */
948 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
949 if (ctx
->API
!= API_OPENGL
)
950 goto invalid_enum_error
;
951 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
952 if (ctx
->Stencil
.TestTwoSide
== state
)
954 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
955 ctx
->Stencil
.TestTwoSide
= state
;
957 ctx
->Stencil
._BackFace
= 2;
959 ctx
->Stencil
._BackFace
= 1;
963 #if FEATURE_ARB_fragment_program
964 case GL_FRAGMENT_PROGRAM_ARB
:
965 if (ctx
->API
!= API_OPENGL
)
966 goto invalid_enum_error
;
967 CHECK_EXTENSION(ARB_fragment_program
, cap
);
968 if (ctx
->FragmentProgram
.Enabled
== state
)
970 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
971 ctx
->FragmentProgram
.Enabled
= state
;
973 #endif /* FEATURE_ARB_fragment_program */
975 /* GL_EXT_depth_bounds_test */
976 case GL_DEPTH_BOUNDS_TEST_EXT
:
977 if (!_mesa_is_desktop_gl(ctx
))
978 goto invalid_enum_error
;
979 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
980 if (ctx
->Depth
.BoundsTest
== state
)
982 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
983 ctx
->Depth
.BoundsTest
= state
;
987 if (!_mesa_is_desktop_gl(ctx
))
988 goto invalid_enum_error
;
989 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
990 if (ctx
->Transform
.DepthClamp
== state
)
992 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
993 ctx
->Transform
.DepthClamp
= state
;
996 #if FEATURE_ATI_fragment_shader
997 case GL_FRAGMENT_SHADER_ATI
:
998 if (ctx
->API
!= API_OPENGL
)
999 goto invalid_enum_error
;
1000 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
1001 if (ctx
->ATIFragmentShader
.Enabled
== state
)
1003 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1004 ctx
->ATIFragmentShader
.Enabled
= state
;
1008 /* GL_MESA_texture_array */
1009 case GL_TEXTURE_1D_ARRAY_EXT
:
1010 if (ctx
->API
!= API_OPENGL
)
1011 goto invalid_enum_error
;
1012 CHECK_EXTENSION(MESA_texture_array
, cap
);
1013 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
1018 case GL_TEXTURE_2D_ARRAY_EXT
:
1019 if (ctx
->API
!= API_OPENGL
)
1020 goto invalid_enum_error
;
1021 CHECK_EXTENSION(MESA_texture_array
, cap
);
1022 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
1027 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1028 if (!_mesa_is_desktop_gl(ctx
))
1029 goto invalid_enum_error
;
1030 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
1031 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
1032 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
1033 ctx
->Texture
.CubeMapSeamless
= state
;
1037 #if FEATURE_EXT_transform_feedback
1038 case GL_RASTERIZER_DISCARD
:
1039 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1040 goto invalid_enum_error
;
1041 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
1042 if (ctx
->RasterDiscard
!= state
) {
1043 FLUSH_VERTICES(ctx
, _NEW_RASTERIZER_DISCARD
);
1044 ctx
->RasterDiscard
= state
;
1049 /* GL 3.1 primitive restart. Note: this enum is different from
1050 * GL_PRIMITIVE_RESTART_NV (which is client state).
1052 case GL_PRIMITIVE_RESTART
:
1053 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1054 goto invalid_enum_error
;
1056 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1057 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
1058 ctx
->Array
.PrimitiveRestart
= state
;
1062 /* GL3.0 - GL_framebuffer_sRGB */
1063 case GL_FRAMEBUFFER_SRGB_EXT
:
1064 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1065 goto invalid_enum_error
;
1066 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
1067 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1068 ctx
->Color
.sRGBEnabled
= state
;
1071 /* GL_OES_EGL_image_external */
1072 case GL_TEXTURE_EXTERNAL_OES
:
1073 if (!_mesa_is_gles(ctx
))
1074 goto invalid_enum_error
;
1075 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1076 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1082 goto invalid_enum_error
;
1085 if (ctx
->Driver
.Enable
) {
1086 ctx
->Driver
.Enable( ctx
, cap
, state
);
1092 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1093 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
1098 * Enable GL capability. Called by glEnable()
1099 * \param cap state to enable.
1102 _mesa_Enable( GLenum cap
)
1104 GET_CURRENT_CONTEXT(ctx
);
1105 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1107 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1112 * Disable GL capability. Called by glDisable()
1113 * \param cap state to disable.
1116 _mesa_Disable( GLenum cap
)
1118 GET_CURRENT_CONTEXT(ctx
);
1119 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1121 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1127 * Enable/disable an indexed state var.
1130 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1131 GLuint index
, GLboolean state
)
1133 ASSERT(state
== 0 || state
== 1);
1136 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1137 goto invalid_enum_error
;
1139 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1140 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1141 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1144 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1145 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1147 ctx
->Color
.BlendEnabled
|= (1 << index
);
1149 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1153 goto invalid_enum_error
;
1158 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1159 state
? "glEnablei" : "glDisablei",
1160 _mesa_lookup_enum_by_nr(cap
));
1165 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1167 GET_CURRENT_CONTEXT(ctx
);
1168 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1169 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1174 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1176 GET_CURRENT_CONTEXT(ctx
);
1177 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1178 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1182 GLboolean GLAPIENTRY
1183 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1185 GET_CURRENT_CONTEXT(ctx
);
1186 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1189 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1190 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1194 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1196 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1197 _mesa_lookup_enum_by_nr(cap
));
1205 #undef CHECK_EXTENSION
1206 #define CHECK_EXTENSION(EXTNAME) \
1207 if (!ctx->Extensions.EXTNAME) { \
1208 goto invalid_enum_error; \
1211 #undef CHECK_EXTENSION2
1212 #define CHECK_EXTENSION2(EXT1, EXT2) \
1213 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1214 goto invalid_enum_error; \
1219 * Helper function to determine whether a texture target is enabled.
1222 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1224 const struct gl_texture_unit
*const texUnit
=
1225 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1226 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1231 * Return simple enable/disable state.
1233 * \param cap state variable to query.
1235 * Returns the state of the specified capability from the current GL context.
1236 * For the capabilities associated with extensions verifies that those
1237 * extensions are effectively present before reporting.
1239 GLboolean GLAPIENTRY
1240 _mesa_IsEnabled( GLenum cap
)
1242 GET_CURRENT_CONTEXT(ctx
);
1243 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1247 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1248 goto invalid_enum_error
;
1249 return ctx
->Color
.AlphaEnabled
;
1250 case GL_AUTO_NORMAL
:
1251 if (ctx
->API
!= API_OPENGL
)
1252 goto invalid_enum_error
;
1253 return ctx
->Eval
.AutoNormal
;
1255 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1256 case GL_CLIP_DISTANCE0
:
1257 case GL_CLIP_DISTANCE1
:
1258 case GL_CLIP_DISTANCE2
:
1259 case GL_CLIP_DISTANCE3
:
1260 case GL_CLIP_DISTANCE4
:
1261 case GL_CLIP_DISTANCE5
:
1262 case GL_CLIP_DISTANCE6
:
1263 case GL_CLIP_DISTANCE7
: {
1264 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1266 if (p
>= ctx
->Const
.MaxClipPlanes
)
1267 goto invalid_enum_error
;
1269 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1271 case GL_COLOR_MATERIAL
:
1272 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1273 goto invalid_enum_error
;
1274 return ctx
->Light
.ColorMaterialEnabled
;
1276 return ctx
->Polygon
.CullFlag
;
1277 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1278 if (!_mesa_is_desktop_gl(ctx
))
1279 goto invalid_enum_error
;
1280 return ctx
->Debug
.SyncOutput
;
1282 return ctx
->Depth
.Test
;
1284 return ctx
->Color
.DitherFlag
;
1286 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1287 goto invalid_enum_error
;
1288 return ctx
->Fog
.Enabled
;
1290 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1291 goto invalid_enum_error
;
1292 return ctx
->Light
.Enabled
;
1301 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1302 goto invalid_enum_error
;
1303 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1304 case GL_LINE_SMOOTH
:
1305 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1306 goto invalid_enum_error
;
1307 return ctx
->Line
.SmoothFlag
;
1308 case GL_LINE_STIPPLE
:
1309 if (ctx
->API
!= API_OPENGL
)
1310 goto invalid_enum_error
;
1311 return ctx
->Line
.StippleFlag
;
1312 case GL_INDEX_LOGIC_OP
:
1313 if (ctx
->API
!= API_OPENGL
)
1314 goto invalid_enum_error
;
1315 return ctx
->Color
.IndexLogicOpEnabled
;
1316 case GL_COLOR_LOGIC_OP
:
1317 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1318 goto invalid_enum_error
;
1319 return ctx
->Color
.ColorLogicOpEnabled
;
1320 case GL_MAP1_COLOR_4
:
1321 if (ctx
->API
!= API_OPENGL
)
1322 goto invalid_enum_error
;
1323 return ctx
->Eval
.Map1Color4
;
1325 if (ctx
->API
!= API_OPENGL
)
1326 goto invalid_enum_error
;
1327 return ctx
->Eval
.Map1Index
;
1328 case GL_MAP1_NORMAL
:
1329 if (ctx
->API
!= API_OPENGL
)
1330 goto invalid_enum_error
;
1331 return ctx
->Eval
.Map1Normal
;
1332 case GL_MAP1_TEXTURE_COORD_1
:
1333 if (ctx
->API
!= API_OPENGL
)
1334 goto invalid_enum_error
;
1335 return ctx
->Eval
.Map1TextureCoord1
;
1336 case GL_MAP1_TEXTURE_COORD_2
:
1337 if (ctx
->API
!= API_OPENGL
)
1338 goto invalid_enum_error
;
1339 return ctx
->Eval
.Map1TextureCoord2
;
1340 case GL_MAP1_TEXTURE_COORD_3
:
1341 if (ctx
->API
!= API_OPENGL
)
1342 goto invalid_enum_error
;
1343 return ctx
->Eval
.Map1TextureCoord3
;
1344 case GL_MAP1_TEXTURE_COORD_4
:
1345 if (ctx
->API
!= API_OPENGL
)
1346 goto invalid_enum_error
;
1347 return ctx
->Eval
.Map1TextureCoord4
;
1348 case GL_MAP1_VERTEX_3
:
1349 if (ctx
->API
!= API_OPENGL
)
1350 goto invalid_enum_error
;
1351 return ctx
->Eval
.Map1Vertex3
;
1352 case GL_MAP1_VERTEX_4
:
1353 if (ctx
->API
!= API_OPENGL
)
1354 goto invalid_enum_error
;
1355 return ctx
->Eval
.Map1Vertex4
;
1356 case GL_MAP2_COLOR_4
:
1357 if (ctx
->API
!= API_OPENGL
)
1358 goto invalid_enum_error
;
1359 return ctx
->Eval
.Map2Color4
;
1361 if (ctx
->API
!= API_OPENGL
)
1362 goto invalid_enum_error
;
1363 return ctx
->Eval
.Map2Index
;
1364 case GL_MAP2_NORMAL
:
1365 if (ctx
->API
!= API_OPENGL
)
1366 goto invalid_enum_error
;
1367 return ctx
->Eval
.Map2Normal
;
1368 case GL_MAP2_TEXTURE_COORD_1
:
1369 if (ctx
->API
!= API_OPENGL
)
1370 goto invalid_enum_error
;
1371 return ctx
->Eval
.Map2TextureCoord1
;
1372 case GL_MAP2_TEXTURE_COORD_2
:
1373 if (ctx
->API
!= API_OPENGL
)
1374 goto invalid_enum_error
;
1375 return ctx
->Eval
.Map2TextureCoord2
;
1376 case GL_MAP2_TEXTURE_COORD_3
:
1377 if (ctx
->API
!= API_OPENGL
)
1378 goto invalid_enum_error
;
1379 return ctx
->Eval
.Map2TextureCoord3
;
1380 case GL_MAP2_TEXTURE_COORD_4
:
1381 if (ctx
->API
!= API_OPENGL
)
1382 goto invalid_enum_error
;
1383 return ctx
->Eval
.Map2TextureCoord4
;
1384 case GL_MAP2_VERTEX_3
:
1385 if (ctx
->API
!= API_OPENGL
)
1386 goto invalid_enum_error
;
1387 return ctx
->Eval
.Map2Vertex3
;
1388 case GL_MAP2_VERTEX_4
:
1389 if (ctx
->API
!= API_OPENGL
)
1390 goto invalid_enum_error
;
1391 return ctx
->Eval
.Map2Vertex4
;
1393 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1394 goto invalid_enum_error
;
1395 return ctx
->Transform
.Normalize
;
1396 case GL_POINT_SMOOTH
:
1397 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1398 goto invalid_enum_error
;
1399 return ctx
->Point
.SmoothFlag
;
1400 case GL_POLYGON_SMOOTH
:
1401 if (!_mesa_is_desktop_gl(ctx
))
1402 goto invalid_enum_error
;
1403 return ctx
->Polygon
.SmoothFlag
;
1404 case GL_POLYGON_STIPPLE
:
1405 if (ctx
->API
!= API_OPENGL
)
1406 goto invalid_enum_error
;
1407 return ctx
->Polygon
.StippleFlag
;
1408 case GL_POLYGON_OFFSET_POINT
:
1409 if (!_mesa_is_desktop_gl(ctx
))
1410 goto invalid_enum_error
;
1411 return ctx
->Polygon
.OffsetPoint
;
1412 case GL_POLYGON_OFFSET_LINE
:
1413 if (!_mesa_is_desktop_gl(ctx
))
1414 goto invalid_enum_error
;
1415 return ctx
->Polygon
.OffsetLine
;
1416 case GL_POLYGON_OFFSET_FILL
:
1417 return ctx
->Polygon
.OffsetFill
;
1418 case GL_RESCALE_NORMAL_EXT
:
1419 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1420 goto invalid_enum_error
;
1421 return ctx
->Transform
.RescaleNormals
;
1422 case GL_SCISSOR_TEST
:
1423 return ctx
->Scissor
.Enabled
;
1424 case GL_STENCIL_TEST
:
1425 return ctx
->Stencil
.Enabled
;
1427 if (ctx
->API
!= API_OPENGL
)
1428 goto invalid_enum_error
;
1429 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1431 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1432 goto invalid_enum_error
;
1433 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1435 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1436 goto invalid_enum_error
;
1437 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1438 case GL_TEXTURE_GEN_S
:
1439 case GL_TEXTURE_GEN_T
:
1440 case GL_TEXTURE_GEN_R
:
1441 case GL_TEXTURE_GEN_Q
:
1443 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1445 if (ctx
->API
!= API_OPENGL
)
1446 goto invalid_enum_error
;
1449 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1450 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1455 case GL_TEXTURE_GEN_STR_OES
:
1457 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1459 if (ctx
->API
!= API_OPENGLES
)
1460 goto invalid_enum_error
;
1463 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1464 ? GL_TRUE
: GL_FALSE
;
1469 /* client-side state */
1470 case GL_VERTEX_ARRAY
:
1471 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1472 goto invalid_enum_error
;
1473 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
!= 0);
1474 case GL_NORMAL_ARRAY
:
1475 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1476 goto invalid_enum_error
;
1477 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1478 case GL_COLOR_ARRAY
:
1479 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1480 goto invalid_enum_error
;
1481 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
!= 0);
1482 case GL_INDEX_ARRAY
:
1483 if (ctx
->API
!= API_OPENGL
)
1484 goto invalid_enum_error
;
1485 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1486 case GL_TEXTURE_COORD_ARRAY
:
1487 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1488 goto invalid_enum_error
;
1489 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1491 case GL_EDGE_FLAG_ARRAY
:
1492 if (ctx
->API
!= API_OPENGL
)
1493 goto invalid_enum_error
;
1494 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1495 case GL_FOG_COORDINATE_ARRAY_EXT
:
1496 if (ctx
->API
!= API_OPENGL
)
1497 goto invalid_enum_error
;
1498 CHECK_EXTENSION(EXT_fog_coord
);
1499 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1500 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1501 if (ctx
->API
!= API_OPENGL
)
1502 goto invalid_enum_error
;
1503 CHECK_EXTENSION(EXT_secondary_color
);
1504 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1505 #if FEATURE_point_size_array
1506 case GL_POINT_SIZE_ARRAY_OES
:
1507 if (ctx
->API
!= API_OPENGLES
)
1508 goto invalid_enum_error
;
1509 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1512 /* GL_ARB_texture_cube_map */
1513 case GL_TEXTURE_CUBE_MAP_ARB
:
1514 CHECK_EXTENSION(ARB_texture_cube_map
);
1515 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1517 /* GL_EXT_secondary_color */
1518 case GL_COLOR_SUM_EXT
:
1519 if (ctx
->API
!= API_OPENGL
)
1520 goto invalid_enum_error
;
1521 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1522 return ctx
->Fog
.ColorSumEnabled
;
1524 /* GL_ARB_multisample */
1525 case GL_MULTISAMPLE_ARB
:
1526 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1527 goto invalid_enum_error
;
1528 return ctx
->Multisample
.Enabled
;
1529 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1530 return ctx
->Multisample
.SampleAlphaToCoverage
;
1531 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1532 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1533 goto invalid_enum_error
;
1534 return ctx
->Multisample
.SampleAlphaToOne
;
1535 case GL_SAMPLE_COVERAGE_ARB
:
1536 return ctx
->Multisample
.SampleCoverage
;
1537 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1538 if (!_mesa_is_desktop_gl(ctx
))
1539 goto invalid_enum_error
;
1540 return ctx
->Multisample
.SampleCoverageInvert
;
1542 /* GL_IBM_rasterpos_clip */
1543 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1544 if (ctx
->API
!= API_OPENGL
)
1545 goto invalid_enum_error
;
1546 CHECK_EXTENSION(IBM_rasterpos_clip
);
1547 return ctx
->Transform
.RasterPositionUnclipped
;
1549 /* GL_NV_point_sprite */
1550 case GL_POINT_SPRITE_NV
:
1551 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1552 goto invalid_enum_error
;
1553 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1554 return ctx
->Point
.PointSprite
;
1556 #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
1557 case GL_VERTEX_PROGRAM_ARB
:
1558 if (ctx
->API
!= API_OPENGL
)
1559 goto invalid_enum_error
;
1560 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1561 return ctx
->VertexProgram
.Enabled
;
1562 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1563 /* This was added with ARB_vertex_program, but it is also used with
1564 * GLSL vertex shaders on desktop.
1566 if (!_mesa_is_desktop_gl(ctx
))
1567 goto invalid_enum_error
;
1568 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1569 return ctx
->VertexProgram
.PointSizeEnabled
;
1570 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1571 if (ctx
->API
!= API_OPENGL
)
1572 goto invalid_enum_error
;
1573 CHECK_EXTENSION2(ARB_vertex_program
, NV_vertex_program
);
1574 return ctx
->VertexProgram
.TwoSideEnabled
;
1576 #if FEATURE_NV_vertex_program
1577 case GL_VERTEX_ATTRIB_ARRAY0_NV
:
1578 case GL_VERTEX_ATTRIB_ARRAY1_NV
:
1579 case GL_VERTEX_ATTRIB_ARRAY2_NV
:
1580 case GL_VERTEX_ATTRIB_ARRAY3_NV
:
1581 case GL_VERTEX_ATTRIB_ARRAY4_NV
:
1582 case GL_VERTEX_ATTRIB_ARRAY5_NV
:
1583 case GL_VERTEX_ATTRIB_ARRAY6_NV
:
1584 case GL_VERTEX_ATTRIB_ARRAY7_NV
:
1585 case GL_VERTEX_ATTRIB_ARRAY8_NV
:
1586 case GL_VERTEX_ATTRIB_ARRAY9_NV
:
1587 case GL_VERTEX_ATTRIB_ARRAY10_NV
:
1588 case GL_VERTEX_ATTRIB_ARRAY11_NV
:
1589 case GL_VERTEX_ATTRIB_ARRAY12_NV
:
1590 case GL_VERTEX_ATTRIB_ARRAY13_NV
:
1591 case GL_VERTEX_ATTRIB_ARRAY14_NV
:
1592 case GL_VERTEX_ATTRIB_ARRAY15_NV
:
1593 if (ctx
->API
!= API_OPENGL
)
1594 goto invalid_enum_error
;
1595 CHECK_EXTENSION(NV_vertex_program
);
1597 GLint n
= (GLint
) cap
- GL_VERTEX_ATTRIB_ARRAY0_NV
;
1598 ASSERT(VERT_ATTRIB_GENERIC(n
) < Elements(ctx
->Array
.ArrayObj
->VertexAttrib
));
1599 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(n
)].Enabled
!= 0);
1601 case GL_MAP1_VERTEX_ATTRIB0_4_NV
:
1602 case GL_MAP1_VERTEX_ATTRIB1_4_NV
:
1603 case GL_MAP1_VERTEX_ATTRIB2_4_NV
:
1604 case GL_MAP1_VERTEX_ATTRIB3_4_NV
:
1605 case GL_MAP1_VERTEX_ATTRIB4_4_NV
:
1606 case GL_MAP1_VERTEX_ATTRIB5_4_NV
:
1607 case GL_MAP1_VERTEX_ATTRIB6_4_NV
:
1608 case GL_MAP1_VERTEX_ATTRIB7_4_NV
:
1609 case GL_MAP1_VERTEX_ATTRIB8_4_NV
:
1610 case GL_MAP1_VERTEX_ATTRIB9_4_NV
:
1611 case GL_MAP1_VERTEX_ATTRIB10_4_NV
:
1612 case GL_MAP1_VERTEX_ATTRIB11_4_NV
:
1613 case GL_MAP1_VERTEX_ATTRIB12_4_NV
:
1614 case GL_MAP1_VERTEX_ATTRIB13_4_NV
:
1615 case GL_MAP1_VERTEX_ATTRIB14_4_NV
:
1616 case GL_MAP1_VERTEX_ATTRIB15_4_NV
:
1617 if (ctx
->API
!= API_OPENGL
)
1618 goto invalid_enum_error
;
1619 CHECK_EXTENSION(NV_vertex_program
);
1621 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1622 return ctx
->Eval
.Map1Attrib
[map
];
1624 case GL_MAP2_VERTEX_ATTRIB0_4_NV
:
1625 case GL_MAP2_VERTEX_ATTRIB1_4_NV
:
1626 case GL_MAP2_VERTEX_ATTRIB2_4_NV
:
1627 case GL_MAP2_VERTEX_ATTRIB3_4_NV
:
1628 case GL_MAP2_VERTEX_ATTRIB4_4_NV
:
1629 case GL_MAP2_VERTEX_ATTRIB5_4_NV
:
1630 case GL_MAP2_VERTEX_ATTRIB6_4_NV
:
1631 case GL_MAP2_VERTEX_ATTRIB7_4_NV
:
1632 case GL_MAP2_VERTEX_ATTRIB8_4_NV
:
1633 case GL_MAP2_VERTEX_ATTRIB9_4_NV
:
1634 case GL_MAP2_VERTEX_ATTRIB10_4_NV
:
1635 case GL_MAP2_VERTEX_ATTRIB11_4_NV
:
1636 case GL_MAP2_VERTEX_ATTRIB12_4_NV
:
1637 case GL_MAP2_VERTEX_ATTRIB13_4_NV
:
1638 case GL_MAP2_VERTEX_ATTRIB14_4_NV
:
1639 case GL_MAP2_VERTEX_ATTRIB15_4_NV
:
1640 if (ctx
->API
!= API_OPENGL
)
1641 goto invalid_enum_error
;
1642 CHECK_EXTENSION(NV_vertex_program
);
1644 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1645 return ctx
->Eval
.Map2Attrib
[map
];
1647 #endif /* FEATURE_NV_vertex_program */
1649 #if FEATURE_NV_fragment_program
1650 case GL_FRAGMENT_PROGRAM_NV
:
1651 if (ctx
->API
!= API_OPENGL
)
1652 goto invalid_enum_error
;
1653 CHECK_EXTENSION(NV_fragment_program
);
1654 return ctx
->FragmentProgram
.Enabled
;
1655 #endif /* FEATURE_NV_fragment_program */
1657 /* GL_NV_texture_rectangle */
1658 case GL_TEXTURE_RECTANGLE_NV
:
1659 if (ctx
->API
!= API_OPENGL
)
1660 goto invalid_enum_error
;
1661 CHECK_EXTENSION(NV_texture_rectangle
);
1662 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1664 /* GL_EXT_stencil_two_side */
1665 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1666 if (ctx
->API
!= API_OPENGL
)
1667 goto invalid_enum_error
;
1668 CHECK_EXTENSION(EXT_stencil_two_side
);
1669 return ctx
->Stencil
.TestTwoSide
;
1671 #if FEATURE_ARB_fragment_program
1672 case GL_FRAGMENT_PROGRAM_ARB
:
1673 if (ctx
->API
!= API_OPENGL
)
1674 goto invalid_enum_error
;
1675 return ctx
->FragmentProgram
.Enabled
;
1676 #endif /* FEATURE_ARB_fragment_program */
1678 /* GL_EXT_depth_bounds_test */
1679 case GL_DEPTH_BOUNDS_TEST_EXT
:
1680 if (!_mesa_is_desktop_gl(ctx
))
1681 goto invalid_enum_error
;
1682 CHECK_EXTENSION(EXT_depth_bounds_test
);
1683 return ctx
->Depth
.BoundsTest
;
1685 /* GL_ARB_depth_clamp */
1686 case GL_DEPTH_CLAMP
:
1687 if (!_mesa_is_desktop_gl(ctx
))
1688 goto invalid_enum_error
;
1689 CHECK_EXTENSION(ARB_depth_clamp
);
1690 return ctx
->Transform
.DepthClamp
;
1692 #if FEATURE_ATI_fragment_shader
1693 case GL_FRAGMENT_SHADER_ATI
:
1694 if (ctx
->API
!= API_OPENGL
)
1695 goto invalid_enum_error
;
1696 CHECK_EXTENSION(ATI_fragment_shader
);
1697 return ctx
->ATIFragmentShader
.Enabled
;
1698 #endif /* FEATURE_ATI_fragment_shader */
1700 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1701 if (!_mesa_is_desktop_gl(ctx
))
1702 goto invalid_enum_error
;
1703 CHECK_EXTENSION(ARB_seamless_cube_map
);
1704 return ctx
->Texture
.CubeMapSeamless
;
1706 #if FEATURE_EXT_transform_feedback
1707 case GL_RASTERIZER_DISCARD
:
1708 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1709 goto invalid_enum_error
;
1710 CHECK_EXTENSION(EXT_transform_feedback
);
1711 return ctx
->RasterDiscard
;
1714 /* GL_NV_primitive_restart */
1715 case GL_PRIMITIVE_RESTART_NV
:
1716 if (ctx
->API
!= API_OPENGL
|| !ctx
->Extensions
.NV_primitive_restart
) {
1717 goto invalid_enum_error
;
1719 return ctx
->Array
.PrimitiveRestart
;
1721 /* GL 3.1 primitive restart */
1722 case GL_PRIMITIVE_RESTART
:
1723 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1724 goto invalid_enum_error
;
1726 return ctx
->Array
.PrimitiveRestart
;
1728 /* GL3.0 - GL_framebuffer_sRGB */
1729 case GL_FRAMEBUFFER_SRGB_EXT
:
1730 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1731 goto invalid_enum_error
;
1732 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1733 return ctx
->Color
.sRGBEnabled
;
1735 /* GL_OES_EGL_image_external */
1736 case GL_TEXTURE_EXTERNAL_OES
:
1737 if (!_mesa_is_gles(ctx
))
1738 goto invalid_enum_error
;
1739 CHECK_EXTENSION(OES_EGL_image_external
);
1740 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1743 goto invalid_enum_error
;
1749 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1750 _mesa_lookup_enum_by_nr(cap
));