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 case GL_POINT_SIZE_ARRAY_OES
:
96 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
97 flag
= VERT_BIT_POINT_SIZE
;
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
);
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
);
125 #endif /* FEATURE_NV_vertex_program */
127 /* GL_NV_primitive_restart */
128 case GL_PRIMITIVE_RESTART_NV
:
129 if (!ctx
->Extensions
.NV_primitive_restart
) {
130 goto invalid_enum_error
;
132 var
= &ctx
->Array
.PrimitiveRestart
;
137 goto invalid_enum_error
;
143 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
145 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
150 arrayObj
->_Enabled
|= flag
;
152 arrayObj
->_Enabled
&= ~flag
;
154 arrayObj
->NewArrays
|= flag
;
156 if (ctx
->Driver
.Enable
) {
157 ctx
->Driver
.Enable( ctx
, cap
, state
);
163 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
164 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
169 * Enable GL capability.
170 * \param cap state to enable/disable.
172 * Get's the current context, assures that we're outside glBegin()/glEnd() and
173 * calls client_state().
176 _mesa_EnableClientState( GLenum cap
)
178 GET_CURRENT_CONTEXT(ctx
);
179 ASSERT_OUTSIDE_BEGIN_END(ctx
);
180 client_state( ctx
, cap
, GL_TRUE
);
185 * Disable GL capability.
186 * \param cap state to enable/disable.
188 * Get's the current context, assures that we're outside glBegin()/glEnd() and
189 * calls client_state().
192 _mesa_DisableClientState( GLenum cap
)
194 GET_CURRENT_CONTEXT(ctx
);
195 ASSERT_OUTSIDE_BEGIN_END(ctx
);
196 client_state( ctx
, cap
, GL_FALSE
);
200 #undef CHECK_EXTENSION
201 #define CHECK_EXTENSION(EXTNAME, CAP) \
202 if (!ctx->Extensions.EXTNAME) { \
203 goto invalid_enum_error; \
206 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
207 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
208 goto invalid_enum_error; \
212 * Return pointer to current texture unit for setting/getting coordinate
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.
217 static struct gl_texture_unit
*
218 get_texcoord_unit(struct gl_context
*ctx
)
220 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
221 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
225 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
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
236 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
238 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
239 const GLbitfield newenabled
= state
240 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
242 if (texUnit
->Enabled
== newenabled
)
245 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
246 texUnit
->Enabled
= newenabled
;
252 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
253 * whether the API supports it (GLES doesn't).
256 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
258 if (ctx
->Multisample
.Enabled
== state
)
260 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
261 ctx
->Multisample
.Enabled
= state
;
263 if (ctx
->Driver
.Enable
) {
264 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
269 * Helper function to enable or disable state.
271 * \param ctx GL context.
272 * \param cap the state to enable/disable
273 * \param state whether to enable or disable the specified capability.
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.
281 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
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
),
291 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
292 goto invalid_enum_error
;
293 if (ctx
->Color
.AlphaEnabled
== state
)
295 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
296 ctx
->Color
.AlphaEnabled
= state
;
299 if (ctx
->API
!= API_OPENGL
)
300 goto invalid_enum_error
;
301 if (ctx
->Eval
.AutoNormal
== state
)
303 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
304 ctx
->Eval
.AutoNormal
= state
;
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
;
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
:
325 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
327 if (p
>= ctx
->Const
.MaxClipPlanes
)
328 goto invalid_enum_error
;
330 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
331 == ((GLuint
) state
<< p
))
334 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
337 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
338 _mesa_update_clip_plane(ctx
, p
);
341 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
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
)
350 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
351 FLUSH_CURRENT(ctx
, 0);
352 ctx
->Light
.ColorMaterialEnabled
= state
;
354 _mesa_update_color_material( ctx
,
355 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
359 if (ctx
->Polygon
.CullFlag
== state
)
361 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
362 ctx
->Polygon
.CullFlag
= state
;
365 if (ctx
->Depth
.Test
== state
)
367 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
368 ctx
->Depth
.Test
= state
;
370 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
371 if (!_mesa_is_desktop_gl(ctx
))
372 goto invalid_enum_error
;
373 ctx
->Debug
.SyncOutput
= state
;
376 if (ctx
->Color
.DitherFlag
== state
)
378 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
379 ctx
->Color
.DitherFlag
= state
;
382 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
383 goto invalid_enum_error
;
384 if (ctx
->Fog
.Enabled
== state
)
386 FLUSH_VERTICES(ctx
, _NEW_FOG
);
387 ctx
->Fog
.Enabled
= state
;
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
)
401 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
402 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
404 insert_at_tail(&ctx
->Light
.EnabledList
,
405 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
408 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
412 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
413 goto invalid_enum_error
;
414 if (ctx
->Light
.Enabled
== state
)
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
;
421 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
424 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
425 goto invalid_enum_error
;
426 if (ctx
->Line
.SmoothFlag
== state
)
428 FLUSH_VERTICES(ctx
, _NEW_LINE
);
429 ctx
->Line
.SmoothFlag
= state
;
430 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
432 case GL_LINE_STIPPLE
:
433 if (ctx
->API
!= API_OPENGL
)
434 goto invalid_enum_error
;
435 if (ctx
->Line
.StippleFlag
== state
)
437 FLUSH_VERTICES(ctx
, _NEW_LINE
);
438 ctx
->Line
.StippleFlag
= state
;
439 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
441 case GL_INDEX_LOGIC_OP
:
442 if (ctx
->API
!= API_OPENGL
)
443 goto invalid_enum_error
;
444 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
446 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
447 ctx
->Color
.IndexLogicOpEnabled
= state
;
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
)
454 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
455 ctx
->Color
.ColorLogicOpEnabled
= state
;
457 case GL_MAP1_COLOR_4
:
458 if (ctx
->API
!= API_OPENGL
)
459 goto invalid_enum_error
;
460 if (ctx
->Eval
.Map1Color4
== state
)
462 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
463 ctx
->Eval
.Map1Color4
= state
;
466 if (ctx
->API
!= API_OPENGL
)
467 goto invalid_enum_error
;
468 if (ctx
->Eval
.Map1Index
== state
)
470 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
471 ctx
->Eval
.Map1Index
= state
;
474 if (ctx
->API
!= API_OPENGL
)
475 goto invalid_enum_error
;
476 if (ctx
->Eval
.Map1Normal
== state
)
478 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
479 ctx
->Eval
.Map1Normal
= state
;
481 case GL_MAP1_TEXTURE_COORD_1
:
482 if (ctx
->API
!= API_OPENGL
)
483 goto invalid_enum_error
;
484 if (ctx
->Eval
.Map1TextureCoord1
== state
)
486 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
487 ctx
->Eval
.Map1TextureCoord1
= state
;
489 case GL_MAP1_TEXTURE_COORD_2
:
490 if (ctx
->API
!= API_OPENGL
)
491 goto invalid_enum_error
;
492 if (ctx
->Eval
.Map1TextureCoord2
== state
)
494 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
495 ctx
->Eval
.Map1TextureCoord2
= state
;
497 case GL_MAP1_TEXTURE_COORD_3
:
498 if (ctx
->API
!= API_OPENGL
)
499 goto invalid_enum_error
;
500 if (ctx
->Eval
.Map1TextureCoord3
== state
)
502 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
503 ctx
->Eval
.Map1TextureCoord3
= state
;
505 case GL_MAP1_TEXTURE_COORD_4
:
506 if (ctx
->API
!= API_OPENGL
)
507 goto invalid_enum_error
;
508 if (ctx
->Eval
.Map1TextureCoord4
== state
)
510 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
511 ctx
->Eval
.Map1TextureCoord4
= state
;
513 case GL_MAP1_VERTEX_3
:
514 if (ctx
->API
!= API_OPENGL
)
515 goto invalid_enum_error
;
516 if (ctx
->Eval
.Map1Vertex3
== state
)
518 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
519 ctx
->Eval
.Map1Vertex3
= state
;
521 case GL_MAP1_VERTEX_4
:
522 if (ctx
->API
!= API_OPENGL
)
523 goto invalid_enum_error
;
524 if (ctx
->Eval
.Map1Vertex4
== state
)
526 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
527 ctx
->Eval
.Map1Vertex4
= state
;
529 case GL_MAP2_COLOR_4
:
530 if (ctx
->API
!= API_OPENGL
)
531 goto invalid_enum_error
;
532 if (ctx
->Eval
.Map2Color4
== state
)
534 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
535 ctx
->Eval
.Map2Color4
= state
;
538 if (ctx
->API
!= API_OPENGL
)
539 goto invalid_enum_error
;
540 if (ctx
->Eval
.Map2Index
== state
)
542 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
543 ctx
->Eval
.Map2Index
= state
;
546 if (ctx
->API
!= API_OPENGL
)
547 goto invalid_enum_error
;
548 if (ctx
->Eval
.Map2Normal
== state
)
550 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
551 ctx
->Eval
.Map2Normal
= state
;
553 case GL_MAP2_TEXTURE_COORD_1
:
554 if (ctx
->API
!= API_OPENGL
)
555 goto invalid_enum_error
;
556 if (ctx
->Eval
.Map2TextureCoord1
== state
)
558 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
559 ctx
->Eval
.Map2TextureCoord1
= state
;
561 case GL_MAP2_TEXTURE_COORD_2
:
562 if (ctx
->API
!= API_OPENGL
)
563 goto invalid_enum_error
;
564 if (ctx
->Eval
.Map2TextureCoord2
== state
)
566 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
567 ctx
->Eval
.Map2TextureCoord2
= state
;
569 case GL_MAP2_TEXTURE_COORD_3
:
570 if (ctx
->API
!= API_OPENGL
)
571 goto invalid_enum_error
;
572 if (ctx
->Eval
.Map2TextureCoord3
== state
)
574 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
575 ctx
->Eval
.Map2TextureCoord3
= state
;
577 case GL_MAP2_TEXTURE_COORD_4
:
578 if (ctx
->API
!= API_OPENGL
)
579 goto invalid_enum_error
;
580 if (ctx
->Eval
.Map2TextureCoord4
== state
)
582 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
583 ctx
->Eval
.Map2TextureCoord4
= state
;
585 case GL_MAP2_VERTEX_3
:
586 if (ctx
->API
!= API_OPENGL
)
587 goto invalid_enum_error
;
588 if (ctx
->Eval
.Map2Vertex3
== state
)
590 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
591 ctx
->Eval
.Map2Vertex3
= state
;
593 case GL_MAP2_VERTEX_4
:
594 if (ctx
->API
!= API_OPENGL
)
595 goto invalid_enum_error
;
596 if (ctx
->Eval
.Map2Vertex4
== state
)
598 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
599 ctx
->Eval
.Map2Vertex4
= state
;
602 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
603 goto invalid_enum_error
;
604 if (ctx
->Transform
.Normalize
== state
)
606 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
607 ctx
->Transform
.Normalize
= state
;
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
)
614 FLUSH_VERTICES(ctx
, _NEW_POINT
);
615 ctx
->Point
.SmoothFlag
= state
;
616 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
618 case GL_POLYGON_SMOOTH
:
619 if (!_mesa_is_desktop_gl(ctx
))
620 goto invalid_enum_error
;
621 if (ctx
->Polygon
.SmoothFlag
== state
)
623 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
624 ctx
->Polygon
.SmoothFlag
= state
;
625 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
627 case GL_POLYGON_STIPPLE
:
628 if (ctx
->API
!= API_OPENGL
)
629 goto invalid_enum_error
;
630 if (ctx
->Polygon
.StippleFlag
== state
)
632 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
633 ctx
->Polygon
.StippleFlag
= state
;
634 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
636 case GL_POLYGON_OFFSET_POINT
:
637 if (!_mesa_is_desktop_gl(ctx
))
638 goto invalid_enum_error
;
639 if (ctx
->Polygon
.OffsetPoint
== state
)
641 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
642 ctx
->Polygon
.OffsetPoint
= state
;
644 case GL_POLYGON_OFFSET_LINE
:
645 if (!_mesa_is_desktop_gl(ctx
))
646 goto invalid_enum_error
;
647 if (ctx
->Polygon
.OffsetLine
== state
)
649 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
650 ctx
->Polygon
.OffsetLine
= state
;
652 case GL_POLYGON_OFFSET_FILL
:
653 if (ctx
->Polygon
.OffsetFill
== state
)
655 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
656 ctx
->Polygon
.OffsetFill
= state
;
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
)
663 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
664 ctx
->Transform
.RescaleNormals
= state
;
666 case GL_SCISSOR_TEST
:
667 if (ctx
->Scissor
.Enabled
== state
)
669 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
670 ctx
->Scissor
.Enabled
= state
;
672 case GL_STENCIL_TEST
:
673 if (ctx
->Stencil
.Enabled
== state
)
675 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
676 ctx
->Stencil
.Enabled
= state
;
679 if (ctx
->API
!= API_OPENGL
)
680 goto invalid_enum_error
;
681 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
686 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
687 goto invalid_enum_error
;
688 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
693 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
694 goto invalid_enum_error
;
695 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
699 case GL_TEXTURE_GEN_S
:
700 case GL_TEXTURE_GEN_T
:
701 case GL_TEXTURE_GEN_R
:
702 case GL_TEXTURE_GEN_Q
:
704 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
706 if (ctx
->API
!= API_OPENGL
)
707 goto invalid_enum_error
;
710 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
711 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
713 newenabled
|= coordBit
;
714 if (texUnit
->TexGenEnabled
== newenabled
)
716 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
717 texUnit
->TexGenEnabled
= newenabled
;
723 case GL_TEXTURE_GEN_STR_OES
:
724 /* disable S, T, and R at the same time */
726 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
728 if (ctx
->API
!= API_OPENGLES
)
729 goto invalid_enum_error
;
733 texUnit
->TexGenEnabled
& ~STR_BITS
;
735 newenabled
|= STR_BITS
;
736 if (texUnit
->TexGenEnabled
== newenabled
)
738 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
739 texUnit
->TexGenEnabled
= newenabled
;
745 /* client-side state */
746 case GL_VERTEX_ARRAY
:
747 case GL_NORMAL_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
);
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
)) {
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
)
775 FLUSH_VERTICES(ctx
, _NEW_FOG
);
776 ctx
->Fog
.ColorSumEnabled
= state
;
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
);
785 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
786 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
788 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
789 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
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
)
796 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
797 ctx
->Multisample
.SampleAlphaToOne
= state
;
799 case GL_SAMPLE_COVERAGE_ARB
:
800 if (ctx
->Multisample
.SampleCoverage
== state
)
802 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
803 ctx
->Multisample
.SampleCoverage
= state
;
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
)
810 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
811 ctx
->Multisample
.SampleCoverageInvert
= state
;
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
)
821 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
822 ctx
->Transform
.RasterPositionUnclipped
= state
;
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
)
832 FLUSH_VERTICES(ctx
, _NEW_POINT
);
833 ctx
->Point
.PointSprite
= state
;
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
)
843 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
844 ctx
->VertexProgram
.Enabled
= state
;
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.
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
)
855 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
856 ctx
->VertexProgram
.PointSizeEnabled
= state
;
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
)
864 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
865 ctx
->VertexProgram
.TwoSideEnabled
= state
;
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
);
889 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
890 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
891 ctx
->Eval
.Map1Attrib
[map
] = state
;
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
);
914 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
915 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
916 ctx
->Eval
.Map2Attrib
[map
] = state
;
919 #endif /* FEATURE_NV_vertex_program */
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
)
928 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
929 ctx
->FragmentProgram
.Enabled
= state
;
931 #endif /* FEATURE_NV_fragment_program */
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
)) {
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
)
950 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
951 ctx
->Stencil
.TestTwoSide
= state
;
953 ctx
->Stencil
._BackFace
= 2;
955 ctx
->Stencil
._BackFace
= 1;
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
)
966 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
967 ctx
->FragmentProgram
.Enabled
= state
;
969 #endif /* FEATURE_ARB_fragment_program */
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
)
978 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
979 ctx
->Depth
.BoundsTest
= state
;
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
)
988 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
989 ctx
->Transform
.DepthClamp
= state
;
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
)
999 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
1000 ctx
->ATIFragmentShader
.Enabled
= state
;
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
)) {
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
)) {
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
;
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
;
1045 /* GL 3.1 primitive restart. Note: this enum is different from
1046 * GL_PRIMITIVE_RESTART_NV (which is client state).
1048 case GL_PRIMITIVE_RESTART
:
1049 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1050 goto invalid_enum_error
;
1052 if (ctx
->Array
.PrimitiveRestart
!= state
) {
1053 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
1054 ctx
->Array
.PrimitiveRestart
= state
;
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
;
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
)) {
1078 goto invalid_enum_error
;
1081 if (ctx
->Driver
.Enable
) {
1082 ctx
->Driver
.Enable( ctx
, cap
, state
);
1088 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1089 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
1094 * Enable GL capability. Called by glEnable()
1095 * \param cap state to enable.
1098 _mesa_Enable( GLenum cap
)
1100 GET_CURRENT_CONTEXT(ctx
);
1101 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1103 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1108 * Disable GL capability. Called by glDisable()
1109 * \param cap state to disable.
1112 _mesa_Disable( GLenum cap
)
1114 GET_CURRENT_CONTEXT(ctx
);
1115 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1117 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1123 * Enable/disable an indexed state var.
1126 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1127 GLuint index
, GLboolean state
)
1129 ASSERT(state
== 0 || state
== 1);
1132 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1133 goto invalid_enum_error
;
1135 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1136 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1137 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1140 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1141 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1143 ctx
->Color
.BlendEnabled
|= (1 << index
);
1145 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1149 goto invalid_enum_error
;
1154 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1155 state
? "glEnablei" : "glDisablei",
1156 _mesa_lookup_enum_by_nr(cap
));
1161 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1163 GET_CURRENT_CONTEXT(ctx
);
1164 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1165 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1170 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1172 GET_CURRENT_CONTEXT(ctx
);
1173 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1174 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1178 GLboolean GLAPIENTRY
1179 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1181 GET_CURRENT_CONTEXT(ctx
);
1182 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1185 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1186 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1190 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1192 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1193 _mesa_lookup_enum_by_nr(cap
));
1201 #undef CHECK_EXTENSION
1202 #define CHECK_EXTENSION(EXTNAME) \
1203 if (!ctx->Extensions.EXTNAME) { \
1204 goto invalid_enum_error; \
1207 #undef CHECK_EXTENSION2
1208 #define CHECK_EXTENSION2(EXT1, EXT2) \
1209 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1210 goto invalid_enum_error; \
1215 * Helper function to determine whether a texture target is enabled.
1218 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1220 const struct gl_texture_unit
*const texUnit
=
1221 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1222 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1227 * Return simple enable/disable state.
1229 * \param cap state variable to query.
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.
1235 GLboolean GLAPIENTRY
1236 _mesa_IsEnabled( GLenum cap
)
1238 GET_CURRENT_CONTEXT(ctx
);
1239 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
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
;
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
;
1262 if (p
>= ctx
->Const
.MaxClipPlanes
)
1263 goto invalid_enum_error
;
1265 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
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
;
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
;
1278 return ctx
->Depth
.Test
;
1280 return ctx
->Color
.DitherFlag
;
1282 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1283 goto invalid_enum_error
;
1284 return ctx
->Fog
.Enabled
;
1286 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1287 goto invalid_enum_error
;
1288 return ctx
->Light
.Enabled
;
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
;
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
;
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
;
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
;
1423 if (ctx
->API
!= API_OPENGL
)
1424 goto invalid_enum_error
;
1425 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1427 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1428 goto invalid_enum_error
;
1429 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
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
:
1439 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1441 if (ctx
->API
!= API_OPENGL
)
1442 goto invalid_enum_error
;
1445 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1446 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1451 case GL_TEXTURE_GEN_STR_OES
:
1453 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1455 if (ctx
->API
!= API_OPENGLES
)
1456 goto invalid_enum_error
;
1459 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1460 ? GL_TRUE
: GL_FALSE
;
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
)]
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);
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);
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
);
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
;
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
;
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
;
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
;
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.
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
;
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
);
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);
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
);
1617 const GLuint map
= (GLuint
) (cap
- GL_MAP1_VERTEX_ATTRIB0_4_NV
);
1618 return ctx
->Eval
.Map1Attrib
[map
];
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
);
1640 const GLuint map
= (GLuint
) (cap
- GL_MAP2_VERTEX_ATTRIB0_4_NV
);
1641 return ctx
->Eval
.Map2Attrib
[map
];
1643 #endif /* FEATURE_NV_vertex_program */
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 */
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
);
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
;
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 */
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
;
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
;
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 */
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
;
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
;
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
;
1715 return ctx
->Array
.PrimitiveRestart
;
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
;
1722 return ctx
->Array
.PrimitiveRestart
;
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
;
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
);
1739 goto invalid_enum_error
;
1745 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1746 _mesa_lookup_enum_by_nr(cap
));