3 * Enable/disable/query GL capabilities.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 #include "simple_list.h"
36 #include "mfeatures.h"
39 #include "api_arrayelt.h"
41 #include "drivers/common/meta.h"
45 #define CHECK_EXTENSION(EXTNAME, CAP) \
46 if (!ctx->Extensions.EXTNAME) { \
47 goto invalid_enum_error; \
52 update_derived_primitive_restart_state(struct gl_context
*ctx
)
54 /* Update derived primitive restart state.
56 if (ctx
->Array
.PrimitiveRestart
)
57 ctx
->Array
._RestartIndex
= ctx
->Array
.RestartIndex
;
59 ctx
->Array
._RestartIndex
= ~0;
61 ctx
->Array
._PrimitiveRestart
= ctx
->Array
.PrimitiveRestart
62 || ctx
->Array
.PrimitiveRestartFixedIndex
;
66 * Helper to enable/disable client-side state.
69 client_state(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
71 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
77 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
;
81 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
;
82 flag
= VERT_BIT_NORMAL
;
85 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
;
86 flag
= VERT_BIT_COLOR0
;
89 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
;
90 flag
= VERT_BIT_COLOR_INDEX
;
92 case GL_TEXTURE_COORD_ARRAY
:
93 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Enabled
;
94 flag
= VERT_BIT_TEX(ctx
->Array
.ActiveTexture
);
96 case GL_EDGE_FLAG_ARRAY
:
97 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
;
98 flag
= VERT_BIT_EDGEFLAG
;
100 case GL_FOG_COORDINATE_ARRAY_EXT
:
101 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
;
104 case GL_SECONDARY_COLOR_ARRAY_EXT
:
105 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
;
106 flag
= VERT_BIT_COLOR1
;
109 case GL_POINT_SIZE_ARRAY_OES
:
110 var
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
;
111 flag
= VERT_BIT_POINT_SIZE
;
114 /* GL_NV_primitive_restart */
115 case GL_PRIMITIVE_RESTART_NV
:
116 if (!ctx
->Extensions
.NV_primitive_restart
) {
117 goto invalid_enum_error
;
119 var
= &ctx
->Array
.PrimitiveRestart
;
124 goto invalid_enum_error
;
130 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
132 _ae_invalidate_state(ctx
, _NEW_ARRAY
);
136 update_derived_primitive_restart_state(ctx
);
139 arrayObj
->_Enabled
|= flag
;
141 arrayObj
->_Enabled
&= ~flag
;
143 arrayObj
->NewArrays
|= flag
;
145 if (ctx
->Driver
.Enable
) {
146 ctx
->Driver
.Enable( ctx
, cap
, state
);
152 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%sClientState(%s)",
153 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
158 * Enable GL capability.
159 * \param cap state to enable/disable.
161 * Get's the current context, assures that we're outside glBegin()/glEnd() and
162 * calls client_state().
165 _mesa_EnableClientState( GLenum cap
)
167 GET_CURRENT_CONTEXT(ctx
);
168 client_state( ctx
, cap
, GL_TRUE
);
173 * Disable GL capability.
174 * \param cap state to enable/disable.
176 * Get's the current context, assures that we're outside glBegin()/glEnd() and
177 * calls client_state().
180 _mesa_DisableClientState( GLenum cap
)
182 GET_CURRENT_CONTEXT(ctx
);
183 client_state( ctx
, cap
, GL_FALSE
);
187 #undef CHECK_EXTENSION
188 #define CHECK_EXTENSION(EXTNAME, CAP) \
189 if (!ctx->Extensions.EXTNAME) { \
190 goto invalid_enum_error; \
193 #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
194 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
195 goto invalid_enum_error; \
199 * Return pointer to current texture unit for setting/getting coordinate
201 * Note that we'll set GL_INVALID_OPERATION and return NULL if the active
202 * texture unit is higher than the number of supported coordinate units.
204 static struct gl_texture_unit
*
205 get_texcoord_unit(struct gl_context
*ctx
)
207 if (ctx
->Texture
.CurrentUnit
>= ctx
->Const
.MaxTextureCoordUnits
) {
208 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glEnable/Disable(texcoord unit)");
212 return &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
218 * Helper function to enable or disable a texture target.
219 * \param bit one of the TEXTURE_x_BIT values
220 * \return GL_TRUE if state is changing or GL_FALSE if no change
223 enable_texture(struct gl_context
*ctx
, GLboolean state
, GLbitfield texBit
)
225 struct gl_texture_unit
*texUnit
= _mesa_get_current_tex_unit(ctx
);
226 const GLbitfield newenabled
= state
227 ? (texUnit
->Enabled
| texBit
) : (texUnit
->Enabled
& ~texBit
);
229 if (texUnit
->Enabled
== newenabled
)
232 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
233 texUnit
->Enabled
= newenabled
;
239 * Helper function to enable or disable GL_MULTISAMPLE, skipping the check for
240 * whether the API supports it (GLES doesn't).
243 _mesa_set_multisample(struct gl_context
*ctx
, GLboolean state
)
245 if (ctx
->Multisample
.Enabled
== state
)
247 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
248 ctx
->Multisample
.Enabled
= state
;
250 if (ctx
->Driver
.Enable
) {
251 ctx
->Driver
.Enable(ctx
, GL_MULTISAMPLE
, state
);
256 * Helper function to enable or disable GL_FRAMEBUFFER_SRGB, skipping the
257 * check for whether the API supports it (GLES doesn't).
260 _mesa_set_framebuffer_srgb(struct gl_context
*ctx
, GLboolean state
)
262 if (ctx
->Color
.sRGBEnabled
== state
)
264 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
265 ctx
->Color
.sRGBEnabled
= state
;
267 if (ctx
->Driver
.Enable
) {
268 ctx
->Driver
.Enable(ctx
, GL_FRAMEBUFFER_SRGB
, state
);
273 * Helper function to enable or disable state.
275 * \param ctx GL context.
276 * \param cap the state to enable/disable
277 * \param state whether to enable or disable the specified capability.
279 * Updates the current context and flushes the vertices as needed. For
280 * capabilities associated with extensions it verifies that those extensions
281 * are effectivly present before updating. Notifies the driver via
282 * dd_function_table::Enable.
285 _mesa_set_enable(struct gl_context
*ctx
, GLenum cap
, GLboolean state
)
287 if (MESA_VERBOSE
& VERBOSE_API
)
288 _mesa_debug(ctx
, "%s %s (newstate is %x)\n",
289 state
? "glEnable" : "glDisable",
290 _mesa_lookup_enum_by_nr(cap
),
295 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
296 goto invalid_enum_error
;
297 if (ctx
->Color
.AlphaEnabled
== state
)
299 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
300 ctx
->Color
.AlphaEnabled
= state
;
303 if (ctx
->API
!= API_OPENGL_COMPAT
)
304 goto invalid_enum_error
;
305 if (ctx
->Eval
.AutoNormal
== state
)
307 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
308 ctx
->Eval
.AutoNormal
= state
;
312 GLbitfield newEnabled
=
313 state
* ((1 << ctx
->Const
.MaxDrawBuffers
) - 1);
314 if (newEnabled
!= ctx
->Color
.BlendEnabled
) {
315 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
316 ctx
->Color
.BlendEnabled
= newEnabled
;
320 case GL_CLIP_DISTANCE0
:
321 case GL_CLIP_DISTANCE1
:
322 case GL_CLIP_DISTANCE2
:
323 case GL_CLIP_DISTANCE3
:
324 case GL_CLIP_DISTANCE4
:
325 case GL_CLIP_DISTANCE5
:
326 case GL_CLIP_DISTANCE6
:
327 case GL_CLIP_DISTANCE7
:
329 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
331 if (p
>= ctx
->Const
.MaxClipPlanes
)
332 goto invalid_enum_error
;
334 if ((ctx
->Transform
.ClipPlanesEnabled
& (1 << p
))
335 == ((GLuint
) state
<< p
))
338 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
341 ctx
->Transform
.ClipPlanesEnabled
|= (1 << p
);
342 _mesa_update_clip_plane(ctx
, p
);
345 ctx
->Transform
.ClipPlanesEnabled
&= ~(1 << p
);
349 case GL_COLOR_MATERIAL
:
350 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
351 goto invalid_enum_error
;
352 if (ctx
->Light
.ColorMaterialEnabled
== state
)
354 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
355 FLUSH_CURRENT(ctx
, 0);
356 ctx
->Light
.ColorMaterialEnabled
= state
;
358 _mesa_update_color_material( ctx
,
359 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
] );
363 if (ctx
->Polygon
.CullFlag
== state
)
365 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
366 ctx
->Polygon
.CullFlag
= state
;
369 if (ctx
->Depth
.Test
== state
)
371 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
372 ctx
->Depth
.Test
= state
;
374 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
375 if (!_mesa_is_desktop_gl(ctx
))
376 goto invalid_enum_error
;
377 ctx
->Debug
.SyncOutput
= state
;
380 if (ctx
->Color
.DitherFlag
== state
)
382 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
383 ctx
->Color
.DitherFlag
= state
;
386 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
387 goto invalid_enum_error
;
388 if (ctx
->Fog
.Enabled
== state
)
390 FLUSH_VERTICES(ctx
, _NEW_FOG
);
391 ctx
->Fog
.Enabled
= state
;
401 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
402 goto invalid_enum_error
;
403 if (ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
== state
)
405 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
406 ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
= state
;
408 insert_at_tail(&ctx
->Light
.EnabledList
,
409 &ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
412 remove_from_list(&ctx
->Light
.Light
[cap
-GL_LIGHT0
]);
416 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
417 goto invalid_enum_error
;
418 if (ctx
->Light
.Enabled
== state
)
420 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
421 ctx
->Light
.Enabled
= state
;
422 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
423 ctx
->_TriangleCaps
|= DD_TRI_LIGHT_TWOSIDE
;
425 ctx
->_TriangleCaps
&= ~DD_TRI_LIGHT_TWOSIDE
;
428 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
429 goto invalid_enum_error
;
430 if (ctx
->Line
.SmoothFlag
== state
)
432 FLUSH_VERTICES(ctx
, _NEW_LINE
);
433 ctx
->Line
.SmoothFlag
= state
;
434 ctx
->_TriangleCaps
^= DD_LINE_SMOOTH
;
436 case GL_LINE_STIPPLE
:
437 if (ctx
->API
!= API_OPENGL_COMPAT
)
438 goto invalid_enum_error
;
439 if (ctx
->Line
.StippleFlag
== state
)
441 FLUSH_VERTICES(ctx
, _NEW_LINE
);
442 ctx
->Line
.StippleFlag
= state
;
443 ctx
->_TriangleCaps
^= DD_LINE_STIPPLE
;
445 case GL_INDEX_LOGIC_OP
:
446 if (ctx
->API
!= API_OPENGL_COMPAT
)
447 goto invalid_enum_error
;
448 if (ctx
->Color
.IndexLogicOpEnabled
== state
)
450 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
451 ctx
->Color
.IndexLogicOpEnabled
= state
;
453 case GL_COLOR_LOGIC_OP
:
454 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
455 goto invalid_enum_error
;
456 if (ctx
->Color
.ColorLogicOpEnabled
== state
)
458 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
459 ctx
->Color
.ColorLogicOpEnabled
= state
;
461 case GL_MAP1_COLOR_4
:
462 if (ctx
->API
!= API_OPENGL_COMPAT
)
463 goto invalid_enum_error
;
464 if (ctx
->Eval
.Map1Color4
== state
)
466 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
467 ctx
->Eval
.Map1Color4
= state
;
470 if (ctx
->API
!= API_OPENGL_COMPAT
)
471 goto invalid_enum_error
;
472 if (ctx
->Eval
.Map1Index
== state
)
474 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
475 ctx
->Eval
.Map1Index
= state
;
478 if (ctx
->API
!= API_OPENGL_COMPAT
)
479 goto invalid_enum_error
;
480 if (ctx
->Eval
.Map1Normal
== state
)
482 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
483 ctx
->Eval
.Map1Normal
= state
;
485 case GL_MAP1_TEXTURE_COORD_1
:
486 if (ctx
->API
!= API_OPENGL_COMPAT
)
487 goto invalid_enum_error
;
488 if (ctx
->Eval
.Map1TextureCoord1
== state
)
490 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
491 ctx
->Eval
.Map1TextureCoord1
= state
;
493 case GL_MAP1_TEXTURE_COORD_2
:
494 if (ctx
->API
!= API_OPENGL_COMPAT
)
495 goto invalid_enum_error
;
496 if (ctx
->Eval
.Map1TextureCoord2
== state
)
498 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
499 ctx
->Eval
.Map1TextureCoord2
= state
;
501 case GL_MAP1_TEXTURE_COORD_3
:
502 if (ctx
->API
!= API_OPENGL_COMPAT
)
503 goto invalid_enum_error
;
504 if (ctx
->Eval
.Map1TextureCoord3
== state
)
506 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
507 ctx
->Eval
.Map1TextureCoord3
= state
;
509 case GL_MAP1_TEXTURE_COORD_4
:
510 if (ctx
->API
!= API_OPENGL_COMPAT
)
511 goto invalid_enum_error
;
512 if (ctx
->Eval
.Map1TextureCoord4
== state
)
514 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
515 ctx
->Eval
.Map1TextureCoord4
= state
;
517 case GL_MAP1_VERTEX_3
:
518 if (ctx
->API
!= API_OPENGL_COMPAT
)
519 goto invalid_enum_error
;
520 if (ctx
->Eval
.Map1Vertex3
== state
)
522 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
523 ctx
->Eval
.Map1Vertex3
= state
;
525 case GL_MAP1_VERTEX_4
:
526 if (ctx
->API
!= API_OPENGL_COMPAT
)
527 goto invalid_enum_error
;
528 if (ctx
->Eval
.Map1Vertex4
== state
)
530 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
531 ctx
->Eval
.Map1Vertex4
= state
;
533 case GL_MAP2_COLOR_4
:
534 if (ctx
->API
!= API_OPENGL_COMPAT
)
535 goto invalid_enum_error
;
536 if (ctx
->Eval
.Map2Color4
== state
)
538 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
539 ctx
->Eval
.Map2Color4
= state
;
542 if (ctx
->API
!= API_OPENGL_COMPAT
)
543 goto invalid_enum_error
;
544 if (ctx
->Eval
.Map2Index
== state
)
546 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
547 ctx
->Eval
.Map2Index
= state
;
550 if (ctx
->API
!= API_OPENGL_COMPAT
)
551 goto invalid_enum_error
;
552 if (ctx
->Eval
.Map2Normal
== state
)
554 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
555 ctx
->Eval
.Map2Normal
= state
;
557 case GL_MAP2_TEXTURE_COORD_1
:
558 if (ctx
->API
!= API_OPENGL_COMPAT
)
559 goto invalid_enum_error
;
560 if (ctx
->Eval
.Map2TextureCoord1
== state
)
562 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
563 ctx
->Eval
.Map2TextureCoord1
= state
;
565 case GL_MAP2_TEXTURE_COORD_2
:
566 if (ctx
->API
!= API_OPENGL_COMPAT
)
567 goto invalid_enum_error
;
568 if (ctx
->Eval
.Map2TextureCoord2
== state
)
570 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
571 ctx
->Eval
.Map2TextureCoord2
= state
;
573 case GL_MAP2_TEXTURE_COORD_3
:
574 if (ctx
->API
!= API_OPENGL_COMPAT
)
575 goto invalid_enum_error
;
576 if (ctx
->Eval
.Map2TextureCoord3
== state
)
578 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
579 ctx
->Eval
.Map2TextureCoord3
= state
;
581 case GL_MAP2_TEXTURE_COORD_4
:
582 if (ctx
->API
!= API_OPENGL_COMPAT
)
583 goto invalid_enum_error
;
584 if (ctx
->Eval
.Map2TextureCoord4
== state
)
586 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
587 ctx
->Eval
.Map2TextureCoord4
= state
;
589 case GL_MAP2_VERTEX_3
:
590 if (ctx
->API
!= API_OPENGL_COMPAT
)
591 goto invalid_enum_error
;
592 if (ctx
->Eval
.Map2Vertex3
== state
)
594 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
595 ctx
->Eval
.Map2Vertex3
= state
;
597 case GL_MAP2_VERTEX_4
:
598 if (ctx
->API
!= API_OPENGL_COMPAT
)
599 goto invalid_enum_error
;
600 if (ctx
->Eval
.Map2Vertex4
== state
)
602 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
603 ctx
->Eval
.Map2Vertex4
= state
;
606 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
607 goto invalid_enum_error
;
608 if (ctx
->Transform
.Normalize
== state
)
610 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
611 ctx
->Transform
.Normalize
= state
;
613 case GL_POINT_SMOOTH
:
614 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
615 goto invalid_enum_error
;
616 if (ctx
->Point
.SmoothFlag
== state
)
618 FLUSH_VERTICES(ctx
, _NEW_POINT
);
619 ctx
->Point
.SmoothFlag
= state
;
620 ctx
->_TriangleCaps
^= DD_POINT_SMOOTH
;
622 case GL_POLYGON_SMOOTH
:
623 if (!_mesa_is_desktop_gl(ctx
))
624 goto invalid_enum_error
;
625 if (ctx
->Polygon
.SmoothFlag
== state
)
627 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
628 ctx
->Polygon
.SmoothFlag
= state
;
629 ctx
->_TriangleCaps
^= DD_TRI_SMOOTH
;
631 case GL_POLYGON_STIPPLE
:
632 if (ctx
->API
!= API_OPENGL_COMPAT
)
633 goto invalid_enum_error
;
634 if (ctx
->Polygon
.StippleFlag
== state
)
636 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
637 ctx
->Polygon
.StippleFlag
= state
;
638 ctx
->_TriangleCaps
^= DD_TRI_STIPPLE
;
640 case GL_POLYGON_OFFSET_POINT
:
641 if (!_mesa_is_desktop_gl(ctx
))
642 goto invalid_enum_error
;
643 if (ctx
->Polygon
.OffsetPoint
== state
)
645 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
646 ctx
->Polygon
.OffsetPoint
= state
;
648 case GL_POLYGON_OFFSET_LINE
:
649 if (!_mesa_is_desktop_gl(ctx
))
650 goto invalid_enum_error
;
651 if (ctx
->Polygon
.OffsetLine
== state
)
653 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
654 ctx
->Polygon
.OffsetLine
= state
;
656 case GL_POLYGON_OFFSET_FILL
:
657 if (ctx
->Polygon
.OffsetFill
== state
)
659 FLUSH_VERTICES(ctx
, _NEW_POLYGON
);
660 ctx
->Polygon
.OffsetFill
= state
;
662 case GL_RESCALE_NORMAL_EXT
:
663 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
664 goto invalid_enum_error
;
665 if (ctx
->Transform
.RescaleNormals
== state
)
667 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
668 ctx
->Transform
.RescaleNormals
= state
;
670 case GL_SCISSOR_TEST
:
671 if (ctx
->Scissor
.Enabled
== state
)
673 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
674 ctx
->Scissor
.Enabled
= state
;
676 case GL_STENCIL_TEST
:
677 if (ctx
->Stencil
.Enabled
== state
)
679 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
680 ctx
->Stencil
.Enabled
= state
;
683 if (ctx
->API
!= API_OPENGL_COMPAT
)
684 goto invalid_enum_error
;
685 if (!enable_texture(ctx
, state
, TEXTURE_1D_BIT
)) {
690 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
691 goto invalid_enum_error
;
692 if (!enable_texture(ctx
, state
, TEXTURE_2D_BIT
)) {
697 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
698 goto invalid_enum_error
;
699 if (!enable_texture(ctx
, state
, TEXTURE_3D_BIT
)) {
703 case GL_TEXTURE_GEN_S
:
704 case GL_TEXTURE_GEN_T
:
705 case GL_TEXTURE_GEN_R
:
706 case GL_TEXTURE_GEN_Q
:
708 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
710 if (ctx
->API
!= API_OPENGL_COMPAT
)
711 goto invalid_enum_error
;
714 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
715 GLbitfield newenabled
= texUnit
->TexGenEnabled
& ~coordBit
;
717 newenabled
|= coordBit
;
718 if (texUnit
->TexGenEnabled
== newenabled
)
720 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
721 texUnit
->TexGenEnabled
= newenabled
;
726 case GL_TEXTURE_GEN_STR_OES
:
727 /* disable S, T, and R at the same time */
729 struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
731 if (ctx
->API
!= API_OPENGLES
)
732 goto invalid_enum_error
;
736 texUnit
->TexGenEnabled
& ~STR_BITS
;
738 newenabled
|= STR_BITS
;
739 if (texUnit
->TexGenEnabled
== newenabled
)
741 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
742 texUnit
->TexGenEnabled
= newenabled
;
747 /* client-side state */
748 case GL_VERTEX_ARRAY
:
749 case GL_NORMAL_ARRAY
:
752 case GL_TEXTURE_COORD_ARRAY
:
753 case GL_EDGE_FLAG_ARRAY
:
754 case GL_FOG_COORDINATE_ARRAY_EXT
:
755 case GL_SECONDARY_COLOR_ARRAY_EXT
:
756 case GL_POINT_SIZE_ARRAY_OES
:
757 client_state( ctx
, cap
, state
);
760 /* GL_ARB_texture_cube_map */
761 case GL_TEXTURE_CUBE_MAP_ARB
:
762 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
763 goto invalid_enum_error
;
764 CHECK_EXTENSION(ARB_texture_cube_map
, cap
);
765 if (!enable_texture(ctx
, state
, TEXTURE_CUBE_BIT
)) {
770 /* GL_EXT_secondary_color */
771 case GL_COLOR_SUM_EXT
:
772 if (ctx
->API
!= API_OPENGL_COMPAT
)
773 goto invalid_enum_error
;
774 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
, cap
);
775 if (ctx
->Fog
.ColorSumEnabled
== state
)
777 FLUSH_VERTICES(ctx
, _NEW_FOG
);
778 ctx
->Fog
.ColorSumEnabled
= state
;
781 /* GL_ARB_multisample */
782 case GL_MULTISAMPLE_ARB
:
783 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
784 goto invalid_enum_error
;
785 _mesa_set_multisample(ctx
, state
);
787 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
788 if (ctx
->Multisample
.SampleAlphaToCoverage
== state
)
790 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
791 ctx
->Multisample
.SampleAlphaToCoverage
= state
;
793 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
794 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
795 goto invalid_enum_error
;
796 if (ctx
->Multisample
.SampleAlphaToOne
== state
)
798 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
799 ctx
->Multisample
.SampleAlphaToOne
= state
;
801 case GL_SAMPLE_COVERAGE_ARB
:
802 if (ctx
->Multisample
.SampleCoverage
== state
)
804 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
805 ctx
->Multisample
.SampleCoverage
= state
;
807 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
808 if (!_mesa_is_desktop_gl(ctx
))
809 goto invalid_enum_error
;
810 if (ctx
->Multisample
.SampleCoverageInvert
== state
)
812 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
813 ctx
->Multisample
.SampleCoverageInvert
= state
;
816 /* GL_IBM_rasterpos_clip */
817 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
818 if (ctx
->API
!= API_OPENGL_COMPAT
)
819 goto invalid_enum_error
;
820 if (ctx
->Transform
.RasterPositionUnclipped
== state
)
822 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
823 ctx
->Transform
.RasterPositionUnclipped
= state
;
826 /* GL_NV_point_sprite */
827 case GL_POINT_SPRITE_NV
:
828 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
829 goto invalid_enum_error
;
830 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
, cap
);
831 if (ctx
->Point
.PointSprite
== state
)
833 FLUSH_VERTICES(ctx
, _NEW_POINT
);
834 ctx
->Point
.PointSprite
= state
;
837 case GL_VERTEX_PROGRAM_ARB
:
838 if (ctx
->API
!= API_OPENGL_COMPAT
)
839 goto invalid_enum_error
;
840 CHECK_EXTENSION(ARB_vertex_program
, cap
);
841 if (ctx
->VertexProgram
.Enabled
== state
)
843 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
844 ctx
->VertexProgram
.Enabled
= state
;
846 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
847 /* This was added with ARB_vertex_program, but it is also used with
848 * GLSL vertex shaders on desktop.
850 if (!_mesa_is_desktop_gl(ctx
))
851 goto invalid_enum_error
;
852 CHECK_EXTENSION(ARB_vertex_program
, cap
);
853 if (ctx
->VertexProgram
.PointSizeEnabled
== state
)
855 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
856 ctx
->VertexProgram
.PointSizeEnabled
= state
;
858 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
859 if (ctx
->API
!= API_OPENGL_COMPAT
)
860 goto invalid_enum_error
;
861 CHECK_EXTENSION(ARB_vertex_program
, cap
);
862 if (ctx
->VertexProgram
.TwoSideEnabled
== state
)
864 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
865 ctx
->VertexProgram
.TwoSideEnabled
= state
;
868 /* GL_NV_texture_rectangle */
869 case GL_TEXTURE_RECTANGLE_NV
:
870 if (ctx
->API
!= API_OPENGL_COMPAT
)
871 goto invalid_enum_error
;
872 CHECK_EXTENSION(NV_texture_rectangle
, cap
);
873 if (!enable_texture(ctx
, state
, TEXTURE_RECT_BIT
)) {
878 /* GL_EXT_stencil_two_side */
879 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
880 if (ctx
->API
!= API_OPENGL_COMPAT
)
881 goto invalid_enum_error
;
882 CHECK_EXTENSION(EXT_stencil_two_side
, cap
);
883 if (ctx
->Stencil
.TestTwoSide
== state
)
885 FLUSH_VERTICES(ctx
, _NEW_STENCIL
);
886 ctx
->Stencil
.TestTwoSide
= state
;
888 ctx
->Stencil
._BackFace
= 2;
890 ctx
->Stencil
._BackFace
= 1;
894 case GL_FRAGMENT_PROGRAM_ARB
:
895 if (ctx
->API
!= API_OPENGL_COMPAT
)
896 goto invalid_enum_error
;
897 CHECK_EXTENSION(ARB_fragment_program
, cap
);
898 if (ctx
->FragmentProgram
.Enabled
== state
)
900 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
901 ctx
->FragmentProgram
.Enabled
= state
;
904 /* GL_EXT_depth_bounds_test */
905 case GL_DEPTH_BOUNDS_TEST_EXT
:
906 if (!_mesa_is_desktop_gl(ctx
))
907 goto invalid_enum_error
;
908 CHECK_EXTENSION(EXT_depth_bounds_test
, cap
);
909 if (ctx
->Depth
.BoundsTest
== state
)
911 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
912 ctx
->Depth
.BoundsTest
= state
;
916 if (!_mesa_is_desktop_gl(ctx
))
917 goto invalid_enum_error
;
918 CHECK_EXTENSION(ARB_depth_clamp
, cap
);
919 if (ctx
->Transform
.DepthClamp
== state
)
921 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
922 ctx
->Transform
.DepthClamp
= state
;
925 case GL_FRAGMENT_SHADER_ATI
:
926 if (ctx
->API
!= API_OPENGL_COMPAT
)
927 goto invalid_enum_error
;
928 CHECK_EXTENSION(ATI_fragment_shader
, cap
);
929 if (ctx
->ATIFragmentShader
.Enabled
== state
)
931 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
932 ctx
->ATIFragmentShader
.Enabled
= state
;
935 /* GL_MESA_texture_array */
936 case GL_TEXTURE_1D_ARRAY_EXT
:
937 if (ctx
->API
!= API_OPENGL_COMPAT
)
938 goto invalid_enum_error
;
939 CHECK_EXTENSION(MESA_texture_array
, cap
);
940 if (!enable_texture(ctx
, state
, TEXTURE_1D_ARRAY_BIT
)) {
945 case GL_TEXTURE_2D_ARRAY_EXT
:
946 if (ctx
->API
!= API_OPENGL_COMPAT
)
947 goto invalid_enum_error
;
948 CHECK_EXTENSION(MESA_texture_array
, cap
);
949 if (!enable_texture(ctx
, state
, TEXTURE_2D_ARRAY_BIT
)) {
954 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
955 if (!_mesa_is_desktop_gl(ctx
))
956 goto invalid_enum_error
;
957 CHECK_EXTENSION(ARB_seamless_cube_map
, cap
);
958 if (ctx
->Texture
.CubeMapSeamless
!= state
) {
959 FLUSH_VERTICES(ctx
, _NEW_TEXTURE
);
960 ctx
->Texture
.CubeMapSeamless
= state
;
964 case GL_RASTERIZER_DISCARD
:
965 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
966 goto invalid_enum_error
;
967 CHECK_EXTENSION(EXT_transform_feedback
, cap
);
968 if (ctx
->RasterDiscard
!= state
) {
969 FLUSH_VERTICES(ctx
, _NEW_RASTERIZER_DISCARD
);
970 ctx
->RasterDiscard
= state
;
974 /* GL 3.1 primitive restart. Note: this enum is different from
975 * GL_PRIMITIVE_RESTART_NV (which is client state).
977 case GL_PRIMITIVE_RESTART
:
978 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
979 goto invalid_enum_error
;
981 if (ctx
->Array
.PrimitiveRestart
!= state
) {
982 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
983 ctx
->Array
.PrimitiveRestart
= state
;
984 update_derived_primitive_restart_state(ctx
);
988 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
989 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
)
990 goto invalid_enum_error
;
991 if (ctx
->Array
.PrimitiveRestartFixedIndex
!= state
) {
992 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
993 ctx
->Array
.PrimitiveRestartFixedIndex
= state
;
994 update_derived_primitive_restart_state(ctx
);
998 /* GL3.0 - GL_framebuffer_sRGB */
999 case GL_FRAMEBUFFER_SRGB_EXT
:
1000 if (!_mesa_is_desktop_gl(ctx
))
1001 goto invalid_enum_error
;
1002 CHECK_EXTENSION(EXT_framebuffer_sRGB
, cap
);
1003 _mesa_set_framebuffer_srgb(ctx
, state
);
1006 /* GL_OES_EGL_image_external */
1007 case GL_TEXTURE_EXTERNAL_OES
:
1008 if (!_mesa_is_gles(ctx
))
1009 goto invalid_enum_error
;
1010 CHECK_EXTENSION(OES_EGL_image_external
, cap
);
1011 if (!enable_texture(ctx
, state
, TEXTURE_EXTERNAL_BIT
)) {
1017 goto invalid_enum_error
;
1020 if (ctx
->Driver
.Enable
) {
1021 ctx
->Driver
.Enable( ctx
, cap
, state
);
1027 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1028 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
1033 * Enable GL capability. Called by glEnable()
1034 * \param cap state to enable.
1037 _mesa_Enable( GLenum cap
)
1039 GET_CURRENT_CONTEXT(ctx
);
1041 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1046 * Disable GL capability. Called by glDisable()
1047 * \param cap state to disable.
1050 _mesa_Disable( GLenum cap
)
1052 GET_CURRENT_CONTEXT(ctx
);
1054 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1060 * Enable/disable an indexed state var.
1063 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1064 GLuint index
, GLboolean state
)
1066 ASSERT(state
== 0 || state
== 1);
1069 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1070 goto invalid_enum_error
;
1072 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1073 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1074 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1077 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1078 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1080 ctx
->Color
.BlendEnabled
|= (1 << index
);
1082 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1086 goto invalid_enum_error
;
1091 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1092 state
? "glEnablei" : "glDisablei",
1093 _mesa_lookup_enum_by_nr(cap
));
1098 _mesa_Disablei( GLenum cap
, GLuint index
)
1100 GET_CURRENT_CONTEXT(ctx
);
1101 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1106 _mesa_Enablei( GLenum cap
, GLuint index
)
1108 GET_CURRENT_CONTEXT(ctx
);
1109 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1113 GLboolean GLAPIENTRY
1114 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1116 GET_CURRENT_CONTEXT(ctx
);
1117 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1120 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1121 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1125 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1127 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1128 _mesa_lookup_enum_by_nr(cap
));
1136 #undef CHECK_EXTENSION
1137 #define CHECK_EXTENSION(EXTNAME) \
1138 if (!ctx->Extensions.EXTNAME) { \
1139 goto invalid_enum_error; \
1142 #undef CHECK_EXTENSION2
1143 #define CHECK_EXTENSION2(EXT1, EXT2) \
1144 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1145 goto invalid_enum_error; \
1150 * Helper function to determine whether a texture target is enabled.
1153 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1155 const struct gl_texture_unit
*const texUnit
=
1156 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1157 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1162 * Return simple enable/disable state.
1164 * \param cap state variable to query.
1166 * Returns the state of the specified capability from the current GL context.
1167 * For the capabilities associated with extensions verifies that those
1168 * extensions are effectively present before reporting.
1170 GLboolean GLAPIENTRY
1171 _mesa_IsEnabled( GLenum cap
)
1173 GET_CURRENT_CONTEXT(ctx
);
1174 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1178 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1179 goto invalid_enum_error
;
1180 return ctx
->Color
.AlphaEnabled
;
1181 case GL_AUTO_NORMAL
:
1182 if (ctx
->API
!= API_OPENGL_COMPAT
)
1183 goto invalid_enum_error
;
1184 return ctx
->Eval
.AutoNormal
;
1186 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1187 case GL_CLIP_DISTANCE0
:
1188 case GL_CLIP_DISTANCE1
:
1189 case GL_CLIP_DISTANCE2
:
1190 case GL_CLIP_DISTANCE3
:
1191 case GL_CLIP_DISTANCE4
:
1192 case GL_CLIP_DISTANCE5
:
1193 case GL_CLIP_DISTANCE6
:
1194 case GL_CLIP_DISTANCE7
: {
1195 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1197 if (p
>= ctx
->Const
.MaxClipPlanes
)
1198 goto invalid_enum_error
;
1200 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1202 case GL_COLOR_MATERIAL
:
1203 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1204 goto invalid_enum_error
;
1205 return ctx
->Light
.ColorMaterialEnabled
;
1207 return ctx
->Polygon
.CullFlag
;
1208 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1209 if (!_mesa_is_desktop_gl(ctx
))
1210 goto invalid_enum_error
;
1211 return ctx
->Debug
.SyncOutput
;
1213 return ctx
->Depth
.Test
;
1215 return ctx
->Color
.DitherFlag
;
1217 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1218 goto invalid_enum_error
;
1219 return ctx
->Fog
.Enabled
;
1221 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1222 goto invalid_enum_error
;
1223 return ctx
->Light
.Enabled
;
1232 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1233 goto invalid_enum_error
;
1234 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1235 case GL_LINE_SMOOTH
:
1236 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1237 goto invalid_enum_error
;
1238 return ctx
->Line
.SmoothFlag
;
1239 case GL_LINE_STIPPLE
:
1240 if (ctx
->API
!= API_OPENGL_COMPAT
)
1241 goto invalid_enum_error
;
1242 return ctx
->Line
.StippleFlag
;
1243 case GL_INDEX_LOGIC_OP
:
1244 if (ctx
->API
!= API_OPENGL_COMPAT
)
1245 goto invalid_enum_error
;
1246 return ctx
->Color
.IndexLogicOpEnabled
;
1247 case GL_COLOR_LOGIC_OP
:
1248 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1249 goto invalid_enum_error
;
1250 return ctx
->Color
.ColorLogicOpEnabled
;
1251 case GL_MAP1_COLOR_4
:
1252 if (ctx
->API
!= API_OPENGL_COMPAT
)
1253 goto invalid_enum_error
;
1254 return ctx
->Eval
.Map1Color4
;
1256 if (ctx
->API
!= API_OPENGL_COMPAT
)
1257 goto invalid_enum_error
;
1258 return ctx
->Eval
.Map1Index
;
1259 case GL_MAP1_NORMAL
:
1260 if (ctx
->API
!= API_OPENGL_COMPAT
)
1261 goto invalid_enum_error
;
1262 return ctx
->Eval
.Map1Normal
;
1263 case GL_MAP1_TEXTURE_COORD_1
:
1264 if (ctx
->API
!= API_OPENGL_COMPAT
)
1265 goto invalid_enum_error
;
1266 return ctx
->Eval
.Map1TextureCoord1
;
1267 case GL_MAP1_TEXTURE_COORD_2
:
1268 if (ctx
->API
!= API_OPENGL_COMPAT
)
1269 goto invalid_enum_error
;
1270 return ctx
->Eval
.Map1TextureCoord2
;
1271 case GL_MAP1_TEXTURE_COORD_3
:
1272 if (ctx
->API
!= API_OPENGL_COMPAT
)
1273 goto invalid_enum_error
;
1274 return ctx
->Eval
.Map1TextureCoord3
;
1275 case GL_MAP1_TEXTURE_COORD_4
:
1276 if (ctx
->API
!= API_OPENGL_COMPAT
)
1277 goto invalid_enum_error
;
1278 return ctx
->Eval
.Map1TextureCoord4
;
1279 case GL_MAP1_VERTEX_3
:
1280 if (ctx
->API
!= API_OPENGL_COMPAT
)
1281 goto invalid_enum_error
;
1282 return ctx
->Eval
.Map1Vertex3
;
1283 case GL_MAP1_VERTEX_4
:
1284 if (ctx
->API
!= API_OPENGL_COMPAT
)
1285 goto invalid_enum_error
;
1286 return ctx
->Eval
.Map1Vertex4
;
1287 case GL_MAP2_COLOR_4
:
1288 if (ctx
->API
!= API_OPENGL_COMPAT
)
1289 goto invalid_enum_error
;
1290 return ctx
->Eval
.Map2Color4
;
1292 if (ctx
->API
!= API_OPENGL_COMPAT
)
1293 goto invalid_enum_error
;
1294 return ctx
->Eval
.Map2Index
;
1295 case GL_MAP2_NORMAL
:
1296 if (ctx
->API
!= API_OPENGL_COMPAT
)
1297 goto invalid_enum_error
;
1298 return ctx
->Eval
.Map2Normal
;
1299 case GL_MAP2_TEXTURE_COORD_1
:
1300 if (ctx
->API
!= API_OPENGL_COMPAT
)
1301 goto invalid_enum_error
;
1302 return ctx
->Eval
.Map2TextureCoord1
;
1303 case GL_MAP2_TEXTURE_COORD_2
:
1304 if (ctx
->API
!= API_OPENGL_COMPAT
)
1305 goto invalid_enum_error
;
1306 return ctx
->Eval
.Map2TextureCoord2
;
1307 case GL_MAP2_TEXTURE_COORD_3
:
1308 if (ctx
->API
!= API_OPENGL_COMPAT
)
1309 goto invalid_enum_error
;
1310 return ctx
->Eval
.Map2TextureCoord3
;
1311 case GL_MAP2_TEXTURE_COORD_4
:
1312 if (ctx
->API
!= API_OPENGL_COMPAT
)
1313 goto invalid_enum_error
;
1314 return ctx
->Eval
.Map2TextureCoord4
;
1315 case GL_MAP2_VERTEX_3
:
1316 if (ctx
->API
!= API_OPENGL_COMPAT
)
1317 goto invalid_enum_error
;
1318 return ctx
->Eval
.Map2Vertex3
;
1319 case GL_MAP2_VERTEX_4
:
1320 if (ctx
->API
!= API_OPENGL_COMPAT
)
1321 goto invalid_enum_error
;
1322 return ctx
->Eval
.Map2Vertex4
;
1324 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1325 goto invalid_enum_error
;
1326 return ctx
->Transform
.Normalize
;
1327 case GL_POINT_SMOOTH
:
1328 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1329 goto invalid_enum_error
;
1330 return ctx
->Point
.SmoothFlag
;
1331 case GL_POLYGON_SMOOTH
:
1332 if (!_mesa_is_desktop_gl(ctx
))
1333 goto invalid_enum_error
;
1334 return ctx
->Polygon
.SmoothFlag
;
1335 case GL_POLYGON_STIPPLE
:
1336 if (ctx
->API
!= API_OPENGL_COMPAT
)
1337 goto invalid_enum_error
;
1338 return ctx
->Polygon
.StippleFlag
;
1339 case GL_POLYGON_OFFSET_POINT
:
1340 if (!_mesa_is_desktop_gl(ctx
))
1341 goto invalid_enum_error
;
1342 return ctx
->Polygon
.OffsetPoint
;
1343 case GL_POLYGON_OFFSET_LINE
:
1344 if (!_mesa_is_desktop_gl(ctx
))
1345 goto invalid_enum_error
;
1346 return ctx
->Polygon
.OffsetLine
;
1347 case GL_POLYGON_OFFSET_FILL
:
1348 return ctx
->Polygon
.OffsetFill
;
1349 case GL_RESCALE_NORMAL_EXT
:
1350 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1351 goto invalid_enum_error
;
1352 return ctx
->Transform
.RescaleNormals
;
1353 case GL_SCISSOR_TEST
:
1354 return ctx
->Scissor
.Enabled
;
1355 case GL_STENCIL_TEST
:
1356 return ctx
->Stencil
.Enabled
;
1358 if (ctx
->API
!= API_OPENGL_COMPAT
)
1359 goto invalid_enum_error
;
1360 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1362 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1363 goto invalid_enum_error
;
1364 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1366 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1367 goto invalid_enum_error
;
1368 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1369 case GL_TEXTURE_GEN_S
:
1370 case GL_TEXTURE_GEN_T
:
1371 case GL_TEXTURE_GEN_R
:
1372 case GL_TEXTURE_GEN_Q
:
1374 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1376 if (ctx
->API
!= API_OPENGL_COMPAT
)
1377 goto invalid_enum_error
;
1380 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1381 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1385 case GL_TEXTURE_GEN_STR_OES
:
1387 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1389 if (ctx
->API
!= API_OPENGLES
)
1390 goto invalid_enum_error
;
1393 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1394 ? GL_TRUE
: GL_FALSE
;
1398 /* client-side state */
1399 case GL_VERTEX_ARRAY
:
1400 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1401 goto invalid_enum_error
;
1402 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
!= 0);
1403 case GL_NORMAL_ARRAY
:
1404 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1405 goto invalid_enum_error
;
1406 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1407 case GL_COLOR_ARRAY
:
1408 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1409 goto invalid_enum_error
;
1410 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
!= 0);
1411 case GL_INDEX_ARRAY
:
1412 if (ctx
->API
!= API_OPENGL_COMPAT
)
1413 goto invalid_enum_error
;
1414 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1415 case GL_TEXTURE_COORD_ARRAY
:
1416 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1417 goto invalid_enum_error
;
1418 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1420 case GL_EDGE_FLAG_ARRAY
:
1421 if (ctx
->API
!= API_OPENGL_COMPAT
)
1422 goto invalid_enum_error
;
1423 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1424 case GL_FOG_COORDINATE_ARRAY_EXT
:
1425 if (ctx
->API
!= API_OPENGL_COMPAT
)
1426 goto invalid_enum_error
;
1427 CHECK_EXTENSION(EXT_fog_coord
);
1428 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1429 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1430 if (ctx
->API
!= API_OPENGL_COMPAT
)
1431 goto invalid_enum_error
;
1432 CHECK_EXTENSION(EXT_secondary_color
);
1433 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1434 case GL_POINT_SIZE_ARRAY_OES
:
1435 if (ctx
->API
!= API_OPENGLES
)
1436 goto invalid_enum_error
;
1437 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1439 /* GL_ARB_texture_cube_map */
1440 case GL_TEXTURE_CUBE_MAP_ARB
:
1441 CHECK_EXTENSION(ARB_texture_cube_map
);
1442 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1444 /* GL_EXT_secondary_color */
1445 case GL_COLOR_SUM_EXT
:
1446 if (ctx
->API
!= API_OPENGL_COMPAT
)
1447 goto invalid_enum_error
;
1448 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1449 return ctx
->Fog
.ColorSumEnabled
;
1451 /* GL_ARB_multisample */
1452 case GL_MULTISAMPLE_ARB
:
1453 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1454 goto invalid_enum_error
;
1455 return ctx
->Multisample
.Enabled
;
1456 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1457 return ctx
->Multisample
.SampleAlphaToCoverage
;
1458 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1459 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1460 goto invalid_enum_error
;
1461 return ctx
->Multisample
.SampleAlphaToOne
;
1462 case GL_SAMPLE_COVERAGE_ARB
:
1463 return ctx
->Multisample
.SampleCoverage
;
1464 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1465 if (!_mesa_is_desktop_gl(ctx
))
1466 goto invalid_enum_error
;
1467 return ctx
->Multisample
.SampleCoverageInvert
;
1469 /* GL_IBM_rasterpos_clip */
1470 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1471 if (ctx
->API
!= API_OPENGL_COMPAT
)
1472 goto invalid_enum_error
;
1473 return ctx
->Transform
.RasterPositionUnclipped
;
1475 /* GL_NV_point_sprite */
1476 case GL_POINT_SPRITE_NV
:
1477 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1478 goto invalid_enum_error
;
1479 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1480 return ctx
->Point
.PointSprite
;
1482 case GL_VERTEX_PROGRAM_ARB
:
1483 if (ctx
->API
!= API_OPENGL_COMPAT
)
1484 goto invalid_enum_error
;
1485 CHECK_EXTENSION(ARB_vertex_program
);
1486 return ctx
->VertexProgram
.Enabled
;
1487 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1488 /* This was added with ARB_vertex_program, but it is also used with
1489 * GLSL vertex shaders on desktop.
1491 if (!_mesa_is_desktop_gl(ctx
))
1492 goto invalid_enum_error
;
1493 CHECK_EXTENSION(ARB_vertex_program
);
1494 return ctx
->VertexProgram
.PointSizeEnabled
;
1495 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1496 if (ctx
->API
!= API_OPENGL_COMPAT
)
1497 goto invalid_enum_error
;
1498 CHECK_EXTENSION(ARB_vertex_program
);
1499 return ctx
->VertexProgram
.TwoSideEnabled
;
1501 /* GL_NV_texture_rectangle */
1502 case GL_TEXTURE_RECTANGLE_NV
:
1503 if (ctx
->API
!= API_OPENGL_COMPAT
)
1504 goto invalid_enum_error
;
1505 CHECK_EXTENSION(NV_texture_rectangle
);
1506 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1508 /* GL_EXT_stencil_two_side */
1509 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1510 if (ctx
->API
!= API_OPENGL_COMPAT
)
1511 goto invalid_enum_error
;
1512 CHECK_EXTENSION(EXT_stencil_two_side
);
1513 return ctx
->Stencil
.TestTwoSide
;
1515 case GL_FRAGMENT_PROGRAM_ARB
:
1516 if (ctx
->API
!= API_OPENGL_COMPAT
)
1517 goto invalid_enum_error
;
1518 return ctx
->FragmentProgram
.Enabled
;
1520 /* GL_EXT_depth_bounds_test */
1521 case GL_DEPTH_BOUNDS_TEST_EXT
:
1522 if (!_mesa_is_desktop_gl(ctx
))
1523 goto invalid_enum_error
;
1524 CHECK_EXTENSION(EXT_depth_bounds_test
);
1525 return ctx
->Depth
.BoundsTest
;
1527 /* GL_ARB_depth_clamp */
1528 case GL_DEPTH_CLAMP
:
1529 if (!_mesa_is_desktop_gl(ctx
))
1530 goto invalid_enum_error
;
1531 CHECK_EXTENSION(ARB_depth_clamp
);
1532 return ctx
->Transform
.DepthClamp
;
1534 case GL_FRAGMENT_SHADER_ATI
:
1535 if (ctx
->API
!= API_OPENGL_COMPAT
)
1536 goto invalid_enum_error
;
1537 CHECK_EXTENSION(ATI_fragment_shader
);
1538 return ctx
->ATIFragmentShader
.Enabled
;
1540 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1541 if (!_mesa_is_desktop_gl(ctx
))
1542 goto invalid_enum_error
;
1543 CHECK_EXTENSION(ARB_seamless_cube_map
);
1544 return ctx
->Texture
.CubeMapSeamless
;
1546 case GL_RASTERIZER_DISCARD
:
1547 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1548 goto invalid_enum_error
;
1549 CHECK_EXTENSION(EXT_transform_feedback
);
1550 return ctx
->RasterDiscard
;
1552 /* GL_NV_primitive_restart */
1553 case GL_PRIMITIVE_RESTART_NV
:
1554 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1555 goto invalid_enum_error
;
1557 return ctx
->Array
.PrimitiveRestart
;
1559 /* GL 3.1 primitive restart */
1560 case GL_PRIMITIVE_RESTART
:
1561 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1562 goto invalid_enum_error
;
1564 return ctx
->Array
.PrimitiveRestart
;
1566 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1567 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1568 goto invalid_enum_error
;
1570 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1572 /* GL3.0 - GL_framebuffer_sRGB */
1573 case GL_FRAMEBUFFER_SRGB_EXT
:
1574 if (!_mesa_is_desktop_gl(ctx
))
1575 goto invalid_enum_error
;
1576 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1577 return ctx
->Color
.sRGBEnabled
;
1579 /* GL_OES_EGL_image_external */
1580 case GL_TEXTURE_EXTERNAL_OES
:
1581 if (!_mesa_is_gles(ctx
))
1582 goto invalid_enum_error
;
1583 CHECK_EXTENSION(OES_EGL_image_external
);
1584 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1587 goto invalid_enum_error
;
1593 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1594 _mesa_lookup_enum_by_nr(cap
));