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 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 arrayObj
->NewArrays
|= flag
;
145 if (ctx
->Driver
.Enable
) {
146 ctx
->Driver
.Enable( ctx
, cap
, state
);
152 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
153 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
158 * Enable GL capability.
159 * \param cap state to enable/disable.
161 * Get's the current context, assures that we're outside glBegin()/glEnd() and
162 * calls client_state().
165 _mesa_EnableClientState( GLenum cap
)
167 GET_CURRENT_CONTEXT(ctx
);
168 client_state( ctx
, cap
, GL_TRUE
);
173 * Disable GL capability.
174 * \param cap state to enable/disable.
176 * Get's the current context, assures that we're outside glBegin()/glEnd() and
177 * calls client_state().
180 _mesa_DisableClientState( GLenum cap
)
182 GET_CURRENT_CONTEXT(ctx
);
183 client_state( ctx
, cap
, GL_FALSE
);
187 #undef CHECK_EXTENSION
188 #define CHECK_EXTENSION(EXTNAME, CAP) \
189 if (!ctx->Extensions.EXTNAME) { \
190 goto invalid_enum_error; \
193 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
194 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
195 goto invalid_enum_error; \
199 * Return pointer to current texture unit for setting/getting coordinate
201 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
202 * texture unit is higher than the number of supported coordinate units.
204 static struct gl_texture_unit
*
205 get_texcoord_unit(struct gl_context
*ctx
)
207 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
208 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
212 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
218 * Helper function to enable or disable a texture target.
219 * \param bit one of the TEXTURE_x_BIT values
220 * \return GL_TRUE if state is changing or GL_FALSE if no change
223 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
225 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
226 const GLbitfield newenabled
= state
227 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
229 if (texUnit
->Enabled
== newenabled
)
232 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
233 texUnit
->Enabled
= newenabled
;
239 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
240 * whether the API supports it (GLES doesn't).
243 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
245 if (ctx
->Multisample
.Enabled
== state
)
247 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
248 ctx
->Multisample
.Enabled
= state
;
250 if (ctx
->Driver
.Enable
) {
251 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
256 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
257 * check for whether the API supports it (GLES doesn't).
260 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
262 if (ctx
->Color
.sRGBEnabled
== state
)
264 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
265 ctx
->Color
.sRGBEnabled
= state
;
267 if (ctx
->Driver
.Enable
) {
268 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
273 * Helper function to enable or disable state.
275 * \param ctx GL context.
276 * \param cap the state to enable/disable
277 * \param state whether to enable or disable the specified capability.
279 * Updates the current context and flushes the vertices as needed. For
280 * capabilities associated with extensions it verifies that those extensions
281 * are effectivly present before updating. Notifies the driver via
282 * dd_function_table::Enable.
285 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
287 if (MESA_VERBOSE
& VERBOSE_API
)
288 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
289 state
? "glEnable" : "glDisable",
290 _mesa_lookup_enum_by_nr(cap
),
295 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
296 goto invalid_enum_error
;
297 if (ctx
->Color
.AlphaEnabled
== state
)
299 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
300 ctx
->Color
.AlphaEnabled
= state
;
303 if (ctx
->API
!= API_OPENGL_COMPAT
)
304 goto invalid_enum_error
;
305 if (ctx
->Eval
.AutoNormal
== state
)
307 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
308 ctx
->Eval
.AutoNormal
= state
;
312 GLbitfield newEnabled
=
313 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
314 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
315 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
316 ctx
->Color
.BlendEnabled
= newEnabled
;
320 case GL_CLIP_DISTANCE0
:
321 case GL_CLIP_DISTANCE1
:
322 case GL_CLIP_DISTANCE2
:
323 case GL_CLIP_DISTANCE3
:
324 case GL_CLIP_DISTANCE4
:
325 case GL_CLIP_DISTANCE5
:
326 case GL_CLIP_DISTANCE6
:
327 case GL_CLIP_DISTANCE7
:
329 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
331 if (p
>= ctx
->Const
.MaxClipPlanes
)
332 goto invalid_enum_error
;
334 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
335 == ((GLuint
) state
<< p
))
338 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
341 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
342 _mesa_update_clip_plane(ctx
, p
);
345 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
349 case GL_COLOR_MATERIAL
:
350 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
351 goto invalid_enum_error
;
352 if (ctx
->Light
.ColorMaterialEnabled
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
355 FLUSH_CURRENT(ctx
, 0);
356 ctx
->Light
.ColorMaterialEnabled
= state
;
358 _mesa_update_color_material( ctx
,
359 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
363 if (ctx
->Polygon
.CullFlag
== state
)
365 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
366 ctx
->Polygon
.CullFlag
= state
;
369 if (ctx
->Depth
.Test
== state
)
371 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
372 ctx
->Depth
.Test
= state
;
374 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
375 if (!_mesa_is_desktop_gl(ctx
))
376 goto invalid_enum_error
;
377 ctx
->Debug
.SyncOutput
= state
;
380 if (ctx
->Color
.DitherFlag
== state
)
382 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
383 ctx
->Color
.DitherFlag
= state
;
386 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
387 goto invalid_enum_error
;
388 if (ctx
->Fog
.Enabled
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_FOG
);
391 ctx
->Fog
.Enabled
= state
;
401 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
402 goto invalid_enum_error
;
403 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
405 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
406 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
408 insert_at_tail(&ctx
->Light
.EnabledList
,
409 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
412 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
416 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
417 goto invalid_enum_error
;
418 if (ctx
->Light
.Enabled
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
421 ctx
->Light
.Enabled
= state
;
422 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
423 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
425 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
428 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
429 goto invalid_enum_error
;
430 if (ctx
->Line
.SmoothFlag
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_LINE
);
433 ctx
->Line
.SmoothFlag
= state
;
435 case GL_LINE_STIPPLE
:
436 if (ctx
->API
!= API_OPENGL_COMPAT
)
437 goto invalid_enum_error
;
438 if (ctx
->Line
.StippleFlag
== state
)
440 FLUSH_VERTICES(ctx
, _NEW_LINE
);
441 ctx
->Line
.StippleFlag
= state
;
443 case GL_INDEX_LOGIC_OP
:
444 if (ctx
->API
!= API_OPENGL_COMPAT
)
445 goto invalid_enum_error
;
446 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
448 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
449 ctx
->Color
.IndexLogicOpEnabled
= state
;
451 case GL_COLOR_LOGIC_OP
:
452 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
453 goto invalid_enum_error
;
454 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
456 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
457 ctx
->Color
.ColorLogicOpEnabled
= state
;
459 case GL_MAP1_COLOR_4
:
460 if (ctx
->API
!= API_OPENGL_COMPAT
)
461 goto invalid_enum_error
;
462 if (ctx
->Eval
.Map1Color4
== state
)
464 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
465 ctx
->Eval
.Map1Color4
= state
;
468 if (ctx
->API
!= API_OPENGL_COMPAT
)
469 goto invalid_enum_error
;
470 if (ctx
->Eval
.Map1Index
== state
)
472 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
473 ctx
->Eval
.Map1Index
= state
;
476 if (ctx
->API
!= API_OPENGL_COMPAT
)
477 goto invalid_enum_error
;
478 if (ctx
->Eval
.Map1Normal
== state
)
480 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
481 ctx
->Eval
.Map1Normal
= state
;
483 case GL_MAP1_TEXTURE_COORD_1
:
484 if (ctx
->API
!= API_OPENGL_COMPAT
)
485 goto invalid_enum_error
;
486 if (ctx
->Eval
.Map1TextureCoord1
== state
)
488 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
489 ctx
->Eval
.Map1TextureCoord1
= state
;
491 case GL_MAP1_TEXTURE_COORD_2
:
492 if (ctx
->API
!= API_OPENGL_COMPAT
)
493 goto invalid_enum_error
;
494 if (ctx
->Eval
.Map1TextureCoord2
== state
)
496 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
497 ctx
->Eval
.Map1TextureCoord2
= state
;
499 case GL_MAP1_TEXTURE_COORD_3
:
500 if (ctx
->API
!= API_OPENGL_COMPAT
)
501 goto invalid_enum_error
;
502 if (ctx
->Eval
.Map1TextureCoord3
== state
)
504 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
505 ctx
->Eval
.Map1TextureCoord3
= state
;
507 case GL_MAP1_TEXTURE_COORD_4
:
508 if (ctx
->API
!= API_OPENGL_COMPAT
)
509 goto invalid_enum_error
;
510 if (ctx
->Eval
.Map1TextureCoord4
== state
)
512 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
513 ctx
->Eval
.Map1TextureCoord4
= state
;
515 case GL_MAP1_VERTEX_3
:
516 if (ctx
->API
!= API_OPENGL_COMPAT
)
517 goto invalid_enum_error
;
518 if (ctx
->Eval
.Map1Vertex3
== state
)
520 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
521 ctx
->Eval
.Map1Vertex3
= state
;
523 case GL_MAP1_VERTEX_4
:
524 if (ctx
->API
!= API_OPENGL_COMPAT
)
525 goto invalid_enum_error
;
526 if (ctx
->Eval
.Map1Vertex4
== state
)
528 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
529 ctx
->Eval
.Map1Vertex4
= state
;
531 case GL_MAP2_COLOR_4
:
532 if (ctx
->API
!= API_OPENGL_COMPAT
)
533 goto invalid_enum_error
;
534 if (ctx
->Eval
.Map2Color4
== state
)
536 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
537 ctx
->Eval
.Map2Color4
= state
;
540 if (ctx
->API
!= API_OPENGL_COMPAT
)
541 goto invalid_enum_error
;
542 if (ctx
->Eval
.Map2Index
== state
)
544 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
545 ctx
->Eval
.Map2Index
= state
;
548 if (ctx
->API
!= API_OPENGL_COMPAT
)
549 goto invalid_enum_error
;
550 if (ctx
->Eval
.Map2Normal
== state
)
552 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
553 ctx
->Eval
.Map2Normal
= state
;
555 case GL_MAP2_TEXTURE_COORD_1
:
556 if (ctx
->API
!= API_OPENGL_COMPAT
)
557 goto invalid_enum_error
;
558 if (ctx
->Eval
.Map2TextureCoord1
== state
)
560 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
561 ctx
->Eval
.Map2TextureCoord1
= state
;
563 case GL_MAP2_TEXTURE_COORD_2
:
564 if (ctx
->API
!= API_OPENGL_COMPAT
)
565 goto invalid_enum_error
;
566 if (ctx
->Eval
.Map2TextureCoord2
== state
)
568 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
569 ctx
->Eval
.Map2TextureCoord2
= state
;
571 case GL_MAP2_TEXTURE_COORD_3
:
572 if (ctx
->API
!= API_OPENGL_COMPAT
)
573 goto invalid_enum_error
;
574 if (ctx
->Eval
.Map2TextureCoord3
== state
)
576 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
577 ctx
->Eval
.Map2TextureCoord3
= state
;
579 case GL_MAP2_TEXTURE_COORD_4
:
580 if (ctx
->API
!= API_OPENGL_COMPAT
)
581 goto invalid_enum_error
;
582 if (ctx
->Eval
.Map2TextureCoord4
== state
)
584 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
585 ctx
->Eval
.Map2TextureCoord4
= state
;
587 case GL_MAP2_VERTEX_3
:
588 if (ctx
->API
!= API_OPENGL_COMPAT
)
589 goto invalid_enum_error
;
590 if (ctx
->Eval
.Map2Vertex3
== state
)
592 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
593 ctx
->Eval
.Map2Vertex3
= state
;
595 case GL_MAP2_VERTEX_4
:
596 if (ctx
->API
!= API_OPENGL_COMPAT
)
597 goto invalid_enum_error
;
598 if (ctx
->Eval
.Map2Vertex4
== state
)
600 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
601 ctx
->Eval
.Map2Vertex4
= state
;
604 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
605 goto invalid_enum_error
;
606 if (ctx
->Transform
.Normalize
== state
)
608 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
609 ctx
->Transform
.Normalize
= state
;
611 case GL_POINT_SMOOTH
:
612 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
613 goto invalid_enum_error
;
614 if (ctx
->Point
.SmoothFlag
== state
)
616 FLUSH_VERTICES(ctx
, _NEW_POINT
);
617 ctx
->Point
.SmoothFlag
= state
;
618 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
620 case GL_POLYGON_SMOOTH
:
621 if (!_mesa_is_desktop_gl(ctx
))
622 goto invalid_enum_error
;
623 if (ctx
->Polygon
.SmoothFlag
== state
)
625 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
626 ctx
->Polygon
.SmoothFlag
= state
;
627 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
629 case GL_POLYGON_STIPPLE
:
630 if (ctx
->API
!= API_OPENGL_COMPAT
)
631 goto invalid_enum_error
;
632 if (ctx
->Polygon
.StippleFlag
== state
)
634 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
635 ctx
->Polygon
.StippleFlag
= state
;
636 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
638 case GL_POLYGON_OFFSET_POINT
:
639 if (!_mesa_is_desktop_gl(ctx
))
640 goto invalid_enum_error
;
641 if (ctx
->Polygon
.OffsetPoint
== state
)
643 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
644 ctx
->Polygon
.OffsetPoint
= state
;
646 case GL_POLYGON_OFFSET_LINE
:
647 if (!_mesa_is_desktop_gl(ctx
))
648 goto invalid_enum_error
;
649 if (ctx
->Polygon
.OffsetLine
== state
)
651 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
652 ctx
->Polygon
.OffsetLine
= state
;
654 case GL_POLYGON_OFFSET_FILL
:
655 if (ctx
->Polygon
.OffsetFill
== state
)
657 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
658 ctx
->Polygon
.OffsetFill
= state
;
660 case GL_RESCALE_NORMAL_EXT
:
661 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
662 goto invalid_enum_error
;
663 if (ctx
->Transform
.RescaleNormals
== state
)
665 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
666 ctx
->Transform
.RescaleNormals
= state
;
668 case GL_SCISSOR_TEST
:
669 if (ctx
->Scissor
.Enabled
== state
)
671 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
672 ctx
->Scissor
.Enabled
= state
;
674 case GL_STENCIL_TEST
:
675 if (ctx
->Stencil
.Enabled
== state
)
677 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
678 ctx
->Stencil
.Enabled
= state
;
681 if (ctx
->API
!= API_OPENGL_COMPAT
)
682 goto invalid_enum_error
;
683 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
688 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
689 goto invalid_enum_error
;
690 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
695 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
696 goto invalid_enum_error
;
697 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
701 case GL_TEXTURE_GEN_S
:
702 case GL_TEXTURE_GEN_T
:
703 case GL_TEXTURE_GEN_R
:
704 case GL_TEXTURE_GEN_Q
:
706 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
708 if (ctx
->API
!= API_OPENGL_COMPAT
)
709 goto invalid_enum_error
;
712 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
713 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
715 newenabled
|= coordBit
;
716 if (texUnit
->TexGenEnabled
== newenabled
)
718 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
719 texUnit
->TexGenEnabled
= newenabled
;
724 case GL_TEXTURE_GEN_STR_OES
:
725 /* disable S, T, and R at the same time */
727 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
729 if (ctx
->API
!= API_OPENGLES
)
730 goto invalid_enum_error
;
734 texUnit
->TexGenEnabled
& ~STR_BITS
;
736 newenabled
|= STR_BITS
;
737 if (texUnit
->TexGenEnabled
== newenabled
)
739 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
740 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_COMPAT
&& 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_COMPAT
)
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_COMPAT
)
817 goto invalid_enum_error
;
818 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
820 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
821 ctx
->Transform
.RasterPositionUnclipped
= state
;
824 /* GL_NV_point_sprite */
825 case GL_POINT_SPRITE_NV
:
826 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
827 goto invalid_enum_error
;
828 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
829 if (ctx
->Point
.PointSprite
== state
)
831 FLUSH_VERTICES(ctx
, _NEW_POINT
);
832 ctx
->Point
.PointSprite
= state
;
835 case GL_VERTEX_PROGRAM_ARB
:
836 if (ctx
->API
!= API_OPENGL_COMPAT
)
837 goto invalid_enum_error
;
838 CHECK_EXTENSION(ARB_vertex_program
, cap
);
839 if (ctx
->VertexProgram
.Enabled
== state
)
841 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
842 ctx
->VertexProgram
.Enabled
= state
;
844 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
845 /* This was added with ARB_vertex_program, but it is also used with
846 * GLSL vertex shaders on desktop.
848 if (!_mesa_is_desktop_gl(ctx
))
849 goto invalid_enum_error
;
850 CHECK_EXTENSION(ARB_vertex_program
, cap
);
851 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
853 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
854 ctx
->VertexProgram
.PointSizeEnabled
= state
;
856 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
857 if (ctx
->API
!= API_OPENGL_COMPAT
)
858 goto invalid_enum_error
;
859 CHECK_EXTENSION(ARB_vertex_program
, cap
);
860 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
862 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
863 ctx
->VertexProgram
.TwoSideEnabled
= state
;
866 /* GL_NV_texture_rectangle */
867 case GL_TEXTURE_RECTANGLE_NV
:
868 if (ctx
->API
!= API_OPENGL_COMPAT
)
869 goto invalid_enum_error
;
870 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
871 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
876 /* GL_EXT_stencil_two_side */
877 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
878 if (ctx
->API
!= API_OPENGL_COMPAT
)
879 goto invalid_enum_error
;
880 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
881 if (ctx
->Stencil
.TestTwoSide
== state
)
883 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
884 ctx
->Stencil
.TestTwoSide
= state
;
886 ctx
->Stencil
._BackFace
= 2;
888 ctx
->Stencil
._BackFace
= 1;
892 case GL_FRAGMENT_PROGRAM_ARB
:
893 if (ctx
->API
!= API_OPENGL_COMPAT
)
894 goto invalid_enum_error
;
895 CHECK_EXTENSION(ARB_fragment_program
, cap
);
896 if (ctx
->FragmentProgram
.Enabled
== state
)
898 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
899 ctx
->FragmentProgram
.Enabled
= state
;
902 /* GL_EXT_depth_bounds_test */
903 case GL_DEPTH_BOUNDS_TEST_EXT
:
904 if (!_mesa_is_desktop_gl(ctx
))
905 goto invalid_enum_error
;
906 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
907 if (ctx
->Depth
.BoundsTest
== state
)
909 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
910 ctx
->Depth
.BoundsTest
= state
;
914 if (!_mesa_is_desktop_gl(ctx
))
915 goto invalid_enum_error
;
916 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
917 if (ctx
->Transform
.DepthClamp
== state
)
919 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
920 ctx
->Transform
.DepthClamp
= state
;
923 case GL_FRAGMENT_SHADER_ATI
:
924 if (ctx
->API
!= API_OPENGL_COMPAT
)
925 goto invalid_enum_error
;
926 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
927 if (ctx
->ATIFragmentShader
.Enabled
== state
)
929 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
930 ctx
->ATIFragmentShader
.Enabled
= state
;
933 /* GL_MESA_texture_array */
934 case GL_TEXTURE_1D_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_1D_ARRAY_BIT
)) {
943 case GL_TEXTURE_2D_ARRAY_EXT
:
944 if (ctx
->API
!= API_OPENGL_COMPAT
)
945 goto invalid_enum_error
;
946 CHECK_EXTENSION(MESA_texture_array
, cap
);
947 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
952 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
953 if (!_mesa_is_desktop_gl(ctx
))
954 goto invalid_enum_error
;
955 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
956 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
957 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
958 ctx
->Texture
.CubeMapSeamless
= state
;
962 case GL_RASTERIZER_DISCARD
:
963 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
964 goto invalid_enum_error
;
965 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
966 if (ctx
->RasterDiscard
!= state
) {
967 FLUSH_VERTICES(ctx
, _NEW_RASTERIZER_DISCARD
);
968 ctx
->RasterDiscard
= state
;
972 /* GL 3.1 primitive restart. Note: this enum is different from
973 * GL_PRIMITIVE_RESTART_NV (which is client state).
975 case GL_PRIMITIVE_RESTART
:
976 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
977 goto invalid_enum_error
;
979 if (ctx
->Array
.PrimitiveRestart
!= state
) {
980 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
981 ctx
->Array
.PrimitiveRestart
= state
;
982 update_derived_primitive_restart_state(ctx
);
986 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
987 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
988 goto invalid_enum_error
;
989 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
990 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
991 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
992 update_derived_primitive_restart_state(ctx
);
996 /* GL3.0 - GL_framebuffer_sRGB */
997 case GL_FRAMEBUFFER_SRGB_EXT
:
998 if (!_mesa_is_desktop_gl(ctx
))
999 goto invalid_enum_error
;
1000 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
1001 _mesa_set_framebuffer_srgb(ctx
, state
);
1004 /* GL_OES_EGL_image_external */
1005 case GL_TEXTURE_EXTERNAL_OES
:
1006 if (!_mesa_is_gles(ctx
))
1007 goto invalid_enum_error
;
1008 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1009 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1014 /* ARB_texture_multisample */
1015 case GL_SAMPLE_MASK
:
1016 if (!_mesa_is_desktop_gl(ctx
))
1017 goto invalid_enum_error
;
1018 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1019 if (ctx
->Multisample
.SampleMask
== state
)
1021 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
1022 ctx
->Multisample
.SampleMask
= state
;
1026 goto invalid_enum_error
;
1029 if (ctx
->Driver
.Enable
) {
1030 ctx
->Driver
.Enable( ctx
, cap
, state
);
1036 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1037 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
1042 * Enable GL capability. Called by glEnable()
1043 * \param cap state to enable.
1046 _mesa_Enable( GLenum cap
)
1048 GET_CURRENT_CONTEXT(ctx
);
1050 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1055 * Disable GL capability. Called by glDisable()
1056 * \param cap state to disable.
1059 _mesa_Disable( GLenum cap
)
1061 GET_CURRENT_CONTEXT(ctx
);
1063 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1069 * Enable/disable an indexed state var.
1072 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1073 GLuint index
, GLboolean state
)
1075 ASSERT(state
== 0 || state
== 1);
1078 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1079 goto invalid_enum_error
;
1081 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1082 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1083 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1086 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1087 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1089 ctx
->Color
.BlendEnabled
|= (1 << index
);
1091 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1095 goto invalid_enum_error
;
1100 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1101 state
? "glEnablei" : "glDisablei",
1102 _mesa_lookup_enum_by_nr(cap
));
1107 _mesa_Disablei( GLenum cap
, GLuint index
)
1109 GET_CURRENT_CONTEXT(ctx
);
1110 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1115 _mesa_Enablei( GLenum cap
, GLuint index
)
1117 GET_CURRENT_CONTEXT(ctx
);
1118 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1122 GLboolean GLAPIENTRY
1123 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1125 GET_CURRENT_CONTEXT(ctx
);
1126 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1129 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1130 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1134 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1136 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1137 _mesa_lookup_enum_by_nr(cap
));
1145 #undef CHECK_EXTENSION
1146 #define CHECK_EXTENSION(EXTNAME) \
1147 if (!ctx->Extensions.EXTNAME) { \
1148 goto invalid_enum_error; \
1151 #undef CHECK_EXTENSION2
1152 #define CHECK_EXTENSION2(EXT1, EXT2) \
1153 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1154 goto invalid_enum_error; \
1159 * Helper function to determine whether a texture target is enabled.
1162 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1164 const struct gl_texture_unit
*const texUnit
=
1165 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1166 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1171 * Return simple enable/disable state.
1173 * \param cap state variable to query.
1175 * Returns the state of the specified capability from the current GL context.
1176 * For the capabilities associated with extensions verifies that those
1177 * extensions are effectively present before reporting.
1179 GLboolean GLAPIENTRY
1180 _mesa_IsEnabled( GLenum cap
)
1182 GET_CURRENT_CONTEXT(ctx
);
1183 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1187 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1188 goto invalid_enum_error
;
1189 return ctx
->Color
.AlphaEnabled
;
1190 case GL_AUTO_NORMAL
:
1191 if (ctx
->API
!= API_OPENGL_COMPAT
)
1192 goto invalid_enum_error
;
1193 return ctx
->Eval
.AutoNormal
;
1195 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1196 case GL_CLIP_DISTANCE0
:
1197 case GL_CLIP_DISTANCE1
:
1198 case GL_CLIP_DISTANCE2
:
1199 case GL_CLIP_DISTANCE3
:
1200 case GL_CLIP_DISTANCE4
:
1201 case GL_CLIP_DISTANCE5
:
1202 case GL_CLIP_DISTANCE6
:
1203 case GL_CLIP_DISTANCE7
: {
1204 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1206 if (p
>= ctx
->Const
.MaxClipPlanes
)
1207 goto invalid_enum_error
;
1209 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1211 case GL_COLOR_MATERIAL
:
1212 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1213 goto invalid_enum_error
;
1214 return ctx
->Light
.ColorMaterialEnabled
;
1216 return ctx
->Polygon
.CullFlag
;
1217 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1218 if (!_mesa_is_desktop_gl(ctx
))
1219 goto invalid_enum_error
;
1220 return ctx
->Debug
.SyncOutput
;
1222 return ctx
->Depth
.Test
;
1224 return ctx
->Color
.DitherFlag
;
1226 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1227 goto invalid_enum_error
;
1228 return ctx
->Fog
.Enabled
;
1230 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1231 goto invalid_enum_error
;
1232 return ctx
->Light
.Enabled
;
1241 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1242 goto invalid_enum_error
;
1243 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1244 case GL_LINE_SMOOTH
:
1245 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1246 goto invalid_enum_error
;
1247 return ctx
->Line
.SmoothFlag
;
1248 case GL_LINE_STIPPLE
:
1249 if (ctx
->API
!= API_OPENGL_COMPAT
)
1250 goto invalid_enum_error
;
1251 return ctx
->Line
.StippleFlag
;
1252 case GL_INDEX_LOGIC_OP
:
1253 if (ctx
->API
!= API_OPENGL_COMPAT
)
1254 goto invalid_enum_error
;
1255 return ctx
->Color
.IndexLogicOpEnabled
;
1256 case GL_COLOR_LOGIC_OP
:
1257 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1258 goto invalid_enum_error
;
1259 return ctx
->Color
.ColorLogicOpEnabled
;
1260 case GL_MAP1_COLOR_4
:
1261 if (ctx
->API
!= API_OPENGL_COMPAT
)
1262 goto invalid_enum_error
;
1263 return ctx
->Eval
.Map1Color4
;
1265 if (ctx
->API
!= API_OPENGL_COMPAT
)
1266 goto invalid_enum_error
;
1267 return ctx
->Eval
.Map1Index
;
1268 case GL_MAP1_NORMAL
:
1269 if (ctx
->API
!= API_OPENGL_COMPAT
)
1270 goto invalid_enum_error
;
1271 return ctx
->Eval
.Map1Normal
;
1272 case GL_MAP1_TEXTURE_COORD_1
:
1273 if (ctx
->API
!= API_OPENGL_COMPAT
)
1274 goto invalid_enum_error
;
1275 return ctx
->Eval
.Map1TextureCoord1
;
1276 case GL_MAP1_TEXTURE_COORD_2
:
1277 if (ctx
->API
!= API_OPENGL_COMPAT
)
1278 goto invalid_enum_error
;
1279 return ctx
->Eval
.Map1TextureCoord2
;
1280 case GL_MAP1_TEXTURE_COORD_3
:
1281 if (ctx
->API
!= API_OPENGL_COMPAT
)
1282 goto invalid_enum_error
;
1283 return ctx
->Eval
.Map1TextureCoord3
;
1284 case GL_MAP1_TEXTURE_COORD_4
:
1285 if (ctx
->API
!= API_OPENGL_COMPAT
)
1286 goto invalid_enum_error
;
1287 return ctx
->Eval
.Map1TextureCoord4
;
1288 case GL_MAP1_VERTEX_3
:
1289 if (ctx
->API
!= API_OPENGL_COMPAT
)
1290 goto invalid_enum_error
;
1291 return ctx
->Eval
.Map1Vertex3
;
1292 case GL_MAP1_VERTEX_4
:
1293 if (ctx
->API
!= API_OPENGL_COMPAT
)
1294 goto invalid_enum_error
;
1295 return ctx
->Eval
.Map1Vertex4
;
1296 case GL_MAP2_COLOR_4
:
1297 if (ctx
->API
!= API_OPENGL_COMPAT
)
1298 goto invalid_enum_error
;
1299 return ctx
->Eval
.Map2Color4
;
1301 if (ctx
->API
!= API_OPENGL_COMPAT
)
1302 goto invalid_enum_error
;
1303 return ctx
->Eval
.Map2Index
;
1304 case GL_MAP2_NORMAL
:
1305 if (ctx
->API
!= API_OPENGL_COMPAT
)
1306 goto invalid_enum_error
;
1307 return ctx
->Eval
.Map2Normal
;
1308 case GL_MAP2_TEXTURE_COORD_1
:
1309 if (ctx
->API
!= API_OPENGL_COMPAT
)
1310 goto invalid_enum_error
;
1311 return ctx
->Eval
.Map2TextureCoord1
;
1312 case GL_MAP2_TEXTURE_COORD_2
:
1313 if (ctx
->API
!= API_OPENGL_COMPAT
)
1314 goto invalid_enum_error
;
1315 return ctx
->Eval
.Map2TextureCoord2
;
1316 case GL_MAP2_TEXTURE_COORD_3
:
1317 if (ctx
->API
!= API_OPENGL_COMPAT
)
1318 goto invalid_enum_error
;
1319 return ctx
->Eval
.Map2TextureCoord3
;
1320 case GL_MAP2_TEXTURE_COORD_4
:
1321 if (ctx
->API
!= API_OPENGL_COMPAT
)
1322 goto invalid_enum_error
;
1323 return ctx
->Eval
.Map2TextureCoord4
;
1324 case GL_MAP2_VERTEX_3
:
1325 if (ctx
->API
!= API_OPENGL_COMPAT
)
1326 goto invalid_enum_error
;
1327 return ctx
->Eval
.Map2Vertex3
;
1328 case GL_MAP2_VERTEX_4
:
1329 if (ctx
->API
!= API_OPENGL_COMPAT
)
1330 goto invalid_enum_error
;
1331 return ctx
->Eval
.Map2Vertex4
;
1333 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1334 goto invalid_enum_error
;
1335 return ctx
->Transform
.Normalize
;
1336 case GL_POINT_SMOOTH
:
1337 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1338 goto invalid_enum_error
;
1339 return ctx
->Point
.SmoothFlag
;
1340 case GL_POLYGON_SMOOTH
:
1341 if (!_mesa_is_desktop_gl(ctx
))
1342 goto invalid_enum_error
;
1343 return ctx
->Polygon
.SmoothFlag
;
1344 case GL_POLYGON_STIPPLE
:
1345 if (ctx
->API
!= API_OPENGL_COMPAT
)
1346 goto invalid_enum_error
;
1347 return ctx
->Polygon
.StippleFlag
;
1348 case GL_POLYGON_OFFSET_POINT
:
1349 if (!_mesa_is_desktop_gl(ctx
))
1350 goto invalid_enum_error
;
1351 return ctx
->Polygon
.OffsetPoint
;
1352 case GL_POLYGON_OFFSET_LINE
:
1353 if (!_mesa_is_desktop_gl(ctx
))
1354 goto invalid_enum_error
;
1355 return ctx
->Polygon
.OffsetLine
;
1356 case GL_POLYGON_OFFSET_FILL
:
1357 return ctx
->Polygon
.OffsetFill
;
1358 case GL_RESCALE_NORMAL_EXT
:
1359 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1360 goto invalid_enum_error
;
1361 return ctx
->Transform
.RescaleNormals
;
1362 case GL_SCISSOR_TEST
:
1363 return ctx
->Scissor
.Enabled
;
1364 case GL_STENCIL_TEST
:
1365 return ctx
->Stencil
.Enabled
;
1367 if (ctx
->API
!= API_OPENGL_COMPAT
)
1368 goto invalid_enum_error
;
1369 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1371 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1372 goto invalid_enum_error
;
1373 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1375 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1376 goto invalid_enum_error
;
1377 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1378 case GL_TEXTURE_GEN_S
:
1379 case GL_TEXTURE_GEN_T
:
1380 case GL_TEXTURE_GEN_R
:
1381 case GL_TEXTURE_GEN_Q
:
1383 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1385 if (ctx
->API
!= API_OPENGL_COMPAT
)
1386 goto invalid_enum_error
;
1389 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1390 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1394 case GL_TEXTURE_GEN_STR_OES
:
1396 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1398 if (ctx
->API
!= API_OPENGLES
)
1399 goto invalid_enum_error
;
1402 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1403 ? GL_TRUE
: GL_FALSE
;
1407 /* client-side state */
1408 case GL_VERTEX_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_POS
].Enabled
!= 0);
1412 case GL_NORMAL_ARRAY
:
1413 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1414 goto invalid_enum_error
;
1415 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1416 case GL_COLOR_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_COLOR0
].Enabled
!= 0);
1420 case GL_INDEX_ARRAY
:
1421 if (ctx
->API
!= API_OPENGL_COMPAT
)
1422 goto invalid_enum_error
;
1423 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1424 case GL_TEXTURE_COORD_ARRAY
:
1425 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1426 goto invalid_enum_error
;
1427 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1429 case GL_EDGE_FLAG_ARRAY
:
1430 if (ctx
->API
!= API_OPENGL_COMPAT
)
1431 goto invalid_enum_error
;
1432 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1433 case GL_FOG_COORDINATE_ARRAY_EXT
:
1434 if (ctx
->API
!= API_OPENGL_COMPAT
)
1435 goto invalid_enum_error
;
1436 CHECK_EXTENSION(EXT_fog_coord
);
1437 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1438 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1439 if (ctx
->API
!= API_OPENGL_COMPAT
)
1440 goto invalid_enum_error
;
1441 CHECK_EXTENSION(EXT_secondary_color
);
1442 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1443 case GL_POINT_SIZE_ARRAY_OES
:
1444 if (ctx
->API
!= API_OPENGLES
)
1445 goto invalid_enum_error
;
1446 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1448 /* GL_ARB_texture_cube_map */
1449 case GL_TEXTURE_CUBE_MAP_ARB
:
1450 CHECK_EXTENSION(ARB_texture_cube_map
);
1451 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1453 /* GL_EXT_secondary_color */
1454 case GL_COLOR_SUM_EXT
:
1455 if (ctx
->API
!= API_OPENGL_COMPAT
)
1456 goto invalid_enum_error
;
1457 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1458 return ctx
->Fog
.ColorSumEnabled
;
1460 /* GL_ARB_multisample */
1461 case GL_MULTISAMPLE_ARB
:
1462 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1463 goto invalid_enum_error
;
1464 return ctx
->Multisample
.Enabled
;
1465 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1466 return ctx
->Multisample
.SampleAlphaToCoverage
;
1467 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1468 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1469 goto invalid_enum_error
;
1470 return ctx
->Multisample
.SampleAlphaToOne
;
1471 case GL_SAMPLE_COVERAGE_ARB
:
1472 return ctx
->Multisample
.SampleCoverage
;
1473 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1474 if (!_mesa_is_desktop_gl(ctx
))
1475 goto invalid_enum_error
;
1476 return ctx
->Multisample
.SampleCoverageInvert
;
1478 /* GL_IBM_rasterpos_clip */
1479 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1480 if (ctx
->API
!= API_OPENGL_COMPAT
)
1481 goto invalid_enum_error
;
1482 return ctx
->Transform
.RasterPositionUnclipped
;
1484 /* GL_NV_point_sprite */
1485 case GL_POINT_SPRITE_NV
:
1486 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1487 goto invalid_enum_error
;
1488 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1489 return ctx
->Point
.PointSprite
;
1491 case GL_VERTEX_PROGRAM_ARB
:
1492 if (ctx
->API
!= API_OPENGL_COMPAT
)
1493 goto invalid_enum_error
;
1494 CHECK_EXTENSION(ARB_vertex_program
);
1495 return ctx
->VertexProgram
.Enabled
;
1496 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1497 /* This was added with ARB_vertex_program, but it is also used with
1498 * GLSL vertex shaders on desktop.
1500 if (!_mesa_is_desktop_gl(ctx
))
1501 goto invalid_enum_error
;
1502 CHECK_EXTENSION(ARB_vertex_program
);
1503 return ctx
->VertexProgram
.PointSizeEnabled
;
1504 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1505 if (ctx
->API
!= API_OPENGL_COMPAT
)
1506 goto invalid_enum_error
;
1507 CHECK_EXTENSION(ARB_vertex_program
);
1508 return ctx
->VertexProgram
.TwoSideEnabled
;
1510 /* GL_NV_texture_rectangle */
1511 case GL_TEXTURE_RECTANGLE_NV
:
1512 if (ctx
->API
!= API_OPENGL_COMPAT
)
1513 goto invalid_enum_error
;
1514 CHECK_EXTENSION(NV_texture_rectangle
);
1515 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1517 /* GL_EXT_stencil_two_side */
1518 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1519 if (ctx
->API
!= API_OPENGL_COMPAT
)
1520 goto invalid_enum_error
;
1521 CHECK_EXTENSION(EXT_stencil_two_side
);
1522 return ctx
->Stencil
.TestTwoSide
;
1524 case GL_FRAGMENT_PROGRAM_ARB
:
1525 if (ctx
->API
!= API_OPENGL_COMPAT
)
1526 goto invalid_enum_error
;
1527 return ctx
->FragmentProgram
.Enabled
;
1529 /* GL_EXT_depth_bounds_test */
1530 case GL_DEPTH_BOUNDS_TEST_EXT
:
1531 if (!_mesa_is_desktop_gl(ctx
))
1532 goto invalid_enum_error
;
1533 CHECK_EXTENSION(EXT_depth_bounds_test
);
1534 return ctx
->Depth
.BoundsTest
;
1536 /* GL_ARB_depth_clamp */
1537 case GL_DEPTH_CLAMP
:
1538 if (!_mesa_is_desktop_gl(ctx
))
1539 goto invalid_enum_error
;
1540 CHECK_EXTENSION(ARB_depth_clamp
);
1541 return ctx
->Transform
.DepthClamp
;
1543 case GL_FRAGMENT_SHADER_ATI
:
1544 if (ctx
->API
!= API_OPENGL_COMPAT
)
1545 goto invalid_enum_error
;
1546 CHECK_EXTENSION(ATI_fragment_shader
);
1547 return ctx
->ATIFragmentShader
.Enabled
;
1549 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1550 if (!_mesa_is_desktop_gl(ctx
))
1551 goto invalid_enum_error
;
1552 CHECK_EXTENSION(ARB_seamless_cube_map
);
1553 return ctx
->Texture
.CubeMapSeamless
;
1555 case GL_RASTERIZER_DISCARD
:
1556 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1557 goto invalid_enum_error
;
1558 CHECK_EXTENSION(EXT_transform_feedback
);
1559 return ctx
->RasterDiscard
;
1561 /* GL_NV_primitive_restart */
1562 case GL_PRIMITIVE_RESTART_NV
:
1563 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1564 goto invalid_enum_error
;
1566 return ctx
->Array
.PrimitiveRestart
;
1568 /* GL 3.1 primitive restart */
1569 case GL_PRIMITIVE_RESTART
:
1570 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1571 goto invalid_enum_error
;
1573 return ctx
->Array
.PrimitiveRestart
;
1575 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1576 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1577 goto invalid_enum_error
;
1579 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1581 /* GL3.0 - GL_framebuffer_sRGB */
1582 case GL_FRAMEBUFFER_SRGB_EXT
:
1583 if (!_mesa_is_desktop_gl(ctx
))
1584 goto invalid_enum_error
;
1585 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1586 return ctx
->Color
.sRGBEnabled
;
1588 /* GL_OES_EGL_image_external */
1589 case GL_TEXTURE_EXTERNAL_OES
:
1590 if (!_mesa_is_gles(ctx
))
1591 goto invalid_enum_error
;
1592 CHECK_EXTENSION(OES_EGL_image_external
);
1593 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1595 /* ARB_texture_multisample */
1596 case GL_SAMPLE_MASK
:
1597 if (!_mesa_is_desktop_gl(ctx
))
1598 goto invalid_enum_error
;
1599 CHECK_EXTENSION(ARB_texture_multisample
);
1600 return ctx
->Multisample
.SampleMask
;
1603 goto invalid_enum_error
;
1609 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1610 _mesa_lookup_enum_by_nr(cap
));