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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
36 #include "simple_list.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 update_derived_primitive_restart_state(struct gl_context
*ctx
)
54 /* Update derived primitive restart state.
56 if (ctx
->Array
.PrimitiveRestart
)
57 ctx
->Array
._RestartIndex
= ctx
->Array
.RestartIndex
;
59 ctx
->Array
._RestartIndex
= ~0;
61 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
62 || ctx
->Array
.PrimitiveRestartFixedIndex
;
66 * Helper to enable/disable client-side state.
69 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
71 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
77 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
81 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
82 flag
= VERT_BIT_NORMAL
;
85 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
86 flag
= VERT_BIT_COLOR0
;
89 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
90 flag
= VERT_BIT_COLOR_INDEX
;
92 case GL_TEXTURE_COORD_ARRAY
:
93 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
94 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
96 case GL_EDGE_FLAG_ARRAY
:
97 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
98 flag
= VERT_BIT_EDGEFLAG
;
100 case GL_FOG_COORDINATE_ARRAY_EXT
:
101 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
104 case GL_SECONDARY_COLOR_ARRAY_EXT
:
105 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
106 flag
= VERT_BIT_COLOR1
;
109 case GL_POINT_SIZE_ARRAY_OES
:
110 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
111 flag
= VERT_BIT_POINT_SIZE
;
114 /* GL_NV_primitive_restart */
115 case GL_PRIMITIVE_RESTART_NV
:
116 if (!ctx
->Extensions
.NV_primitive_restart
) {
117 goto invalid_enum_error
;
119 var
= &ctx
->Array
.PrimitiveRestart
;
124 goto invalid_enum_error
;
130 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
132 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
136 update_derived_primitive_restart_state(ctx
);
139 arrayObj
->_Enabled
|= flag
;
141 arrayObj
->_Enabled
&= ~flag
;
143 if (ctx
->Driver
.Enable
) {
144 ctx
->Driver
.Enable( ctx
, cap
, state
);
150 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
151 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
156 * Enable GL capability.
157 * \param cap state to enable/disable.
159 * Get's the current context, assures that we're outside glBegin()/glEnd() and
160 * calls client_state().
163 _mesa_EnableClientState( GLenum cap
)
165 GET_CURRENT_CONTEXT(ctx
);
166 client_state( ctx
, cap
, GL_TRUE
);
171 * Disable 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_DisableClientState( GLenum cap
)
180 GET_CURRENT_CONTEXT(ctx
);
181 client_state( ctx
, cap
, GL_FALSE
);
185 #undef CHECK_EXTENSION
186 #define CHECK_EXTENSION(EXTNAME, CAP) \
187 if (!ctx->Extensions.EXTNAME) { \
188 goto invalid_enum_error; \
191 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
192 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
193 goto invalid_enum_error; \
197 * Return pointer to current texture unit for setting/getting coordinate
199 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
200 * texture unit is higher than the number of supported coordinate units.
202 static struct gl_texture_unit
*
203 get_texcoord_unit(struct gl_context
*ctx
)
205 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
206 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
210 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
216 * Helper function to enable or disable a texture target.
217 * \param bit one of the TEXTURE_x_BIT values
218 * \return GL_TRUE if state is changing or GL_FALSE if no change
221 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
223 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
224 const GLbitfield newenabled
= state
225 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
227 if (texUnit
->Enabled
== newenabled
)
230 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
231 texUnit
->Enabled
= newenabled
;
237 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
238 * whether the API supports it (GLES doesn't).
241 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
243 if (ctx
->Multisample
.Enabled
== state
)
245 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
246 ctx
->Multisample
.Enabled
= state
;
248 if (ctx
->Driver
.Enable
) {
249 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
254 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
255 * check for whether the API supports it (GLES doesn't).
258 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
260 if (ctx
->Color
.sRGBEnabled
== state
)
262 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
263 ctx
->Color
.sRGBEnabled
= state
;
265 if (ctx
->Driver
.Enable
) {
266 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, 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_COMPAT
&& 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_COMPAT
)
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
;
318 case GL_CLIP_DISTANCE0
:
319 case GL_CLIP_DISTANCE1
:
320 case GL_CLIP_DISTANCE2
:
321 case GL_CLIP_DISTANCE3
:
322 case GL_CLIP_DISTANCE4
:
323 case GL_CLIP_DISTANCE5
:
324 case GL_CLIP_DISTANCE6
:
325 case GL_CLIP_DISTANCE7
:
327 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
329 if (p
>= ctx
->Const
.MaxClipPlanes
)
330 goto invalid_enum_error
;
332 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
333 == ((GLuint
) state
<< p
))
336 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
339 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
340 _mesa_update_clip_plane(ctx
, p
);
343 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
347 case GL_COLOR_MATERIAL
:
348 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
349 goto invalid_enum_error
;
350 if (ctx
->Light
.ColorMaterialEnabled
== state
)
352 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
353 FLUSH_CURRENT(ctx
, 0);
354 ctx
->Light
.ColorMaterialEnabled
= state
;
356 _mesa_update_color_material( ctx
,
357 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
361 if (ctx
->Polygon
.CullFlag
== state
)
363 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
364 ctx
->Polygon
.CullFlag
= state
;
367 if (ctx
->Depth
.Test
== state
)
369 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
370 ctx
->Depth
.Test
= state
;
372 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
373 if (!_mesa_is_desktop_gl(ctx
))
374 goto invalid_enum_error
;
375 ctx
->Debug
.SyncOutput
= state
;
378 if (ctx
->Color
.DitherFlag
== state
)
380 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
381 ctx
->Color
.DitherFlag
= state
;
384 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
385 goto invalid_enum_error
;
386 if (ctx
->Fog
.Enabled
== state
)
388 FLUSH_VERTICES(ctx
, _NEW_FOG
);
389 ctx
->Fog
.Enabled
= state
;
399 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
400 goto invalid_enum_error
;
401 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
403 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
404 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
406 insert_at_tail(&ctx
->Light
.EnabledList
,
407 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
410 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
414 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
415 goto invalid_enum_error
;
416 if (ctx
->Light
.Enabled
== state
)
418 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
419 ctx
->Light
.Enabled
= state
;
422 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
423 goto invalid_enum_error
;
424 if (ctx
->Line
.SmoothFlag
== state
)
426 FLUSH_VERTICES(ctx
, _NEW_LINE
);
427 ctx
->Line
.SmoothFlag
= state
;
429 case GL_LINE_STIPPLE
:
430 if (ctx
->API
!= API_OPENGL_COMPAT
)
431 goto invalid_enum_error
;
432 if (ctx
->Line
.StippleFlag
== state
)
434 FLUSH_VERTICES(ctx
, _NEW_LINE
);
435 ctx
->Line
.StippleFlag
= state
;
437 case GL_INDEX_LOGIC_OP
:
438 if (ctx
->API
!= API_OPENGL_COMPAT
)
439 goto invalid_enum_error
;
440 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
442 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
443 ctx
->Color
.IndexLogicOpEnabled
= state
;
445 case GL_COLOR_LOGIC_OP
:
446 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
447 goto invalid_enum_error
;
448 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
451 ctx
->Color
.ColorLogicOpEnabled
= state
;
453 case GL_MAP1_COLOR_4
:
454 if (ctx
->API
!= API_OPENGL_COMPAT
)
455 goto invalid_enum_error
;
456 if (ctx
->Eval
.Map1Color4
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
459 ctx
->Eval
.Map1Color4
= state
;
462 if (ctx
->API
!= API_OPENGL_COMPAT
)
463 goto invalid_enum_error
;
464 if (ctx
->Eval
.Map1Index
== state
)
466 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
467 ctx
->Eval
.Map1Index
= state
;
470 if (ctx
->API
!= API_OPENGL_COMPAT
)
471 goto invalid_enum_error
;
472 if (ctx
->Eval
.Map1Normal
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map1Normal
= state
;
477 case GL_MAP1_TEXTURE_COORD_1
:
478 if (ctx
->API
!= API_OPENGL_COMPAT
)
479 goto invalid_enum_error
;
480 if (ctx
->Eval
.Map1TextureCoord1
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map1TextureCoord1
= state
;
485 case GL_MAP1_TEXTURE_COORD_2
:
486 if (ctx
->API
!= API_OPENGL_COMPAT
)
487 goto invalid_enum_error
;
488 if (ctx
->Eval
.Map1TextureCoord2
== state
)
490 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
491 ctx
->Eval
.Map1TextureCoord2
= state
;
493 case GL_MAP1_TEXTURE_COORD_3
:
494 if (ctx
->API
!= API_OPENGL_COMPAT
)
495 goto invalid_enum_error
;
496 if (ctx
->Eval
.Map1TextureCoord3
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map1TextureCoord3
= state
;
501 case GL_MAP1_TEXTURE_COORD_4
:
502 if (ctx
->API
!= API_OPENGL_COMPAT
)
503 goto invalid_enum_error
;
504 if (ctx
->Eval
.Map1TextureCoord4
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map1TextureCoord4
= state
;
509 case GL_MAP1_VERTEX_3
:
510 if (ctx
->API
!= API_OPENGL_COMPAT
)
511 goto invalid_enum_error
;
512 if (ctx
->Eval
.Map1Vertex3
== state
)
514 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
515 ctx
->Eval
.Map1Vertex3
= state
;
517 case GL_MAP1_VERTEX_4
:
518 if (ctx
->API
!= API_OPENGL_COMPAT
)
519 goto invalid_enum_error
;
520 if (ctx
->Eval
.Map1Vertex4
== state
)
522 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
523 ctx
->Eval
.Map1Vertex4
= state
;
525 case GL_MAP2_COLOR_4
:
526 if (ctx
->API
!= API_OPENGL_COMPAT
)
527 goto invalid_enum_error
;
528 if (ctx
->Eval
.Map2Color4
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
531 ctx
->Eval
.Map2Color4
= state
;
534 if (ctx
->API
!= API_OPENGL_COMPAT
)
535 goto invalid_enum_error
;
536 if (ctx
->Eval
.Map2Index
== state
)
538 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
539 ctx
->Eval
.Map2Index
= state
;
542 if (ctx
->API
!= API_OPENGL_COMPAT
)
543 goto invalid_enum_error
;
544 if (ctx
->Eval
.Map2Normal
== state
)
546 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
547 ctx
->Eval
.Map2Normal
= state
;
549 case GL_MAP2_TEXTURE_COORD_1
:
550 if (ctx
->API
!= API_OPENGL_COMPAT
)
551 goto invalid_enum_error
;
552 if (ctx
->Eval
.Map2TextureCoord1
== state
)
554 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
555 ctx
->Eval
.Map2TextureCoord1
= state
;
557 case GL_MAP2_TEXTURE_COORD_2
:
558 if (ctx
->API
!= API_OPENGL_COMPAT
)
559 goto invalid_enum_error
;
560 if (ctx
->Eval
.Map2TextureCoord2
== state
)
562 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
563 ctx
->Eval
.Map2TextureCoord2
= state
;
565 case GL_MAP2_TEXTURE_COORD_3
:
566 if (ctx
->API
!= API_OPENGL_COMPAT
)
567 goto invalid_enum_error
;
568 if (ctx
->Eval
.Map2TextureCoord3
== state
)
570 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
571 ctx
->Eval
.Map2TextureCoord3
= state
;
573 case GL_MAP2_TEXTURE_COORD_4
:
574 if (ctx
->API
!= API_OPENGL_COMPAT
)
575 goto invalid_enum_error
;
576 if (ctx
->Eval
.Map2TextureCoord4
== state
)
578 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
579 ctx
->Eval
.Map2TextureCoord4
= state
;
581 case GL_MAP2_VERTEX_3
:
582 if (ctx
->API
!= API_OPENGL_COMPAT
)
583 goto invalid_enum_error
;
584 if (ctx
->Eval
.Map2Vertex3
== state
)
586 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
587 ctx
->Eval
.Map2Vertex3
= state
;
589 case GL_MAP2_VERTEX_4
:
590 if (ctx
->API
!= API_OPENGL_COMPAT
)
591 goto invalid_enum_error
;
592 if (ctx
->Eval
.Map2Vertex4
== state
)
594 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
595 ctx
->Eval
.Map2Vertex4
= state
;
598 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
599 goto invalid_enum_error
;
600 if (ctx
->Transform
.Normalize
== state
)
602 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
603 ctx
->Transform
.Normalize
= state
;
605 case GL_POINT_SMOOTH
:
606 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
607 goto invalid_enum_error
;
608 if (ctx
->Point
.SmoothFlag
== state
)
610 FLUSH_VERTICES(ctx
, _NEW_POINT
);
611 ctx
->Point
.SmoothFlag
= state
;
613 case GL_POLYGON_SMOOTH
:
614 if (!_mesa_is_desktop_gl(ctx
))
615 goto invalid_enum_error
;
616 if (ctx
->Polygon
.SmoothFlag
== state
)
618 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
619 ctx
->Polygon
.SmoothFlag
= state
;
621 case GL_POLYGON_STIPPLE
:
622 if (ctx
->API
!= API_OPENGL_COMPAT
)
623 goto invalid_enum_error
;
624 if (ctx
->Polygon
.StippleFlag
== state
)
626 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
627 ctx
->Polygon
.StippleFlag
= state
;
629 case GL_POLYGON_OFFSET_POINT
:
630 if (!_mesa_is_desktop_gl(ctx
))
631 goto invalid_enum_error
;
632 if (ctx
->Polygon
.OffsetPoint
== state
)
634 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
635 ctx
->Polygon
.OffsetPoint
= state
;
637 case GL_POLYGON_OFFSET_LINE
:
638 if (!_mesa_is_desktop_gl(ctx
))
639 goto invalid_enum_error
;
640 if (ctx
->Polygon
.OffsetLine
== state
)
642 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
643 ctx
->Polygon
.OffsetLine
= state
;
645 case GL_POLYGON_OFFSET_FILL
:
646 if (ctx
->Polygon
.OffsetFill
== state
)
648 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
649 ctx
->Polygon
.OffsetFill
= state
;
651 case GL_RESCALE_NORMAL_EXT
:
652 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
653 goto invalid_enum_error
;
654 if (ctx
->Transform
.RescaleNormals
== state
)
656 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
657 ctx
->Transform
.RescaleNormals
= state
;
659 case GL_SCISSOR_TEST
:
660 if (ctx
->Scissor
.Enabled
== state
)
662 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
663 ctx
->Scissor
.Enabled
= state
;
665 case GL_STENCIL_TEST
:
666 if (ctx
->Stencil
.Enabled
== state
)
668 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
669 ctx
->Stencil
.Enabled
= state
;
672 if (ctx
->API
!= API_OPENGL_COMPAT
)
673 goto invalid_enum_error
;
674 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
679 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
680 goto invalid_enum_error
;
681 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
686 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
687 goto invalid_enum_error
;
688 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
692 case GL_TEXTURE_GEN_S
:
693 case GL_TEXTURE_GEN_T
:
694 case GL_TEXTURE_GEN_R
:
695 case GL_TEXTURE_GEN_Q
:
697 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
699 if (ctx
->API
!= API_OPENGL_COMPAT
)
700 goto invalid_enum_error
;
703 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
704 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
706 newenabled
|= coordBit
;
707 if (texUnit
->TexGenEnabled
== newenabled
)
709 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
710 texUnit
->TexGenEnabled
= newenabled
;
715 case GL_TEXTURE_GEN_STR_OES
:
716 /* disable S, T, and R at the same time */
718 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
720 if (ctx
->API
!= API_OPENGLES
)
721 goto invalid_enum_error
;
725 texUnit
->TexGenEnabled
& ~STR_BITS
;
727 newenabled
|= STR_BITS
;
728 if (texUnit
->TexGenEnabled
== newenabled
)
730 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
731 texUnit
->TexGenEnabled
= newenabled
;
736 /* client-side state */
737 case GL_VERTEX_ARRAY
:
738 case GL_NORMAL_ARRAY
:
741 case GL_TEXTURE_COORD_ARRAY
:
742 case GL_EDGE_FLAG_ARRAY
:
743 case GL_FOG_COORDINATE_ARRAY_EXT
:
744 case GL_SECONDARY_COLOR_ARRAY_EXT
:
745 case GL_POINT_SIZE_ARRAY_OES
:
746 client_state( ctx
, cap
, state
);
749 /* GL_ARB_texture_cube_map */
750 case GL_TEXTURE_CUBE_MAP_ARB
:
751 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
752 goto invalid_enum_error
;
753 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
754 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
759 /* GL_EXT_secondary_color */
760 case GL_COLOR_SUM_EXT
:
761 if (ctx
->API
!= API_OPENGL_COMPAT
)
762 goto invalid_enum_error
;
763 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
764 if (ctx
->Fog
.ColorSumEnabled
== state
)
766 FLUSH_VERTICES(ctx
, _NEW_FOG
);
767 ctx
->Fog
.ColorSumEnabled
= state
;
770 /* GL_ARB_multisample */
771 case GL_MULTISAMPLE_ARB
:
772 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
773 goto invalid_enum_error
;
774 _mesa_set_multisample(ctx
, state
);
776 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
777 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
779 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
780 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
782 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
783 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
784 goto invalid_enum_error
;
785 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
787 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
788 ctx
->Multisample
.SampleAlphaToOne
= state
;
790 case GL_SAMPLE_COVERAGE_ARB
:
791 if (ctx
->Multisample
.SampleCoverage
== state
)
793 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
794 ctx
->Multisample
.SampleCoverage
= state
;
796 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
797 if (!_mesa_is_desktop_gl(ctx
))
798 goto invalid_enum_error
;
799 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
801 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
802 ctx
->Multisample
.SampleCoverageInvert
= state
;
805 /* GL_IBM_rasterpos_clip */
806 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
807 if (ctx
->API
!= API_OPENGL_COMPAT
)
808 goto invalid_enum_error
;
809 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
811 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
812 ctx
->Transform
.RasterPositionUnclipped
= state
;
815 /* GL_NV_point_sprite */
816 case GL_POINT_SPRITE_NV
:
817 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
818 goto invalid_enum_error
;
819 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
820 if (ctx
->Point
.PointSprite
== state
)
822 FLUSH_VERTICES(ctx
, _NEW_POINT
);
823 ctx
->Point
.PointSprite
= state
;
826 case GL_VERTEX_PROGRAM_ARB
:
827 if (ctx
->API
!= API_OPENGL_COMPAT
)
828 goto invalid_enum_error
;
829 CHECK_EXTENSION(ARB_vertex_program
, cap
);
830 if (ctx
->VertexProgram
.Enabled
== state
)
832 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
833 ctx
->VertexProgram
.Enabled
= state
;
835 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
836 /* This was added with ARB_vertex_program, but it is also used with
837 * GLSL vertex shaders on desktop.
839 if (!_mesa_is_desktop_gl(ctx
))
840 goto invalid_enum_error
;
841 CHECK_EXTENSION(ARB_vertex_program
, cap
);
842 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
844 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
845 ctx
->VertexProgram
.PointSizeEnabled
= state
;
847 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
848 if (ctx
->API
!= API_OPENGL_COMPAT
)
849 goto invalid_enum_error
;
850 CHECK_EXTENSION(ARB_vertex_program
, cap
);
851 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
853 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
854 ctx
->VertexProgram
.TwoSideEnabled
= state
;
857 /* GL_NV_texture_rectangle */
858 case GL_TEXTURE_RECTANGLE_NV
:
859 if (ctx
->API
!= API_OPENGL_COMPAT
)
860 goto invalid_enum_error
;
861 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
862 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
867 /* GL_EXT_stencil_two_side */
868 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
869 if (ctx
->API
!= API_OPENGL_COMPAT
)
870 goto invalid_enum_error
;
871 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
872 if (ctx
->Stencil
.TestTwoSide
== state
)
874 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
875 ctx
->Stencil
.TestTwoSide
= state
;
877 ctx
->Stencil
._BackFace
= 2;
879 ctx
->Stencil
._BackFace
= 1;
883 case GL_FRAGMENT_PROGRAM_ARB
:
884 if (ctx
->API
!= API_OPENGL_COMPAT
)
885 goto invalid_enum_error
;
886 CHECK_EXTENSION(ARB_fragment_program
, cap
);
887 if (ctx
->FragmentProgram
.Enabled
== state
)
889 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
890 ctx
->FragmentProgram
.Enabled
= state
;
893 /* GL_EXT_depth_bounds_test */
894 case GL_DEPTH_BOUNDS_TEST_EXT
:
895 if (!_mesa_is_desktop_gl(ctx
))
896 goto invalid_enum_error
;
897 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
898 if (ctx
->Depth
.BoundsTest
== state
)
900 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
901 ctx
->Depth
.BoundsTest
= state
;
905 if (!_mesa_is_desktop_gl(ctx
))
906 goto invalid_enum_error
;
907 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
908 if (ctx
->Transform
.DepthClamp
== state
)
910 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
911 ctx
->Transform
.DepthClamp
= state
;
914 case GL_FRAGMENT_SHADER_ATI
:
915 if (ctx
->API
!= API_OPENGL_COMPAT
)
916 goto invalid_enum_error
;
917 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
918 if (ctx
->ATIFragmentShader
.Enabled
== state
)
920 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
921 ctx
->ATIFragmentShader
.Enabled
= state
;
924 /* GL_MESA_texture_array */
925 case GL_TEXTURE_1D_ARRAY_EXT
:
926 if (ctx
->API
!= API_OPENGL_COMPAT
)
927 goto invalid_enum_error
;
928 CHECK_EXTENSION(MESA_texture_array
, cap
);
929 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
934 case GL_TEXTURE_2D_ARRAY_EXT
:
935 if (ctx
->API
!= API_OPENGL_COMPAT
)
936 goto invalid_enum_error
;
937 CHECK_EXTENSION(MESA_texture_array
, cap
);
938 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
943 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
944 if (!_mesa_is_desktop_gl(ctx
))
945 goto invalid_enum_error
;
946 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
947 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
948 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
949 ctx
->Texture
.CubeMapSeamless
= state
;
953 case GL_RASTERIZER_DISCARD
:
954 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
955 goto invalid_enum_error
;
956 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
957 if (ctx
->RasterDiscard
!= state
) {
958 FLUSH_VERTICES(ctx
, 0);
959 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
960 ctx
->RasterDiscard
= state
;
964 /* GL 3.1 primitive restart. Note: this enum is different from
965 * GL_PRIMITIVE_RESTART_NV (which is client state).
967 case GL_PRIMITIVE_RESTART
:
968 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
969 goto invalid_enum_error
;
971 if (ctx
->Array
.PrimitiveRestart
!= state
) {
972 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
973 ctx
->Array
.PrimitiveRestart
= state
;
974 update_derived_primitive_restart_state(ctx
);
978 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
979 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
980 goto invalid_enum_error
;
981 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
982 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
983 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
984 update_derived_primitive_restart_state(ctx
);
988 /* GL3.0 - GL_framebuffer_sRGB */
989 case GL_FRAMEBUFFER_SRGB_EXT
:
990 if (!_mesa_is_desktop_gl(ctx
))
991 goto invalid_enum_error
;
992 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
993 _mesa_set_framebuffer_srgb(ctx
, state
);
996 /* GL_OES_EGL_image_external */
997 case GL_TEXTURE_EXTERNAL_OES
:
998 if (!_mesa_is_gles(ctx
))
999 goto invalid_enum_error
;
1000 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1001 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1006 /* ARB_texture_multisample */
1007 case GL_SAMPLE_MASK
:
1008 if (!_mesa_is_desktop_gl(ctx
))
1009 goto invalid_enum_error
;
1010 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1011 if (ctx
->Multisample
.SampleMask
== state
)
1013 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
1014 ctx
->Multisample
.SampleMask
= state
;
1018 goto invalid_enum_error
;
1021 if (ctx
->Driver
.Enable
) {
1022 ctx
->Driver
.Enable( ctx
, cap
, state
);
1028 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1029 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
1034 * Enable GL capability. Called by glEnable()
1035 * \param cap state to enable.
1038 _mesa_Enable( GLenum cap
)
1040 GET_CURRENT_CONTEXT(ctx
);
1042 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1047 * Disable GL capability. Called by glDisable()
1048 * \param cap state to disable.
1051 _mesa_Disable( GLenum cap
)
1053 GET_CURRENT_CONTEXT(ctx
);
1055 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1061 * Enable/disable an indexed state var.
1064 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1065 GLuint index
, GLboolean state
)
1067 ASSERT(state
== 0 || state
== 1);
1070 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1071 goto invalid_enum_error
;
1073 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1074 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1075 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1078 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1079 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1081 ctx
->Color
.BlendEnabled
|= (1 << index
);
1083 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1087 goto invalid_enum_error
;
1092 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1093 state
? "glEnablei" : "glDisablei",
1094 _mesa_lookup_enum_by_nr(cap
));
1099 _mesa_Disablei( GLenum cap
, GLuint index
)
1101 GET_CURRENT_CONTEXT(ctx
);
1102 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1107 _mesa_Enablei( GLenum cap
, GLuint index
)
1109 GET_CURRENT_CONTEXT(ctx
);
1110 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1114 GLboolean GLAPIENTRY
1115 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1117 GET_CURRENT_CONTEXT(ctx
);
1118 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1121 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1122 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1126 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1128 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1129 _mesa_lookup_enum_by_nr(cap
));
1137 #undef CHECK_EXTENSION
1138 #define CHECK_EXTENSION(EXTNAME) \
1139 if (!ctx->Extensions.EXTNAME) { \
1140 goto invalid_enum_error; \
1143 #undef CHECK_EXTENSION2
1144 #define CHECK_EXTENSION2(EXT1, EXT2) \
1145 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1146 goto invalid_enum_error; \
1151 * Helper function to determine whether a texture target is enabled.
1154 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1156 const struct gl_texture_unit
*const texUnit
=
1157 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1158 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1163 * Return simple enable/disable state.
1165 * \param cap state variable to query.
1167 * Returns the state of the specified capability from the current GL context.
1168 * For the capabilities associated with extensions verifies that those
1169 * extensions are effectively present before reporting.
1171 GLboolean GLAPIENTRY
1172 _mesa_IsEnabled( GLenum cap
)
1174 GET_CURRENT_CONTEXT(ctx
);
1175 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1179 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1180 goto invalid_enum_error
;
1181 return ctx
->Color
.AlphaEnabled
;
1182 case GL_AUTO_NORMAL
:
1183 if (ctx
->API
!= API_OPENGL_COMPAT
)
1184 goto invalid_enum_error
;
1185 return ctx
->Eval
.AutoNormal
;
1187 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1188 case GL_CLIP_DISTANCE0
:
1189 case GL_CLIP_DISTANCE1
:
1190 case GL_CLIP_DISTANCE2
:
1191 case GL_CLIP_DISTANCE3
:
1192 case GL_CLIP_DISTANCE4
:
1193 case GL_CLIP_DISTANCE5
:
1194 case GL_CLIP_DISTANCE6
:
1195 case GL_CLIP_DISTANCE7
: {
1196 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1198 if (p
>= ctx
->Const
.MaxClipPlanes
)
1199 goto invalid_enum_error
;
1201 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1203 case GL_COLOR_MATERIAL
:
1204 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1205 goto invalid_enum_error
;
1206 return ctx
->Light
.ColorMaterialEnabled
;
1208 return ctx
->Polygon
.CullFlag
;
1209 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1210 if (!_mesa_is_desktop_gl(ctx
))
1211 goto invalid_enum_error
;
1212 return ctx
->Debug
.SyncOutput
;
1214 return ctx
->Depth
.Test
;
1216 return ctx
->Color
.DitherFlag
;
1218 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1219 goto invalid_enum_error
;
1220 return ctx
->Fog
.Enabled
;
1222 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1223 goto invalid_enum_error
;
1224 return ctx
->Light
.Enabled
;
1233 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1234 goto invalid_enum_error
;
1235 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1236 case GL_LINE_SMOOTH
:
1237 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1238 goto invalid_enum_error
;
1239 return ctx
->Line
.SmoothFlag
;
1240 case GL_LINE_STIPPLE
:
1241 if (ctx
->API
!= API_OPENGL_COMPAT
)
1242 goto invalid_enum_error
;
1243 return ctx
->Line
.StippleFlag
;
1244 case GL_INDEX_LOGIC_OP
:
1245 if (ctx
->API
!= API_OPENGL_COMPAT
)
1246 goto invalid_enum_error
;
1247 return ctx
->Color
.IndexLogicOpEnabled
;
1248 case GL_COLOR_LOGIC_OP
:
1249 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1250 goto invalid_enum_error
;
1251 return ctx
->Color
.ColorLogicOpEnabled
;
1252 case GL_MAP1_COLOR_4
:
1253 if (ctx
->API
!= API_OPENGL_COMPAT
)
1254 goto invalid_enum_error
;
1255 return ctx
->Eval
.Map1Color4
;
1257 if (ctx
->API
!= API_OPENGL_COMPAT
)
1258 goto invalid_enum_error
;
1259 return ctx
->Eval
.Map1Index
;
1260 case GL_MAP1_NORMAL
:
1261 if (ctx
->API
!= API_OPENGL_COMPAT
)
1262 goto invalid_enum_error
;
1263 return ctx
->Eval
.Map1Normal
;
1264 case GL_MAP1_TEXTURE_COORD_1
:
1265 if (ctx
->API
!= API_OPENGL_COMPAT
)
1266 goto invalid_enum_error
;
1267 return ctx
->Eval
.Map1TextureCoord1
;
1268 case GL_MAP1_TEXTURE_COORD_2
:
1269 if (ctx
->API
!= API_OPENGL_COMPAT
)
1270 goto invalid_enum_error
;
1271 return ctx
->Eval
.Map1TextureCoord2
;
1272 case GL_MAP1_TEXTURE_COORD_3
:
1273 if (ctx
->API
!= API_OPENGL_COMPAT
)
1274 goto invalid_enum_error
;
1275 return ctx
->Eval
.Map1TextureCoord3
;
1276 case GL_MAP1_TEXTURE_COORD_4
:
1277 if (ctx
->API
!= API_OPENGL_COMPAT
)
1278 goto invalid_enum_error
;
1279 return ctx
->Eval
.Map1TextureCoord4
;
1280 case GL_MAP1_VERTEX_3
:
1281 if (ctx
->API
!= API_OPENGL_COMPAT
)
1282 goto invalid_enum_error
;
1283 return ctx
->Eval
.Map1Vertex3
;
1284 case GL_MAP1_VERTEX_4
:
1285 if (ctx
->API
!= API_OPENGL_COMPAT
)
1286 goto invalid_enum_error
;
1287 return ctx
->Eval
.Map1Vertex4
;
1288 case GL_MAP2_COLOR_4
:
1289 if (ctx
->API
!= API_OPENGL_COMPAT
)
1290 goto invalid_enum_error
;
1291 return ctx
->Eval
.Map2Color4
;
1293 if (ctx
->API
!= API_OPENGL_COMPAT
)
1294 goto invalid_enum_error
;
1295 return ctx
->Eval
.Map2Index
;
1296 case GL_MAP2_NORMAL
:
1297 if (ctx
->API
!= API_OPENGL_COMPAT
)
1298 goto invalid_enum_error
;
1299 return ctx
->Eval
.Map2Normal
;
1300 case GL_MAP2_TEXTURE_COORD_1
:
1301 if (ctx
->API
!= API_OPENGL_COMPAT
)
1302 goto invalid_enum_error
;
1303 return ctx
->Eval
.Map2TextureCoord1
;
1304 case GL_MAP2_TEXTURE_COORD_2
:
1305 if (ctx
->API
!= API_OPENGL_COMPAT
)
1306 goto invalid_enum_error
;
1307 return ctx
->Eval
.Map2TextureCoord2
;
1308 case GL_MAP2_TEXTURE_COORD_3
:
1309 if (ctx
->API
!= API_OPENGL_COMPAT
)
1310 goto invalid_enum_error
;
1311 return ctx
->Eval
.Map2TextureCoord3
;
1312 case GL_MAP2_TEXTURE_COORD_4
:
1313 if (ctx
->API
!= API_OPENGL_COMPAT
)
1314 goto invalid_enum_error
;
1315 return ctx
->Eval
.Map2TextureCoord4
;
1316 case GL_MAP2_VERTEX_3
:
1317 if (ctx
->API
!= API_OPENGL_COMPAT
)
1318 goto invalid_enum_error
;
1319 return ctx
->Eval
.Map2Vertex3
;
1320 case GL_MAP2_VERTEX_4
:
1321 if (ctx
->API
!= API_OPENGL_COMPAT
)
1322 goto invalid_enum_error
;
1323 return ctx
->Eval
.Map2Vertex4
;
1325 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1326 goto invalid_enum_error
;
1327 return ctx
->Transform
.Normalize
;
1328 case GL_POINT_SMOOTH
:
1329 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1330 goto invalid_enum_error
;
1331 return ctx
->Point
.SmoothFlag
;
1332 case GL_POLYGON_SMOOTH
:
1333 if (!_mesa_is_desktop_gl(ctx
))
1334 goto invalid_enum_error
;
1335 return ctx
->Polygon
.SmoothFlag
;
1336 case GL_POLYGON_STIPPLE
:
1337 if (ctx
->API
!= API_OPENGL_COMPAT
)
1338 goto invalid_enum_error
;
1339 return ctx
->Polygon
.StippleFlag
;
1340 case GL_POLYGON_OFFSET_POINT
:
1341 if (!_mesa_is_desktop_gl(ctx
))
1342 goto invalid_enum_error
;
1343 return ctx
->Polygon
.OffsetPoint
;
1344 case GL_POLYGON_OFFSET_LINE
:
1345 if (!_mesa_is_desktop_gl(ctx
))
1346 goto invalid_enum_error
;
1347 return ctx
->Polygon
.OffsetLine
;
1348 case GL_POLYGON_OFFSET_FILL
:
1349 return ctx
->Polygon
.OffsetFill
;
1350 case GL_RESCALE_NORMAL_EXT
:
1351 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1352 goto invalid_enum_error
;
1353 return ctx
->Transform
.RescaleNormals
;
1354 case GL_SCISSOR_TEST
:
1355 return ctx
->Scissor
.Enabled
;
1356 case GL_STENCIL_TEST
:
1357 return ctx
->Stencil
.Enabled
;
1359 if (ctx
->API
!= API_OPENGL_COMPAT
)
1360 goto invalid_enum_error
;
1361 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1363 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1364 goto invalid_enum_error
;
1365 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1367 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1368 goto invalid_enum_error
;
1369 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1370 case GL_TEXTURE_GEN_S
:
1371 case GL_TEXTURE_GEN_T
:
1372 case GL_TEXTURE_GEN_R
:
1373 case GL_TEXTURE_GEN_Q
:
1375 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1377 if (ctx
->API
!= API_OPENGL_COMPAT
)
1378 goto invalid_enum_error
;
1381 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1382 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1386 case GL_TEXTURE_GEN_STR_OES
:
1388 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1390 if (ctx
->API
!= API_OPENGLES
)
1391 goto invalid_enum_error
;
1394 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1395 ? GL_TRUE
: GL_FALSE
;
1399 /* client-side state */
1400 case GL_VERTEX_ARRAY
:
1401 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1402 goto invalid_enum_error
;
1403 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
!= 0);
1404 case GL_NORMAL_ARRAY
:
1405 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1406 goto invalid_enum_error
;
1407 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1408 case GL_COLOR_ARRAY
:
1409 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1410 goto invalid_enum_error
;
1411 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
!= 0);
1412 case GL_INDEX_ARRAY
:
1413 if (ctx
->API
!= API_OPENGL_COMPAT
)
1414 goto invalid_enum_error
;
1415 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1416 case GL_TEXTURE_COORD_ARRAY
:
1417 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1418 goto invalid_enum_error
;
1419 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1421 case GL_EDGE_FLAG_ARRAY
:
1422 if (ctx
->API
!= API_OPENGL_COMPAT
)
1423 goto invalid_enum_error
;
1424 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1425 case GL_FOG_COORDINATE_ARRAY_EXT
:
1426 if (ctx
->API
!= API_OPENGL_COMPAT
)
1427 goto invalid_enum_error
;
1428 CHECK_EXTENSION(EXT_fog_coord
);
1429 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1430 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1431 if (ctx
->API
!= API_OPENGL_COMPAT
)
1432 goto invalid_enum_error
;
1433 CHECK_EXTENSION(EXT_secondary_color
);
1434 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1435 case GL_POINT_SIZE_ARRAY_OES
:
1436 if (ctx
->API
!= API_OPENGLES
)
1437 goto invalid_enum_error
;
1438 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1440 /* GL_ARB_texture_cube_map */
1441 case GL_TEXTURE_CUBE_MAP_ARB
:
1442 CHECK_EXTENSION(ARB_texture_cube_map
);
1443 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1445 /* GL_EXT_secondary_color */
1446 case GL_COLOR_SUM_EXT
:
1447 if (ctx
->API
!= API_OPENGL_COMPAT
)
1448 goto invalid_enum_error
;
1449 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1450 return ctx
->Fog
.ColorSumEnabled
;
1452 /* GL_ARB_multisample */
1453 case GL_MULTISAMPLE_ARB
:
1454 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1455 goto invalid_enum_error
;
1456 return ctx
->Multisample
.Enabled
;
1457 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1458 return ctx
->Multisample
.SampleAlphaToCoverage
;
1459 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1460 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1461 goto invalid_enum_error
;
1462 return ctx
->Multisample
.SampleAlphaToOne
;
1463 case GL_SAMPLE_COVERAGE_ARB
:
1464 return ctx
->Multisample
.SampleCoverage
;
1465 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1466 if (!_mesa_is_desktop_gl(ctx
))
1467 goto invalid_enum_error
;
1468 return ctx
->Multisample
.SampleCoverageInvert
;
1470 /* GL_IBM_rasterpos_clip */
1471 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1472 if (ctx
->API
!= API_OPENGL_COMPAT
)
1473 goto invalid_enum_error
;
1474 return ctx
->Transform
.RasterPositionUnclipped
;
1476 /* GL_NV_point_sprite */
1477 case GL_POINT_SPRITE_NV
:
1478 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1479 goto invalid_enum_error
;
1480 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1481 return ctx
->Point
.PointSprite
;
1483 case GL_VERTEX_PROGRAM_ARB
:
1484 if (ctx
->API
!= API_OPENGL_COMPAT
)
1485 goto invalid_enum_error
;
1486 CHECK_EXTENSION(ARB_vertex_program
);
1487 return ctx
->VertexProgram
.Enabled
;
1488 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1489 /* This was added with ARB_vertex_program, but it is also used with
1490 * GLSL vertex shaders on desktop.
1492 if (!_mesa_is_desktop_gl(ctx
))
1493 goto invalid_enum_error
;
1494 CHECK_EXTENSION(ARB_vertex_program
);
1495 return ctx
->VertexProgram
.PointSizeEnabled
;
1496 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1497 if (ctx
->API
!= API_OPENGL_COMPAT
)
1498 goto invalid_enum_error
;
1499 CHECK_EXTENSION(ARB_vertex_program
);
1500 return ctx
->VertexProgram
.TwoSideEnabled
;
1502 /* GL_NV_texture_rectangle */
1503 case GL_TEXTURE_RECTANGLE_NV
:
1504 if (ctx
->API
!= API_OPENGL_COMPAT
)
1505 goto invalid_enum_error
;
1506 CHECK_EXTENSION(NV_texture_rectangle
);
1507 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1509 /* GL_EXT_stencil_two_side */
1510 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1511 if (ctx
->API
!= API_OPENGL_COMPAT
)
1512 goto invalid_enum_error
;
1513 CHECK_EXTENSION(EXT_stencil_two_side
);
1514 return ctx
->Stencil
.TestTwoSide
;
1516 case GL_FRAGMENT_PROGRAM_ARB
:
1517 if (ctx
->API
!= API_OPENGL_COMPAT
)
1518 goto invalid_enum_error
;
1519 return ctx
->FragmentProgram
.Enabled
;
1521 /* GL_EXT_depth_bounds_test */
1522 case GL_DEPTH_BOUNDS_TEST_EXT
:
1523 if (!_mesa_is_desktop_gl(ctx
))
1524 goto invalid_enum_error
;
1525 CHECK_EXTENSION(EXT_depth_bounds_test
);
1526 return ctx
->Depth
.BoundsTest
;
1528 /* GL_ARB_depth_clamp */
1529 case GL_DEPTH_CLAMP
:
1530 if (!_mesa_is_desktop_gl(ctx
))
1531 goto invalid_enum_error
;
1532 CHECK_EXTENSION(ARB_depth_clamp
);
1533 return ctx
->Transform
.DepthClamp
;
1535 case GL_FRAGMENT_SHADER_ATI
:
1536 if (ctx
->API
!= API_OPENGL_COMPAT
)
1537 goto invalid_enum_error
;
1538 CHECK_EXTENSION(ATI_fragment_shader
);
1539 return ctx
->ATIFragmentShader
.Enabled
;
1541 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1542 if (!_mesa_is_desktop_gl(ctx
))
1543 goto invalid_enum_error
;
1544 CHECK_EXTENSION(ARB_seamless_cube_map
);
1545 return ctx
->Texture
.CubeMapSeamless
;
1547 case GL_RASTERIZER_DISCARD
:
1548 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1549 goto invalid_enum_error
;
1550 CHECK_EXTENSION(EXT_transform_feedback
);
1551 return ctx
->RasterDiscard
;
1553 /* GL_NV_primitive_restart */
1554 case GL_PRIMITIVE_RESTART_NV
:
1555 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1556 goto invalid_enum_error
;
1558 return ctx
->Array
.PrimitiveRestart
;
1560 /* GL 3.1 primitive restart */
1561 case GL_PRIMITIVE_RESTART
:
1562 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1563 goto invalid_enum_error
;
1565 return ctx
->Array
.PrimitiveRestart
;
1567 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1568 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1569 goto invalid_enum_error
;
1571 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1573 /* GL3.0 - GL_framebuffer_sRGB */
1574 case GL_FRAMEBUFFER_SRGB_EXT
:
1575 if (!_mesa_is_desktop_gl(ctx
))
1576 goto invalid_enum_error
;
1577 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1578 return ctx
->Color
.sRGBEnabled
;
1580 /* GL_OES_EGL_image_external */
1581 case GL_TEXTURE_EXTERNAL_OES
:
1582 if (!_mesa_is_gles(ctx
))
1583 goto invalid_enum_error
;
1584 CHECK_EXTENSION(OES_EGL_image_external
);
1585 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1587 /* ARB_texture_multisample */
1588 case GL_SAMPLE_MASK
:
1589 if (!_mesa_is_desktop_gl(ctx
))
1590 goto invalid_enum_error
;
1591 CHECK_EXTENSION(ARB_texture_multisample
);
1592 return ctx
->Multisample
.SampleMask
;
1595 goto invalid_enum_error
;
1601 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1602 _mesa_lookup_enum_by_nr(cap
));