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
)) {
1016 /* ARB_texture_multisample */
1017 case GL_SAMPLE_MASK
:
1018 if (!_mesa_is_desktop_gl(ctx
))
1019 goto invalid_enum_error
;
1020 CHECK_EXTENSION(ARB_texture_multisample
, cap
);
1021 if (ctx
->Multisample
.SampleMask
== state
)
1023 FLUSH_VERTICES(ctx
, _NEW_MULTISAMPLE
);
1024 ctx
->Multisample
.SampleMask
= state
;
1028 goto invalid_enum_error
;
1031 if (ctx
->Driver
.Enable
) {
1032 ctx
->Driver
.Enable( ctx
, cap
, state
);
1038 _mesa_error(ctx
, GL_INVALID_ENUM
, "gl%s(%s)",
1039 state
? "Enable" : "Disable", _mesa_lookup_enum_by_nr(cap
));
1044 * Enable GL capability. Called by glEnable()
1045 * \param cap state to enable.
1048 _mesa_Enable( GLenum cap
)
1050 GET_CURRENT_CONTEXT(ctx
);
1052 _mesa_set_enable( ctx
, cap
, GL_TRUE
);
1057 * Disable GL capability. Called by glDisable()
1058 * \param cap state to disable.
1061 _mesa_Disable( GLenum cap
)
1063 GET_CURRENT_CONTEXT(ctx
);
1065 _mesa_set_enable( ctx
, cap
, GL_FALSE
);
1071 * Enable/disable an indexed state var.
1074 _mesa_set_enablei(struct gl_context
*ctx
, GLenum cap
,
1075 GLuint index
, GLboolean state
)
1077 ASSERT(state
== 0 || state
== 1);
1080 if (!ctx
->Extensions
.EXT_draw_buffers2
) {
1081 goto invalid_enum_error
;
1083 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1084 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)",
1085 state
? "glEnableIndexed" : "glDisableIndexed", index
);
1088 if (((ctx
->Color
.BlendEnabled
>> index
) & 1) != state
) {
1089 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
1091 ctx
->Color
.BlendEnabled
|= (1 << index
);
1093 ctx
->Color
.BlendEnabled
&= ~(1 << index
);
1097 goto invalid_enum_error
;
1102 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(cap=%s)",
1103 state
? "glEnablei" : "glDisablei",
1104 _mesa_lookup_enum_by_nr(cap
));
1109 _mesa_Disablei( GLenum cap
, GLuint index
)
1111 GET_CURRENT_CONTEXT(ctx
);
1112 _mesa_set_enablei(ctx
, cap
, index
, GL_FALSE
);
1117 _mesa_Enablei( GLenum cap
, GLuint index
)
1119 GET_CURRENT_CONTEXT(ctx
);
1120 _mesa_set_enablei(ctx
, cap
, index
, GL_TRUE
);
1124 GLboolean GLAPIENTRY
1125 _mesa_IsEnabledi( GLenum cap
, GLuint index
)
1127 GET_CURRENT_CONTEXT(ctx
);
1128 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1131 if (index
>= ctx
->Const
.MaxDrawBuffers
) {
1132 _mesa_error(ctx
, GL_INVALID_VALUE
, "glIsEnabledIndexed(index=%u)",
1136 return (ctx
->Color
.BlendEnabled
>> index
) & 1;
1138 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabledIndexed(cap=%s)",
1139 _mesa_lookup_enum_by_nr(cap
));
1147 #undef CHECK_EXTENSION
1148 #define CHECK_EXTENSION(EXTNAME) \
1149 if (!ctx->Extensions.EXTNAME) { \
1150 goto invalid_enum_error; \
1153 #undef CHECK_EXTENSION2
1154 #define CHECK_EXTENSION2(EXT1, EXT2) \
1155 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1156 goto invalid_enum_error; \
1161 * Helper function to determine whether a texture target is enabled.
1164 is_texture_enabled(struct gl_context
*ctx
, GLbitfield bit
)
1166 const struct gl_texture_unit
*const texUnit
=
1167 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
];
1168 return (texUnit
->Enabled
& bit
) ? GL_TRUE
: GL_FALSE
;
1173 * Return simple enable/disable state.
1175 * \param cap state variable to query.
1177 * Returns the state of the specified capability from the current GL context.
1178 * For the capabilities associated with extensions verifies that those
1179 * extensions are effectively present before reporting.
1181 GLboolean GLAPIENTRY
1182 _mesa_IsEnabled( GLenum cap
)
1184 GET_CURRENT_CONTEXT(ctx
);
1185 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1189 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1190 goto invalid_enum_error
;
1191 return ctx
->Color
.AlphaEnabled
;
1192 case GL_AUTO_NORMAL
:
1193 if (ctx
->API
!= API_OPENGL_COMPAT
)
1194 goto invalid_enum_error
;
1195 return ctx
->Eval
.AutoNormal
;
1197 return ctx
->Color
.BlendEnabled
& 1; /* return state for buffer[0] */
1198 case GL_CLIP_DISTANCE0
:
1199 case GL_CLIP_DISTANCE1
:
1200 case GL_CLIP_DISTANCE2
:
1201 case GL_CLIP_DISTANCE3
:
1202 case GL_CLIP_DISTANCE4
:
1203 case GL_CLIP_DISTANCE5
:
1204 case GL_CLIP_DISTANCE6
:
1205 case GL_CLIP_DISTANCE7
: {
1206 const GLuint p
= cap
- GL_CLIP_DISTANCE0
;
1208 if (p
>= ctx
->Const
.MaxClipPlanes
)
1209 goto invalid_enum_error
;
1211 return (ctx
->Transform
.ClipPlanesEnabled
>> p
) & 1;
1213 case GL_COLOR_MATERIAL
:
1214 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1215 goto invalid_enum_error
;
1216 return ctx
->Light
.ColorMaterialEnabled
;
1218 return ctx
->Polygon
.CullFlag
;
1219 case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
:
1220 if (!_mesa_is_desktop_gl(ctx
))
1221 goto invalid_enum_error
;
1222 return ctx
->Debug
.SyncOutput
;
1224 return ctx
->Depth
.Test
;
1226 return ctx
->Color
.DitherFlag
;
1228 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1229 goto invalid_enum_error
;
1230 return ctx
->Fog
.Enabled
;
1232 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1233 goto invalid_enum_error
;
1234 return ctx
->Light
.Enabled
;
1243 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1244 goto invalid_enum_error
;
1245 return ctx
->Light
.Light
[cap
-GL_LIGHT0
].Enabled
;
1246 case GL_LINE_SMOOTH
:
1247 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1248 goto invalid_enum_error
;
1249 return ctx
->Line
.SmoothFlag
;
1250 case GL_LINE_STIPPLE
:
1251 if (ctx
->API
!= API_OPENGL_COMPAT
)
1252 goto invalid_enum_error
;
1253 return ctx
->Line
.StippleFlag
;
1254 case GL_INDEX_LOGIC_OP
:
1255 if (ctx
->API
!= API_OPENGL_COMPAT
)
1256 goto invalid_enum_error
;
1257 return ctx
->Color
.IndexLogicOpEnabled
;
1258 case GL_COLOR_LOGIC_OP
:
1259 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1260 goto invalid_enum_error
;
1261 return ctx
->Color
.ColorLogicOpEnabled
;
1262 case GL_MAP1_COLOR_4
:
1263 if (ctx
->API
!= API_OPENGL_COMPAT
)
1264 goto invalid_enum_error
;
1265 return ctx
->Eval
.Map1Color4
;
1267 if (ctx
->API
!= API_OPENGL_COMPAT
)
1268 goto invalid_enum_error
;
1269 return ctx
->Eval
.Map1Index
;
1270 case GL_MAP1_NORMAL
:
1271 if (ctx
->API
!= API_OPENGL_COMPAT
)
1272 goto invalid_enum_error
;
1273 return ctx
->Eval
.Map1Normal
;
1274 case GL_MAP1_TEXTURE_COORD_1
:
1275 if (ctx
->API
!= API_OPENGL_COMPAT
)
1276 goto invalid_enum_error
;
1277 return ctx
->Eval
.Map1TextureCoord1
;
1278 case GL_MAP1_TEXTURE_COORD_2
:
1279 if (ctx
->API
!= API_OPENGL_COMPAT
)
1280 goto invalid_enum_error
;
1281 return ctx
->Eval
.Map1TextureCoord2
;
1282 case GL_MAP1_TEXTURE_COORD_3
:
1283 if (ctx
->API
!= API_OPENGL_COMPAT
)
1284 goto invalid_enum_error
;
1285 return ctx
->Eval
.Map1TextureCoord3
;
1286 case GL_MAP1_TEXTURE_COORD_4
:
1287 if (ctx
->API
!= API_OPENGL_COMPAT
)
1288 goto invalid_enum_error
;
1289 return ctx
->Eval
.Map1TextureCoord4
;
1290 case GL_MAP1_VERTEX_3
:
1291 if (ctx
->API
!= API_OPENGL_COMPAT
)
1292 goto invalid_enum_error
;
1293 return ctx
->Eval
.Map1Vertex3
;
1294 case GL_MAP1_VERTEX_4
:
1295 if (ctx
->API
!= API_OPENGL_COMPAT
)
1296 goto invalid_enum_error
;
1297 return ctx
->Eval
.Map1Vertex4
;
1298 case GL_MAP2_COLOR_4
:
1299 if (ctx
->API
!= API_OPENGL_COMPAT
)
1300 goto invalid_enum_error
;
1301 return ctx
->Eval
.Map2Color4
;
1303 if (ctx
->API
!= API_OPENGL_COMPAT
)
1304 goto invalid_enum_error
;
1305 return ctx
->Eval
.Map2Index
;
1306 case GL_MAP2_NORMAL
:
1307 if (ctx
->API
!= API_OPENGL_COMPAT
)
1308 goto invalid_enum_error
;
1309 return ctx
->Eval
.Map2Normal
;
1310 case GL_MAP2_TEXTURE_COORD_1
:
1311 if (ctx
->API
!= API_OPENGL_COMPAT
)
1312 goto invalid_enum_error
;
1313 return ctx
->Eval
.Map2TextureCoord1
;
1314 case GL_MAP2_TEXTURE_COORD_2
:
1315 if (ctx
->API
!= API_OPENGL_COMPAT
)
1316 goto invalid_enum_error
;
1317 return ctx
->Eval
.Map2TextureCoord2
;
1318 case GL_MAP2_TEXTURE_COORD_3
:
1319 if (ctx
->API
!= API_OPENGL_COMPAT
)
1320 goto invalid_enum_error
;
1321 return ctx
->Eval
.Map2TextureCoord3
;
1322 case GL_MAP2_TEXTURE_COORD_4
:
1323 if (ctx
->API
!= API_OPENGL_COMPAT
)
1324 goto invalid_enum_error
;
1325 return ctx
->Eval
.Map2TextureCoord4
;
1326 case GL_MAP2_VERTEX_3
:
1327 if (ctx
->API
!= API_OPENGL_COMPAT
)
1328 goto invalid_enum_error
;
1329 return ctx
->Eval
.Map2Vertex3
;
1330 case GL_MAP2_VERTEX_4
:
1331 if (ctx
->API
!= API_OPENGL_COMPAT
)
1332 goto invalid_enum_error
;
1333 return ctx
->Eval
.Map2Vertex4
;
1335 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1336 goto invalid_enum_error
;
1337 return ctx
->Transform
.Normalize
;
1338 case GL_POINT_SMOOTH
:
1339 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1340 goto invalid_enum_error
;
1341 return ctx
->Point
.SmoothFlag
;
1342 case GL_POLYGON_SMOOTH
:
1343 if (!_mesa_is_desktop_gl(ctx
))
1344 goto invalid_enum_error
;
1345 return ctx
->Polygon
.SmoothFlag
;
1346 case GL_POLYGON_STIPPLE
:
1347 if (ctx
->API
!= API_OPENGL_COMPAT
)
1348 goto invalid_enum_error
;
1349 return ctx
->Polygon
.StippleFlag
;
1350 case GL_POLYGON_OFFSET_POINT
:
1351 if (!_mesa_is_desktop_gl(ctx
))
1352 goto invalid_enum_error
;
1353 return ctx
->Polygon
.OffsetPoint
;
1354 case GL_POLYGON_OFFSET_LINE
:
1355 if (!_mesa_is_desktop_gl(ctx
))
1356 goto invalid_enum_error
;
1357 return ctx
->Polygon
.OffsetLine
;
1358 case GL_POLYGON_OFFSET_FILL
:
1359 return ctx
->Polygon
.OffsetFill
;
1360 case GL_RESCALE_NORMAL_EXT
:
1361 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1362 goto invalid_enum_error
;
1363 return ctx
->Transform
.RescaleNormals
;
1364 case GL_SCISSOR_TEST
:
1365 return ctx
->Scissor
.Enabled
;
1366 case GL_STENCIL_TEST
:
1367 return ctx
->Stencil
.Enabled
;
1369 if (ctx
->API
!= API_OPENGL_COMPAT
)
1370 goto invalid_enum_error
;
1371 return is_texture_enabled(ctx
, TEXTURE_1D_BIT
);
1373 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1374 goto invalid_enum_error
;
1375 return is_texture_enabled(ctx
, TEXTURE_2D_BIT
);
1377 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1378 goto invalid_enum_error
;
1379 return is_texture_enabled(ctx
, TEXTURE_3D_BIT
);
1380 case GL_TEXTURE_GEN_S
:
1381 case GL_TEXTURE_GEN_T
:
1382 case GL_TEXTURE_GEN_R
:
1383 case GL_TEXTURE_GEN_Q
:
1385 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1387 if (ctx
->API
!= API_OPENGL_COMPAT
)
1388 goto invalid_enum_error
;
1391 GLbitfield coordBit
= S_BIT
<< (cap
- GL_TEXTURE_GEN_S
);
1392 return (texUnit
->TexGenEnabled
& coordBit
) ? GL_TRUE
: GL_FALSE
;
1396 case GL_TEXTURE_GEN_STR_OES
:
1398 const struct gl_texture_unit
*texUnit
= get_texcoord_unit(ctx
);
1400 if (ctx
->API
!= API_OPENGLES
)
1401 goto invalid_enum_error
;
1404 return (texUnit
->TexGenEnabled
& STR_BITS
) == STR_BITS
1405 ? GL_TRUE
: GL_FALSE
;
1409 /* client-side state */
1410 case GL_VERTEX_ARRAY
:
1411 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1412 goto invalid_enum_error
;
1413 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
!= 0);
1414 case GL_NORMAL_ARRAY
:
1415 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1416 goto invalid_enum_error
;
1417 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
!= 0);
1418 case GL_COLOR_ARRAY
:
1419 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1420 goto invalid_enum_error
;
1421 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
!= 0);
1422 case GL_INDEX_ARRAY
:
1423 if (ctx
->API
!= API_OPENGL_COMPAT
)
1424 goto invalid_enum_error
;
1425 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
!= 0);
1426 case GL_TEXTURE_COORD_ARRAY
:
1427 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1428 goto invalid_enum_error
;
1429 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)]
1431 case GL_EDGE_FLAG_ARRAY
:
1432 if (ctx
->API
!= API_OPENGL_COMPAT
)
1433 goto invalid_enum_error
;
1434 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
!= 0);
1435 case GL_FOG_COORDINATE_ARRAY_EXT
:
1436 if (ctx
->API
!= API_OPENGL_COMPAT
)
1437 goto invalid_enum_error
;
1438 CHECK_EXTENSION(EXT_fog_coord
);
1439 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
!= 0);
1440 case GL_SECONDARY_COLOR_ARRAY_EXT
:
1441 if (ctx
->API
!= API_OPENGL_COMPAT
)
1442 goto invalid_enum_error
;
1443 CHECK_EXTENSION(EXT_secondary_color
);
1444 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
!= 0);
1445 case GL_POINT_SIZE_ARRAY_OES
:
1446 if (ctx
->API
!= API_OPENGLES
)
1447 goto invalid_enum_error
;
1448 return (ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Enabled
!= 0);
1450 /* GL_ARB_texture_cube_map */
1451 case GL_TEXTURE_CUBE_MAP_ARB
:
1452 CHECK_EXTENSION(ARB_texture_cube_map
);
1453 return is_texture_enabled(ctx
, TEXTURE_CUBE_BIT
);
1455 /* GL_EXT_secondary_color */
1456 case GL_COLOR_SUM_EXT
:
1457 if (ctx
->API
!= API_OPENGL_COMPAT
)
1458 goto invalid_enum_error
;
1459 CHECK_EXTENSION2(EXT_secondary_color
, ARB_vertex_program
);
1460 return ctx
->Fog
.ColorSumEnabled
;
1462 /* GL_ARB_multisample */
1463 case GL_MULTISAMPLE_ARB
:
1464 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1465 goto invalid_enum_error
;
1466 return ctx
->Multisample
.Enabled
;
1467 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
:
1468 return ctx
->Multisample
.SampleAlphaToCoverage
;
1469 case GL_SAMPLE_ALPHA_TO_ONE_ARB
:
1470 if (!_mesa_is_desktop_gl(ctx
) && ctx
->API
!= API_OPENGLES
)
1471 goto invalid_enum_error
;
1472 return ctx
->Multisample
.SampleAlphaToOne
;
1473 case GL_SAMPLE_COVERAGE_ARB
:
1474 return ctx
->Multisample
.SampleCoverage
;
1475 case GL_SAMPLE_COVERAGE_INVERT_ARB
:
1476 if (!_mesa_is_desktop_gl(ctx
))
1477 goto invalid_enum_error
;
1478 return ctx
->Multisample
.SampleCoverageInvert
;
1480 /* GL_IBM_rasterpos_clip */
1481 case GL_RASTER_POSITION_UNCLIPPED_IBM
:
1482 if (ctx
->API
!= API_OPENGL_COMPAT
)
1483 goto invalid_enum_error
;
1484 return ctx
->Transform
.RasterPositionUnclipped
;
1486 /* GL_NV_point_sprite */
1487 case GL_POINT_SPRITE_NV
:
1488 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
1489 goto invalid_enum_error
;
1490 CHECK_EXTENSION2(NV_point_sprite
, ARB_point_sprite
)
1491 return ctx
->Point
.PointSprite
;
1493 case GL_VERTEX_PROGRAM_ARB
:
1494 if (ctx
->API
!= API_OPENGL_COMPAT
)
1495 goto invalid_enum_error
;
1496 CHECK_EXTENSION(ARB_vertex_program
);
1497 return ctx
->VertexProgram
.Enabled
;
1498 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB
:
1499 /* This was added with ARB_vertex_program, but it is also used with
1500 * GLSL vertex shaders on desktop.
1502 if (!_mesa_is_desktop_gl(ctx
))
1503 goto invalid_enum_error
;
1504 CHECK_EXTENSION(ARB_vertex_program
);
1505 return ctx
->VertexProgram
.PointSizeEnabled
;
1506 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB
:
1507 if (ctx
->API
!= API_OPENGL_COMPAT
)
1508 goto invalid_enum_error
;
1509 CHECK_EXTENSION(ARB_vertex_program
);
1510 return ctx
->VertexProgram
.TwoSideEnabled
;
1512 /* GL_NV_texture_rectangle */
1513 case GL_TEXTURE_RECTANGLE_NV
:
1514 if (ctx
->API
!= API_OPENGL_COMPAT
)
1515 goto invalid_enum_error
;
1516 CHECK_EXTENSION(NV_texture_rectangle
);
1517 return is_texture_enabled(ctx
, TEXTURE_RECT_BIT
);
1519 /* GL_EXT_stencil_two_side */
1520 case GL_STENCIL_TEST_TWO_SIDE_EXT
:
1521 if (ctx
->API
!= API_OPENGL_COMPAT
)
1522 goto invalid_enum_error
;
1523 CHECK_EXTENSION(EXT_stencil_two_side
);
1524 return ctx
->Stencil
.TestTwoSide
;
1526 case GL_FRAGMENT_PROGRAM_ARB
:
1527 if (ctx
->API
!= API_OPENGL_COMPAT
)
1528 goto invalid_enum_error
;
1529 return ctx
->FragmentProgram
.Enabled
;
1531 /* GL_EXT_depth_bounds_test */
1532 case GL_DEPTH_BOUNDS_TEST_EXT
:
1533 if (!_mesa_is_desktop_gl(ctx
))
1534 goto invalid_enum_error
;
1535 CHECK_EXTENSION(EXT_depth_bounds_test
);
1536 return ctx
->Depth
.BoundsTest
;
1538 /* GL_ARB_depth_clamp */
1539 case GL_DEPTH_CLAMP
:
1540 if (!_mesa_is_desktop_gl(ctx
))
1541 goto invalid_enum_error
;
1542 CHECK_EXTENSION(ARB_depth_clamp
);
1543 return ctx
->Transform
.DepthClamp
;
1545 case GL_FRAGMENT_SHADER_ATI
:
1546 if (ctx
->API
!= API_OPENGL_COMPAT
)
1547 goto invalid_enum_error
;
1548 CHECK_EXTENSION(ATI_fragment_shader
);
1549 return ctx
->ATIFragmentShader
.Enabled
;
1551 case GL_TEXTURE_CUBE_MAP_SEAMLESS
:
1552 if (!_mesa_is_desktop_gl(ctx
))
1553 goto invalid_enum_error
;
1554 CHECK_EXTENSION(ARB_seamless_cube_map
);
1555 return ctx
->Texture
.CubeMapSeamless
;
1557 case GL_RASTERIZER_DISCARD
:
1558 if (!_mesa_is_desktop_gl(ctx
) && !_mesa_is_gles3(ctx
))
1559 goto invalid_enum_error
;
1560 CHECK_EXTENSION(EXT_transform_feedback
);
1561 return ctx
->RasterDiscard
;
1563 /* GL_NV_primitive_restart */
1564 case GL_PRIMITIVE_RESTART_NV
:
1565 if (ctx
->API
!= API_OPENGL_COMPAT
|| !ctx
->Extensions
.NV_primitive_restart
) {
1566 goto invalid_enum_error
;
1568 return ctx
->Array
.PrimitiveRestart
;
1570 /* GL 3.1 primitive restart */
1571 case GL_PRIMITIVE_RESTART
:
1572 if (!_mesa_is_desktop_gl(ctx
) || ctx
->Version
< 31) {
1573 goto invalid_enum_error
;
1575 return ctx
->Array
.PrimitiveRestart
;
1577 case GL_PRIMITIVE_RESTART_FIXED_INDEX
:
1578 if (!_mesa_is_gles3(ctx
) && !ctx
->Extensions
.ARB_ES3_compatibility
) {
1579 goto invalid_enum_error
;
1581 return ctx
->Array
.PrimitiveRestartFixedIndex
;
1583 /* GL3.0 - GL_framebuffer_sRGB */
1584 case GL_FRAMEBUFFER_SRGB_EXT
:
1585 if (!_mesa_is_desktop_gl(ctx
))
1586 goto invalid_enum_error
;
1587 CHECK_EXTENSION(EXT_framebuffer_sRGB
);
1588 return ctx
->Color
.sRGBEnabled
;
1590 /* GL_OES_EGL_image_external */
1591 case GL_TEXTURE_EXTERNAL_OES
:
1592 if (!_mesa_is_gles(ctx
))
1593 goto invalid_enum_error
;
1594 CHECK_EXTENSION(OES_EGL_image_external
);
1595 return is_texture_enabled(ctx
, TEXTURE_EXTERNAL_BIT
);
1597 /* ARB_texture_multisample */
1598 case GL_SAMPLE_MASK
:
1599 if (!_mesa_is_desktop_gl(ctx
))
1600 goto invalid_enum_error
;
1601 CHECK_EXTENSION(ARB_texture_multisample
);
1602 return ctx
->Multisample
.SampleMask
;
1605 goto invalid_enum_error
;
1611 _mesa_error(ctx
, GL_INVALID_ENUM
, "glIsEnabled(%s)",
1612 _mesa_lookup_enum_by_nr(cap
));