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.
34 #include "debug_output.h"
38 #include "util/simple_list.h"
41 #include "api_arrayelt.h"
46 #define CHECK_EXTENSION(EXTNAME, CAP) \
47 if (!ctx->Extensions.EXTNAME) { \
48 goto invalid_enum_error; \
53 update_derived_primitive_restart_state(struct gl_context
*ctx
)
55 /* Update derived primitive restart state.
57 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
58 || ctx
->Array
.PrimitiveRestartFixedIndex
;
62 * Helper to enable/disable client-side state.
65 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
67 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
73 var
= &vao
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
77 var
= &vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
78 flag
= VERT_BIT_NORMAL
;
81 var
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
82 flag
= VERT_BIT_COLOR0
;
85 var
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
86 flag
= VERT_BIT_COLOR_INDEX
;
88 case GL_TEXTURE_COORD_ARRAY
:
89 var
= &vao
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
90 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
92 case GL_EDGE_FLAG_ARRAY
:
93 var
= &vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
94 flag
= VERT_BIT_EDGEFLAG
;
96 case GL_FOG_COORDINATE_ARRAY_EXT
:
97 var
= &vao
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
100 case GL_SECONDARY_COLOR_ARRAY_EXT
:
101 var
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
102 flag
= VERT_BIT_COLOR1
;
105 case GL_POINT_SIZE_ARRAY_OES
:
106 var
= &vao
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
107 flag
= VERT_BIT_POINT_SIZE
;
108 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
109 ctx
->VertexProgram
.PointSizeEnabled
= state
;
112 /* GL_NV_primitive_restart */
113 case GL_PRIMITIVE_RESTART_NV
:
114 if (!ctx
->Extensions
.NV_primitive_restart
) {
115 goto invalid_enum_error
;
117 var
= &ctx
->Array
.PrimitiveRestart
;
122 goto invalid_enum_error
;
128 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
130 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
134 update_derived_primitive_restart_state(ctx
);
137 vao
->_Enabled
|= flag
;
139 vao
->_Enabled
&= ~flag
;
141 vao
->NewArrays
|= 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_enum_to_string(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_enum_to_string(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
: /* aka GL_CLIP_PLANE0 */
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
:
373 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
374 _mesa_set_debug_state_int(ctx
, cap
, state
);
377 if (ctx
->Color
.DitherFlag
== state
)
379 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
380 ctx
->Color
.DitherFlag
= state
;
383 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
384 goto invalid_enum_error
;
385 if (ctx
->Fog
.Enabled
== state
)
387 FLUSH_VERTICES(ctx
, _NEW_FOG
);
388 ctx
->Fog
.Enabled
= state
;
398 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
399 goto invalid_enum_error
;
400 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
402 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
403 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
405 insert_at_tail(&ctx
->Light
.EnabledList
,
406 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
409 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
413 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
414 goto invalid_enum_error
;
415 if (ctx
->Light
.Enabled
== state
)
417 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
418 ctx
->Light
.Enabled
= state
;
421 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
422 goto invalid_enum_error
;
423 if (ctx
->Line
.SmoothFlag
== state
)
425 FLUSH_VERTICES(ctx
, _NEW_LINE
);
426 ctx
->Line
.SmoothFlag
= state
;
428 case GL_LINE_STIPPLE
:
429 if (ctx
->API
!= API_OPENGL_COMPAT
)
430 goto invalid_enum_error
;
431 if (ctx
->Line
.StippleFlag
== state
)
433 FLUSH_VERTICES(ctx
, _NEW_LINE
);
434 ctx
->Line
.StippleFlag
= state
;
436 case GL_INDEX_LOGIC_OP
:
437 if (ctx
->API
!= API_OPENGL_COMPAT
)
438 goto invalid_enum_error
;
439 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
441 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
442 ctx
->Color
.IndexLogicOpEnabled
= state
;
444 case GL_COLOR_LOGIC_OP
:
445 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
446 goto invalid_enum_error
;
447 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
449 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
450 ctx
->Color
.ColorLogicOpEnabled
= state
;
452 case GL_MAP1_COLOR_4
:
453 if (ctx
->API
!= API_OPENGL_COMPAT
)
454 goto invalid_enum_error
;
455 if (ctx
->Eval
.Map1Color4
== state
)
457 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
458 ctx
->Eval
.Map1Color4
= state
;
461 if (ctx
->API
!= API_OPENGL_COMPAT
)
462 goto invalid_enum_error
;
463 if (ctx
->Eval
.Map1Index
== state
)
465 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
466 ctx
->Eval
.Map1Index
= state
;
469 if (ctx
->API
!= API_OPENGL_COMPAT
)
470 goto invalid_enum_error
;
471 if (ctx
->Eval
.Map1Normal
== state
)
473 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
474 ctx
->Eval
.Map1Normal
= state
;
476 case GL_MAP1_TEXTURE_COORD_1
:
477 if (ctx
->API
!= API_OPENGL_COMPAT
)
478 goto invalid_enum_error
;
479 if (ctx
->Eval
.Map1TextureCoord1
== state
)
481 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
482 ctx
->Eval
.Map1TextureCoord1
= state
;
484 case GL_MAP1_TEXTURE_COORD_2
:
485 if (ctx
->API
!= API_OPENGL_COMPAT
)
486 goto invalid_enum_error
;
487 if (ctx
->Eval
.Map1TextureCoord2
== state
)
489 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
490 ctx
->Eval
.Map1TextureCoord2
= state
;
492 case GL_MAP1_TEXTURE_COORD_3
:
493 if (ctx
->API
!= API_OPENGL_COMPAT
)
494 goto invalid_enum_error
;
495 if (ctx
->Eval
.Map1TextureCoord3
== state
)
497 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
498 ctx
->Eval
.Map1TextureCoord3
= state
;
500 case GL_MAP1_TEXTURE_COORD_4
:
501 if (ctx
->API
!= API_OPENGL_COMPAT
)
502 goto invalid_enum_error
;
503 if (ctx
->Eval
.Map1TextureCoord4
== state
)
505 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
506 ctx
->Eval
.Map1TextureCoord4
= state
;
508 case GL_MAP1_VERTEX_3
:
509 if (ctx
->API
!= API_OPENGL_COMPAT
)
510 goto invalid_enum_error
;
511 if (ctx
->Eval
.Map1Vertex3
== state
)
513 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
514 ctx
->Eval
.Map1Vertex3
= state
;
516 case GL_MAP1_VERTEX_4
:
517 if (ctx
->API
!= API_OPENGL_COMPAT
)
518 goto invalid_enum_error
;
519 if (ctx
->Eval
.Map1Vertex4
== state
)
521 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
522 ctx
->Eval
.Map1Vertex4
= state
;
524 case GL_MAP2_COLOR_4
:
525 if (ctx
->API
!= API_OPENGL_COMPAT
)
526 goto invalid_enum_error
;
527 if (ctx
->Eval
.Map2Color4
== state
)
529 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
530 ctx
->Eval
.Map2Color4
= state
;
533 if (ctx
->API
!= API_OPENGL_COMPAT
)
534 goto invalid_enum_error
;
535 if (ctx
->Eval
.Map2Index
== state
)
537 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
538 ctx
->Eval
.Map2Index
= state
;
541 if (ctx
->API
!= API_OPENGL_COMPAT
)
542 goto invalid_enum_error
;
543 if (ctx
->Eval
.Map2Normal
== state
)
545 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
546 ctx
->Eval
.Map2Normal
= state
;
548 case GL_MAP2_TEXTURE_COORD_1
:
549 if (ctx
->API
!= API_OPENGL_COMPAT
)
550 goto invalid_enum_error
;
551 if (ctx
->Eval
.Map2TextureCoord1
== state
)
553 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
554 ctx
->Eval
.Map2TextureCoord1
= state
;
556 case GL_MAP2_TEXTURE_COORD_2
:
557 if (ctx
->API
!= API_OPENGL_COMPAT
)
558 goto invalid_enum_error
;
559 if (ctx
->Eval
.Map2TextureCoord2
== state
)
561 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
562 ctx
->Eval
.Map2TextureCoord2
= state
;
564 case GL_MAP2_TEXTURE_COORD_3
:
565 if (ctx
->API
!= API_OPENGL_COMPAT
)
566 goto invalid_enum_error
;
567 if (ctx
->Eval
.Map2TextureCoord3
== state
)
569 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
570 ctx
->Eval
.Map2TextureCoord3
= state
;
572 case GL_MAP2_TEXTURE_COORD_4
:
573 if (ctx
->API
!= API_OPENGL_COMPAT
)
574 goto invalid_enum_error
;
575 if (ctx
->Eval
.Map2TextureCoord4
== state
)
577 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
578 ctx
->Eval
.Map2TextureCoord4
= state
;
580 case GL_MAP2_VERTEX_3
:
581 if (ctx
->API
!= API_OPENGL_COMPAT
)
582 goto invalid_enum_error
;
583 if (ctx
->Eval
.Map2Vertex3
== state
)
585 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
586 ctx
->Eval
.Map2Vertex3
= state
;
588 case GL_MAP2_VERTEX_4
:
589 if (ctx
->API
!= API_OPENGL_COMPAT
)
590 goto invalid_enum_error
;
591 if (ctx
->Eval
.Map2Vertex4
== state
)
593 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
594 ctx
->Eval
.Map2Vertex4
= state
;
597 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
598 goto invalid_enum_error
;
599 if (ctx
->Transform
.Normalize
== state
)
601 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
602 ctx
->Transform
.Normalize
= state
;
604 case GL_POINT_SMOOTH
:
605 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
606 goto invalid_enum_error
;
607 if (ctx
->Point
.SmoothFlag
== state
)
609 FLUSH_VERTICES(ctx
, _NEW_POINT
);
610 ctx
->Point
.SmoothFlag
= state
;
612 case GL_POLYGON_SMOOTH
:
613 if (!_mesa_is_desktop_gl(ctx
))
614 goto invalid_enum_error
;
615 if (ctx
->Polygon
.SmoothFlag
== state
)
617 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
618 ctx
->Polygon
.SmoothFlag
= state
;
620 case GL_POLYGON_STIPPLE
:
621 if (ctx
->API
!= API_OPENGL_COMPAT
)
622 goto invalid_enum_error
;
623 if (ctx
->Polygon
.StippleFlag
== state
)
625 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
626 ctx
->Polygon
.StippleFlag
= state
;
628 case GL_POLYGON_OFFSET_POINT
:
629 if (!_mesa_is_desktop_gl(ctx
))
630 goto invalid_enum_error
;
631 if (ctx
->Polygon
.OffsetPoint
== state
)
633 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
634 ctx
->Polygon
.OffsetPoint
= state
;
636 case GL_POLYGON_OFFSET_LINE
:
637 if (!_mesa_is_desktop_gl(ctx
))
638 goto invalid_enum_error
;
639 if (ctx
->Polygon
.OffsetLine
== state
)
641 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
642 ctx
->Polygon
.OffsetLine
= state
;
644 case GL_POLYGON_OFFSET_FILL
:
645 if (ctx
->Polygon
.OffsetFill
== state
)
647 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
648 ctx
->Polygon
.OffsetFill
= state
;
650 case GL_RESCALE_NORMAL_EXT
:
651 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
652 goto invalid_enum_error
;
653 if (ctx
->Transform
.RescaleNormals
== state
)
655 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
656 ctx
->Transform
.RescaleNormals
= state
;
658 case GL_SCISSOR_TEST
:
660 /* Must expand glEnable to all scissors */
661 GLbitfield newEnabled
=
662 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
663 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
664 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
665 ctx
->Scissor
.EnableFlags
= newEnabled
;
669 case GL_STENCIL_TEST
:
670 if (ctx
->Stencil
.Enabled
== state
)
672 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
673 ctx
->Stencil
.Enabled
= state
;
676 if (ctx
->API
!= API_OPENGL_COMPAT
)
677 goto invalid_enum_error
;
678 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
683 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
684 goto invalid_enum_error
;
685 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
690 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
691 goto invalid_enum_error
;
692 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
696 case GL_TEXTURE_GEN_S
:
697 case GL_TEXTURE_GEN_T
:
698 case GL_TEXTURE_GEN_R
:
699 case GL_TEXTURE_GEN_Q
:
701 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
703 if (ctx
->API
!= API_OPENGL_COMPAT
)
704 goto invalid_enum_error
;
707 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
708 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
710 newenabled
|= coordBit
;
711 if (texUnit
->TexGenEnabled
== newenabled
)
713 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
714 texUnit
->TexGenEnabled
= newenabled
;
719 case GL_TEXTURE_GEN_STR_OES
:
720 /* disable S, T, and R at the same time */
722 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
724 if (ctx
->API
!= API_OPENGLES
)
725 goto invalid_enum_error
;
729 texUnit
->TexGenEnabled
& ~STR_BITS
;
731 newenabled
|= STR_BITS
;
732 if (texUnit
->TexGenEnabled
== newenabled
)
734 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
735 texUnit
->TexGenEnabled
= newenabled
;
740 /* client-side state */
741 case GL_VERTEX_ARRAY
:
742 case GL_NORMAL_ARRAY
:
745 case GL_TEXTURE_COORD_ARRAY
:
746 case GL_EDGE_FLAG_ARRAY
:
747 case GL_FOG_COORDINATE_ARRAY_EXT
:
748 case GL_SECONDARY_COLOR_ARRAY_EXT
:
749 case GL_POINT_SIZE_ARRAY_OES
:
750 client_state( ctx
, cap
, state
);
753 /* GL_ARB_texture_cube_map */
754 case GL_TEXTURE_CUBE_MAP
:
755 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
756 goto invalid_enum_error
;
757 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
758 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
763 /* GL_EXT_secondary_color */
764 case GL_COLOR_SUM_EXT
:
765 if (ctx
->API
!= API_OPENGL_COMPAT
)
766 goto invalid_enum_error
;
767 if (ctx
->Fog
.ColorSumEnabled
== state
)
769 FLUSH_VERTICES(ctx
, _NEW_FOG
);
770 ctx
->Fog
.ColorSumEnabled
= state
;
773 /* GL_ARB_multisample */
774 case GL_MULTISAMPLE_ARB
:
775 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
776 goto invalid_enum_error
;
777 _mesa_set_multisample(ctx
, state
);
779 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
780 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
782 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
783 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
785 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
786 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
787 goto invalid_enum_error
;
788 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
790 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
791 ctx
->Multisample
.SampleAlphaToOne
= state
;
793 case GL_SAMPLE_COVERAGE_ARB
:
794 if (ctx
->Multisample
.SampleCoverage
== state
)
796 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
797 ctx
->Multisample
.SampleCoverage
= state
;
799 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
800 if (!_mesa_is_desktop_gl(ctx
))
801 goto invalid_enum_error
;
802 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
804 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
805 ctx
->Multisample
.SampleCoverageInvert
= state
;
808 /* GL_ARB_sample_shading */
809 case GL_SAMPLE_SHADING
:
810 if (!_mesa_is_desktop_gl(ctx
))
811 goto invalid_enum_error
;
812 CHECK_EXTENSION(ARB_sample_shading
, cap
);
813 if (ctx
->Multisample
.SampleShading
== state
)
815 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
816 ctx
->Multisample
.SampleShading
= state
;
819 /* GL_IBM_rasterpos_clip */
820 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
821 if (ctx
->API
!= API_OPENGL_COMPAT
)
822 goto invalid_enum_error
;
823 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
825 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
826 ctx
->Transform
.RasterPositionUnclipped
= state
;
829 /* GL_NV_point_sprite */
830 case GL_POINT_SPRITE_NV
:
831 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
832 goto invalid_enum_error
;
833 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
834 if (ctx
->Point
.PointSprite
== state
)
836 FLUSH_VERTICES(ctx
, _NEW_POINT
);
837 ctx
->Point
.PointSprite
= state
;
840 case GL_VERTEX_PROGRAM_ARB
:
841 if (ctx
->API
!= API_OPENGL_COMPAT
)
842 goto invalid_enum_error
;
843 CHECK_EXTENSION(ARB_vertex_program
, cap
);
844 if (ctx
->VertexProgram
.Enabled
== state
)
846 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
847 ctx
->VertexProgram
.Enabled
= state
;
849 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
850 /* This was added with ARB_vertex_program, but it is also used with
851 * GLSL vertex shaders on desktop.
853 if (!_mesa_is_desktop_gl(ctx
))
854 goto invalid_enum_error
;
855 CHECK_EXTENSION(ARB_vertex_program
, cap
);
856 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
858 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
859 ctx
->VertexProgram
.PointSizeEnabled
= state
;
861 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
862 if (ctx
->API
!= API_OPENGL_COMPAT
)
863 goto invalid_enum_error
;
864 CHECK_EXTENSION(ARB_vertex_program
, cap
);
865 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
867 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
868 ctx
->VertexProgram
.TwoSideEnabled
= state
;
871 /* GL_NV_texture_rectangle */
872 case GL_TEXTURE_RECTANGLE_NV
:
873 if (ctx
->API
!= API_OPENGL_COMPAT
)
874 goto invalid_enum_error
;
875 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
876 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
881 /* GL_EXT_stencil_two_side */
882 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
883 if (ctx
->API
!= API_OPENGL_COMPAT
)
884 goto invalid_enum_error
;
885 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
886 if (ctx
->Stencil
.TestTwoSide
== state
)
888 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
889 ctx
->Stencil
.TestTwoSide
= state
;
891 ctx
->Stencil
._BackFace
= 2;
893 ctx
->Stencil
._BackFace
= 1;
897 case GL_FRAGMENT_PROGRAM_ARB
:
898 if (ctx
->API
!= API_OPENGL_COMPAT
)
899 goto invalid_enum_error
;
900 CHECK_EXTENSION(ARB_fragment_program
, cap
);
901 if (ctx
->FragmentProgram
.Enabled
== state
)
903 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
904 ctx
->FragmentProgram
.Enabled
= state
;
907 /* GL_EXT_depth_bounds_test */
908 case GL_DEPTH_BOUNDS_TEST_EXT
:
909 if (!_mesa_is_desktop_gl(ctx
))
910 goto invalid_enum_error
;
911 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
912 if (ctx
->Depth
.BoundsTest
== state
)
914 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
915 ctx
->Depth
.BoundsTest
= state
;
919 if (!_mesa_is_desktop_gl(ctx
))
920 goto invalid_enum_error
;
921 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
922 if (ctx
->Transform
.DepthClamp
== state
)
924 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
925 ctx
->Transform
.DepthClamp
= state
;
928 case GL_FRAGMENT_SHADER_ATI
:
929 if (ctx
->API
!= API_OPENGL_COMPAT
)
930 goto invalid_enum_error
;
931 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
932 if (ctx
->ATIFragmentShader
.Enabled
== state
)
934 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
935 ctx
->ATIFragmentShader
.Enabled
= state
;
938 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
939 if (!_mesa_is_desktop_gl(ctx
))
940 goto invalid_enum_error
;
941 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
942 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
943 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
944 ctx
->Texture
.CubeMapSeamless
= state
;
948 case GL_RASTERIZER_DISCARD
:
949 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
950 goto invalid_enum_error
;
951 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
952 if (ctx
->RasterDiscard
!= state
) {
953 FLUSH_VERTICES(ctx
, 0);
954 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
955 ctx
->RasterDiscard
= state
;
959 /* GL 3.1 primitive restart. Note: this enum is different from
960 * GL_PRIMITIVE_RESTART_NV (which is client state).
962 case GL_PRIMITIVE_RESTART
:
963 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
964 goto invalid_enum_error
;
966 if (ctx
->Array
.PrimitiveRestart
!= state
) {
967 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
968 ctx
->Array
.PrimitiveRestart
= state
;
969 update_derived_primitive_restart_state(ctx
);
973 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
974 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
975 goto invalid_enum_error
;
976 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
977 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
978 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
979 update_derived_primitive_restart_state(ctx
);
983 /* GL3.0 - GL_framebuffer_sRGB */
984 case GL_FRAMEBUFFER_SRGB_EXT
:
985 if (!_mesa_is_desktop_gl(ctx
))
986 goto invalid_enum_error
;
987 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
988 _mesa_set_framebuffer_srgb(ctx
, state
);
991 /* GL_OES_EGL_image_external */
992 case GL_TEXTURE_EXTERNAL_OES
:
993 if (!_mesa_is_gles(ctx
))
994 goto invalid_enum_error
;
995 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
996 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1001 /* ARB_texture_multisample */
1002 case GL_SAMPLE_MASK
:
1003 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1004 goto invalid_enum_error
;
1005 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1006 if (ctx
->Multisample
.SampleMask
== state
)
1008 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
1009 ctx
->Multisample
.SampleMask
= state
;
1013 goto invalid_enum_error
;
1016 if (ctx
->Driver
.Enable
) {
1017 ctx
->Driver
.Enable( ctx
, cap
, state
);
1023 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1024 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1029 * Enable GL capability. Called by glEnable()
1030 * \param cap state to enable.
1033 _mesa_Enable( GLenum cap
)
1035 GET_CURRENT_CONTEXT(ctx
);
1037 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1042 * Disable GL capability. Called by glDisable()
1043 * \param cap state to disable.
1046 _mesa_Disable( GLenum cap
)
1048 GET_CURRENT_CONTEXT(ctx
);
1050 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1056 * Enable/disable an indexed state var.
1059 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1060 GLuint index
, GLboolean state
)
1062 assert(state
== 0 || state
== 1);
1065 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1066 goto invalid_enum_error
;
1068 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1069 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1070 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1073 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1074 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1076 ctx
->Color
.BlendEnabled
|= (1 << index
);
1078 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1081 case GL_SCISSOR_TEST
:
1082 if (index
>= ctx
->Const
.MaxViewports
) {
1083 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1084 state
? "glEnablei" : "glDisablei", index
);
1087 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1088 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
1090 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1092 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1096 goto invalid_enum_error
;
1101 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1102 state
? "glEnablei" : "glDisablei",
1103 _mesa_enum_to_string(cap
));
1108 _mesa_Disablei( GLenum cap
, GLuint index
)
1110 GET_CURRENT_CONTEXT(ctx
);
1111 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1116 _mesa_Enablei( GLenum cap
, GLuint index
)
1118 GET_CURRENT_CONTEXT(ctx
);
1119 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1123 GLboolean GLAPIENTRY
1124 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1126 GET_CURRENT_CONTEXT(ctx
);
1127 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1130 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1131 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1135 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1136 case GL_SCISSOR_TEST
:
1137 if (index
>= ctx
->Const
.MaxViewports
) {
1138 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1142 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1144 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1145 _mesa_enum_to_string(cap
));
1153 #undef CHECK_EXTENSION
1154 #define CHECK_EXTENSION(EXTNAME) \
1155 if (!ctx->Extensions.EXTNAME) { \
1156 goto invalid_enum_error; \
1159 #undef CHECK_EXTENSION2
1160 #define CHECK_EXTENSION2(EXT1, EXT2) \
1161 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1162 goto invalid_enum_error; \
1167 * Helper function to determine whether a texture target is enabled.
1170 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1172 const struct gl_texture_unit
*const texUnit
=
1173 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1174 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1179 * Return simple enable/disable state.
1181 * \param cap state variable to query.
1183 * Returns the state of the specified capability from the current GL context.
1184 * For the capabilities associated with extensions verifies that those
1185 * extensions are effectively present before reporting.
1187 GLboolean GLAPIENTRY
1188 _mesa_IsEnabled( GLenum cap
)
1190 GET_CURRENT_CONTEXT(ctx
);
1191 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1195 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1196 goto invalid_enum_error
;
1197 return ctx
->Color
.AlphaEnabled
;
1198 case GL_AUTO_NORMAL
:
1199 if (ctx
->API
!= API_OPENGL_COMPAT
)
1200 goto invalid_enum_error
;
1201 return ctx
->Eval
.AutoNormal
;
1203 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1204 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1205 case GL_CLIP_DISTANCE1
:
1206 case GL_CLIP_DISTANCE2
:
1207 case GL_CLIP_DISTANCE3
:
1208 case GL_CLIP_DISTANCE4
:
1209 case GL_CLIP_DISTANCE5
:
1210 case GL_CLIP_DISTANCE6
:
1211 case GL_CLIP_DISTANCE7
: {
1212 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1214 if (p
>= ctx
->Const
.MaxClipPlanes
)
1215 goto invalid_enum_error
;
1217 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1219 case GL_COLOR_MATERIAL
:
1220 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1221 goto invalid_enum_error
;
1222 return ctx
->Light
.ColorMaterialEnabled
;
1224 return ctx
->Polygon
.CullFlag
;
1225 case GL_DEBUG_OUTPUT
:
1226 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1227 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1229 return ctx
->Depth
.Test
;
1231 return ctx
->Color
.DitherFlag
;
1233 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1234 goto invalid_enum_error
;
1235 return ctx
->Fog
.Enabled
;
1237 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1238 goto invalid_enum_error
;
1239 return ctx
->Light
.Enabled
;
1248 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1249 goto invalid_enum_error
;
1250 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1251 case GL_LINE_SMOOTH
:
1252 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1253 goto invalid_enum_error
;
1254 return ctx
->Line
.SmoothFlag
;
1255 case GL_LINE_STIPPLE
:
1256 if (ctx
->API
!= API_OPENGL_COMPAT
)
1257 goto invalid_enum_error
;
1258 return ctx
->Line
.StippleFlag
;
1259 case GL_INDEX_LOGIC_OP
:
1260 if (ctx
->API
!= API_OPENGL_COMPAT
)
1261 goto invalid_enum_error
;
1262 return ctx
->Color
.IndexLogicOpEnabled
;
1263 case GL_COLOR_LOGIC_OP
:
1264 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1265 goto invalid_enum_error
;
1266 return ctx
->Color
.ColorLogicOpEnabled
;
1267 case GL_MAP1_COLOR_4
:
1268 if (ctx
->API
!= API_OPENGL_COMPAT
)
1269 goto invalid_enum_error
;
1270 return ctx
->Eval
.Map1Color4
;
1272 if (ctx
->API
!= API_OPENGL_COMPAT
)
1273 goto invalid_enum_error
;
1274 return ctx
->Eval
.Map1Index
;
1275 case GL_MAP1_NORMAL
:
1276 if (ctx
->API
!= API_OPENGL_COMPAT
)
1277 goto invalid_enum_error
;
1278 return ctx
->Eval
.Map1Normal
;
1279 case GL_MAP1_TEXTURE_COORD_1
:
1280 if (ctx
->API
!= API_OPENGL_COMPAT
)
1281 goto invalid_enum_error
;
1282 return ctx
->Eval
.Map1TextureCoord1
;
1283 case GL_MAP1_TEXTURE_COORD_2
:
1284 if (ctx
->API
!= API_OPENGL_COMPAT
)
1285 goto invalid_enum_error
;
1286 return ctx
->Eval
.Map1TextureCoord2
;
1287 case GL_MAP1_TEXTURE_COORD_3
:
1288 if (ctx
->API
!= API_OPENGL_COMPAT
)
1289 goto invalid_enum_error
;
1290 return ctx
->Eval
.Map1TextureCoord3
;
1291 case GL_MAP1_TEXTURE_COORD_4
:
1292 if (ctx
->API
!= API_OPENGL_COMPAT
)
1293 goto invalid_enum_error
;
1294 return ctx
->Eval
.Map1TextureCoord4
;
1295 case GL_MAP1_VERTEX_3
:
1296 if (ctx
->API
!= API_OPENGL_COMPAT
)
1297 goto invalid_enum_error
;
1298 return ctx
->Eval
.Map1Vertex3
;
1299 case GL_MAP1_VERTEX_4
:
1300 if (ctx
->API
!= API_OPENGL_COMPAT
)
1301 goto invalid_enum_error
;
1302 return ctx
->Eval
.Map1Vertex4
;
1303 case GL_MAP2_COLOR_4
:
1304 if (ctx
->API
!= API_OPENGL_COMPAT
)
1305 goto invalid_enum_error
;
1306 return ctx
->Eval
.Map2Color4
;
1308 if (ctx
->API
!= API_OPENGL_COMPAT
)
1309 goto invalid_enum_error
;
1310 return ctx
->Eval
.Map2Index
;
1311 case GL_MAP2_NORMAL
:
1312 if (ctx
->API
!= API_OPENGL_COMPAT
)
1313 goto invalid_enum_error
;
1314 return ctx
->Eval
.Map2Normal
;
1315 case GL_MAP2_TEXTURE_COORD_1
:
1316 if (ctx
->API
!= API_OPENGL_COMPAT
)
1317 goto invalid_enum_error
;
1318 return ctx
->Eval
.Map2TextureCoord1
;
1319 case GL_MAP2_TEXTURE_COORD_2
:
1320 if (ctx
->API
!= API_OPENGL_COMPAT
)
1321 goto invalid_enum_error
;
1322 return ctx
->Eval
.Map2TextureCoord2
;
1323 case GL_MAP2_TEXTURE_COORD_3
:
1324 if (ctx
->API
!= API_OPENGL_COMPAT
)
1325 goto invalid_enum_error
;
1326 return ctx
->Eval
.Map2TextureCoord3
;
1327 case GL_MAP2_TEXTURE_COORD_4
:
1328 if (ctx
->API
!= API_OPENGL_COMPAT
)
1329 goto invalid_enum_error
;
1330 return ctx
->Eval
.Map2TextureCoord4
;
1331 case GL_MAP2_VERTEX_3
:
1332 if (ctx
->API
!= API_OPENGL_COMPAT
)
1333 goto invalid_enum_error
;
1334 return ctx
->Eval
.Map2Vertex3
;
1335 case GL_MAP2_VERTEX_4
:
1336 if (ctx
->API
!= API_OPENGL_COMPAT
)
1337 goto invalid_enum_error
;
1338 return ctx
->Eval
.Map2Vertex4
;
1340 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1341 goto invalid_enum_error
;
1342 return ctx
->Transform
.Normalize
;
1343 case GL_POINT_SMOOTH
:
1344 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1345 goto invalid_enum_error
;
1346 return ctx
->Point
.SmoothFlag
;
1347 case GL_POLYGON_SMOOTH
:
1348 if (!_mesa_is_desktop_gl(ctx
))
1349 goto invalid_enum_error
;
1350 return ctx
->Polygon
.SmoothFlag
;
1351 case GL_POLYGON_STIPPLE
:
1352 if (ctx
->API
!= API_OPENGL_COMPAT
)
1353 goto invalid_enum_error
;
1354 return ctx
->Polygon
.StippleFlag
;
1355 case GL_POLYGON_OFFSET_POINT
:
1356 if (!_mesa_is_desktop_gl(ctx
))
1357 goto invalid_enum_error
;
1358 return ctx
->Polygon
.OffsetPoint
;
1359 case GL_POLYGON_OFFSET_LINE
:
1360 if (!_mesa_is_desktop_gl(ctx
))
1361 goto invalid_enum_error
;
1362 return ctx
->Polygon
.OffsetLine
;
1363 case GL_POLYGON_OFFSET_FILL
:
1364 return ctx
->Polygon
.OffsetFill
;
1365 case GL_RESCALE_NORMAL_EXT
:
1366 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1367 goto invalid_enum_error
;
1368 return ctx
->Transform
.RescaleNormals
;
1369 case GL_SCISSOR_TEST
:
1370 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1371 case GL_STENCIL_TEST
:
1372 return ctx
->Stencil
.Enabled
;
1374 if (ctx
->API
!= API_OPENGL_COMPAT
)
1375 goto invalid_enum_error
;
1376 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1378 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1379 goto invalid_enum_error
;
1380 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1382 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1383 goto invalid_enum_error
;
1384 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1385 case GL_TEXTURE_GEN_S
:
1386 case GL_TEXTURE_GEN_T
:
1387 case GL_TEXTURE_GEN_R
:
1388 case GL_TEXTURE_GEN_Q
:
1390 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1392 if (ctx
->API
!= API_OPENGL_COMPAT
)
1393 goto invalid_enum_error
;
1396 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1397 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1401 case GL_TEXTURE_GEN_STR_OES
:
1403 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1405 if (ctx
->API
!= API_OPENGLES
)
1406 goto invalid_enum_error
;
1409 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1410 ? GL_TRUE
: GL_FALSE
;
1414 /* client-side state */
1415 case GL_VERTEX_ARRAY
:
1416 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1417 goto invalid_enum_error
;
1418 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
1419 case GL_NORMAL_ARRAY
:
1420 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1421 goto invalid_enum_error
;
1422 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
1423 case GL_COLOR_ARRAY
:
1424 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1425 goto invalid_enum_error
;
1426 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
1427 case GL_INDEX_ARRAY
:
1428 if (ctx
->API
!= API_OPENGL_COMPAT
)
1429 goto invalid_enum_error
;
1430 return ctx
->Array
.VAO
->
1431 VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
1432 case GL_TEXTURE_COORD_ARRAY
:
1433 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1434 goto invalid_enum_error
;
1435 return ctx
->Array
.VAO
->
1436 VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
1437 case GL_EDGE_FLAG_ARRAY
:
1438 if (ctx
->API
!= API_OPENGL_COMPAT
)
1439 goto invalid_enum_error
;
1440 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
1441 case GL_FOG_COORDINATE_ARRAY_EXT
:
1442 if (ctx
->API
!= API_OPENGL_COMPAT
)
1443 goto invalid_enum_error
;
1444 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
1445 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1446 if (ctx
->API
!= API_OPENGL_COMPAT
)
1447 goto invalid_enum_error
;
1448 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
1449 case GL_POINT_SIZE_ARRAY_OES
:
1450 if (ctx
->API
!= API_OPENGLES
)
1451 goto invalid_enum_error
;
1452 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
1454 /* GL_ARB_texture_cube_map */
1455 case GL_TEXTURE_CUBE_MAP
:
1456 CHECK_EXTENSION(ARB_texture_cube_map
);
1457 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1459 /* GL_EXT_secondary_color */
1460 case GL_COLOR_SUM_EXT
:
1461 if (ctx
->API
!= API_OPENGL_COMPAT
)
1462 goto invalid_enum_error
;
1463 return ctx
->Fog
.ColorSumEnabled
;
1465 /* GL_ARB_multisample */
1466 case GL_MULTISAMPLE_ARB
:
1467 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1468 goto invalid_enum_error
;
1469 return ctx
->Multisample
.Enabled
;
1470 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1471 return ctx
->Multisample
.SampleAlphaToCoverage
;
1472 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1473 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1474 goto invalid_enum_error
;
1475 return ctx
->Multisample
.SampleAlphaToOne
;
1476 case GL_SAMPLE_COVERAGE_ARB
:
1477 return ctx
->Multisample
.SampleCoverage
;
1478 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1479 if (!_mesa_is_desktop_gl(ctx
))
1480 goto invalid_enum_error
;
1481 return ctx
->Multisample
.SampleCoverageInvert
;
1483 /* GL_IBM_rasterpos_clip */
1484 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1485 if (ctx
->API
!= API_OPENGL_COMPAT
)
1486 goto invalid_enum_error
;
1487 return ctx
->Transform
.RasterPositionUnclipped
;
1489 /* GL_NV_point_sprite */
1490 case GL_POINT_SPRITE_NV
:
1491 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1492 goto invalid_enum_error
;
1493 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1494 return ctx
->Point
.PointSprite
;
1496 case GL_VERTEX_PROGRAM_ARB
:
1497 if (ctx
->API
!= API_OPENGL_COMPAT
)
1498 goto invalid_enum_error
;
1499 CHECK_EXTENSION(ARB_vertex_program
);
1500 return ctx
->VertexProgram
.Enabled
;
1501 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1502 /* This was added with ARB_vertex_program, but it is also used with
1503 * GLSL vertex shaders on desktop.
1505 if (!_mesa_is_desktop_gl(ctx
))
1506 goto invalid_enum_error
;
1507 CHECK_EXTENSION(ARB_vertex_program
);
1508 return ctx
->VertexProgram
.PointSizeEnabled
;
1509 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1510 if (ctx
->API
!= API_OPENGL_COMPAT
)
1511 goto invalid_enum_error
;
1512 CHECK_EXTENSION(ARB_vertex_program
);
1513 return ctx
->VertexProgram
.TwoSideEnabled
;
1515 /* GL_NV_texture_rectangle */
1516 case GL_TEXTURE_RECTANGLE_NV
:
1517 if (ctx
->API
!= API_OPENGL_COMPAT
)
1518 goto invalid_enum_error
;
1519 CHECK_EXTENSION(NV_texture_rectangle
);
1520 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1522 /* GL_EXT_stencil_two_side */
1523 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1524 if (ctx
->API
!= API_OPENGL_COMPAT
)
1525 goto invalid_enum_error
;
1526 CHECK_EXTENSION(EXT_stencil_two_side
);
1527 return ctx
->Stencil
.TestTwoSide
;
1529 case GL_FRAGMENT_PROGRAM_ARB
:
1530 if (ctx
->API
!= API_OPENGL_COMPAT
)
1531 goto invalid_enum_error
;
1532 return ctx
->FragmentProgram
.Enabled
;
1534 /* GL_EXT_depth_bounds_test */
1535 case GL_DEPTH_BOUNDS_TEST_EXT
:
1536 if (!_mesa_is_desktop_gl(ctx
))
1537 goto invalid_enum_error
;
1538 CHECK_EXTENSION(EXT_depth_bounds_test
);
1539 return ctx
->Depth
.BoundsTest
;
1541 /* GL_ARB_depth_clamp */
1542 case GL_DEPTH_CLAMP
:
1543 if (!_mesa_is_desktop_gl(ctx
))
1544 goto invalid_enum_error
;
1545 CHECK_EXTENSION(ARB_depth_clamp
);
1546 return ctx
->Transform
.DepthClamp
;
1548 case GL_FRAGMENT_SHADER_ATI
:
1549 if (ctx
->API
!= API_OPENGL_COMPAT
)
1550 goto invalid_enum_error
;
1551 CHECK_EXTENSION(ATI_fragment_shader
);
1552 return ctx
->ATIFragmentShader
.Enabled
;
1554 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1555 if (!_mesa_is_desktop_gl(ctx
))
1556 goto invalid_enum_error
;
1557 CHECK_EXTENSION(ARB_seamless_cube_map
);
1558 return ctx
->Texture
.CubeMapSeamless
;
1560 case GL_RASTERIZER_DISCARD
:
1561 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1562 goto invalid_enum_error
;
1563 CHECK_EXTENSION(EXT_transform_feedback
);
1564 return ctx
->RasterDiscard
;
1566 /* GL_NV_primitive_restart */
1567 case GL_PRIMITIVE_RESTART_NV
:
1568 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1569 goto invalid_enum_error
;
1571 return ctx
->Array
.PrimitiveRestart
;
1573 /* GL 3.1 primitive restart */
1574 case GL_PRIMITIVE_RESTART
:
1575 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1576 goto invalid_enum_error
;
1578 return ctx
->Array
.PrimitiveRestart
;
1580 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1581 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1582 goto invalid_enum_error
;
1584 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1586 /* GL3.0 - GL_framebuffer_sRGB */
1587 case GL_FRAMEBUFFER_SRGB_EXT
:
1588 if (!_mesa_is_desktop_gl(ctx
))
1589 goto invalid_enum_error
;
1590 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1591 return ctx
->Color
.sRGBEnabled
;
1593 /* GL_OES_EGL_image_external */
1594 case GL_TEXTURE_EXTERNAL_OES
:
1595 if (!_mesa_is_gles(ctx
))
1596 goto invalid_enum_error
;
1597 CHECK_EXTENSION(OES_EGL_image_external
);
1598 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1600 /* ARB_texture_multisample */
1601 case GL_SAMPLE_MASK
:
1602 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1603 goto invalid_enum_error
;
1604 CHECK_EXTENSION(ARB_texture_multisample
);
1605 return ctx
->Multisample
.SampleMask
;
1607 /* ARB_sample_shading */
1608 case GL_SAMPLE_SHADING
:
1609 if (!_mesa_is_desktop_gl(ctx
))
1610 goto invalid_enum_error
;
1611 CHECK_EXTENSION(ARB_sample_shading
);
1612 return ctx
->Multisample
.SampleShading
;
1615 goto invalid_enum_error
;
1621 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1622 _mesa_enum_to_string(cap
));