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 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
57 || ctx
->Array
.PrimitiveRestartFixedIndex
;
61 * Helper to enable/disable client-side state.
64 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
66 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
72 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
76 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
77 flag
= VERT_BIT_NORMAL
;
80 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
81 flag
= VERT_BIT_COLOR0
;
84 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
85 flag
= VERT_BIT_COLOR_INDEX
;
87 case GL_TEXTURE_COORD_ARRAY
:
88 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
89 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
91 case GL_EDGE_FLAG_ARRAY
:
92 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
93 flag
= VERT_BIT_EDGEFLAG
;
95 case GL_FOG_COORDINATE_ARRAY_EXT
:
96 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
99 case GL_SECONDARY_COLOR_ARRAY_EXT
:
100 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
101 flag
= VERT_BIT_COLOR1
;
104 case GL_POINT_SIZE_ARRAY_OES
:
105 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
106 flag
= VERT_BIT_POINT_SIZE
;
109 /* GL_NV_primitive_restart */
110 case GL_PRIMITIVE_RESTART_NV
:
111 if (!ctx
->Extensions
.NV_primitive_restart
) {
112 goto invalid_enum_error
;
114 var
= &ctx
->Array
.PrimitiveRestart
;
119 goto invalid_enum_error
;
125 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
127 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
131 update_derived_primitive_restart_state(ctx
);
134 arrayObj
->_Enabled
|= flag
;
136 arrayObj
->_Enabled
&= ~flag
;
138 if (ctx
->Driver
.Enable
) {
139 ctx
->Driver
.Enable( ctx
, cap
, state
);
145 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
146 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
151 * Enable GL capability.
152 * \param cap state to enable/disable.
154 * Get's the current context, assures that we're outside glBegin()/glEnd() and
155 * calls client_state().
158 _mesa_EnableClientState( GLenum cap
)
160 GET_CURRENT_CONTEXT(ctx
);
161 client_state( ctx
, cap
, GL_TRUE
);
166 * Disable GL capability.
167 * \param cap state to enable/disable.
169 * Get's the current context, assures that we're outside glBegin()/glEnd() and
170 * calls client_state().
173 _mesa_DisableClientState( GLenum cap
)
175 GET_CURRENT_CONTEXT(ctx
);
176 client_state( ctx
, cap
, GL_FALSE
);
180 #undef CHECK_EXTENSION
181 #define CHECK_EXTENSION(EXTNAME, CAP) \
182 if (!ctx->Extensions.EXTNAME) { \
183 goto invalid_enum_error; \
186 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
187 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
188 goto invalid_enum_error; \
192 * Return pointer to current texture unit for setting/getting coordinate
194 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
195 * texture unit is higher than the number of supported coordinate units.
197 static struct gl_texture_unit
*
198 get_texcoord_unit(struct gl_context
*ctx
)
200 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
201 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
205 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
211 * Helper function to enable or disable a texture target.
212 * \param bit one of the TEXTURE_x_BIT values
213 * \return GL_TRUE if state is changing or GL_FALSE if no change
216 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
218 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
219 const GLbitfield newenabled
= state
220 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
222 if (texUnit
->Enabled
== newenabled
)
225 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
226 texUnit
->Enabled
= newenabled
;
232 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
233 * whether the API supports it (GLES doesn't).
236 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
238 if (ctx
->Multisample
.Enabled
== state
)
240 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
241 ctx
->Multisample
.Enabled
= state
;
243 if (ctx
->Driver
.Enable
) {
244 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
249 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
250 * check for whether the API supports it (GLES doesn't).
253 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
255 if (ctx
->Color
.sRGBEnabled
== state
)
257 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
258 ctx
->Color
.sRGBEnabled
= state
;
260 if (ctx
->Driver
.Enable
) {
261 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
266 * Helper function to enable or disable state.
268 * \param ctx GL context.
269 * \param cap the state to enable/disable
270 * \param state whether to enable or disable the specified capability.
272 * Updates the current context and flushes the vertices as needed. For
273 * capabilities associated with extensions it verifies that those extensions
274 * are effectivly present before updating. Notifies the driver via
275 * dd_function_table::Enable.
278 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
280 if (MESA_VERBOSE
& VERBOSE_API
)
281 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
282 state
? "glEnable" : "glDisable",
283 _mesa_lookup_enum_by_nr(cap
),
288 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
289 goto invalid_enum_error
;
290 if (ctx
->Color
.AlphaEnabled
== state
)
292 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
293 ctx
->Color
.AlphaEnabled
= state
;
296 if (ctx
->API
!= API_OPENGL_COMPAT
)
297 goto invalid_enum_error
;
298 if (ctx
->Eval
.AutoNormal
== state
)
300 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
301 ctx
->Eval
.AutoNormal
= state
;
305 GLbitfield newEnabled
=
306 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
307 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
308 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
309 ctx
->Color
.BlendEnabled
= newEnabled
;
313 case GL_CLIP_DISTANCE0
:
314 case GL_CLIP_DISTANCE1
:
315 case GL_CLIP_DISTANCE2
:
316 case GL_CLIP_DISTANCE3
:
317 case GL_CLIP_DISTANCE4
:
318 case GL_CLIP_DISTANCE5
:
319 case GL_CLIP_DISTANCE6
:
320 case GL_CLIP_DISTANCE7
:
322 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
324 if (p
>= ctx
->Const
.MaxClipPlanes
)
325 goto invalid_enum_error
;
327 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
328 == ((GLuint
) state
<< p
))
331 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
334 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
335 _mesa_update_clip_plane(ctx
, p
);
338 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
342 case GL_COLOR_MATERIAL
:
343 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
344 goto invalid_enum_error
;
345 if (ctx
->Light
.ColorMaterialEnabled
== state
)
347 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
348 FLUSH_CURRENT(ctx
, 0);
349 ctx
->Light
.ColorMaterialEnabled
= state
;
351 _mesa_update_color_material( ctx
,
352 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
356 if (ctx
->Polygon
.CullFlag
== state
)
358 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
359 ctx
->Polygon
.CullFlag
= state
;
362 if (ctx
->Depth
.Test
== state
)
364 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
365 ctx
->Depth
.Test
= state
;
367 case GL_DEBUG_OUTPUT
:
368 if (!_mesa_is_desktop_gl(ctx
))
369 goto invalid_enum_error
;
370 ctx
->Debug
.DebugOutput
= 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_EXTENSION(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
:
1210 if (!_mesa_is_desktop_gl(ctx
))
1211 goto invalid_enum_error
;
1212 return ctx
->Debug
.DebugOutput
;
1213 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1214 if (!_mesa_is_desktop_gl(ctx
))
1215 goto invalid_enum_error
;
1216 return ctx
->Debug
.SyncOutput
;
1218 return ctx
->Depth
.Test
;
1220 return ctx
->Color
.DitherFlag
;
1222 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1223 goto invalid_enum_error
;
1224 return ctx
->Fog
.Enabled
;
1226 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1227 goto invalid_enum_error
;
1228 return ctx
->Light
.Enabled
;
1237 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1238 goto invalid_enum_error
;
1239 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1240 case GL_LINE_SMOOTH
:
1241 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1242 goto invalid_enum_error
;
1243 return ctx
->Line
.SmoothFlag
;
1244 case GL_LINE_STIPPLE
:
1245 if (ctx
->API
!= API_OPENGL_COMPAT
)
1246 goto invalid_enum_error
;
1247 return ctx
->Line
.StippleFlag
;
1248 case GL_INDEX_LOGIC_OP
:
1249 if (ctx
->API
!= API_OPENGL_COMPAT
)
1250 goto invalid_enum_error
;
1251 return ctx
->Color
.IndexLogicOpEnabled
;
1252 case GL_COLOR_LOGIC_OP
:
1253 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1254 goto invalid_enum_error
;
1255 return ctx
->Color
.ColorLogicOpEnabled
;
1256 case GL_MAP1_COLOR_4
:
1257 if (ctx
->API
!= API_OPENGL_COMPAT
)
1258 goto invalid_enum_error
;
1259 return ctx
->Eval
.Map1Color4
;
1261 if (ctx
->API
!= API_OPENGL_COMPAT
)
1262 goto invalid_enum_error
;
1263 return ctx
->Eval
.Map1Index
;
1264 case GL_MAP1_NORMAL
:
1265 if (ctx
->API
!= API_OPENGL_COMPAT
)
1266 goto invalid_enum_error
;
1267 return ctx
->Eval
.Map1Normal
;
1268 case GL_MAP1_TEXTURE_COORD_1
:
1269 if (ctx
->API
!= API_OPENGL_COMPAT
)
1270 goto invalid_enum_error
;
1271 return ctx
->Eval
.Map1TextureCoord1
;
1272 case GL_MAP1_TEXTURE_COORD_2
:
1273 if (ctx
->API
!= API_OPENGL_COMPAT
)
1274 goto invalid_enum_error
;
1275 return ctx
->Eval
.Map1TextureCoord2
;
1276 case GL_MAP1_TEXTURE_COORD_3
:
1277 if (ctx
->API
!= API_OPENGL_COMPAT
)
1278 goto invalid_enum_error
;
1279 return ctx
->Eval
.Map1TextureCoord3
;
1280 case GL_MAP1_TEXTURE_COORD_4
:
1281 if (ctx
->API
!= API_OPENGL_COMPAT
)
1282 goto invalid_enum_error
;
1283 return ctx
->Eval
.Map1TextureCoord4
;
1284 case GL_MAP1_VERTEX_3
:
1285 if (ctx
->API
!= API_OPENGL_COMPAT
)
1286 goto invalid_enum_error
;
1287 return ctx
->Eval
.Map1Vertex3
;
1288 case GL_MAP1_VERTEX_4
:
1289 if (ctx
->API
!= API_OPENGL_COMPAT
)
1290 goto invalid_enum_error
;
1291 return ctx
->Eval
.Map1Vertex4
;
1292 case GL_MAP2_COLOR_4
:
1293 if (ctx
->API
!= API_OPENGL_COMPAT
)
1294 goto invalid_enum_error
;
1295 return ctx
->Eval
.Map2Color4
;
1297 if (ctx
->API
!= API_OPENGL_COMPAT
)
1298 goto invalid_enum_error
;
1299 return ctx
->Eval
.Map2Index
;
1300 case GL_MAP2_NORMAL
:
1301 if (ctx
->API
!= API_OPENGL_COMPAT
)
1302 goto invalid_enum_error
;
1303 return ctx
->Eval
.Map2Normal
;
1304 case GL_MAP2_TEXTURE_COORD_1
:
1305 if (ctx
->API
!= API_OPENGL_COMPAT
)
1306 goto invalid_enum_error
;
1307 return ctx
->Eval
.Map2TextureCoord1
;
1308 case GL_MAP2_TEXTURE_COORD_2
:
1309 if (ctx
->API
!= API_OPENGL_COMPAT
)
1310 goto invalid_enum_error
;
1311 return ctx
->Eval
.Map2TextureCoord2
;
1312 case GL_MAP2_TEXTURE_COORD_3
:
1313 if (ctx
->API
!= API_OPENGL_COMPAT
)
1314 goto invalid_enum_error
;
1315 return ctx
->Eval
.Map2TextureCoord3
;
1316 case GL_MAP2_TEXTURE_COORD_4
:
1317 if (ctx
->API
!= API_OPENGL_COMPAT
)
1318 goto invalid_enum_error
;
1319 return ctx
->Eval
.Map2TextureCoord4
;
1320 case GL_MAP2_VERTEX_3
:
1321 if (ctx
->API
!= API_OPENGL_COMPAT
)
1322 goto invalid_enum_error
;
1323 return ctx
->Eval
.Map2Vertex3
;
1324 case GL_MAP2_VERTEX_4
:
1325 if (ctx
->API
!= API_OPENGL_COMPAT
)
1326 goto invalid_enum_error
;
1327 return ctx
->Eval
.Map2Vertex4
;
1329 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1330 goto invalid_enum_error
;
1331 return ctx
->Transform
.Normalize
;
1332 case GL_POINT_SMOOTH
:
1333 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1334 goto invalid_enum_error
;
1335 return ctx
->Point
.SmoothFlag
;
1336 case GL_POLYGON_SMOOTH
:
1337 if (!_mesa_is_desktop_gl(ctx
))
1338 goto invalid_enum_error
;
1339 return ctx
->Polygon
.SmoothFlag
;
1340 case GL_POLYGON_STIPPLE
:
1341 if (ctx
->API
!= API_OPENGL_COMPAT
)
1342 goto invalid_enum_error
;
1343 return ctx
->Polygon
.StippleFlag
;
1344 case GL_POLYGON_OFFSET_POINT
:
1345 if (!_mesa_is_desktop_gl(ctx
))
1346 goto invalid_enum_error
;
1347 return ctx
->Polygon
.OffsetPoint
;
1348 case GL_POLYGON_OFFSET_LINE
:
1349 if (!_mesa_is_desktop_gl(ctx
))
1350 goto invalid_enum_error
;
1351 return ctx
->Polygon
.OffsetLine
;
1352 case GL_POLYGON_OFFSET_FILL
:
1353 return ctx
->Polygon
.OffsetFill
;
1354 case GL_RESCALE_NORMAL_EXT
:
1355 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1356 goto invalid_enum_error
;
1357 return ctx
->Transform
.RescaleNormals
;
1358 case GL_SCISSOR_TEST
:
1359 return ctx
->Scissor
.Enabled
;
1360 case GL_STENCIL_TEST
:
1361 return ctx
->Stencil
.Enabled
;
1363 if (ctx
->API
!= API_OPENGL_COMPAT
)
1364 goto invalid_enum_error
;
1365 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1367 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1368 goto invalid_enum_error
;
1369 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1371 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1372 goto invalid_enum_error
;
1373 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1374 case GL_TEXTURE_GEN_S
:
1375 case GL_TEXTURE_GEN_T
:
1376 case GL_TEXTURE_GEN_R
:
1377 case GL_TEXTURE_GEN_Q
:
1379 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1381 if (ctx
->API
!= API_OPENGL_COMPAT
)
1382 goto invalid_enum_error
;
1385 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1386 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1390 case GL_TEXTURE_GEN_STR_OES
:
1392 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1394 if (ctx
->API
!= API_OPENGLES
)
1395 goto invalid_enum_error
;
1398 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1399 ? GL_TRUE
: GL_FALSE
;
1403 /* client-side state */
1404 case GL_VERTEX_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_POS
].Enabled
;
1408 case GL_NORMAL_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_NORMAL
].Enabled
;
1412 case GL_COLOR_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_COLOR0
].Enabled
;
1416 case GL_INDEX_ARRAY
:
1417 if (ctx
->API
!= API_OPENGL_COMPAT
)
1418 goto invalid_enum_error
;
1419 return ctx
->Array
.ArrayObj
->
1420 VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
1421 case GL_TEXTURE_COORD_ARRAY
:
1422 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1423 goto invalid_enum_error
;
1424 return ctx
->Array
.ArrayObj
->
1425 VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
1426 case GL_EDGE_FLAG_ARRAY
:
1427 if (ctx
->API
!= API_OPENGL_COMPAT
)
1428 goto invalid_enum_error
;
1429 return ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
1430 case GL_FOG_COORDINATE_ARRAY_EXT
:
1431 if (ctx
->API
!= API_OPENGL_COMPAT
)
1432 goto invalid_enum_error
;
1433 return ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
1434 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1435 if (ctx
->API
!= API_OPENGL_COMPAT
)
1436 goto invalid_enum_error
;
1437 return ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
1438 case GL_POINT_SIZE_ARRAY_OES
:
1439 if (ctx
->API
!= API_OPENGLES
)
1440 goto invalid_enum_error
;
1441 return ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
1443 /* GL_ARB_texture_cube_map */
1444 case GL_TEXTURE_CUBE_MAP_ARB
:
1445 CHECK_EXTENSION(ARB_texture_cube_map
);
1446 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1448 /* GL_EXT_secondary_color */
1449 case GL_COLOR_SUM_EXT
:
1450 if (ctx
->API
!= API_OPENGL_COMPAT
)
1451 goto invalid_enum_error
;
1452 CHECK_EXTENSION(ARB_vertex_program
);
1453 return ctx
->Fog
.ColorSumEnabled
;
1455 /* GL_ARB_multisample */
1456 case GL_MULTISAMPLE_ARB
:
1457 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1458 goto invalid_enum_error
;
1459 return ctx
->Multisample
.Enabled
;
1460 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1461 return ctx
->Multisample
.SampleAlphaToCoverage
;
1462 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1463 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1464 goto invalid_enum_error
;
1465 return ctx
->Multisample
.SampleAlphaToOne
;
1466 case GL_SAMPLE_COVERAGE_ARB
:
1467 return ctx
->Multisample
.SampleCoverage
;
1468 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1469 if (!_mesa_is_desktop_gl(ctx
))
1470 goto invalid_enum_error
;
1471 return ctx
->Multisample
.SampleCoverageInvert
;
1473 /* GL_IBM_rasterpos_clip */
1474 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1475 if (ctx
->API
!= API_OPENGL_COMPAT
)
1476 goto invalid_enum_error
;
1477 return ctx
->Transform
.RasterPositionUnclipped
;
1479 /* GL_NV_point_sprite */
1480 case GL_POINT_SPRITE_NV
:
1481 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1482 goto invalid_enum_error
;
1483 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1484 return ctx
->Point
.PointSprite
;
1486 case GL_VERTEX_PROGRAM_ARB
:
1487 if (ctx
->API
!= API_OPENGL_COMPAT
)
1488 goto invalid_enum_error
;
1489 CHECK_EXTENSION(ARB_vertex_program
);
1490 return ctx
->VertexProgram
.Enabled
;
1491 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1492 /* This was added with ARB_vertex_program, but it is also used with
1493 * GLSL vertex shaders on desktop.
1495 if (!_mesa_is_desktop_gl(ctx
))
1496 goto invalid_enum_error
;
1497 CHECK_EXTENSION(ARB_vertex_program
);
1498 return ctx
->VertexProgram
.PointSizeEnabled
;
1499 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1500 if (ctx
->API
!= API_OPENGL_COMPAT
)
1501 goto invalid_enum_error
;
1502 CHECK_EXTENSION(ARB_vertex_program
);
1503 return ctx
->VertexProgram
.TwoSideEnabled
;
1505 /* GL_NV_texture_rectangle */
1506 case GL_TEXTURE_RECTANGLE_NV
:
1507 if (ctx
->API
!= API_OPENGL_COMPAT
)
1508 goto invalid_enum_error
;
1509 CHECK_EXTENSION(NV_texture_rectangle
);
1510 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1512 /* GL_EXT_stencil_two_side */
1513 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1514 if (ctx
->API
!= API_OPENGL_COMPAT
)
1515 goto invalid_enum_error
;
1516 CHECK_EXTENSION(EXT_stencil_two_side
);
1517 return ctx
->Stencil
.TestTwoSide
;
1519 case GL_FRAGMENT_PROGRAM_ARB
:
1520 if (ctx
->API
!= API_OPENGL_COMPAT
)
1521 goto invalid_enum_error
;
1522 return ctx
->FragmentProgram
.Enabled
;
1524 /* GL_EXT_depth_bounds_test */
1525 case GL_DEPTH_BOUNDS_TEST_EXT
:
1526 if (!_mesa_is_desktop_gl(ctx
))
1527 goto invalid_enum_error
;
1528 CHECK_EXTENSION(EXT_depth_bounds_test
);
1529 return ctx
->Depth
.BoundsTest
;
1531 /* GL_ARB_depth_clamp */
1532 case GL_DEPTH_CLAMP
:
1533 if (!_mesa_is_desktop_gl(ctx
))
1534 goto invalid_enum_error
;
1535 CHECK_EXTENSION(ARB_depth_clamp
);
1536 return ctx
->Transform
.DepthClamp
;
1538 case GL_FRAGMENT_SHADER_ATI
:
1539 if (ctx
->API
!= API_OPENGL_COMPAT
)
1540 goto invalid_enum_error
;
1541 CHECK_EXTENSION(ATI_fragment_shader
);
1542 return ctx
->ATIFragmentShader
.Enabled
;
1544 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1545 if (!_mesa_is_desktop_gl(ctx
))
1546 goto invalid_enum_error
;
1547 CHECK_EXTENSION(ARB_seamless_cube_map
);
1548 return ctx
->Texture
.CubeMapSeamless
;
1550 case GL_RASTERIZER_DISCARD
:
1551 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1552 goto invalid_enum_error
;
1553 CHECK_EXTENSION(EXT_transform_feedback
);
1554 return ctx
->RasterDiscard
;
1556 /* GL_NV_primitive_restart */
1557 case GL_PRIMITIVE_RESTART_NV
:
1558 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1559 goto invalid_enum_error
;
1561 return ctx
->Array
.PrimitiveRestart
;
1563 /* GL 3.1 primitive restart */
1564 case GL_PRIMITIVE_RESTART
:
1565 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1566 goto invalid_enum_error
;
1568 return ctx
->Array
.PrimitiveRestart
;
1570 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1571 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1572 goto invalid_enum_error
;
1574 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1576 /* GL3.0 - GL_framebuffer_sRGB */
1577 case GL_FRAMEBUFFER_SRGB_EXT
:
1578 if (!_mesa_is_desktop_gl(ctx
))
1579 goto invalid_enum_error
;
1580 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1581 return ctx
->Color
.sRGBEnabled
;
1583 /* GL_OES_EGL_image_external */
1584 case GL_TEXTURE_EXTERNAL_OES
:
1585 if (!_mesa_is_gles(ctx
))
1586 goto invalid_enum_error
;
1587 CHECK_EXTENSION(OES_EGL_image_external
);
1588 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1590 /* ARB_texture_multisample */
1591 case GL_SAMPLE_MASK
:
1592 if (!_mesa_is_desktop_gl(ctx
))
1593 goto invalid_enum_error
;
1594 CHECK_EXTENSION(ARB_texture_multisample
);
1595 return ctx
->Multisample
.SampleMask
;
1598 goto invalid_enum_error
;
1604 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1605 _mesa_lookup_enum_by_nr(cap
));