3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 #include "simple_list.h"
36 #include "mfeatures.h"
39 #include "api_arrayelt.h"
41 #include "drivers/common/meta.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
52 * Helper to enable/disable client-side state.
55 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
57 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
63 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
67 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
68 flag
= VERT_BIT_NORMAL
;
71 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
72 flag
= VERT_BIT_COLOR0
;
75 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
76 flag
= VERT_BIT_COLOR_INDEX
;
78 case GL_TEXTURE_COORD_ARRAY
:
79 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
80 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
82 case GL_EDGE_FLAG_ARRAY
:
83 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
84 flag
= VERT_BIT_EDGEFLAG
;
86 case GL_FOG_COORDINATE_ARRAY_EXT
:
87 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
90 case GL_SECONDARY_COLOR_ARRAY_EXT
:
91 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
92 flag
= VERT_BIT_COLOR1
;
95 case GL_POINT_SIZE_ARRAY_OES
:
96 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
97 flag
= VERT_BIT_POINT_SIZE
;
100 /* GL_NV_primitive_restart */
101 case GL_PRIMITIVE_RESTART_NV
:
102 if (!ctx
->Extensions
.NV_primitive_restart
) {
103 goto invalid_enum_error
;
105 var
= &ctx
->Array
.PrimitiveRestart
;
110 goto invalid_enum_error
;
116 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
118 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
123 arrayObj
->_Enabled
|= flag
;
125 arrayObj
->_Enabled
&= ~flag
;
127 arrayObj
->NewArrays
|= flag
;
129 if (ctx
->Driver
.Enable
) {
130 ctx
->Driver
.Enable( ctx
, cap
, state
);
136 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
137 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
142 * Enable GL capability.
143 * \param cap state to enable/disable.
145 * Get's the current context, assures that we're outside glBegin()/glEnd() and
146 * calls client_state().
149 _mesa_EnableClientState( GLenum cap
)
151 GET_CURRENT_CONTEXT(ctx
);
152 ASSERT_OUTSIDE_BEGIN_END(ctx
);
153 client_state( ctx
, cap
, GL_TRUE
);
158 * Disable GL capability.
159 * \param cap state to enable/disable.
161 * Get's the current context, assures that we're outside glBegin()/glEnd() and
162 * calls client_state().
165 _mesa_DisableClientState( GLenum cap
)
167 GET_CURRENT_CONTEXT(ctx
);
168 ASSERT_OUTSIDE_BEGIN_END(ctx
);
169 client_state( ctx
, cap
, GL_FALSE
);
173 #undef CHECK_EXTENSION
174 #define CHECK_EXTENSION(EXTNAME, CAP) \
175 if (!ctx->Extensions.EXTNAME) { \
176 goto invalid_enum_error; \
179 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
180 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
181 goto invalid_enum_error; \
185 * Return pointer to current texture unit for setting/getting coordinate
187 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
188 * texture unit is higher than the number of supported coordinate units.
190 static struct gl_texture_unit
*
191 get_texcoord_unit(struct gl_context
*ctx
)
193 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
194 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
198 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
204 * Helper function to enable or disable a texture target.
205 * \param bit one of the TEXTURE_x_BIT values
206 * \return GL_TRUE if state is changing or GL_FALSE if no change
209 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
211 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
212 const GLbitfield newenabled
= state
213 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
215 if (texUnit
->Enabled
== newenabled
)
218 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
219 texUnit
->Enabled
= newenabled
;
225 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
226 * whether the API supports it (GLES doesn't).
229 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
231 if (ctx
->Multisample
.Enabled
== state
)
233 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
234 ctx
->Multisample
.Enabled
= state
;
236 if (ctx
->Driver
.Enable
) {
237 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
242 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
243 * check for whether the API supports it (GLES doesn't).
246 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
248 if (ctx
->Color
.sRGBEnabled
== state
)
250 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
251 ctx
->Color
.sRGBEnabled
= state
;
253 if (ctx
->Driver
.Enable
) {
254 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
259 * Helper function to enable or disable state.
261 * \param ctx GL context.
262 * \param cap the state to enable/disable
263 * \param state whether to enable or disable the specified capability.
265 * Updates the current context and flushes the vertices as needed. For
266 * capabilities associated with extensions it verifies that those extensions
267 * are effectivly present before updating. Notifies the driver via
268 * dd_function_table::Enable.
271 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
273 if (MESA_VERBOSE
& VERBOSE_API
)
274 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
275 state
? "glEnable" : "glDisable",
276 _mesa_lookup_enum_by_nr(cap
),
281 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
282 goto invalid_enum_error
;
283 if (ctx
->Color
.AlphaEnabled
== state
)
285 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
286 ctx
->Color
.AlphaEnabled
= state
;
289 if (ctx
->API
!= API_OPENGL
)
290 goto invalid_enum_error
;
291 if (ctx
->Eval
.AutoNormal
== state
)
293 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
294 ctx
->Eval
.AutoNormal
= state
;
298 GLbitfield newEnabled
=
299 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
300 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
301 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
302 ctx
->Color
.BlendEnabled
= newEnabled
;
306 case GL_CLIP_DISTANCE0
:
307 case GL_CLIP_DISTANCE1
:
308 case GL_CLIP_DISTANCE2
:
309 case GL_CLIP_DISTANCE3
:
310 case GL_CLIP_DISTANCE4
:
311 case GL_CLIP_DISTANCE5
:
312 case GL_CLIP_DISTANCE6
:
313 case GL_CLIP_DISTANCE7
:
315 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
317 if (p
>= ctx
->Const
.MaxClipPlanes
)
318 goto invalid_enum_error
;
320 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
321 == ((GLuint
) state
<< p
))
324 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
327 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
328 _mesa_update_clip_plane(ctx
, p
);
331 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
335 case GL_COLOR_MATERIAL
:
336 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
337 goto invalid_enum_error
;
338 if (ctx
->Light
.ColorMaterialEnabled
== state
)
340 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
341 FLUSH_CURRENT(ctx
, 0);
342 ctx
->Light
.ColorMaterialEnabled
= state
;
344 _mesa_update_color_material( ctx
,
345 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
349 if (ctx
->Polygon
.CullFlag
== state
)
351 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
352 ctx
->Polygon
.CullFlag
= state
;
355 if (ctx
->Depth
.Test
== state
)
357 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
358 ctx
->Depth
.Test
= state
;
360 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
361 if (!_mesa_is_desktop_gl(ctx
))
362 goto invalid_enum_error
;
363 ctx
->Debug
.SyncOutput
= state
;
366 if (ctx
->Color
.DitherFlag
== state
)
368 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
369 ctx
->Color
.DitherFlag
= state
;
372 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
373 goto invalid_enum_error
;
374 if (ctx
->Fog
.Enabled
== state
)
376 FLUSH_VERTICES(ctx
, _NEW_FOG
);
377 ctx
->Fog
.Enabled
= state
;
387 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
388 goto invalid_enum_error
;
389 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
391 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
392 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
394 insert_at_tail(&ctx
->Light
.EnabledList
,
395 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
398 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
402 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
403 goto invalid_enum_error
;
404 if (ctx
->Light
.Enabled
== state
)
406 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
407 ctx
->Light
.Enabled
= state
;
408 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
409 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
411 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
414 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
415 goto invalid_enum_error
;
416 if (ctx
->Line
.SmoothFlag
== state
)
418 FLUSH_VERTICES(ctx
, _NEW_LINE
);
419 ctx
->Line
.SmoothFlag
= state
;
420 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
422 case GL_LINE_STIPPLE
:
423 if (ctx
->API
!= API_OPENGL
)
424 goto invalid_enum_error
;
425 if (ctx
->Line
.StippleFlag
== state
)
427 FLUSH_VERTICES(ctx
, _NEW_LINE
);
428 ctx
->Line
.StippleFlag
= state
;
429 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
431 case GL_INDEX_LOGIC_OP
:
432 if (ctx
->API
!= API_OPENGL
)
433 goto invalid_enum_error
;
434 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
436 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
437 ctx
->Color
.IndexLogicOpEnabled
= state
;
439 case GL_COLOR_LOGIC_OP
:
440 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
441 goto invalid_enum_error
;
442 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
444 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
445 ctx
->Color
.ColorLogicOpEnabled
= state
;
447 case GL_MAP1_COLOR_4
:
448 if (ctx
->API
!= API_OPENGL
)
449 goto invalid_enum_error
;
450 if (ctx
->Eval
.Map1Color4
== state
)
452 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
453 ctx
->Eval
.Map1Color4
= state
;
456 if (ctx
->API
!= API_OPENGL
)
457 goto invalid_enum_error
;
458 if (ctx
->Eval
.Map1Index
== state
)
460 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
461 ctx
->Eval
.Map1Index
= state
;
464 if (ctx
->API
!= API_OPENGL
)
465 goto invalid_enum_error
;
466 if (ctx
->Eval
.Map1Normal
== state
)
468 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
469 ctx
->Eval
.Map1Normal
= state
;
471 case GL_MAP1_TEXTURE_COORD_1
:
472 if (ctx
->API
!= API_OPENGL
)
473 goto invalid_enum_error
;
474 if (ctx
->Eval
.Map1TextureCoord1
== state
)
476 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
477 ctx
->Eval
.Map1TextureCoord1
= state
;
479 case GL_MAP1_TEXTURE_COORD_2
:
480 if (ctx
->API
!= API_OPENGL
)
481 goto invalid_enum_error
;
482 if (ctx
->Eval
.Map1TextureCoord2
== state
)
484 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
485 ctx
->Eval
.Map1TextureCoord2
= state
;
487 case GL_MAP1_TEXTURE_COORD_3
:
488 if (ctx
->API
!= API_OPENGL
)
489 goto invalid_enum_error
;
490 if (ctx
->Eval
.Map1TextureCoord3
== state
)
492 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
493 ctx
->Eval
.Map1TextureCoord3
= state
;
495 case GL_MAP1_TEXTURE_COORD_4
:
496 if (ctx
->API
!= API_OPENGL
)
497 goto invalid_enum_error
;
498 if (ctx
->Eval
.Map1TextureCoord4
== state
)
500 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
501 ctx
->Eval
.Map1TextureCoord4
= state
;
503 case GL_MAP1_VERTEX_3
:
504 if (ctx
->API
!= API_OPENGL
)
505 goto invalid_enum_error
;
506 if (ctx
->Eval
.Map1Vertex3
== state
)
508 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
509 ctx
->Eval
.Map1Vertex3
= state
;
511 case GL_MAP1_VERTEX_4
:
512 if (ctx
->API
!= API_OPENGL
)
513 goto invalid_enum_error
;
514 if (ctx
->Eval
.Map1Vertex4
== state
)
516 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
517 ctx
->Eval
.Map1Vertex4
= state
;
519 case GL_MAP2_COLOR_4
:
520 if (ctx
->API
!= API_OPENGL
)
521 goto invalid_enum_error
;
522 if (ctx
->Eval
.Map2Color4
== state
)
524 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
525 ctx
->Eval
.Map2Color4
= state
;
528 if (ctx
->API
!= API_OPENGL
)
529 goto invalid_enum_error
;
530 if (ctx
->Eval
.Map2Index
== state
)
532 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
533 ctx
->Eval
.Map2Index
= state
;
536 if (ctx
->API
!= API_OPENGL
)
537 goto invalid_enum_error
;
538 if (ctx
->Eval
.Map2Normal
== state
)
540 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
541 ctx
->Eval
.Map2Normal
= state
;
543 case GL_MAP2_TEXTURE_COORD_1
:
544 if (ctx
->API
!= API_OPENGL
)
545 goto invalid_enum_error
;
546 if (ctx
->Eval
.Map2TextureCoord1
== state
)
548 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
549 ctx
->Eval
.Map2TextureCoord1
= state
;
551 case GL_MAP2_TEXTURE_COORD_2
:
552 if (ctx
->API
!= API_OPENGL
)
553 goto invalid_enum_error
;
554 if (ctx
->Eval
.Map2TextureCoord2
== state
)
556 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
557 ctx
->Eval
.Map2TextureCoord2
= state
;
559 case GL_MAP2_TEXTURE_COORD_3
:
560 if (ctx
->API
!= API_OPENGL
)
561 goto invalid_enum_error
;
562 if (ctx
->Eval
.Map2TextureCoord3
== state
)
564 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
565 ctx
->Eval
.Map2TextureCoord3
= state
;
567 case GL_MAP2_TEXTURE_COORD_4
:
568 if (ctx
->API
!= API_OPENGL
)
569 goto invalid_enum_error
;
570 if (ctx
->Eval
.Map2TextureCoord4
== state
)
572 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
573 ctx
->Eval
.Map2TextureCoord4
= state
;
575 case GL_MAP2_VERTEX_3
:
576 if (ctx
->API
!= API_OPENGL
)
577 goto invalid_enum_error
;
578 if (ctx
->Eval
.Map2Vertex3
== state
)
580 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
581 ctx
->Eval
.Map2Vertex3
= state
;
583 case GL_MAP2_VERTEX_4
:
584 if (ctx
->API
!= API_OPENGL
)
585 goto invalid_enum_error
;
586 if (ctx
->Eval
.Map2Vertex4
== state
)
588 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
589 ctx
->Eval
.Map2Vertex4
= state
;
592 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
593 goto invalid_enum_error
;
594 if (ctx
->Transform
.Normalize
== state
)
596 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
597 ctx
->Transform
.Normalize
= state
;
599 case GL_POINT_SMOOTH
:
600 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
601 goto invalid_enum_error
;
602 if (ctx
->Point
.SmoothFlag
== state
)
604 FLUSH_VERTICES(ctx
, _NEW_POINT
);
605 ctx
->Point
.SmoothFlag
= state
;
606 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
608 case GL_POLYGON_SMOOTH
:
609 if (!_mesa_is_desktop_gl(ctx
))
610 goto invalid_enum_error
;
611 if (ctx
->Polygon
.SmoothFlag
== state
)
613 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
614 ctx
->Polygon
.SmoothFlag
= state
;
615 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
617 case GL_POLYGON_STIPPLE
:
618 if (ctx
->API
!= API_OPENGL
)
619 goto invalid_enum_error
;
620 if (ctx
->Polygon
.StippleFlag
== state
)
622 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
623 ctx
->Polygon
.StippleFlag
= state
;
624 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
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
&& 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
:
657 if (ctx
->Scissor
.Enabled
== state
)
659 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
660 ctx
->Scissor
.Enabled
= state
;
662 case GL_STENCIL_TEST
:
663 if (ctx
->Stencil
.Enabled
== state
)
665 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
666 ctx
->Stencil
.Enabled
= state
;
669 if (ctx
->API
!= API_OPENGL
)
670 goto invalid_enum_error
;
671 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
676 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
677 goto invalid_enum_error
;
678 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
683 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
684 goto invalid_enum_error
;
685 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
689 case GL_TEXTURE_GEN_S
:
690 case GL_TEXTURE_GEN_T
:
691 case GL_TEXTURE_GEN_R
:
692 case GL_TEXTURE_GEN_Q
:
694 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
696 if (ctx
->API
!= API_OPENGL
)
697 goto invalid_enum_error
;
700 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
701 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
703 newenabled
|= coordBit
;
704 if (texUnit
->TexGenEnabled
== newenabled
)
706 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
707 texUnit
->TexGenEnabled
= newenabled
;
712 case GL_TEXTURE_GEN_STR_OES
:
713 /* disable S, T, and R at the same time */
715 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
717 if (ctx
->API
!= API_OPENGLES
)
718 goto invalid_enum_error
;
722 texUnit
->TexGenEnabled
& ~STR_BITS
;
724 newenabled
|= STR_BITS
;
725 if (texUnit
->TexGenEnabled
== newenabled
)
727 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
728 texUnit
->TexGenEnabled
= newenabled
;
733 /* client-side state */
734 case GL_VERTEX_ARRAY
:
735 case GL_NORMAL_ARRAY
:
738 case GL_TEXTURE_COORD_ARRAY
:
739 case GL_EDGE_FLAG_ARRAY
:
740 case GL_FOG_COORDINATE_ARRAY_EXT
:
741 case GL_SECONDARY_COLOR_ARRAY_EXT
:
742 case GL_POINT_SIZE_ARRAY_OES
:
743 client_state( ctx
, cap
, state
);
746 /* GL_ARB_texture_cube_map */
747 case GL_TEXTURE_CUBE_MAP_ARB
:
748 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
749 goto invalid_enum_error
;
750 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
751 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
756 /* GL_EXT_secondary_color */
757 case GL_COLOR_SUM_EXT
:
758 if (ctx
->API
!= API_OPENGL
)
759 goto invalid_enum_error
;
760 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
761 if (ctx
->Fog
.ColorSumEnabled
== state
)
763 FLUSH_VERTICES(ctx
, _NEW_FOG
);
764 ctx
->Fog
.ColorSumEnabled
= state
;
767 /* GL_ARB_multisample */
768 case GL_MULTISAMPLE_ARB
:
769 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
770 goto invalid_enum_error
;
771 _mesa_set_multisample(ctx
, state
);
773 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
774 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
776 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
777 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
779 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
780 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
781 goto invalid_enum_error
;
782 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
784 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
785 ctx
->Multisample
.SampleAlphaToOne
= state
;
787 case GL_SAMPLE_COVERAGE_ARB
:
788 if (ctx
->Multisample
.SampleCoverage
== state
)
790 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
791 ctx
->Multisample
.SampleCoverage
= state
;
793 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
794 if (!_mesa_is_desktop_gl(ctx
))
795 goto invalid_enum_error
;
796 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
798 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
799 ctx
->Multisample
.SampleCoverageInvert
= state
;
802 /* GL_IBM_rasterpos_clip */
803 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
804 if (ctx
->API
!= API_OPENGL
)
805 goto invalid_enum_error
;
806 CHECK_EXTENSION(IBM_rasterpos_clip
, cap
);
807 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
809 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
810 ctx
->Transform
.RasterPositionUnclipped
= state
;
813 /* GL_NV_point_sprite */
814 case GL_POINT_SPRITE_NV
:
815 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
816 goto invalid_enum_error
;
817 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
818 if (ctx
->Point
.PointSprite
== state
)
820 FLUSH_VERTICES(ctx
, _NEW_POINT
);
821 ctx
->Point
.PointSprite
= state
;
824 case GL_VERTEX_PROGRAM_ARB
:
825 if (ctx
->API
!= API_OPENGL
)
826 goto invalid_enum_error
;
827 CHECK_EXTENSION(ARB_vertex_program
, cap
);
828 if (ctx
->VertexProgram
.Enabled
== state
)
830 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
831 ctx
->VertexProgram
.Enabled
= state
;
833 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
834 /* This was added with ARB_vertex_program, but it is also used with
835 * GLSL vertex shaders on desktop.
837 if (!_mesa_is_desktop_gl(ctx
))
838 goto invalid_enum_error
;
839 CHECK_EXTENSION(ARB_vertex_program
, cap
);
840 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
842 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
843 ctx
->VertexProgram
.PointSizeEnabled
= state
;
845 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
846 if (ctx
->API
!= API_OPENGL
)
847 goto invalid_enum_error
;
848 CHECK_EXTENSION(ARB_vertex_program
, cap
);
849 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
851 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
852 ctx
->VertexProgram
.TwoSideEnabled
= state
;
855 /* GL_NV_texture_rectangle */
856 case GL_TEXTURE_RECTANGLE_NV
:
857 if (ctx
->API
!= API_OPENGL
)
858 goto invalid_enum_error
;
859 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
860 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
865 /* GL_EXT_stencil_two_side */
866 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
867 if (ctx
->API
!= API_OPENGL
)
868 goto invalid_enum_error
;
869 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
870 if (ctx
->Stencil
.TestTwoSide
== state
)
872 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
873 ctx
->Stencil
.TestTwoSide
= state
;
875 ctx
->Stencil
._BackFace
= 2;
877 ctx
->Stencil
._BackFace
= 1;
881 case GL_FRAGMENT_PROGRAM_ARB
:
882 if (ctx
->API
!= API_OPENGL
)
883 goto invalid_enum_error
;
884 CHECK_EXTENSION(ARB_fragment_program
, cap
);
885 if (ctx
->FragmentProgram
.Enabled
== state
)
887 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
888 ctx
->FragmentProgram
.Enabled
= state
;
891 /* GL_EXT_depth_bounds_test */
892 case GL_DEPTH_BOUNDS_TEST_EXT
:
893 if (!_mesa_is_desktop_gl(ctx
))
894 goto invalid_enum_error
;
895 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
896 if (ctx
->Depth
.BoundsTest
== state
)
898 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
899 ctx
->Depth
.BoundsTest
= state
;
903 if (!_mesa_is_desktop_gl(ctx
))
904 goto invalid_enum_error
;
905 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
906 if (ctx
->Transform
.DepthClamp
== state
)
908 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
909 ctx
->Transform
.DepthClamp
= state
;
912 case GL_FRAGMENT_SHADER_ATI
:
913 if (ctx
->API
!= API_OPENGL
)
914 goto invalid_enum_error
;
915 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
916 if (ctx
->ATIFragmentShader
.Enabled
== state
)
918 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
919 ctx
->ATIFragmentShader
.Enabled
= state
;
922 /* GL_MESA_texture_array */
923 case GL_TEXTURE_1D_ARRAY_EXT
:
924 if (ctx
->API
!= API_OPENGL
)
925 goto invalid_enum_error
;
926 CHECK_EXTENSION(MESA_texture_array
, cap
);
927 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
932 case GL_TEXTURE_2D_ARRAY_EXT
:
933 if (ctx
->API
!= API_OPENGL
)
934 goto invalid_enum_error
;
935 CHECK_EXTENSION(MESA_texture_array
, cap
);
936 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
941 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
942 if (!_mesa_is_desktop_gl(ctx
))
943 goto invalid_enum_error
;
944 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
945 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
946 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
947 ctx
->Texture
.CubeMapSeamless
= state
;
951 case GL_RASTERIZER_DISCARD
:
952 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
953 goto invalid_enum_error
;
954 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
955 if (ctx
->RasterDiscard
!= state
) {
956 FLUSH_VERTICES(ctx
, _NEW_RASTERIZER_DISCARD
);
957 ctx
->RasterDiscard
= state
;
961 /* GL 3.1 primitive restart. Note: this enum is different from
962 * GL_PRIMITIVE_RESTART_NV (which is client state).
964 case GL_PRIMITIVE_RESTART
:
965 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
966 goto invalid_enum_error
;
968 if (ctx
->Array
.PrimitiveRestart
!= state
) {
969 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
970 ctx
->Array
.PrimitiveRestart
= state
;
974 /* GL3.0 - GL_framebuffer_sRGB */
975 case GL_FRAMEBUFFER_SRGB_EXT
:
976 if (!_mesa_is_desktop_gl(ctx
))
977 goto invalid_enum_error
;
978 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
979 _mesa_set_framebuffer_srgb(ctx
, state
);
982 /* GL_OES_EGL_image_external */
983 case GL_TEXTURE_EXTERNAL_OES
:
984 if (!_mesa_is_gles(ctx
))
985 goto invalid_enum_error
;
986 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
987 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
993 goto invalid_enum_error
;
996 if (ctx
->Driver
.Enable
) {
997 ctx
->Driver
.Enable( ctx
, cap
, state
);
1003 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1004 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
1009 * Enable GL capability. Called by glEnable()
1010 * \param cap state to enable.
1013 _mesa_Enable( GLenum cap
)
1015 GET_CURRENT_CONTEXT(ctx
);
1016 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1018 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1023 * Disable GL capability. Called by glDisable()
1024 * \param cap state to disable.
1027 _mesa_Disable( GLenum cap
)
1029 GET_CURRENT_CONTEXT(ctx
);
1030 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1032 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1038 * Enable/disable an indexed state var.
1041 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1042 GLuint index
, GLboolean state
)
1044 ASSERT(state
== 0 || state
== 1);
1047 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1048 goto invalid_enum_error
;
1050 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1051 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1052 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1055 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1056 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1058 ctx
->Color
.BlendEnabled
|= (1 << index
);
1060 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1064 goto invalid_enum_error
;
1069 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1070 state
? "glEnablei" : "glDisablei",
1071 _mesa_lookup_enum_by_nr(cap
));
1076 _mesa_DisableIndexed( GLenum cap
, GLuint index
)
1078 GET_CURRENT_CONTEXT(ctx
);
1079 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1080 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1085 _mesa_EnableIndexed( GLenum cap
, GLuint index
)
1087 GET_CURRENT_CONTEXT(ctx
);
1088 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1089 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1093 GLboolean GLAPIENTRY
1094 _mesa_IsEnabledIndexed( GLenum cap
, GLuint index
)
1096 GET_CURRENT_CONTEXT(ctx
);
1097 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1100 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1101 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1105 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1107 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1108 _mesa_lookup_enum_by_nr(cap
));
1116 #undef CHECK_EXTENSION
1117 #define CHECK_EXTENSION(EXTNAME) \
1118 if (!ctx->Extensions.EXTNAME) { \
1119 goto invalid_enum_error; \
1122 #undef CHECK_EXTENSION2
1123 #define CHECK_EXTENSION2(EXT1, EXT2) \
1124 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1125 goto invalid_enum_error; \
1130 * Helper function to determine whether a texture target is enabled.
1133 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1135 const struct gl_texture_unit
*const texUnit
=
1136 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1137 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1142 * Return simple enable/disable state.
1144 * \param cap state variable to query.
1146 * Returns the state of the specified capability from the current GL context.
1147 * For the capabilities associated with extensions verifies that those
1148 * extensions are effectively present before reporting.
1150 GLboolean GLAPIENTRY
1151 _mesa_IsEnabled( GLenum cap
)
1153 GET_CURRENT_CONTEXT(ctx
);
1154 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1158 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1159 goto invalid_enum_error
;
1160 return ctx
->Color
.AlphaEnabled
;
1161 case GL_AUTO_NORMAL
:
1162 if (ctx
->API
!= API_OPENGL
)
1163 goto invalid_enum_error
;
1164 return ctx
->Eval
.AutoNormal
;
1166 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1167 case GL_CLIP_DISTANCE0
:
1168 case GL_CLIP_DISTANCE1
:
1169 case GL_CLIP_DISTANCE2
:
1170 case GL_CLIP_DISTANCE3
:
1171 case GL_CLIP_DISTANCE4
:
1172 case GL_CLIP_DISTANCE5
:
1173 case GL_CLIP_DISTANCE6
:
1174 case GL_CLIP_DISTANCE7
: {
1175 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1177 if (p
>= ctx
->Const
.MaxClipPlanes
)
1178 goto invalid_enum_error
;
1180 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1182 case GL_COLOR_MATERIAL
:
1183 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1184 goto invalid_enum_error
;
1185 return ctx
->Light
.ColorMaterialEnabled
;
1187 return ctx
->Polygon
.CullFlag
;
1188 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1189 if (!_mesa_is_desktop_gl(ctx
))
1190 goto invalid_enum_error
;
1191 return ctx
->Debug
.SyncOutput
;
1193 return ctx
->Depth
.Test
;
1195 return ctx
->Color
.DitherFlag
;
1197 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1198 goto invalid_enum_error
;
1199 return ctx
->Fog
.Enabled
;
1201 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1202 goto invalid_enum_error
;
1203 return ctx
->Light
.Enabled
;
1212 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1213 goto invalid_enum_error
;
1214 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1215 case GL_LINE_SMOOTH
:
1216 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1217 goto invalid_enum_error
;
1218 return ctx
->Line
.SmoothFlag
;
1219 case GL_LINE_STIPPLE
:
1220 if (ctx
->API
!= API_OPENGL
)
1221 goto invalid_enum_error
;
1222 return ctx
->Line
.StippleFlag
;
1223 case GL_INDEX_LOGIC_OP
:
1224 if (ctx
->API
!= API_OPENGL
)
1225 goto invalid_enum_error
;
1226 return ctx
->Color
.IndexLogicOpEnabled
;
1227 case GL_COLOR_LOGIC_OP
:
1228 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1229 goto invalid_enum_error
;
1230 return ctx
->Color
.ColorLogicOpEnabled
;
1231 case GL_MAP1_COLOR_4
:
1232 if (ctx
->API
!= API_OPENGL
)
1233 goto invalid_enum_error
;
1234 return ctx
->Eval
.Map1Color4
;
1236 if (ctx
->API
!= API_OPENGL
)
1237 goto invalid_enum_error
;
1238 return ctx
->Eval
.Map1Index
;
1239 case GL_MAP1_NORMAL
:
1240 if (ctx
->API
!= API_OPENGL
)
1241 goto invalid_enum_error
;
1242 return ctx
->Eval
.Map1Normal
;
1243 case GL_MAP1_TEXTURE_COORD_1
:
1244 if (ctx
->API
!= API_OPENGL
)
1245 goto invalid_enum_error
;
1246 return ctx
->Eval
.Map1TextureCoord1
;
1247 case GL_MAP1_TEXTURE_COORD_2
:
1248 if (ctx
->API
!= API_OPENGL
)
1249 goto invalid_enum_error
;
1250 return ctx
->Eval
.Map1TextureCoord2
;
1251 case GL_MAP1_TEXTURE_COORD_3
:
1252 if (ctx
->API
!= API_OPENGL
)
1253 goto invalid_enum_error
;
1254 return ctx
->Eval
.Map1TextureCoord3
;
1255 case GL_MAP1_TEXTURE_COORD_4
:
1256 if (ctx
->API
!= API_OPENGL
)
1257 goto invalid_enum_error
;
1258 return ctx
->Eval
.Map1TextureCoord4
;
1259 case GL_MAP1_VERTEX_3
:
1260 if (ctx
->API
!= API_OPENGL
)
1261 goto invalid_enum_error
;
1262 return ctx
->Eval
.Map1Vertex3
;
1263 case GL_MAP1_VERTEX_4
:
1264 if (ctx
->API
!= API_OPENGL
)
1265 goto invalid_enum_error
;
1266 return ctx
->Eval
.Map1Vertex4
;
1267 case GL_MAP2_COLOR_4
:
1268 if (ctx
->API
!= API_OPENGL
)
1269 goto invalid_enum_error
;
1270 return ctx
->Eval
.Map2Color4
;
1272 if (ctx
->API
!= API_OPENGL
)
1273 goto invalid_enum_error
;
1274 return ctx
->Eval
.Map2Index
;
1275 case GL_MAP2_NORMAL
:
1276 if (ctx
->API
!= API_OPENGL
)
1277 goto invalid_enum_error
;
1278 return ctx
->Eval
.Map2Normal
;
1279 case GL_MAP2_TEXTURE_COORD_1
:
1280 if (ctx
->API
!= API_OPENGL
)
1281 goto invalid_enum_error
;
1282 return ctx
->Eval
.Map2TextureCoord1
;
1283 case GL_MAP2_TEXTURE_COORD_2
:
1284 if (ctx
->API
!= API_OPENGL
)
1285 goto invalid_enum_error
;
1286 return ctx
->Eval
.Map2TextureCoord2
;
1287 case GL_MAP2_TEXTURE_COORD_3
:
1288 if (ctx
->API
!= API_OPENGL
)
1289 goto invalid_enum_error
;
1290 return ctx
->Eval
.Map2TextureCoord3
;
1291 case GL_MAP2_TEXTURE_COORD_4
:
1292 if (ctx
->API
!= API_OPENGL
)
1293 goto invalid_enum_error
;
1294 return ctx
->Eval
.Map2TextureCoord4
;
1295 case GL_MAP2_VERTEX_3
:
1296 if (ctx
->API
!= API_OPENGL
)
1297 goto invalid_enum_error
;
1298 return ctx
->Eval
.Map2Vertex3
;
1299 case GL_MAP2_VERTEX_4
:
1300 if (ctx
->API
!= API_OPENGL
)
1301 goto invalid_enum_error
;
1302 return ctx
->Eval
.Map2Vertex4
;
1304 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1305 goto invalid_enum_error
;
1306 return ctx
->Transform
.Normalize
;
1307 case GL_POINT_SMOOTH
:
1308 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1309 goto invalid_enum_error
;
1310 return ctx
->Point
.SmoothFlag
;
1311 case GL_POLYGON_SMOOTH
:
1312 if (!_mesa_is_desktop_gl(ctx
))
1313 goto invalid_enum_error
;
1314 return ctx
->Polygon
.SmoothFlag
;
1315 case GL_POLYGON_STIPPLE
:
1316 if (ctx
->API
!= API_OPENGL
)
1317 goto invalid_enum_error
;
1318 return ctx
->Polygon
.StippleFlag
;
1319 case GL_POLYGON_OFFSET_POINT
:
1320 if (!_mesa_is_desktop_gl(ctx
))
1321 goto invalid_enum_error
;
1322 return ctx
->Polygon
.OffsetPoint
;
1323 case GL_POLYGON_OFFSET_LINE
:
1324 if (!_mesa_is_desktop_gl(ctx
))
1325 goto invalid_enum_error
;
1326 return ctx
->Polygon
.OffsetLine
;
1327 case GL_POLYGON_OFFSET_FILL
:
1328 return ctx
->Polygon
.OffsetFill
;
1329 case GL_RESCALE_NORMAL_EXT
:
1330 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1331 goto invalid_enum_error
;
1332 return ctx
->Transform
.RescaleNormals
;
1333 case GL_SCISSOR_TEST
:
1334 return ctx
->Scissor
.Enabled
;
1335 case GL_STENCIL_TEST
:
1336 return ctx
->Stencil
.Enabled
;
1338 if (ctx
->API
!= API_OPENGL
)
1339 goto invalid_enum_error
;
1340 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1342 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1343 goto invalid_enum_error
;
1344 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1346 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1347 goto invalid_enum_error
;
1348 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1349 case GL_TEXTURE_GEN_S
:
1350 case GL_TEXTURE_GEN_T
:
1351 case GL_TEXTURE_GEN_R
:
1352 case GL_TEXTURE_GEN_Q
:
1354 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1356 if (ctx
->API
!= API_OPENGL
)
1357 goto invalid_enum_error
;
1360 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1361 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1365 case GL_TEXTURE_GEN_STR_OES
:
1367 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1369 if (ctx
->API
!= API_OPENGLES
)
1370 goto invalid_enum_error
;
1373 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1374 ? GL_TRUE
: GL_FALSE
;
1378 /* client-side state */
1379 case GL_VERTEX_ARRAY
:
1380 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1381 goto invalid_enum_error
;
1382 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
!= 0);
1383 case GL_NORMAL_ARRAY
:
1384 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1385 goto invalid_enum_error
;
1386 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1387 case GL_COLOR_ARRAY
:
1388 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1389 goto invalid_enum_error
;
1390 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
!= 0);
1391 case GL_INDEX_ARRAY
:
1392 if (ctx
->API
!= API_OPENGL
)
1393 goto invalid_enum_error
;
1394 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1395 case GL_TEXTURE_COORD_ARRAY
:
1396 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1397 goto invalid_enum_error
;
1398 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1400 case GL_EDGE_FLAG_ARRAY
:
1401 if (ctx
->API
!= API_OPENGL
)
1402 goto invalid_enum_error
;
1403 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1404 case GL_FOG_COORDINATE_ARRAY_EXT
:
1405 if (ctx
->API
!= API_OPENGL
)
1406 goto invalid_enum_error
;
1407 CHECK_EXTENSION(EXT_fog_coord
);
1408 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1409 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1410 if (ctx
->API
!= API_OPENGL
)
1411 goto invalid_enum_error
;
1412 CHECK_EXTENSION(EXT_secondary_color
);
1413 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1414 case GL_POINT_SIZE_ARRAY_OES
:
1415 if (ctx
->API
!= API_OPENGLES
)
1416 goto invalid_enum_error
;
1417 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1419 /* GL_ARB_texture_cube_map */
1420 case GL_TEXTURE_CUBE_MAP_ARB
:
1421 CHECK_EXTENSION(ARB_texture_cube_map
);
1422 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1424 /* GL_EXT_secondary_color */
1425 case GL_COLOR_SUM_EXT
:
1426 if (ctx
->API
!= API_OPENGL
)
1427 goto invalid_enum_error
;
1428 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1429 return ctx
->Fog
.ColorSumEnabled
;
1431 /* GL_ARB_multisample */
1432 case GL_MULTISAMPLE_ARB
:
1433 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1434 goto invalid_enum_error
;
1435 return ctx
->Multisample
.Enabled
;
1436 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1437 return ctx
->Multisample
.SampleAlphaToCoverage
;
1438 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1439 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1440 goto invalid_enum_error
;
1441 return ctx
->Multisample
.SampleAlphaToOne
;
1442 case GL_SAMPLE_COVERAGE_ARB
:
1443 return ctx
->Multisample
.SampleCoverage
;
1444 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1445 if (!_mesa_is_desktop_gl(ctx
))
1446 goto invalid_enum_error
;
1447 return ctx
->Multisample
.SampleCoverageInvert
;
1449 /* GL_IBM_rasterpos_clip */
1450 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1451 if (ctx
->API
!= API_OPENGL
)
1452 goto invalid_enum_error
;
1453 CHECK_EXTENSION(IBM_rasterpos_clip
);
1454 return ctx
->Transform
.RasterPositionUnclipped
;
1456 /* GL_NV_point_sprite */
1457 case GL_POINT_SPRITE_NV
:
1458 if (ctx
->API
!= API_OPENGL
&& ctx
->API
!= API_OPENGLES
)
1459 goto invalid_enum_error
;
1460 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1461 return ctx
->Point
.PointSprite
;
1463 case GL_VERTEX_PROGRAM_ARB
:
1464 if (ctx
->API
!= API_OPENGL
)
1465 goto invalid_enum_error
;
1466 CHECK_EXTENSION(ARB_vertex_program
);
1467 return ctx
->VertexProgram
.Enabled
;
1468 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1469 /* This was added with ARB_vertex_program, but it is also used with
1470 * GLSL vertex shaders on desktop.
1472 if (!_mesa_is_desktop_gl(ctx
))
1473 goto invalid_enum_error
;
1474 CHECK_EXTENSION(ARB_vertex_program
);
1475 return ctx
->VertexProgram
.PointSizeEnabled
;
1476 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1477 if (ctx
->API
!= API_OPENGL
)
1478 goto invalid_enum_error
;
1479 CHECK_EXTENSION(ARB_vertex_program
);
1480 return ctx
->VertexProgram
.TwoSideEnabled
;
1482 /* GL_NV_texture_rectangle */
1483 case GL_TEXTURE_RECTANGLE_NV
:
1484 if (ctx
->API
!= API_OPENGL
)
1485 goto invalid_enum_error
;
1486 CHECK_EXTENSION(NV_texture_rectangle
);
1487 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1489 /* GL_EXT_stencil_two_side */
1490 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1491 if (ctx
->API
!= API_OPENGL
)
1492 goto invalid_enum_error
;
1493 CHECK_EXTENSION(EXT_stencil_two_side
);
1494 return ctx
->Stencil
.TestTwoSide
;
1496 case GL_FRAGMENT_PROGRAM_ARB
:
1497 if (ctx
->API
!= API_OPENGL
)
1498 goto invalid_enum_error
;
1499 return ctx
->FragmentProgram
.Enabled
;
1501 /* GL_EXT_depth_bounds_test */
1502 case GL_DEPTH_BOUNDS_TEST_EXT
:
1503 if (!_mesa_is_desktop_gl(ctx
))
1504 goto invalid_enum_error
;
1505 CHECK_EXTENSION(EXT_depth_bounds_test
);
1506 return ctx
->Depth
.BoundsTest
;
1508 /* GL_ARB_depth_clamp */
1509 case GL_DEPTH_CLAMP
:
1510 if (!_mesa_is_desktop_gl(ctx
))
1511 goto invalid_enum_error
;
1512 CHECK_EXTENSION(ARB_depth_clamp
);
1513 return ctx
->Transform
.DepthClamp
;
1515 case GL_FRAGMENT_SHADER_ATI
:
1516 if (ctx
->API
!= API_OPENGL
)
1517 goto invalid_enum_error
;
1518 CHECK_EXTENSION(ATI_fragment_shader
);
1519 return ctx
->ATIFragmentShader
.Enabled
;
1521 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1522 if (!_mesa_is_desktop_gl(ctx
))
1523 goto invalid_enum_error
;
1524 CHECK_EXTENSION(ARB_seamless_cube_map
);
1525 return ctx
->Texture
.CubeMapSeamless
;
1527 case GL_RASTERIZER_DISCARD
:
1528 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1529 goto invalid_enum_error
;
1530 CHECK_EXTENSION(EXT_transform_feedback
);
1531 return ctx
->RasterDiscard
;
1533 /* GL_NV_primitive_restart */
1534 case GL_PRIMITIVE_RESTART_NV
:
1535 if (ctx
->API
!= API_OPENGL
|| !ctx
->Extensions
.NV_primitive_restart
) {
1536 goto invalid_enum_error
;
1538 return ctx
->Array
.PrimitiveRestart
;
1540 /* GL 3.1 primitive restart */
1541 case GL_PRIMITIVE_RESTART
:
1542 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1543 goto invalid_enum_error
;
1545 return ctx
->Array
.PrimitiveRestart
;
1547 /* GL3.0 - GL_framebuffer_sRGB */
1548 case GL_FRAMEBUFFER_SRGB_EXT
:
1549 if (!_mesa_is_desktop_gl(ctx
))
1550 goto invalid_enum_error
;
1551 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1552 return ctx
->Color
.sRGBEnabled
;
1554 /* GL_OES_EGL_image_external */
1555 case GL_TEXTURE_EXTERNAL_OES
:
1556 if (!_mesa_is_gles(ctx
))
1557 goto invalid_enum_error
;
1558 CHECK_EXTENSION(OES_EGL_image_external
);
1559 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1562 goto invalid_enum_error
;
1568 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1569 _mesa_lookup_enum_by_nr(cap
));