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
;
110 /* GL_NV_primitive_restart */
111 case GL_PRIMITIVE_RESTART_NV
:
112 if (!ctx
->Extensions
.NV_primitive_restart
) {
113 goto invalid_enum_error
;
115 var
= &ctx
->Array
.PrimitiveRestart
;
120 goto invalid_enum_error
;
126 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
128 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
132 update_derived_primitive_restart_state(ctx
);
135 vao
->_Enabled
|= flag
;
137 vao
->_Enabled
&= ~flag
;
139 vao
->NewArrays
|= flag
;
141 if (ctx
->Driver
.Enable
) {
142 ctx
->Driver
.Enable( ctx
, cap
, state
);
148 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
149 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
154 * Enable GL capability.
155 * \param cap state to enable/disable.
157 * Get's the current context, assures that we're outside glBegin()/glEnd() and
158 * calls client_state().
161 _mesa_EnableClientState( GLenum cap
)
163 GET_CURRENT_CONTEXT(ctx
);
164 client_state( ctx
, cap
, GL_TRUE
);
169 * Disable GL capability.
170 * \param cap state to enable/disable.
172 * Get's the current context, assures that we're outside glBegin()/glEnd() and
173 * calls client_state().
176 _mesa_DisableClientState( GLenum cap
)
178 GET_CURRENT_CONTEXT(ctx
);
179 client_state( ctx
, cap
, GL_FALSE
);
183 #undef CHECK_EXTENSION
184 #define CHECK_EXTENSION(EXTNAME, CAP) \
185 if (!ctx->Extensions.EXTNAME) { \
186 goto invalid_enum_error; \
189 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
190 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
191 goto invalid_enum_error; \
195 * Return pointer to current texture unit for setting/getting coordinate
197 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
198 * texture unit is higher than the number of supported coordinate units.
200 static struct gl_texture_unit
*
201 get_texcoord_unit(struct gl_context
*ctx
)
203 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
204 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
208 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
214 * Helper function to enable or disable a texture target.
215 * \param bit one of the TEXTURE_x_BIT values
216 * \return GL_TRUE if state is changing or GL_FALSE if no change
219 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
221 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
222 const GLbitfield newenabled
= state
223 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
225 if (texUnit
->Enabled
== newenabled
)
228 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
229 texUnit
->Enabled
= newenabled
;
235 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
236 * whether the API supports it (GLES doesn't).
239 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
241 if (ctx
->Multisample
.Enabled
== state
)
243 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
244 ctx
->Multisample
.Enabled
= state
;
246 if (ctx
->Driver
.Enable
) {
247 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
252 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
253 * check for whether the API supports it (GLES doesn't).
256 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
258 if (ctx
->Color
.sRGBEnabled
== state
)
260 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
261 ctx
->Color
.sRGBEnabled
= state
;
263 if (ctx
->Driver
.Enable
) {
264 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
269 * Helper function to enable or disable state.
271 * \param ctx GL context.
272 * \param cap the state to enable/disable
273 * \param state whether to enable or disable the specified capability.
275 * Updates the current context and flushes the vertices as needed. For
276 * capabilities associated with extensions it verifies that those extensions
277 * are effectivly present before updating. Notifies the driver via
278 * dd_function_table::Enable.
281 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
283 if (MESA_VERBOSE
& VERBOSE_API
)
284 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
285 state
? "glEnable" : "glDisable",
286 _mesa_enum_to_string(cap
),
291 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
292 goto invalid_enum_error
;
293 if (ctx
->Color
.AlphaEnabled
== state
)
295 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
296 ctx
->Color
.AlphaEnabled
= state
;
299 if (ctx
->API
!= API_OPENGL_COMPAT
)
300 goto invalid_enum_error
;
301 if (ctx
->Eval
.AutoNormal
== state
)
303 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
304 ctx
->Eval
.AutoNormal
= state
;
308 GLbitfield newEnabled
=
309 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
310 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
311 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
312 ctx
->Color
.BlendEnabled
= newEnabled
;
316 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
317 case GL_CLIP_DISTANCE1
:
318 case GL_CLIP_DISTANCE2
:
319 case GL_CLIP_DISTANCE3
:
320 case GL_CLIP_DISTANCE4
:
321 case GL_CLIP_DISTANCE5
:
322 case GL_CLIP_DISTANCE6
:
323 case GL_CLIP_DISTANCE7
:
325 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
327 if (p
>= ctx
->Const
.MaxClipPlanes
)
328 goto invalid_enum_error
;
330 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
331 == ((GLuint
) state
<< p
))
334 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
337 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
338 _mesa_update_clip_plane(ctx
, p
);
341 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
345 case GL_COLOR_MATERIAL
:
346 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
347 goto invalid_enum_error
;
348 if (ctx
->Light
.ColorMaterialEnabled
== state
)
350 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
351 FLUSH_CURRENT(ctx
, 0);
352 ctx
->Light
.ColorMaterialEnabled
= state
;
354 _mesa_update_color_material( ctx
,
355 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
359 if (ctx
->Polygon
.CullFlag
== state
)
361 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
362 ctx
->Polygon
.CullFlag
= state
;
365 if (ctx
->Depth
.Test
== state
)
367 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
368 ctx
->Depth
.Test
= state
;
370 case GL_DEBUG_OUTPUT
:
371 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
372 _mesa_set_debug_state_int(ctx
, cap
, state
);
375 if (ctx
->Color
.DitherFlag
== state
)
377 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
378 ctx
->Color
.DitherFlag
= state
;
381 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
382 goto invalid_enum_error
;
383 if (ctx
->Fog
.Enabled
== state
)
385 FLUSH_VERTICES(ctx
, _NEW_FOG
);
386 ctx
->Fog
.Enabled
= state
;
396 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
397 goto invalid_enum_error
;
398 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
400 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
401 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
403 insert_at_tail(&ctx
->Light
.EnabledList
,
404 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
407 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
411 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
412 goto invalid_enum_error
;
413 if (ctx
->Light
.Enabled
== state
)
415 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
416 ctx
->Light
.Enabled
= state
;
419 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
420 goto invalid_enum_error
;
421 if (ctx
->Line
.SmoothFlag
== state
)
423 FLUSH_VERTICES(ctx
, _NEW_LINE
);
424 ctx
->Line
.SmoothFlag
= state
;
426 case GL_LINE_STIPPLE
:
427 if (ctx
->API
!= API_OPENGL_COMPAT
)
428 goto invalid_enum_error
;
429 if (ctx
->Line
.StippleFlag
== state
)
431 FLUSH_VERTICES(ctx
, _NEW_LINE
);
432 ctx
->Line
.StippleFlag
= state
;
434 case GL_INDEX_LOGIC_OP
:
435 if (ctx
->API
!= API_OPENGL_COMPAT
)
436 goto invalid_enum_error
;
437 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
439 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
440 ctx
->Color
.IndexLogicOpEnabled
= state
;
442 case GL_COLOR_LOGIC_OP
:
443 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
444 goto invalid_enum_error
;
445 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
447 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
448 ctx
->Color
.ColorLogicOpEnabled
= state
;
450 case GL_MAP1_COLOR_4
:
451 if (ctx
->API
!= API_OPENGL_COMPAT
)
452 goto invalid_enum_error
;
453 if (ctx
->Eval
.Map1Color4
== state
)
455 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
456 ctx
->Eval
.Map1Color4
= state
;
459 if (ctx
->API
!= API_OPENGL_COMPAT
)
460 goto invalid_enum_error
;
461 if (ctx
->Eval
.Map1Index
== state
)
463 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
464 ctx
->Eval
.Map1Index
= state
;
467 if (ctx
->API
!= API_OPENGL_COMPAT
)
468 goto invalid_enum_error
;
469 if (ctx
->Eval
.Map1Normal
== state
)
471 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
472 ctx
->Eval
.Map1Normal
= state
;
474 case GL_MAP1_TEXTURE_COORD_1
:
475 if (ctx
->API
!= API_OPENGL_COMPAT
)
476 goto invalid_enum_error
;
477 if (ctx
->Eval
.Map1TextureCoord1
== state
)
479 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
480 ctx
->Eval
.Map1TextureCoord1
= state
;
482 case GL_MAP1_TEXTURE_COORD_2
:
483 if (ctx
->API
!= API_OPENGL_COMPAT
)
484 goto invalid_enum_error
;
485 if (ctx
->Eval
.Map1TextureCoord2
== state
)
487 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
488 ctx
->Eval
.Map1TextureCoord2
= state
;
490 case GL_MAP1_TEXTURE_COORD_3
:
491 if (ctx
->API
!= API_OPENGL_COMPAT
)
492 goto invalid_enum_error
;
493 if (ctx
->Eval
.Map1TextureCoord3
== state
)
495 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
496 ctx
->Eval
.Map1TextureCoord3
= state
;
498 case GL_MAP1_TEXTURE_COORD_4
:
499 if (ctx
->API
!= API_OPENGL_COMPAT
)
500 goto invalid_enum_error
;
501 if (ctx
->Eval
.Map1TextureCoord4
== state
)
503 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
504 ctx
->Eval
.Map1TextureCoord4
= state
;
506 case GL_MAP1_VERTEX_3
:
507 if (ctx
->API
!= API_OPENGL_COMPAT
)
508 goto invalid_enum_error
;
509 if (ctx
->Eval
.Map1Vertex3
== state
)
511 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
512 ctx
->Eval
.Map1Vertex3
= state
;
514 case GL_MAP1_VERTEX_4
:
515 if (ctx
->API
!= API_OPENGL_COMPAT
)
516 goto invalid_enum_error
;
517 if (ctx
->Eval
.Map1Vertex4
== state
)
519 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
520 ctx
->Eval
.Map1Vertex4
= state
;
522 case GL_MAP2_COLOR_4
:
523 if (ctx
->API
!= API_OPENGL_COMPAT
)
524 goto invalid_enum_error
;
525 if (ctx
->Eval
.Map2Color4
== state
)
527 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
528 ctx
->Eval
.Map2Color4
= state
;
531 if (ctx
->API
!= API_OPENGL_COMPAT
)
532 goto invalid_enum_error
;
533 if (ctx
->Eval
.Map2Index
== state
)
535 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
536 ctx
->Eval
.Map2Index
= state
;
539 if (ctx
->API
!= API_OPENGL_COMPAT
)
540 goto invalid_enum_error
;
541 if (ctx
->Eval
.Map2Normal
== state
)
543 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
544 ctx
->Eval
.Map2Normal
= state
;
546 case GL_MAP2_TEXTURE_COORD_1
:
547 if (ctx
->API
!= API_OPENGL_COMPAT
)
548 goto invalid_enum_error
;
549 if (ctx
->Eval
.Map2TextureCoord1
== state
)
551 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
552 ctx
->Eval
.Map2TextureCoord1
= state
;
554 case GL_MAP2_TEXTURE_COORD_2
:
555 if (ctx
->API
!= API_OPENGL_COMPAT
)
556 goto invalid_enum_error
;
557 if (ctx
->Eval
.Map2TextureCoord2
== state
)
559 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
560 ctx
->Eval
.Map2TextureCoord2
= state
;
562 case GL_MAP2_TEXTURE_COORD_3
:
563 if (ctx
->API
!= API_OPENGL_COMPAT
)
564 goto invalid_enum_error
;
565 if (ctx
->Eval
.Map2TextureCoord3
== state
)
567 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
568 ctx
->Eval
.Map2TextureCoord3
= state
;
570 case GL_MAP2_TEXTURE_COORD_4
:
571 if (ctx
->API
!= API_OPENGL_COMPAT
)
572 goto invalid_enum_error
;
573 if (ctx
->Eval
.Map2TextureCoord4
== state
)
575 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
576 ctx
->Eval
.Map2TextureCoord4
= state
;
578 case GL_MAP2_VERTEX_3
:
579 if (ctx
->API
!= API_OPENGL_COMPAT
)
580 goto invalid_enum_error
;
581 if (ctx
->Eval
.Map2Vertex3
== state
)
583 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
584 ctx
->Eval
.Map2Vertex3
= state
;
586 case GL_MAP2_VERTEX_4
:
587 if (ctx
->API
!= API_OPENGL_COMPAT
)
588 goto invalid_enum_error
;
589 if (ctx
->Eval
.Map2Vertex4
== state
)
591 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
592 ctx
->Eval
.Map2Vertex4
= state
;
595 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
596 goto invalid_enum_error
;
597 if (ctx
->Transform
.Normalize
== state
)
599 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
600 ctx
->Transform
.Normalize
= state
;
602 case GL_POINT_SMOOTH
:
603 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
604 goto invalid_enum_error
;
605 if (ctx
->Point
.SmoothFlag
== state
)
607 FLUSH_VERTICES(ctx
, _NEW_POINT
);
608 ctx
->Point
.SmoothFlag
= state
;
610 case GL_POLYGON_SMOOTH
:
611 if (!_mesa_is_desktop_gl(ctx
))
612 goto invalid_enum_error
;
613 if (ctx
->Polygon
.SmoothFlag
== state
)
615 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
616 ctx
->Polygon
.SmoothFlag
= state
;
618 case GL_POLYGON_STIPPLE
:
619 if (ctx
->API
!= API_OPENGL_COMPAT
)
620 goto invalid_enum_error
;
621 if (ctx
->Polygon
.StippleFlag
== state
)
623 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
624 ctx
->Polygon
.StippleFlag
= state
;
626 case GL_POLYGON_OFFSET_POINT
:
627 if (!_mesa_is_desktop_gl(ctx
))
628 goto invalid_enum_error
;
629 if (ctx
->Polygon
.OffsetPoint
== state
)
631 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
632 ctx
->Polygon
.OffsetPoint
= state
;
634 case GL_POLYGON_OFFSET_LINE
:
635 if (!_mesa_is_desktop_gl(ctx
))
636 goto invalid_enum_error
;
637 if (ctx
->Polygon
.OffsetLine
== state
)
639 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
640 ctx
->Polygon
.OffsetLine
= state
;
642 case GL_POLYGON_OFFSET_FILL
:
643 if (ctx
->Polygon
.OffsetFill
== state
)
645 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
646 ctx
->Polygon
.OffsetFill
= state
;
648 case GL_RESCALE_NORMAL_EXT
:
649 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
650 goto invalid_enum_error
;
651 if (ctx
->Transform
.RescaleNormals
== state
)
653 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
654 ctx
->Transform
.RescaleNormals
= state
;
656 case GL_SCISSOR_TEST
:
658 /* Must expand glEnable to all scissors */
659 GLbitfield newEnabled
=
660 state
* ((1 << ctx
->Const
.MaxViewports
) - 1);
661 if (newEnabled
!= ctx
->Scissor
.EnableFlags
) {
662 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
663 ctx
->Scissor
.EnableFlags
= newEnabled
;
667 case GL_STENCIL_TEST
:
668 if (ctx
->Stencil
.Enabled
== state
)
670 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
671 ctx
->Stencil
.Enabled
= state
;
674 if (ctx
->API
!= API_OPENGL_COMPAT
)
675 goto invalid_enum_error
;
676 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
681 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
682 goto invalid_enum_error
;
683 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
688 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
689 goto invalid_enum_error
;
690 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
694 case GL_TEXTURE_GEN_S
:
695 case GL_TEXTURE_GEN_T
:
696 case GL_TEXTURE_GEN_R
:
697 case GL_TEXTURE_GEN_Q
:
699 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
701 if (ctx
->API
!= API_OPENGL_COMPAT
)
702 goto invalid_enum_error
;
705 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
706 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
708 newenabled
|= coordBit
;
709 if (texUnit
->TexGenEnabled
== newenabled
)
711 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
712 texUnit
->TexGenEnabled
= newenabled
;
717 case GL_TEXTURE_GEN_STR_OES
:
718 /* disable S, T, and R at the same time */
720 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
722 if (ctx
->API
!= API_OPENGLES
)
723 goto invalid_enum_error
;
727 texUnit
->TexGenEnabled
& ~STR_BITS
;
729 newenabled
|= STR_BITS
;
730 if (texUnit
->TexGenEnabled
== newenabled
)
732 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
733 texUnit
->TexGenEnabled
= newenabled
;
738 /* client-side state */
739 case GL_VERTEX_ARRAY
:
740 case GL_NORMAL_ARRAY
:
743 case GL_TEXTURE_COORD_ARRAY
:
744 case GL_EDGE_FLAG_ARRAY
:
745 case GL_FOG_COORDINATE_ARRAY_EXT
:
746 case GL_SECONDARY_COLOR_ARRAY_EXT
:
747 case GL_POINT_SIZE_ARRAY_OES
:
748 client_state( ctx
, cap
, state
);
751 /* GL_ARB_texture_cube_map */
752 case GL_TEXTURE_CUBE_MAP
:
753 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
754 goto invalid_enum_error
;
755 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
756 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
761 /* GL_EXT_secondary_color */
762 case GL_COLOR_SUM_EXT
:
763 if (ctx
->API
!= API_OPENGL_COMPAT
)
764 goto invalid_enum_error
;
765 if (ctx
->Fog
.ColorSumEnabled
== state
)
767 FLUSH_VERTICES(ctx
, _NEW_FOG
);
768 ctx
->Fog
.ColorSumEnabled
= state
;
771 /* GL_ARB_multisample */
772 case GL_MULTISAMPLE_ARB
:
773 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
774 goto invalid_enum_error
;
775 _mesa_set_multisample(ctx
, state
);
777 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
778 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
780 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
781 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
783 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
784 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
785 goto invalid_enum_error
;
786 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
788 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
789 ctx
->Multisample
.SampleAlphaToOne
= state
;
791 case GL_SAMPLE_COVERAGE_ARB
:
792 if (ctx
->Multisample
.SampleCoverage
== state
)
794 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
795 ctx
->Multisample
.SampleCoverage
= state
;
797 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
798 if (!_mesa_is_desktop_gl(ctx
))
799 goto invalid_enum_error
;
800 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
802 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
803 ctx
->Multisample
.SampleCoverageInvert
= state
;
806 /* GL_ARB_sample_shading */
807 case GL_SAMPLE_SHADING
:
808 if (!_mesa_is_desktop_gl(ctx
))
809 goto invalid_enum_error
;
810 CHECK_EXTENSION(ARB_sample_shading
, cap
);
811 if (ctx
->Multisample
.SampleShading
== state
)
813 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
814 ctx
->Multisample
.SampleShading
= state
;
817 /* GL_IBM_rasterpos_clip */
818 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
819 if (ctx
->API
!= API_OPENGL_COMPAT
)
820 goto invalid_enum_error
;
821 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
823 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
824 ctx
->Transform
.RasterPositionUnclipped
= state
;
827 /* GL_NV_point_sprite */
828 case GL_POINT_SPRITE_NV
:
829 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
830 goto invalid_enum_error
;
831 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
832 if (ctx
->Point
.PointSprite
== state
)
834 FLUSH_VERTICES(ctx
, _NEW_POINT
);
835 ctx
->Point
.PointSprite
= state
;
838 case GL_VERTEX_PROGRAM_ARB
:
839 if (ctx
->API
!= API_OPENGL_COMPAT
)
840 goto invalid_enum_error
;
841 CHECK_EXTENSION(ARB_vertex_program
, cap
);
842 if (ctx
->VertexProgram
.Enabled
== state
)
844 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
845 ctx
->VertexProgram
.Enabled
= state
;
847 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
848 /* This was added with ARB_vertex_program, but it is also used with
849 * GLSL vertex shaders on desktop.
851 if (!_mesa_is_desktop_gl(ctx
))
852 goto invalid_enum_error
;
853 CHECK_EXTENSION(ARB_vertex_program
, cap
);
854 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
856 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
857 ctx
->VertexProgram
.PointSizeEnabled
= state
;
859 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
860 if (ctx
->API
!= API_OPENGL_COMPAT
)
861 goto invalid_enum_error
;
862 CHECK_EXTENSION(ARB_vertex_program
, cap
);
863 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
865 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
866 ctx
->VertexProgram
.TwoSideEnabled
= state
;
869 /* GL_NV_texture_rectangle */
870 case GL_TEXTURE_RECTANGLE_NV
:
871 if (ctx
->API
!= API_OPENGL_COMPAT
)
872 goto invalid_enum_error
;
873 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
874 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
879 /* GL_EXT_stencil_two_side */
880 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
881 if (ctx
->API
!= API_OPENGL_COMPAT
)
882 goto invalid_enum_error
;
883 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
884 if (ctx
->Stencil
.TestTwoSide
== state
)
886 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
887 ctx
->Stencil
.TestTwoSide
= state
;
889 ctx
->Stencil
._BackFace
= 2;
891 ctx
->Stencil
._BackFace
= 1;
895 case GL_FRAGMENT_PROGRAM_ARB
:
896 if (ctx
->API
!= API_OPENGL_COMPAT
)
897 goto invalid_enum_error
;
898 CHECK_EXTENSION(ARB_fragment_program
, cap
);
899 if (ctx
->FragmentProgram
.Enabled
== state
)
901 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
902 ctx
->FragmentProgram
.Enabled
= state
;
905 /* GL_EXT_depth_bounds_test */
906 case GL_DEPTH_BOUNDS_TEST_EXT
:
907 if (!_mesa_is_desktop_gl(ctx
))
908 goto invalid_enum_error
;
909 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
910 if (ctx
->Depth
.BoundsTest
== state
)
912 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
913 ctx
->Depth
.BoundsTest
= state
;
917 if (!_mesa_is_desktop_gl(ctx
))
918 goto invalid_enum_error
;
919 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
920 if (ctx
->Transform
.DepthClamp
== state
)
922 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
923 ctx
->Transform
.DepthClamp
= state
;
926 case GL_FRAGMENT_SHADER_ATI
:
927 if (ctx
->API
!= API_OPENGL_COMPAT
)
928 goto invalid_enum_error
;
929 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
930 if (ctx
->ATIFragmentShader
.Enabled
== state
)
932 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
933 ctx
->ATIFragmentShader
.Enabled
= state
;
936 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
937 if (!_mesa_is_desktop_gl(ctx
))
938 goto invalid_enum_error
;
939 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
940 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
941 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
942 ctx
->Texture
.CubeMapSeamless
= state
;
946 case GL_RASTERIZER_DISCARD
:
947 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
948 goto invalid_enum_error
;
949 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
950 if (ctx
->RasterDiscard
!= state
) {
951 FLUSH_VERTICES(ctx
, 0);
952 ctx
->NewDriverState
|= ctx
->DriverFlags
.NewRasterizerDiscard
;
953 ctx
->RasterDiscard
= state
;
957 /* GL 3.1 primitive restart. Note: this enum is different from
958 * GL_PRIMITIVE_RESTART_NV (which is client state).
960 case GL_PRIMITIVE_RESTART
:
961 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
962 goto invalid_enum_error
;
964 if (ctx
->Array
.PrimitiveRestart
!= state
) {
965 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
966 ctx
->Array
.PrimitiveRestart
= state
;
967 update_derived_primitive_restart_state(ctx
);
971 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
972 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
973 goto invalid_enum_error
;
974 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
975 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
976 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
977 update_derived_primitive_restart_state(ctx
);
981 /* GL3.0 - GL_framebuffer_sRGB */
982 case GL_FRAMEBUFFER_SRGB_EXT
:
983 if (!_mesa_is_desktop_gl(ctx
))
984 goto invalid_enum_error
;
985 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
986 _mesa_set_framebuffer_srgb(ctx
, state
);
989 /* GL_OES_EGL_image_external */
990 case GL_TEXTURE_EXTERNAL_OES
:
991 if (!_mesa_is_gles(ctx
))
992 goto invalid_enum_error
;
993 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
994 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
999 /* ARB_texture_multisample */
1000 case GL_SAMPLE_MASK
:
1001 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1002 goto invalid_enum_error
;
1003 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1004 if (ctx
->Multisample
.SampleMask
== state
)
1006 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
1007 ctx
->Multisample
.SampleMask
= state
;
1011 goto invalid_enum_error
;
1014 if (ctx
->Driver
.Enable
) {
1015 ctx
->Driver
.Enable( ctx
, cap
, state
);
1021 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1022 state
? "Enable" : "Disable", _mesa_enum_to_string(cap
));
1027 * Enable GL capability. Called by glEnable()
1028 * \param cap state to enable.
1031 _mesa_Enable( GLenum cap
)
1033 GET_CURRENT_CONTEXT(ctx
);
1035 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1040 * Disable GL capability. Called by glDisable()
1041 * \param cap state to disable.
1044 _mesa_Disable( GLenum cap
)
1046 GET_CURRENT_CONTEXT(ctx
);
1048 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1054 * Enable/disable an indexed state var.
1057 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1058 GLuint index
, GLboolean state
)
1060 assert(state
== 0 || state
== 1);
1063 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1064 goto invalid_enum_error
;
1066 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1067 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1068 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1071 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1072 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1074 ctx
->Color
.BlendEnabled
|= (1 << index
);
1076 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1079 case GL_SCISSOR_TEST
:
1080 if (index
>= ctx
->Const
.MaxViewports
) {
1081 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1082 state
? "glEnablei" : "glDisablei", index
);
1085 if (((ctx
->Scissor
.EnableFlags
>> index
) & 1) != state
) {
1086 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
1088 ctx
->Scissor
.EnableFlags
|= (1 << index
);
1090 ctx
->Scissor
.EnableFlags
&= ~(1 << index
);
1094 goto invalid_enum_error
;
1099 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1100 state
? "glEnablei" : "glDisablei",
1101 _mesa_enum_to_string(cap
));
1106 _mesa_Disablei( GLenum cap
, GLuint index
)
1108 GET_CURRENT_CONTEXT(ctx
);
1109 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1114 _mesa_Enablei( GLenum cap
, GLuint index
)
1116 GET_CURRENT_CONTEXT(ctx
);
1117 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1121 GLboolean GLAPIENTRY
1122 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1124 GET_CURRENT_CONTEXT(ctx
);
1125 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1128 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1129 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1133 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1134 case GL_SCISSOR_TEST
:
1135 if (index
>= ctx
->Const
.MaxViewports
) {
1136 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1140 return (ctx
->Scissor
.EnableFlags
>> index
) & 1;
1142 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1143 _mesa_enum_to_string(cap
));
1151 #undef CHECK_EXTENSION
1152 #define CHECK_EXTENSION(EXTNAME) \
1153 if (!ctx->Extensions.EXTNAME) { \
1154 goto invalid_enum_error; \
1157 #undef CHECK_EXTENSION2
1158 #define CHECK_EXTENSION2(EXT1, EXT2) \
1159 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1160 goto invalid_enum_error; \
1165 * Helper function to determine whether a texture target is enabled.
1168 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1170 const struct gl_texture_unit
*const texUnit
=
1171 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1172 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1177 * Return simple enable/disable state.
1179 * \param cap state variable to query.
1181 * Returns the state of the specified capability from the current GL context.
1182 * For the capabilities associated with extensions verifies that those
1183 * extensions are effectively present before reporting.
1185 GLboolean GLAPIENTRY
1186 _mesa_IsEnabled( GLenum cap
)
1188 GET_CURRENT_CONTEXT(ctx
);
1189 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1193 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1194 goto invalid_enum_error
;
1195 return ctx
->Color
.AlphaEnabled
;
1196 case GL_AUTO_NORMAL
:
1197 if (ctx
->API
!= API_OPENGL_COMPAT
)
1198 goto invalid_enum_error
;
1199 return ctx
->Eval
.AutoNormal
;
1201 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1202 case GL_CLIP_DISTANCE0
: /* aka GL_CLIP_PLANE0 */
1203 case GL_CLIP_DISTANCE1
:
1204 case GL_CLIP_DISTANCE2
:
1205 case GL_CLIP_DISTANCE3
:
1206 case GL_CLIP_DISTANCE4
:
1207 case GL_CLIP_DISTANCE5
:
1208 case GL_CLIP_DISTANCE6
:
1209 case GL_CLIP_DISTANCE7
: {
1210 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1212 if (p
>= ctx
->Const
.MaxClipPlanes
)
1213 goto invalid_enum_error
;
1215 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1217 case GL_COLOR_MATERIAL
:
1218 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1219 goto invalid_enum_error
;
1220 return ctx
->Light
.ColorMaterialEnabled
;
1222 return ctx
->Polygon
.CullFlag
;
1223 case GL_DEBUG_OUTPUT
:
1224 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1225 return (GLboolean
) _mesa_get_debug_state_int(ctx
, cap
);
1227 return ctx
->Depth
.Test
;
1229 return ctx
->Color
.DitherFlag
;
1231 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1232 goto invalid_enum_error
;
1233 return ctx
->Fog
.Enabled
;
1235 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1236 goto invalid_enum_error
;
1237 return ctx
->Light
.Enabled
;
1246 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1247 goto invalid_enum_error
;
1248 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1249 case GL_LINE_SMOOTH
:
1250 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1251 goto invalid_enum_error
;
1252 return ctx
->Line
.SmoothFlag
;
1253 case GL_LINE_STIPPLE
:
1254 if (ctx
->API
!= API_OPENGL_COMPAT
)
1255 goto invalid_enum_error
;
1256 return ctx
->Line
.StippleFlag
;
1257 case GL_INDEX_LOGIC_OP
:
1258 if (ctx
->API
!= API_OPENGL_COMPAT
)
1259 goto invalid_enum_error
;
1260 return ctx
->Color
.IndexLogicOpEnabled
;
1261 case GL_COLOR_LOGIC_OP
:
1262 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1263 goto invalid_enum_error
;
1264 return ctx
->Color
.ColorLogicOpEnabled
;
1265 case GL_MAP1_COLOR_4
:
1266 if (ctx
->API
!= API_OPENGL_COMPAT
)
1267 goto invalid_enum_error
;
1268 return ctx
->Eval
.Map1Color4
;
1270 if (ctx
->API
!= API_OPENGL_COMPAT
)
1271 goto invalid_enum_error
;
1272 return ctx
->Eval
.Map1Index
;
1273 case GL_MAP1_NORMAL
:
1274 if (ctx
->API
!= API_OPENGL_COMPAT
)
1275 goto invalid_enum_error
;
1276 return ctx
->Eval
.Map1Normal
;
1277 case GL_MAP1_TEXTURE_COORD_1
:
1278 if (ctx
->API
!= API_OPENGL_COMPAT
)
1279 goto invalid_enum_error
;
1280 return ctx
->Eval
.Map1TextureCoord1
;
1281 case GL_MAP1_TEXTURE_COORD_2
:
1282 if (ctx
->API
!= API_OPENGL_COMPAT
)
1283 goto invalid_enum_error
;
1284 return ctx
->Eval
.Map1TextureCoord2
;
1285 case GL_MAP1_TEXTURE_COORD_3
:
1286 if (ctx
->API
!= API_OPENGL_COMPAT
)
1287 goto invalid_enum_error
;
1288 return ctx
->Eval
.Map1TextureCoord3
;
1289 case GL_MAP1_TEXTURE_COORD_4
:
1290 if (ctx
->API
!= API_OPENGL_COMPAT
)
1291 goto invalid_enum_error
;
1292 return ctx
->Eval
.Map1TextureCoord4
;
1293 case GL_MAP1_VERTEX_3
:
1294 if (ctx
->API
!= API_OPENGL_COMPAT
)
1295 goto invalid_enum_error
;
1296 return ctx
->Eval
.Map1Vertex3
;
1297 case GL_MAP1_VERTEX_4
:
1298 if (ctx
->API
!= API_OPENGL_COMPAT
)
1299 goto invalid_enum_error
;
1300 return ctx
->Eval
.Map1Vertex4
;
1301 case GL_MAP2_COLOR_4
:
1302 if (ctx
->API
!= API_OPENGL_COMPAT
)
1303 goto invalid_enum_error
;
1304 return ctx
->Eval
.Map2Color4
;
1306 if (ctx
->API
!= API_OPENGL_COMPAT
)
1307 goto invalid_enum_error
;
1308 return ctx
->Eval
.Map2Index
;
1309 case GL_MAP2_NORMAL
:
1310 if (ctx
->API
!= API_OPENGL_COMPAT
)
1311 goto invalid_enum_error
;
1312 return ctx
->Eval
.Map2Normal
;
1313 case GL_MAP2_TEXTURE_COORD_1
:
1314 if (ctx
->API
!= API_OPENGL_COMPAT
)
1315 goto invalid_enum_error
;
1316 return ctx
->Eval
.Map2TextureCoord1
;
1317 case GL_MAP2_TEXTURE_COORD_2
:
1318 if (ctx
->API
!= API_OPENGL_COMPAT
)
1319 goto invalid_enum_error
;
1320 return ctx
->Eval
.Map2TextureCoord2
;
1321 case GL_MAP2_TEXTURE_COORD_3
:
1322 if (ctx
->API
!= API_OPENGL_COMPAT
)
1323 goto invalid_enum_error
;
1324 return ctx
->Eval
.Map2TextureCoord3
;
1325 case GL_MAP2_TEXTURE_COORD_4
:
1326 if (ctx
->API
!= API_OPENGL_COMPAT
)
1327 goto invalid_enum_error
;
1328 return ctx
->Eval
.Map2TextureCoord4
;
1329 case GL_MAP2_VERTEX_3
:
1330 if (ctx
->API
!= API_OPENGL_COMPAT
)
1331 goto invalid_enum_error
;
1332 return ctx
->Eval
.Map2Vertex3
;
1333 case GL_MAP2_VERTEX_4
:
1334 if (ctx
->API
!= API_OPENGL_COMPAT
)
1335 goto invalid_enum_error
;
1336 return ctx
->Eval
.Map2Vertex4
;
1338 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1339 goto invalid_enum_error
;
1340 return ctx
->Transform
.Normalize
;
1341 case GL_POINT_SMOOTH
:
1342 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1343 goto invalid_enum_error
;
1344 return ctx
->Point
.SmoothFlag
;
1345 case GL_POLYGON_SMOOTH
:
1346 if (!_mesa_is_desktop_gl(ctx
))
1347 goto invalid_enum_error
;
1348 return ctx
->Polygon
.SmoothFlag
;
1349 case GL_POLYGON_STIPPLE
:
1350 if (ctx
->API
!= API_OPENGL_COMPAT
)
1351 goto invalid_enum_error
;
1352 return ctx
->Polygon
.StippleFlag
;
1353 case GL_POLYGON_OFFSET_POINT
:
1354 if (!_mesa_is_desktop_gl(ctx
))
1355 goto invalid_enum_error
;
1356 return ctx
->Polygon
.OffsetPoint
;
1357 case GL_POLYGON_OFFSET_LINE
:
1358 if (!_mesa_is_desktop_gl(ctx
))
1359 goto invalid_enum_error
;
1360 return ctx
->Polygon
.OffsetLine
;
1361 case GL_POLYGON_OFFSET_FILL
:
1362 return ctx
->Polygon
.OffsetFill
;
1363 case GL_RESCALE_NORMAL_EXT
:
1364 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1365 goto invalid_enum_error
;
1366 return ctx
->Transform
.RescaleNormals
;
1367 case GL_SCISSOR_TEST
:
1368 return ctx
->Scissor
.EnableFlags
& 1; /* return state for index 0 */
1369 case GL_STENCIL_TEST
:
1370 return ctx
->Stencil
.Enabled
;
1372 if (ctx
->API
!= API_OPENGL_COMPAT
)
1373 goto invalid_enum_error
;
1374 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1376 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1377 goto invalid_enum_error
;
1378 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1380 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1381 goto invalid_enum_error
;
1382 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1383 case GL_TEXTURE_GEN_S
:
1384 case GL_TEXTURE_GEN_T
:
1385 case GL_TEXTURE_GEN_R
:
1386 case GL_TEXTURE_GEN_Q
:
1388 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1390 if (ctx
->API
!= API_OPENGL_COMPAT
)
1391 goto invalid_enum_error
;
1394 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1395 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1399 case GL_TEXTURE_GEN_STR_OES
:
1401 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1403 if (ctx
->API
!= API_OPENGLES
)
1404 goto invalid_enum_error
;
1407 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1408 ? GL_TRUE
: GL_FALSE
;
1412 /* client-side state */
1413 case GL_VERTEX_ARRAY
:
1414 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1415 goto invalid_enum_error
;
1416 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
1417 case GL_NORMAL_ARRAY
:
1418 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1419 goto invalid_enum_error
;
1420 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
1421 case GL_COLOR_ARRAY
:
1422 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1423 goto invalid_enum_error
;
1424 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
1425 case GL_INDEX_ARRAY
:
1426 if (ctx
->API
!= API_OPENGL_COMPAT
)
1427 goto invalid_enum_error
;
1428 return ctx
->Array
.VAO
->
1429 VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
1430 case GL_TEXTURE_COORD_ARRAY
:
1431 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1432 goto invalid_enum_error
;
1433 return ctx
->Array
.VAO
->
1434 VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
1435 case GL_EDGE_FLAG_ARRAY
:
1436 if (ctx
->API
!= API_OPENGL_COMPAT
)
1437 goto invalid_enum_error
;
1438 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
1439 case GL_FOG_COORDINATE_ARRAY_EXT
:
1440 if (ctx
->API
!= API_OPENGL_COMPAT
)
1441 goto invalid_enum_error
;
1442 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
1443 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1444 if (ctx
->API
!= API_OPENGL_COMPAT
)
1445 goto invalid_enum_error
;
1446 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
1447 case GL_POINT_SIZE_ARRAY_OES
:
1448 if (ctx
->API
!= API_OPENGLES
)
1449 goto invalid_enum_error
;
1450 return ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
1452 /* GL_ARB_texture_cube_map */
1453 case GL_TEXTURE_CUBE_MAP
:
1454 CHECK_EXTENSION(ARB_texture_cube_map
);
1455 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1457 /* GL_EXT_secondary_color */
1458 case GL_COLOR_SUM_EXT
:
1459 if (ctx
->API
!= API_OPENGL_COMPAT
)
1460 goto invalid_enum_error
;
1461 return ctx
->Fog
.ColorSumEnabled
;
1463 /* GL_ARB_multisample */
1464 case GL_MULTISAMPLE_ARB
:
1465 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1466 goto invalid_enum_error
;
1467 return ctx
->Multisample
.Enabled
;
1468 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1469 return ctx
->Multisample
.SampleAlphaToCoverage
;
1470 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1471 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1472 goto invalid_enum_error
;
1473 return ctx
->Multisample
.SampleAlphaToOne
;
1474 case GL_SAMPLE_COVERAGE_ARB
:
1475 return ctx
->Multisample
.SampleCoverage
;
1476 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1477 if (!_mesa_is_desktop_gl(ctx
))
1478 goto invalid_enum_error
;
1479 return ctx
->Multisample
.SampleCoverageInvert
;
1481 /* GL_IBM_rasterpos_clip */
1482 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1483 if (ctx
->API
!= API_OPENGL_COMPAT
)
1484 goto invalid_enum_error
;
1485 return ctx
->Transform
.RasterPositionUnclipped
;
1487 /* GL_NV_point_sprite */
1488 case GL_POINT_SPRITE_NV
:
1489 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1490 goto invalid_enum_error
;
1491 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1492 return ctx
->Point
.PointSprite
;
1494 case GL_VERTEX_PROGRAM_ARB
:
1495 if (ctx
->API
!= API_OPENGL_COMPAT
)
1496 goto invalid_enum_error
;
1497 CHECK_EXTENSION(ARB_vertex_program
);
1498 return ctx
->VertexProgram
.Enabled
;
1499 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1500 /* This was added with ARB_vertex_program, but it is also used with
1501 * GLSL vertex shaders on desktop.
1503 if (!_mesa_is_desktop_gl(ctx
))
1504 goto invalid_enum_error
;
1505 CHECK_EXTENSION(ARB_vertex_program
);
1506 return ctx
->VertexProgram
.PointSizeEnabled
;
1507 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1508 if (ctx
->API
!= API_OPENGL_COMPAT
)
1509 goto invalid_enum_error
;
1510 CHECK_EXTENSION(ARB_vertex_program
);
1511 return ctx
->VertexProgram
.TwoSideEnabled
;
1513 /* GL_NV_texture_rectangle */
1514 case GL_TEXTURE_RECTANGLE_NV
:
1515 if (ctx
->API
!= API_OPENGL_COMPAT
)
1516 goto invalid_enum_error
;
1517 CHECK_EXTENSION(NV_texture_rectangle
);
1518 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1520 /* GL_EXT_stencil_two_side */
1521 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1522 if (ctx
->API
!= API_OPENGL_COMPAT
)
1523 goto invalid_enum_error
;
1524 CHECK_EXTENSION(EXT_stencil_two_side
);
1525 return ctx
->Stencil
.TestTwoSide
;
1527 case GL_FRAGMENT_PROGRAM_ARB
:
1528 if (ctx
->API
!= API_OPENGL_COMPAT
)
1529 goto invalid_enum_error
;
1530 return ctx
->FragmentProgram
.Enabled
;
1532 /* GL_EXT_depth_bounds_test */
1533 case GL_DEPTH_BOUNDS_TEST_EXT
:
1534 if (!_mesa_is_desktop_gl(ctx
))
1535 goto invalid_enum_error
;
1536 CHECK_EXTENSION(EXT_depth_bounds_test
);
1537 return ctx
->Depth
.BoundsTest
;
1539 /* GL_ARB_depth_clamp */
1540 case GL_DEPTH_CLAMP
:
1541 if (!_mesa_is_desktop_gl(ctx
))
1542 goto invalid_enum_error
;
1543 CHECK_EXTENSION(ARB_depth_clamp
);
1544 return ctx
->Transform
.DepthClamp
;
1546 case GL_FRAGMENT_SHADER_ATI
:
1547 if (ctx
->API
!= API_OPENGL_COMPAT
)
1548 goto invalid_enum_error
;
1549 CHECK_EXTENSION(ATI_fragment_shader
);
1550 return ctx
->ATIFragmentShader
.Enabled
;
1552 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1553 if (!_mesa_is_desktop_gl(ctx
))
1554 goto invalid_enum_error
;
1555 CHECK_EXTENSION(ARB_seamless_cube_map
);
1556 return ctx
->Texture
.CubeMapSeamless
;
1558 case GL_RASTERIZER_DISCARD
:
1559 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1560 goto invalid_enum_error
;
1561 CHECK_EXTENSION(EXT_transform_feedback
);
1562 return ctx
->RasterDiscard
;
1564 /* GL_NV_primitive_restart */
1565 case GL_PRIMITIVE_RESTART_NV
:
1566 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1567 goto invalid_enum_error
;
1569 return ctx
->Array
.PrimitiveRestart
;
1571 /* GL 3.1 primitive restart */
1572 case GL_PRIMITIVE_RESTART
:
1573 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1574 goto invalid_enum_error
;
1576 return ctx
->Array
.PrimitiveRestart
;
1578 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1579 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1580 goto invalid_enum_error
;
1582 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1584 /* GL3.0 - GL_framebuffer_sRGB */
1585 case GL_FRAMEBUFFER_SRGB_EXT
:
1586 if (!_mesa_is_desktop_gl(ctx
))
1587 goto invalid_enum_error
;
1588 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1589 return ctx
->Color
.sRGBEnabled
;
1591 /* GL_OES_EGL_image_external */
1592 case GL_TEXTURE_EXTERNAL_OES
:
1593 if (!_mesa_is_gles(ctx
))
1594 goto invalid_enum_error
;
1595 CHECK_EXTENSION(OES_EGL_image_external
);
1596 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1598 /* ARB_texture_multisample */
1599 case GL_SAMPLE_MASK
:
1600 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles31(ctx
))
1601 goto invalid_enum_error
;
1602 CHECK_EXTENSION(ARB_texture_multisample
);
1603 return ctx
->Multisample
.SampleMask
;
1605 /* ARB_sample_shading */
1606 case GL_SAMPLE_SHADING
:
1607 if (!_mesa_is_desktop_gl(ctx
))
1608 goto invalid_enum_error
;
1609 CHECK_EXTENSION(ARB_sample_shading
);
1610 return ctx
->Multisample
.SampleShading
;
1613 goto invalid_enum_error
;
1619 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1620 _mesa_enum_to_string(cap
));