enable.c revision 4a49301e
17117f1b4Smrg/** 27117f1b4Smrg * \file enable.c 37117f1b4Smrg * Enable/disable/query GL capabilities. 47117f1b4Smrg */ 57117f1b4Smrg 67117f1b4Smrg/* 77117f1b4Smrg * Mesa 3-D graphics library 87117f1b4Smrg * Version: 7.0.3 97117f1b4Smrg * 107117f1b4Smrg * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 117117f1b4Smrg * 127117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 137117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 147117f1b4Smrg * to deal in the Software without restriction, including without limitation 157117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 167117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 177117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 187117f1b4Smrg * 197117f1b4Smrg * The above copyright notice and this permission notice shall be included 207117f1b4Smrg * in all copies or substantial portions of the Software. 217117f1b4Smrg * 227117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 237117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 247117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 257117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 267117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 277117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 287117f1b4Smrg */ 297117f1b4Smrg 307117f1b4Smrg 317117f1b4Smrg#include "glheader.h" 327117f1b4Smrg#include "context.h" 337117f1b4Smrg#include "enable.h" 347117f1b4Smrg#include "light.h" 357117f1b4Smrg#include "simple_list.h" 367117f1b4Smrg#include "mtypes.h" 377117f1b4Smrg#include "enums.h" 38c1f859d4Smrg#include "api_arrayelt.h" 394a49301eSmrg#include "texstate.h" 407117f1b4Smrg 417117f1b4Smrg 427117f1b4Smrg 437117f1b4Smrg#define CHECK_EXTENSION(EXTNAME, CAP) \ 447117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 457117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \ 467117f1b4Smrg state ? "Enable" : "Disable", CAP); \ 477117f1b4Smrg return; \ 487117f1b4Smrg } 497117f1b4Smrg 507117f1b4Smrg 517117f1b4Smrg/** 527117f1b4Smrg * Helper to enable/disable client-side state. 537117f1b4Smrg */ 547117f1b4Smrgstatic void 557117f1b4Smrgclient_state(GLcontext *ctx, GLenum cap, GLboolean state) 567117f1b4Smrg{ 574a49301eSmrg struct gl_array_object *arrayObj = ctx->Array.ArrayObj; 587117f1b4Smrg GLuint flag; 597117f1b4Smrg GLboolean *var; 607117f1b4Smrg 617117f1b4Smrg switch (cap) { 627117f1b4Smrg case GL_VERTEX_ARRAY: 634a49301eSmrg var = &arrayObj->Vertex.Enabled; 647117f1b4Smrg flag = _NEW_ARRAY_VERTEX; 657117f1b4Smrg break; 667117f1b4Smrg case GL_NORMAL_ARRAY: 674a49301eSmrg var = &arrayObj->Normal.Enabled; 687117f1b4Smrg flag = _NEW_ARRAY_NORMAL; 697117f1b4Smrg break; 707117f1b4Smrg case GL_COLOR_ARRAY: 714a49301eSmrg var = &arrayObj->Color.Enabled; 727117f1b4Smrg flag = _NEW_ARRAY_COLOR0; 737117f1b4Smrg break; 747117f1b4Smrg case GL_INDEX_ARRAY: 754a49301eSmrg var = &arrayObj->Index.Enabled; 767117f1b4Smrg flag = _NEW_ARRAY_INDEX; 777117f1b4Smrg break; 787117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 794a49301eSmrg var = &arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled; 807117f1b4Smrg flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); 817117f1b4Smrg break; 827117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 834a49301eSmrg var = &arrayObj->EdgeFlag.Enabled; 847117f1b4Smrg flag = _NEW_ARRAY_EDGEFLAG; 857117f1b4Smrg break; 867117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 874a49301eSmrg var = &arrayObj->FogCoord.Enabled; 887117f1b4Smrg flag = _NEW_ARRAY_FOGCOORD; 897117f1b4Smrg break; 907117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 914a49301eSmrg var = &arrayObj->SecondaryColor.Enabled; 927117f1b4Smrg flag = _NEW_ARRAY_COLOR1; 937117f1b4Smrg break; 947117f1b4Smrg 95c1f859d4Smrg#if FEATURE_point_size_array 96c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 974a49301eSmrg var = &arrayObj->PointSize.Enabled; 98c1f859d4Smrg flag = _NEW_ARRAY_POINT_SIZE; 99c1f859d4Smrg break; 100c1f859d4Smrg#endif 101c1f859d4Smrg 1027117f1b4Smrg#if FEATURE_NV_vertex_program 1037117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY0_NV: 1047117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY1_NV: 1057117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY2_NV: 1067117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY3_NV: 1077117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY4_NV: 1087117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY5_NV: 1097117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY6_NV: 1107117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY7_NV: 1117117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY8_NV: 1127117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY9_NV: 1137117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY10_NV: 1147117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY11_NV: 1157117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY12_NV: 1167117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY13_NV: 1177117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY14_NV: 1187117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY15_NV: 1197117f1b4Smrg CHECK_EXTENSION(NV_vertex_program, cap); 1207117f1b4Smrg { 1217117f1b4Smrg GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; 1224a49301eSmrg ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); 1234a49301eSmrg var = &arrayObj->VertexAttrib[n].Enabled; 1247117f1b4Smrg flag = _NEW_ARRAY_ATTRIB(n); 1257117f1b4Smrg } 1267117f1b4Smrg break; 1277117f1b4Smrg#endif /* FEATURE_NV_vertex_program */ 1287117f1b4Smrg 1297117f1b4Smrg default: 1307117f1b4Smrg _mesa_error( ctx, GL_INVALID_ENUM, 1317117f1b4Smrg "glEnable/DisableClientState(0x%x)", cap); 1327117f1b4Smrg return; 1337117f1b4Smrg } 1347117f1b4Smrg 1357117f1b4Smrg if (*var == state) 1367117f1b4Smrg return; 1377117f1b4Smrg 1387117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_ARRAY); 1397117f1b4Smrg ctx->Array.NewState |= flag; 140c1f859d4Smrg 141c1f859d4Smrg _ae_invalidate_state(ctx, _NEW_ARRAY); 142c1f859d4Smrg 1437117f1b4Smrg *var = state; 1447117f1b4Smrg 1457117f1b4Smrg if (state) 1467117f1b4Smrg ctx->Array.ArrayObj->_Enabled |= flag; 1477117f1b4Smrg else 1487117f1b4Smrg ctx->Array.ArrayObj->_Enabled &= ~flag; 1497117f1b4Smrg 1507117f1b4Smrg if (ctx->Driver.Enable) { 1517117f1b4Smrg ctx->Driver.Enable( ctx, cap, state ); 1527117f1b4Smrg } 1537117f1b4Smrg} 1547117f1b4Smrg 1557117f1b4Smrg 1567117f1b4Smrg/** 1577117f1b4Smrg * Enable GL capability. 1587117f1b4Smrg * \param cap state to enable/disable. 1597117f1b4Smrg * 1607117f1b4Smrg * Get's the current context, assures that we're outside glBegin()/glEnd() and 1617117f1b4Smrg * calls client_state(). 1627117f1b4Smrg */ 1637117f1b4Smrgvoid GLAPIENTRY 1647117f1b4Smrg_mesa_EnableClientState( GLenum cap ) 1657117f1b4Smrg{ 1667117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 1677117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 1687117f1b4Smrg client_state( ctx, cap, GL_TRUE ); 1697117f1b4Smrg} 1707117f1b4Smrg 1717117f1b4Smrg 1727117f1b4Smrg/** 1737117f1b4Smrg * Disable GL capability. 1747117f1b4Smrg * \param cap state to enable/disable. 1757117f1b4Smrg * 1767117f1b4Smrg * Get's the current context, assures that we're outside glBegin()/glEnd() and 1777117f1b4Smrg * calls client_state(). 1787117f1b4Smrg */ 1797117f1b4Smrgvoid GLAPIENTRY 1807117f1b4Smrg_mesa_DisableClientState( GLenum cap ) 1817117f1b4Smrg{ 1827117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 1837117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 1847117f1b4Smrg client_state( ctx, cap, GL_FALSE ); 1857117f1b4Smrg} 1867117f1b4Smrg 1877117f1b4Smrg 1887117f1b4Smrg#undef CHECK_EXTENSION 1897117f1b4Smrg#define CHECK_EXTENSION(EXTNAME, CAP) \ 1907117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 1917117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \ 1927117f1b4Smrg state ? "Enable" : "Disable", CAP); \ 1937117f1b4Smrg return; \ 1947117f1b4Smrg } 1957117f1b4Smrg 1967117f1b4Smrg#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ 1977117f1b4Smrg if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ 1987117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \ 1997117f1b4Smrg state ? "Enable" : "Disable", CAP); \ 2007117f1b4Smrg return; \ 2017117f1b4Smrg } 2027117f1b4Smrg 2037117f1b4Smrg 204c1f859d4Smrg 205c1f859d4Smrg/** 206c1f859d4Smrg * Return pointer to current texture unit for setting/getting coordinate 207c1f859d4Smrg * state. 208c1f859d4Smrg * Note that we'll set GL_INVALID_OPERATION if the active texture unit is 209c1f859d4Smrg * higher than the number of supported coordinate units. And we'll return NULL. 210c1f859d4Smrg */ 211c1f859d4Smrgstatic struct gl_texture_unit * 212c1f859d4Smrgget_texcoord_unit(GLcontext *ctx) 213c1f859d4Smrg{ 214c1f859d4Smrg if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 215c1f859d4Smrg _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); 216c1f859d4Smrg return NULL; 217c1f859d4Smrg } 218c1f859d4Smrg else { 219c1f859d4Smrg return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; 220c1f859d4Smrg } 221c1f859d4Smrg} 222c1f859d4Smrg 223c1f859d4Smrg 2247117f1b4Smrg/** 2257117f1b4Smrg * Helper function to enable or disable a texture target. 2264a49301eSmrg * \param bit one of the TEXTURE_x_BIT values 2274a49301eSmrg * \return GL_TRUE if state is changing or GL_FALSE if no change 2287117f1b4Smrg */ 2297117f1b4Smrgstatic GLboolean 2304a49301eSmrgenable_texture(GLcontext *ctx, GLboolean state, GLbitfield texBit) 2317117f1b4Smrg{ 2324a49301eSmrg struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); 2334a49301eSmrg const GLbitfield newenabled = state 2344a49301eSmrg ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); 2357117f1b4Smrg 2364a49301eSmrg if (texUnit->Enabled == newenabled) 2377117f1b4Smrg return GL_FALSE; 2387117f1b4Smrg 2397117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 2407117f1b4Smrg texUnit->Enabled = newenabled; 2417117f1b4Smrg return GL_TRUE; 2427117f1b4Smrg} 2437117f1b4Smrg 2447117f1b4Smrg 2457117f1b4Smrg/** 2467117f1b4Smrg * Helper function to enable or disable state. 2477117f1b4Smrg * 2487117f1b4Smrg * \param ctx GL context. 2497117f1b4Smrg * \param cap the state to enable/disable 2507117f1b4Smrg * \param state whether to enable or disable the specified capability. 2517117f1b4Smrg * 2527117f1b4Smrg * Updates the current context and flushes the vertices as needed. For 2537117f1b4Smrg * capabilities associated with extensions it verifies that those extensions 2547117f1b4Smrg * are effectivly present before updating. Notifies the driver via 2557117f1b4Smrg * dd_function_table::Enable. 2567117f1b4Smrg */ 2577117f1b4Smrgvoid 2587117f1b4Smrg_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) 2597117f1b4Smrg{ 2607117f1b4Smrg if (MESA_VERBOSE & VERBOSE_API) 2617117f1b4Smrg _mesa_debug(ctx, "%s %s (newstate is %x)\n", 2627117f1b4Smrg state ? "glEnable" : "glDisable", 2637117f1b4Smrg _mesa_lookup_enum_by_nr(cap), 2647117f1b4Smrg ctx->NewState); 2657117f1b4Smrg 2667117f1b4Smrg switch (cap) { 2677117f1b4Smrg case GL_ALPHA_TEST: 2687117f1b4Smrg if (ctx->Color.AlphaEnabled == state) 2697117f1b4Smrg return; 2707117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 2717117f1b4Smrg ctx->Color.AlphaEnabled = state; 2727117f1b4Smrg break; 2737117f1b4Smrg case GL_AUTO_NORMAL: 2747117f1b4Smrg if (ctx->Eval.AutoNormal == state) 2757117f1b4Smrg return; 2767117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 2777117f1b4Smrg ctx->Eval.AutoNormal = state; 2787117f1b4Smrg break; 2797117f1b4Smrg case GL_BLEND: 2807117f1b4Smrg if (ctx->Color.BlendEnabled == state) 2817117f1b4Smrg return; 2827117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 2837117f1b4Smrg ctx->Color.BlendEnabled = state; 2847117f1b4Smrg break; 2857117f1b4Smrg#if FEATURE_userclip 2867117f1b4Smrg case GL_CLIP_PLANE0: 2877117f1b4Smrg case GL_CLIP_PLANE1: 2887117f1b4Smrg case GL_CLIP_PLANE2: 2897117f1b4Smrg case GL_CLIP_PLANE3: 2907117f1b4Smrg case GL_CLIP_PLANE4: 2917117f1b4Smrg case GL_CLIP_PLANE5: 2927117f1b4Smrg { 2937117f1b4Smrg const GLuint p = cap - GL_CLIP_PLANE0; 2947117f1b4Smrg 2957117f1b4Smrg if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) 2967117f1b4Smrg return; 2977117f1b4Smrg 2987117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 2997117f1b4Smrg 3007117f1b4Smrg if (state) { 3017117f1b4Smrg ctx->Transform.ClipPlanesEnabled |= (1 << p); 3027117f1b4Smrg 3037117f1b4Smrg if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) 3047117f1b4Smrg _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); 3057117f1b4Smrg 3067117f1b4Smrg /* This derived state also calculated in clip.c and 3077117f1b4Smrg * from _mesa_update_state() on changes to EyeUserPlane 3087117f1b4Smrg * and ctx->ProjectionMatrix respectively. 3097117f1b4Smrg */ 3107117f1b4Smrg _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], 3117117f1b4Smrg ctx->Transform.EyeUserPlane[p], 3127117f1b4Smrg ctx->ProjectionMatrixStack.Top->inv ); 3137117f1b4Smrg } 3147117f1b4Smrg else { 3157117f1b4Smrg ctx->Transform.ClipPlanesEnabled &= ~(1 << p); 3167117f1b4Smrg } 3177117f1b4Smrg } 3187117f1b4Smrg break; 3197117f1b4Smrg#endif 3207117f1b4Smrg case GL_COLOR_MATERIAL: 3217117f1b4Smrg if (ctx->Light.ColorMaterialEnabled == state) 3227117f1b4Smrg return; 3237117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 3247117f1b4Smrg FLUSH_CURRENT(ctx, 0); 3257117f1b4Smrg ctx->Light.ColorMaterialEnabled = state; 3267117f1b4Smrg if (state) { 3277117f1b4Smrg _mesa_update_color_material( ctx, 3287117f1b4Smrg ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); 3297117f1b4Smrg } 3307117f1b4Smrg break; 3317117f1b4Smrg case GL_CULL_FACE: 3327117f1b4Smrg if (ctx->Polygon.CullFlag == state) 3337117f1b4Smrg return; 3347117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 3357117f1b4Smrg ctx->Polygon.CullFlag = state; 3367117f1b4Smrg break; 3377117f1b4Smrg case GL_CULL_VERTEX_EXT: 3387117f1b4Smrg CHECK_EXTENSION(EXT_cull_vertex, cap); 3397117f1b4Smrg if (ctx->Transform.CullVertexFlag == state) 3407117f1b4Smrg return; 3417117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 3427117f1b4Smrg ctx->Transform.CullVertexFlag = state; 3437117f1b4Smrg break; 3447117f1b4Smrg case GL_DEPTH_TEST: 3457117f1b4Smrg if (ctx->Depth.Test == state) 3467117f1b4Smrg return; 3477117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_DEPTH); 3487117f1b4Smrg ctx->Depth.Test = state; 3497117f1b4Smrg break; 3507117f1b4Smrg case GL_DITHER: 3517117f1b4Smrg if (ctx->NoDither) { 3527117f1b4Smrg state = GL_FALSE; /* MESA_NO_DITHER env var */ 3537117f1b4Smrg } 3547117f1b4Smrg if (ctx->Color.DitherFlag == state) 3557117f1b4Smrg return; 3567117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 3577117f1b4Smrg ctx->Color.DitherFlag = state; 3587117f1b4Smrg break; 3597117f1b4Smrg case GL_FOG: 3607117f1b4Smrg if (ctx->Fog.Enabled == state) 3617117f1b4Smrg return; 3627117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_FOG); 3637117f1b4Smrg ctx->Fog.Enabled = state; 3647117f1b4Smrg break; 3657117f1b4Smrg case GL_HISTOGRAM: 3667117f1b4Smrg CHECK_EXTENSION(EXT_histogram, cap); 3677117f1b4Smrg if (ctx->Pixel.HistogramEnabled == state) 3687117f1b4Smrg return; 3697117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 3707117f1b4Smrg ctx->Pixel.HistogramEnabled = state; 3717117f1b4Smrg break; 3727117f1b4Smrg case GL_LIGHT0: 3737117f1b4Smrg case GL_LIGHT1: 3747117f1b4Smrg case GL_LIGHT2: 3757117f1b4Smrg case GL_LIGHT3: 3767117f1b4Smrg case GL_LIGHT4: 3777117f1b4Smrg case GL_LIGHT5: 3787117f1b4Smrg case GL_LIGHT6: 3797117f1b4Smrg case GL_LIGHT7: 3807117f1b4Smrg if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) 3817117f1b4Smrg return; 3827117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 3837117f1b4Smrg ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; 3847117f1b4Smrg if (state) { 3857117f1b4Smrg insert_at_tail(&ctx->Light.EnabledList, 3867117f1b4Smrg &ctx->Light.Light[cap-GL_LIGHT0]); 3877117f1b4Smrg } 3887117f1b4Smrg else { 3897117f1b4Smrg remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); 3907117f1b4Smrg } 3917117f1b4Smrg break; 3927117f1b4Smrg case GL_LIGHTING: 3937117f1b4Smrg if (ctx->Light.Enabled == state) 3947117f1b4Smrg return; 3957117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LIGHT); 3967117f1b4Smrg ctx->Light.Enabled = state; 3977117f1b4Smrg if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) 3987117f1b4Smrg ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; 3997117f1b4Smrg else 4007117f1b4Smrg ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; 4017117f1b4Smrg break; 4027117f1b4Smrg case GL_LINE_SMOOTH: 4037117f1b4Smrg if (ctx->Line.SmoothFlag == state) 4047117f1b4Smrg return; 4057117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LINE); 4067117f1b4Smrg ctx->Line.SmoothFlag = state; 4077117f1b4Smrg ctx->_TriangleCaps ^= DD_LINE_SMOOTH; 4087117f1b4Smrg break; 4097117f1b4Smrg case GL_LINE_STIPPLE: 4107117f1b4Smrg if (ctx->Line.StippleFlag == state) 4117117f1b4Smrg return; 4127117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_LINE); 4137117f1b4Smrg ctx->Line.StippleFlag = state; 4147117f1b4Smrg ctx->_TriangleCaps ^= DD_LINE_STIPPLE; 4157117f1b4Smrg break; 4167117f1b4Smrg case GL_INDEX_LOGIC_OP: 4177117f1b4Smrg if (ctx->Color.IndexLogicOpEnabled == state) 4187117f1b4Smrg return; 4197117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 4207117f1b4Smrg ctx->Color.IndexLogicOpEnabled = state; 4217117f1b4Smrg break; 4227117f1b4Smrg case GL_COLOR_LOGIC_OP: 4237117f1b4Smrg if (ctx->Color.ColorLogicOpEnabled == state) 4247117f1b4Smrg return; 4257117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_COLOR); 4267117f1b4Smrg ctx->Color.ColorLogicOpEnabled = state; 4277117f1b4Smrg break; 4287117f1b4Smrg case GL_MAP1_COLOR_4: 4297117f1b4Smrg if (ctx->Eval.Map1Color4 == state) 4307117f1b4Smrg return; 4317117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4327117f1b4Smrg ctx->Eval.Map1Color4 = state; 4337117f1b4Smrg break; 4347117f1b4Smrg case GL_MAP1_INDEX: 4357117f1b4Smrg if (ctx->Eval.Map1Index == state) 4367117f1b4Smrg return; 4377117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4387117f1b4Smrg ctx->Eval.Map1Index = state; 4397117f1b4Smrg break; 4407117f1b4Smrg case GL_MAP1_NORMAL: 4417117f1b4Smrg if (ctx->Eval.Map1Normal == state) 4427117f1b4Smrg return; 4437117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4447117f1b4Smrg ctx->Eval.Map1Normal = state; 4457117f1b4Smrg break; 4467117f1b4Smrg case GL_MAP1_TEXTURE_COORD_1: 4477117f1b4Smrg if (ctx->Eval.Map1TextureCoord1 == state) 4487117f1b4Smrg return; 4497117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4507117f1b4Smrg ctx->Eval.Map1TextureCoord1 = state; 4517117f1b4Smrg break; 4527117f1b4Smrg case GL_MAP1_TEXTURE_COORD_2: 4537117f1b4Smrg if (ctx->Eval.Map1TextureCoord2 == state) 4547117f1b4Smrg return; 4557117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4567117f1b4Smrg ctx->Eval.Map1TextureCoord2 = state; 4577117f1b4Smrg break; 4587117f1b4Smrg case GL_MAP1_TEXTURE_COORD_3: 4597117f1b4Smrg if (ctx->Eval.Map1TextureCoord3 == state) 4607117f1b4Smrg return; 4617117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4627117f1b4Smrg ctx->Eval.Map1TextureCoord3 = state; 4637117f1b4Smrg break; 4647117f1b4Smrg case GL_MAP1_TEXTURE_COORD_4: 4657117f1b4Smrg if (ctx->Eval.Map1TextureCoord4 == state) 4667117f1b4Smrg return; 4677117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4687117f1b4Smrg ctx->Eval.Map1TextureCoord4 = state; 4697117f1b4Smrg break; 4707117f1b4Smrg case GL_MAP1_VERTEX_3: 4717117f1b4Smrg if (ctx->Eval.Map1Vertex3 == state) 4727117f1b4Smrg return; 4737117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4747117f1b4Smrg ctx->Eval.Map1Vertex3 = state; 4757117f1b4Smrg break; 4767117f1b4Smrg case GL_MAP1_VERTEX_4: 4777117f1b4Smrg if (ctx->Eval.Map1Vertex4 == state) 4787117f1b4Smrg return; 4797117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4807117f1b4Smrg ctx->Eval.Map1Vertex4 = state; 4817117f1b4Smrg break; 4827117f1b4Smrg case GL_MAP2_COLOR_4: 4837117f1b4Smrg if (ctx->Eval.Map2Color4 == state) 4847117f1b4Smrg return; 4857117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4867117f1b4Smrg ctx->Eval.Map2Color4 = state; 4877117f1b4Smrg break; 4887117f1b4Smrg case GL_MAP2_INDEX: 4897117f1b4Smrg if (ctx->Eval.Map2Index == state) 4907117f1b4Smrg return; 4917117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4927117f1b4Smrg ctx->Eval.Map2Index = state; 4937117f1b4Smrg break; 4947117f1b4Smrg case GL_MAP2_NORMAL: 4957117f1b4Smrg if (ctx->Eval.Map2Normal == state) 4967117f1b4Smrg return; 4977117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 4987117f1b4Smrg ctx->Eval.Map2Normal = state; 4997117f1b4Smrg break; 5007117f1b4Smrg case GL_MAP2_TEXTURE_COORD_1: 5017117f1b4Smrg if (ctx->Eval.Map2TextureCoord1 == state) 5027117f1b4Smrg return; 5037117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5047117f1b4Smrg ctx->Eval.Map2TextureCoord1 = state; 5057117f1b4Smrg break; 5067117f1b4Smrg case GL_MAP2_TEXTURE_COORD_2: 5077117f1b4Smrg if (ctx->Eval.Map2TextureCoord2 == state) 5087117f1b4Smrg return; 5097117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5107117f1b4Smrg ctx->Eval.Map2TextureCoord2 = state; 5117117f1b4Smrg break; 5127117f1b4Smrg case GL_MAP2_TEXTURE_COORD_3: 5137117f1b4Smrg if (ctx->Eval.Map2TextureCoord3 == state) 5147117f1b4Smrg return; 5157117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5167117f1b4Smrg ctx->Eval.Map2TextureCoord3 = state; 5177117f1b4Smrg break; 5187117f1b4Smrg case GL_MAP2_TEXTURE_COORD_4: 5197117f1b4Smrg if (ctx->Eval.Map2TextureCoord4 == state) 5207117f1b4Smrg return; 5217117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5227117f1b4Smrg ctx->Eval.Map2TextureCoord4 = state; 5237117f1b4Smrg break; 5247117f1b4Smrg case GL_MAP2_VERTEX_3: 5257117f1b4Smrg if (ctx->Eval.Map2Vertex3 == state) 5267117f1b4Smrg return; 5277117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5287117f1b4Smrg ctx->Eval.Map2Vertex3 = state; 5297117f1b4Smrg break; 5307117f1b4Smrg case GL_MAP2_VERTEX_4: 5317117f1b4Smrg if (ctx->Eval.Map2Vertex4 == state) 5327117f1b4Smrg return; 5337117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 5347117f1b4Smrg ctx->Eval.Map2Vertex4 = state; 5357117f1b4Smrg break; 5367117f1b4Smrg case GL_MINMAX: 5377117f1b4Smrg if (ctx->Pixel.MinMaxEnabled == state) 5387117f1b4Smrg return; 5397117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 5407117f1b4Smrg ctx->Pixel.MinMaxEnabled = state; 5417117f1b4Smrg break; 5427117f1b4Smrg case GL_NORMALIZE: 5437117f1b4Smrg if (ctx->Transform.Normalize == state) 5447117f1b4Smrg return; 5457117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 5467117f1b4Smrg ctx->Transform.Normalize = state; 5477117f1b4Smrg break; 5487117f1b4Smrg case GL_POINT_SMOOTH: 5497117f1b4Smrg if (ctx->Point.SmoothFlag == state) 5507117f1b4Smrg return; 5517117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POINT); 5527117f1b4Smrg ctx->Point.SmoothFlag = state; 5537117f1b4Smrg ctx->_TriangleCaps ^= DD_POINT_SMOOTH; 5547117f1b4Smrg break; 5557117f1b4Smrg case GL_POLYGON_SMOOTH: 5567117f1b4Smrg if (ctx->Polygon.SmoothFlag == state) 5577117f1b4Smrg return; 5587117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 5597117f1b4Smrg ctx->Polygon.SmoothFlag = state; 5607117f1b4Smrg ctx->_TriangleCaps ^= DD_TRI_SMOOTH; 5617117f1b4Smrg break; 5627117f1b4Smrg case GL_POLYGON_STIPPLE: 5637117f1b4Smrg if (ctx->Polygon.StippleFlag == state) 5647117f1b4Smrg return; 5657117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 5667117f1b4Smrg ctx->Polygon.StippleFlag = state; 5677117f1b4Smrg ctx->_TriangleCaps ^= DD_TRI_STIPPLE; 5687117f1b4Smrg break; 5697117f1b4Smrg case GL_POLYGON_OFFSET_POINT: 5707117f1b4Smrg if (ctx->Polygon.OffsetPoint == state) 5717117f1b4Smrg return; 5727117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 5737117f1b4Smrg ctx->Polygon.OffsetPoint = state; 5747117f1b4Smrg break; 5757117f1b4Smrg case GL_POLYGON_OFFSET_LINE: 5767117f1b4Smrg if (ctx->Polygon.OffsetLine == state) 5777117f1b4Smrg return; 5787117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 5797117f1b4Smrg ctx->Polygon.OffsetLine = state; 5807117f1b4Smrg break; 5817117f1b4Smrg case GL_POLYGON_OFFSET_FILL: 5827117f1b4Smrg /*case GL_POLYGON_OFFSET_EXT:*/ 5837117f1b4Smrg if (ctx->Polygon.OffsetFill == state) 5847117f1b4Smrg return; 5857117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POLYGON); 5867117f1b4Smrg ctx->Polygon.OffsetFill = state; 5877117f1b4Smrg break; 5887117f1b4Smrg case GL_RESCALE_NORMAL_EXT: 5897117f1b4Smrg if (ctx->Transform.RescaleNormals == state) 5907117f1b4Smrg return; 5917117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 5927117f1b4Smrg ctx->Transform.RescaleNormals = state; 5937117f1b4Smrg break; 5947117f1b4Smrg case GL_SCISSOR_TEST: 5957117f1b4Smrg if (ctx->Scissor.Enabled == state) 5967117f1b4Smrg return; 5977117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_SCISSOR); 5987117f1b4Smrg ctx->Scissor.Enabled = state; 5997117f1b4Smrg break; 6007117f1b4Smrg case GL_SHARED_TEXTURE_PALETTE_EXT: 6017117f1b4Smrg if (ctx->Texture.SharedPalette == state) 6027117f1b4Smrg return; 6037117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 6047117f1b4Smrg ctx->Texture.SharedPalette = state; 6057117f1b4Smrg break; 6067117f1b4Smrg case GL_STENCIL_TEST: 6077117f1b4Smrg if (ctx->Stencil.Enabled == state) 6087117f1b4Smrg return; 6097117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_STENCIL); 6107117f1b4Smrg ctx->Stencil.Enabled = state; 6117117f1b4Smrg break; 6127117f1b4Smrg case GL_TEXTURE_1D: 6137117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { 6147117f1b4Smrg return; 6157117f1b4Smrg } 6167117f1b4Smrg break; 6177117f1b4Smrg case GL_TEXTURE_2D: 6187117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { 6197117f1b4Smrg return; 6207117f1b4Smrg } 6217117f1b4Smrg break; 6227117f1b4Smrg case GL_TEXTURE_3D: 6237117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { 6247117f1b4Smrg return; 6257117f1b4Smrg } 6267117f1b4Smrg break; 627c1f859d4Smrg case GL_TEXTURE_GEN_Q: 628c1f859d4Smrg { 629c1f859d4Smrg struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 630c1f859d4Smrg if (texUnit) { 631c1f859d4Smrg GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; 632c1f859d4Smrg if (state) 633c1f859d4Smrg newenabled |= Q_BIT; 634c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 635c1f859d4Smrg return; 636c1f859d4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 637c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 638c1f859d4Smrg } 639c1f859d4Smrg } 6407117f1b4Smrg break; 641c1f859d4Smrg case GL_TEXTURE_GEN_R: 642c1f859d4Smrg { 643c1f859d4Smrg struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 644c1f859d4Smrg if (texUnit) { 645c1f859d4Smrg GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; 646c1f859d4Smrg if (state) 647c1f859d4Smrg newenabled |= R_BIT; 648c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 649c1f859d4Smrg return; 650c1f859d4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 651c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 652c1f859d4Smrg } 653c1f859d4Smrg } 6547117f1b4Smrg break; 655c1f859d4Smrg case GL_TEXTURE_GEN_S: 656c1f859d4Smrg { 657c1f859d4Smrg struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 658c1f859d4Smrg if (texUnit) { 659c1f859d4Smrg GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; 660c1f859d4Smrg if (state) 661c1f859d4Smrg newenabled |= S_BIT; 662c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 663c1f859d4Smrg return; 664c1f859d4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 665c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 666c1f859d4Smrg } 667c1f859d4Smrg } 6687117f1b4Smrg break; 669c1f859d4Smrg case GL_TEXTURE_GEN_T: 670c1f859d4Smrg { 671c1f859d4Smrg struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 672c1f859d4Smrg if (texUnit) { 673c1f859d4Smrg GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; 674c1f859d4Smrg if (state) 675c1f859d4Smrg newenabled |= T_BIT; 676c1f859d4Smrg if (texUnit->TexGenEnabled == newenabled) 677c1f859d4Smrg return; 678c1f859d4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 679c1f859d4Smrg texUnit->TexGenEnabled = newenabled; 680c1f859d4Smrg } 681c1f859d4Smrg } 6827117f1b4Smrg break; 6837117f1b4Smrg 6847117f1b4Smrg /* 6857117f1b4Smrg * CLIENT STATE!!! 6867117f1b4Smrg */ 6877117f1b4Smrg case GL_VERTEX_ARRAY: 6887117f1b4Smrg case GL_NORMAL_ARRAY: 6897117f1b4Smrg case GL_COLOR_ARRAY: 6907117f1b4Smrg case GL_INDEX_ARRAY: 6917117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 6927117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 6937117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 6947117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 695c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 6967117f1b4Smrg client_state( ctx, cap, state ); 6977117f1b4Smrg return; 6987117f1b4Smrg 6997117f1b4Smrg /* GL_SGI_color_table */ 7007117f1b4Smrg case GL_COLOR_TABLE_SGI: 7017117f1b4Smrg CHECK_EXTENSION(SGI_color_table, cap); 7027117f1b4Smrg if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state) 7037117f1b4Smrg return; 7047117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 7057117f1b4Smrg ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state; 7067117f1b4Smrg break; 7077117f1b4Smrg case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: 7087117f1b4Smrg CHECK_EXTENSION(SGI_color_table, cap); 7097117f1b4Smrg if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state) 7107117f1b4Smrg return; 7117117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 7127117f1b4Smrg ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state; 7137117f1b4Smrg break; 7147117f1b4Smrg case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: 7157117f1b4Smrg CHECK_EXTENSION(SGI_color_table, cap); 7167117f1b4Smrg if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state) 7177117f1b4Smrg return; 7187117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 7197117f1b4Smrg ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state; 7207117f1b4Smrg break; 7217117f1b4Smrg case GL_TEXTURE_COLOR_TABLE_SGI: 7227117f1b4Smrg CHECK_EXTENSION(SGI_texture_color_table, cap); 7237117f1b4Smrg if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state) 7247117f1b4Smrg return; 7257117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TEXTURE); 7267117f1b4Smrg ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state; 7277117f1b4Smrg break; 7287117f1b4Smrg 7297117f1b4Smrg /* GL_EXT_convolution */ 7307117f1b4Smrg case GL_CONVOLUTION_1D: 7317117f1b4Smrg CHECK_EXTENSION(EXT_convolution, cap); 7327117f1b4Smrg if (ctx->Pixel.Convolution1DEnabled == state) 7337117f1b4Smrg return; 7347117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 7357117f1b4Smrg ctx->Pixel.Convolution1DEnabled = state; 7367117f1b4Smrg break; 7377117f1b4Smrg case GL_CONVOLUTION_2D: 7387117f1b4Smrg CHECK_EXTENSION(EXT_convolution, cap); 7397117f1b4Smrg if (ctx->Pixel.Convolution2DEnabled == state) 7407117f1b4Smrg return; 7417117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 7427117f1b4Smrg ctx->Pixel.Convolution2DEnabled = state; 7437117f1b4Smrg break; 7447117f1b4Smrg case GL_SEPARABLE_2D: 7457117f1b4Smrg CHECK_EXTENSION(EXT_convolution, cap); 7467117f1b4Smrg if (ctx->Pixel.Separable2DEnabled == state) 7477117f1b4Smrg return; 7487117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PIXEL); 7497117f1b4Smrg ctx->Pixel.Separable2DEnabled = state; 7507117f1b4Smrg break; 7517117f1b4Smrg 7527117f1b4Smrg /* GL_ARB_texture_cube_map */ 7537117f1b4Smrg case GL_TEXTURE_CUBE_MAP_ARB: 7547117f1b4Smrg CHECK_EXTENSION(ARB_texture_cube_map, cap); 7557117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { 7567117f1b4Smrg return; 7577117f1b4Smrg } 7587117f1b4Smrg break; 7597117f1b4Smrg 7607117f1b4Smrg /* GL_EXT_secondary_color */ 7617117f1b4Smrg case GL_COLOR_SUM_EXT: 7627117f1b4Smrg CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); 7637117f1b4Smrg if (ctx->Fog.ColorSumEnabled == state) 7647117f1b4Smrg return; 7657117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_FOG); 7667117f1b4Smrg ctx->Fog.ColorSumEnabled = state; 7677117f1b4Smrg break; 7687117f1b4Smrg 7697117f1b4Smrg /* GL_ARB_multisample */ 7707117f1b4Smrg case GL_MULTISAMPLE_ARB: 7717117f1b4Smrg if (ctx->Multisample.Enabled == state) 7727117f1b4Smrg return; 7737117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7747117f1b4Smrg ctx->Multisample.Enabled = state; 7757117f1b4Smrg break; 7767117f1b4Smrg case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: 7777117f1b4Smrg if (ctx->Multisample.SampleAlphaToCoverage == state) 7787117f1b4Smrg return; 7797117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7807117f1b4Smrg ctx->Multisample.SampleAlphaToCoverage = state; 7817117f1b4Smrg break; 7827117f1b4Smrg case GL_SAMPLE_ALPHA_TO_ONE_ARB: 7837117f1b4Smrg if (ctx->Multisample.SampleAlphaToOne == state) 7847117f1b4Smrg return; 7857117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7867117f1b4Smrg ctx->Multisample.SampleAlphaToOne = state; 7877117f1b4Smrg break; 7887117f1b4Smrg case GL_SAMPLE_COVERAGE_ARB: 7897117f1b4Smrg if (ctx->Multisample.SampleCoverage == state) 7907117f1b4Smrg return; 7917117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7927117f1b4Smrg ctx->Multisample.SampleCoverage = state; 7937117f1b4Smrg break; 7947117f1b4Smrg case GL_SAMPLE_COVERAGE_INVERT_ARB: 7957117f1b4Smrg if (ctx->Multisample.SampleCoverageInvert == state) 7967117f1b4Smrg return; 7977117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); 7987117f1b4Smrg ctx->Multisample.SampleCoverageInvert = state; 7997117f1b4Smrg break; 8007117f1b4Smrg 8017117f1b4Smrg /* GL_IBM_rasterpos_clip */ 8027117f1b4Smrg case GL_RASTER_POSITION_UNCLIPPED_IBM: 8037117f1b4Smrg CHECK_EXTENSION(IBM_rasterpos_clip, cap); 8047117f1b4Smrg if (ctx->Transform.RasterPositionUnclipped == state) 8057117f1b4Smrg return; 8067117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 8077117f1b4Smrg ctx->Transform.RasterPositionUnclipped = state; 8087117f1b4Smrg break; 8097117f1b4Smrg 8107117f1b4Smrg /* GL_NV_point_sprite */ 8117117f1b4Smrg case GL_POINT_SPRITE_NV: 8127117f1b4Smrg CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); 8137117f1b4Smrg if (ctx->Point.PointSprite == state) 8147117f1b4Smrg return; 8157117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_POINT); 8167117f1b4Smrg ctx->Point.PointSprite = state; 8177117f1b4Smrg break; 8187117f1b4Smrg 8197117f1b4Smrg#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program 8207117f1b4Smrg case GL_VERTEX_PROGRAM_ARB: 8217117f1b4Smrg CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); 8227117f1b4Smrg if (ctx->VertexProgram.Enabled == state) 8237117f1b4Smrg return; 8247117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 8257117f1b4Smrg ctx->VertexProgram.Enabled = state; 8267117f1b4Smrg break; 8277117f1b4Smrg case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: 8287117f1b4Smrg CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); 8297117f1b4Smrg if (ctx->VertexProgram.PointSizeEnabled == state) 8307117f1b4Smrg return; 8317117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 8327117f1b4Smrg ctx->VertexProgram.PointSizeEnabled = state; 8337117f1b4Smrg break; 8347117f1b4Smrg case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: 8357117f1b4Smrg CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); 8367117f1b4Smrg if (ctx->VertexProgram.TwoSideEnabled == state) 8377117f1b4Smrg return; 8387117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 8397117f1b4Smrg ctx->VertexProgram.TwoSideEnabled = state; 8407117f1b4Smrg break; 8417117f1b4Smrg#endif 8427117f1b4Smrg#if FEATURE_NV_vertex_program 8437117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB0_4_NV: 8447117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB1_4_NV: 8457117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB2_4_NV: 8467117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB3_4_NV: 8477117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB4_4_NV: 8487117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB5_4_NV: 8497117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB6_4_NV: 8507117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB7_4_NV: 8517117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB8_4_NV: 8527117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB9_4_NV: 8537117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB10_4_NV: 8547117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB11_4_NV: 8557117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB12_4_NV: 8567117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB13_4_NV: 8577117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB14_4_NV: 8587117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB15_4_NV: 8597117f1b4Smrg CHECK_EXTENSION(NV_vertex_program, cap); 8607117f1b4Smrg { 8617117f1b4Smrg const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); 8627117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 8637117f1b4Smrg ctx->Eval.Map1Attrib[map] = state; 8647117f1b4Smrg } 8657117f1b4Smrg break; 8667117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB0_4_NV: 8677117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB1_4_NV: 8687117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB2_4_NV: 8697117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB3_4_NV: 8707117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB4_4_NV: 8717117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB5_4_NV: 8727117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB6_4_NV: 8737117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB7_4_NV: 8747117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB8_4_NV: 8757117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB9_4_NV: 8767117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB10_4_NV: 8777117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB11_4_NV: 8787117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB12_4_NV: 8797117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB13_4_NV: 8807117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB14_4_NV: 8817117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB15_4_NV: 8827117f1b4Smrg CHECK_EXTENSION(NV_vertex_program, cap); 8837117f1b4Smrg { 8847117f1b4Smrg const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); 8857117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 8867117f1b4Smrg ctx->Eval.Map2Attrib[map] = state; 8877117f1b4Smrg } 8887117f1b4Smrg break; 8897117f1b4Smrg#endif /* FEATURE_NV_vertex_program */ 8907117f1b4Smrg 8917117f1b4Smrg#if FEATURE_NV_fragment_program 8927117f1b4Smrg case GL_FRAGMENT_PROGRAM_NV: 8937117f1b4Smrg CHECK_EXTENSION(NV_fragment_program, cap); 8947117f1b4Smrg if (ctx->FragmentProgram.Enabled == state) 8957117f1b4Smrg return; 8967117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 8977117f1b4Smrg ctx->FragmentProgram.Enabled = state; 8987117f1b4Smrg break; 8997117f1b4Smrg#endif /* FEATURE_NV_fragment_program */ 9007117f1b4Smrg 9017117f1b4Smrg /* GL_NV_texture_rectangle */ 9027117f1b4Smrg case GL_TEXTURE_RECTANGLE_NV: 9037117f1b4Smrg CHECK_EXTENSION(NV_texture_rectangle, cap); 9047117f1b4Smrg if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { 9057117f1b4Smrg return; 9067117f1b4Smrg } 9077117f1b4Smrg break; 9087117f1b4Smrg 9097117f1b4Smrg /* GL_EXT_stencil_two_side */ 9107117f1b4Smrg case GL_STENCIL_TEST_TWO_SIDE_EXT: 9117117f1b4Smrg CHECK_EXTENSION(EXT_stencil_two_side, cap); 9127117f1b4Smrg if (ctx->Stencil.TestTwoSide == state) 9137117f1b4Smrg return; 9147117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_STENCIL); 9157117f1b4Smrg ctx->Stencil.TestTwoSide = state; 916c1f859d4Smrg if (state) { 917c1f859d4Smrg ctx->Stencil._BackFace = 2; 9187117f1b4Smrg ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; 919c1f859d4Smrg } else { 920c1f859d4Smrg ctx->Stencil._BackFace = 1; 9217117f1b4Smrg ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; 922c1f859d4Smrg } 9237117f1b4Smrg break; 9247117f1b4Smrg 9257117f1b4Smrg#if FEATURE_ARB_fragment_program 9267117f1b4Smrg case GL_FRAGMENT_PROGRAM_ARB: 9277117f1b4Smrg CHECK_EXTENSION(ARB_fragment_program, cap); 9287117f1b4Smrg if (ctx->FragmentProgram.Enabled == state) 9297117f1b4Smrg return; 9307117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9317117f1b4Smrg ctx->FragmentProgram.Enabled = state; 9327117f1b4Smrg break; 9337117f1b4Smrg#endif /* FEATURE_ARB_fragment_program */ 9347117f1b4Smrg 9357117f1b4Smrg /* GL_EXT_depth_bounds_test */ 9367117f1b4Smrg case GL_DEPTH_BOUNDS_TEST_EXT: 9377117f1b4Smrg CHECK_EXTENSION(EXT_depth_bounds_test, cap); 9387117f1b4Smrg if (ctx->Depth.BoundsTest == state) 9397117f1b4Smrg return; 9407117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_DEPTH); 9417117f1b4Smrg ctx->Depth.BoundsTest = state; 9427117f1b4Smrg break; 9437117f1b4Smrg 9444a49301eSmrg case GL_DEPTH_CLAMP: 9454a49301eSmrg if (ctx->Transform.DepthClamp == state) 9464a49301eSmrg return; 9474a49301eSmrg CHECK_EXTENSION(ARB_depth_clamp, cap); 9484a49301eSmrg FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 9494a49301eSmrg ctx->Transform.DepthClamp = state; 9504a49301eSmrg break; 9517117f1b4Smrg 9527117f1b4Smrg#if FEATURE_ATI_fragment_shader 9537117f1b4Smrg case GL_FRAGMENT_SHADER_ATI: 9547117f1b4Smrg CHECK_EXTENSION(ATI_fragment_shader, cap); 9557117f1b4Smrg if (ctx->ATIFragmentShader.Enabled == state) 9567117f1b4Smrg return; 9577117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_PROGRAM); 9587117f1b4Smrg ctx->ATIFragmentShader.Enabled = state; 9597117f1b4Smrg break; 9607117f1b4Smrg#endif 961c1f859d4Smrg 962c1f859d4Smrg /* GL_MESA_texture_array */ 963c1f859d4Smrg case GL_TEXTURE_1D_ARRAY_EXT: 964c1f859d4Smrg CHECK_EXTENSION(MESA_texture_array, cap); 965c1f859d4Smrg if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { 966c1f859d4Smrg return; 967c1f859d4Smrg } 968c1f859d4Smrg break; 969c1f859d4Smrg 970c1f859d4Smrg case GL_TEXTURE_2D_ARRAY_EXT: 971c1f859d4Smrg CHECK_EXTENSION(MESA_texture_array, cap); 972c1f859d4Smrg if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { 973c1f859d4Smrg return; 974c1f859d4Smrg } 975c1f859d4Smrg break; 976c1f859d4Smrg 9774a49301eSmrg case GL_TEXTURE_CUBE_MAP_SEAMLESS: 9784a49301eSmrg CHECK_EXTENSION(ARB_seamless_cube_map, cap); 9794a49301eSmrg ctx->Texture.CubeMapSeamless = state; 9804a49301eSmrg break; 9814a49301eSmrg 9827117f1b4Smrg default: 9837117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, 9847117f1b4Smrg "%s(0x%x)", state ? "glEnable" : "glDisable", cap); 9857117f1b4Smrg return; 9867117f1b4Smrg } 9877117f1b4Smrg 9887117f1b4Smrg if (ctx->Driver.Enable) { 9897117f1b4Smrg ctx->Driver.Enable( ctx, cap, state ); 9907117f1b4Smrg } 9917117f1b4Smrg} 9927117f1b4Smrg 9937117f1b4Smrg 9947117f1b4Smrg/** 9957117f1b4Smrg * Enable GL capability. Called by glEnable() 9967117f1b4Smrg * \param cap state to enable. 9977117f1b4Smrg */ 9987117f1b4Smrgvoid GLAPIENTRY 9997117f1b4Smrg_mesa_Enable( GLenum cap ) 10007117f1b4Smrg{ 10017117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 10027117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 10037117f1b4Smrg 10047117f1b4Smrg _mesa_set_enable( ctx, cap, GL_TRUE ); 10057117f1b4Smrg} 10067117f1b4Smrg 10077117f1b4Smrg 10087117f1b4Smrg/** 10097117f1b4Smrg * Disable GL capability. Called by glDisable() 10107117f1b4Smrg * \param cap state to disable. 10117117f1b4Smrg */ 10127117f1b4Smrgvoid GLAPIENTRY 10137117f1b4Smrg_mesa_Disable( GLenum cap ) 10147117f1b4Smrg{ 10157117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 10167117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 10177117f1b4Smrg 10187117f1b4Smrg _mesa_set_enable( ctx, cap, GL_FALSE ); 10197117f1b4Smrg} 10207117f1b4Smrg 10217117f1b4Smrg 10227117f1b4Smrg#undef CHECK_EXTENSION 10237117f1b4Smrg#define CHECK_EXTENSION(EXTNAME) \ 10247117f1b4Smrg if (!ctx->Extensions.EXTNAME) { \ 10257117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \ 10267117f1b4Smrg return GL_FALSE; \ 10277117f1b4Smrg } 10287117f1b4Smrg 10297117f1b4Smrg#undef CHECK_EXTENSION2 10307117f1b4Smrg#define CHECK_EXTENSION2(EXT1, EXT2) \ 10317117f1b4Smrg if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ 10327117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \ 10337117f1b4Smrg return GL_FALSE; \ 10347117f1b4Smrg } 10357117f1b4Smrg 10367117f1b4Smrg 10377117f1b4Smrg/** 10387117f1b4Smrg * Helper function to determine whether a texture target is enabled. 10397117f1b4Smrg */ 10407117f1b4Smrgstatic GLboolean 10417117f1b4Smrgis_texture_enabled(GLcontext *ctx, GLbitfield bit) 10427117f1b4Smrg{ 10437117f1b4Smrg const struct gl_texture_unit *const texUnit = 10447117f1b4Smrg &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; 10457117f1b4Smrg return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; 10467117f1b4Smrg} 10477117f1b4Smrg 10487117f1b4Smrg 10497117f1b4Smrg/** 10507117f1b4Smrg * Return simple enable/disable state. 10517117f1b4Smrg * 10527117f1b4Smrg * \param cap state variable to query. 10537117f1b4Smrg * 10547117f1b4Smrg * Returns the state of the specified capability from the current GL context. 10557117f1b4Smrg * For the capabilities associated with extensions verifies that those 10567117f1b4Smrg * extensions are effectively present before reporting. 10577117f1b4Smrg */ 10587117f1b4SmrgGLboolean GLAPIENTRY 10597117f1b4Smrg_mesa_IsEnabled( GLenum cap ) 10607117f1b4Smrg{ 10617117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 10627117f1b4Smrg switch (cap) { 10637117f1b4Smrg case GL_ALPHA_TEST: 10647117f1b4Smrg return ctx->Color.AlphaEnabled; 10657117f1b4Smrg case GL_AUTO_NORMAL: 10667117f1b4Smrg return ctx->Eval.AutoNormal; 10677117f1b4Smrg case GL_BLEND: 10687117f1b4Smrg return ctx->Color.BlendEnabled; 10697117f1b4Smrg case GL_CLIP_PLANE0: 10707117f1b4Smrg case GL_CLIP_PLANE1: 10717117f1b4Smrg case GL_CLIP_PLANE2: 10727117f1b4Smrg case GL_CLIP_PLANE3: 10737117f1b4Smrg case GL_CLIP_PLANE4: 10747117f1b4Smrg case GL_CLIP_PLANE5: 10757117f1b4Smrg return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; 10767117f1b4Smrg case GL_COLOR_MATERIAL: 10777117f1b4Smrg return ctx->Light.ColorMaterialEnabled; 10787117f1b4Smrg case GL_CULL_FACE: 10797117f1b4Smrg return ctx->Polygon.CullFlag; 10807117f1b4Smrg case GL_DEPTH_TEST: 10817117f1b4Smrg return ctx->Depth.Test; 10827117f1b4Smrg case GL_DITHER: 10837117f1b4Smrg return ctx->Color.DitherFlag; 10847117f1b4Smrg case GL_FOG: 10857117f1b4Smrg return ctx->Fog.Enabled; 10867117f1b4Smrg case GL_LIGHTING: 10877117f1b4Smrg return ctx->Light.Enabled; 10887117f1b4Smrg case GL_LIGHT0: 10897117f1b4Smrg case GL_LIGHT1: 10907117f1b4Smrg case GL_LIGHT2: 10917117f1b4Smrg case GL_LIGHT3: 10927117f1b4Smrg case GL_LIGHT4: 10937117f1b4Smrg case GL_LIGHT5: 10947117f1b4Smrg case GL_LIGHT6: 10957117f1b4Smrg case GL_LIGHT7: 10967117f1b4Smrg return ctx->Light.Light[cap-GL_LIGHT0].Enabled; 10977117f1b4Smrg case GL_LINE_SMOOTH: 10987117f1b4Smrg return ctx->Line.SmoothFlag; 10997117f1b4Smrg case GL_LINE_STIPPLE: 11007117f1b4Smrg return ctx->Line.StippleFlag; 11017117f1b4Smrg case GL_INDEX_LOGIC_OP: 11027117f1b4Smrg return ctx->Color.IndexLogicOpEnabled; 11037117f1b4Smrg case GL_COLOR_LOGIC_OP: 11047117f1b4Smrg return ctx->Color.ColorLogicOpEnabled; 11057117f1b4Smrg case GL_MAP1_COLOR_4: 11067117f1b4Smrg return ctx->Eval.Map1Color4; 11077117f1b4Smrg case GL_MAP1_INDEX: 11087117f1b4Smrg return ctx->Eval.Map1Index; 11097117f1b4Smrg case GL_MAP1_NORMAL: 11107117f1b4Smrg return ctx->Eval.Map1Normal; 11117117f1b4Smrg case GL_MAP1_TEXTURE_COORD_1: 11127117f1b4Smrg return ctx->Eval.Map1TextureCoord1; 11137117f1b4Smrg case GL_MAP1_TEXTURE_COORD_2: 11147117f1b4Smrg return ctx->Eval.Map1TextureCoord2; 11157117f1b4Smrg case GL_MAP1_TEXTURE_COORD_3: 11167117f1b4Smrg return ctx->Eval.Map1TextureCoord3; 11177117f1b4Smrg case GL_MAP1_TEXTURE_COORD_4: 11187117f1b4Smrg return ctx->Eval.Map1TextureCoord4; 11197117f1b4Smrg case GL_MAP1_VERTEX_3: 11207117f1b4Smrg return ctx->Eval.Map1Vertex3; 11217117f1b4Smrg case GL_MAP1_VERTEX_4: 11227117f1b4Smrg return ctx->Eval.Map1Vertex4; 11237117f1b4Smrg case GL_MAP2_COLOR_4: 11247117f1b4Smrg return ctx->Eval.Map2Color4; 11257117f1b4Smrg case GL_MAP2_INDEX: 11267117f1b4Smrg return ctx->Eval.Map2Index; 11277117f1b4Smrg case GL_MAP2_NORMAL: 11287117f1b4Smrg return ctx->Eval.Map2Normal; 11297117f1b4Smrg case GL_MAP2_TEXTURE_COORD_1: 11307117f1b4Smrg return ctx->Eval.Map2TextureCoord1; 11317117f1b4Smrg case GL_MAP2_TEXTURE_COORD_2: 11327117f1b4Smrg return ctx->Eval.Map2TextureCoord2; 11337117f1b4Smrg case GL_MAP2_TEXTURE_COORD_3: 11347117f1b4Smrg return ctx->Eval.Map2TextureCoord3; 11357117f1b4Smrg case GL_MAP2_TEXTURE_COORD_4: 11367117f1b4Smrg return ctx->Eval.Map2TextureCoord4; 11377117f1b4Smrg case GL_MAP2_VERTEX_3: 11387117f1b4Smrg return ctx->Eval.Map2Vertex3; 11397117f1b4Smrg case GL_MAP2_VERTEX_4: 11407117f1b4Smrg return ctx->Eval.Map2Vertex4; 11417117f1b4Smrg case GL_NORMALIZE: 11427117f1b4Smrg return ctx->Transform.Normalize; 11437117f1b4Smrg case GL_POINT_SMOOTH: 11447117f1b4Smrg return ctx->Point.SmoothFlag; 11457117f1b4Smrg case GL_POLYGON_SMOOTH: 11467117f1b4Smrg return ctx->Polygon.SmoothFlag; 11477117f1b4Smrg case GL_POLYGON_STIPPLE: 11487117f1b4Smrg return ctx->Polygon.StippleFlag; 11497117f1b4Smrg case GL_POLYGON_OFFSET_POINT: 11507117f1b4Smrg return ctx->Polygon.OffsetPoint; 11517117f1b4Smrg case GL_POLYGON_OFFSET_LINE: 11527117f1b4Smrg return ctx->Polygon.OffsetLine; 11537117f1b4Smrg case GL_POLYGON_OFFSET_FILL: 11547117f1b4Smrg /*case GL_POLYGON_OFFSET_EXT:*/ 11557117f1b4Smrg return ctx->Polygon.OffsetFill; 11567117f1b4Smrg case GL_RESCALE_NORMAL_EXT: 11577117f1b4Smrg return ctx->Transform.RescaleNormals; 11587117f1b4Smrg case GL_SCISSOR_TEST: 11597117f1b4Smrg return ctx->Scissor.Enabled; 11607117f1b4Smrg case GL_SHARED_TEXTURE_PALETTE_EXT: 11617117f1b4Smrg return ctx->Texture.SharedPalette; 11627117f1b4Smrg case GL_STENCIL_TEST: 11637117f1b4Smrg return ctx->Stencil.Enabled; 11647117f1b4Smrg case GL_TEXTURE_1D: 11657117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_1D_BIT); 11667117f1b4Smrg case GL_TEXTURE_2D: 11677117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_2D_BIT); 11687117f1b4Smrg case GL_TEXTURE_3D: 11697117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_3D_BIT); 11707117f1b4Smrg case GL_TEXTURE_GEN_Q: 11717117f1b4Smrg { 1172c1f859d4Smrg const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 1173c1f859d4Smrg if (texUnit) { 1174c1f859d4Smrg return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; 1175c1f859d4Smrg } 11767117f1b4Smrg } 1177c1f859d4Smrg return GL_FALSE; 11787117f1b4Smrg case GL_TEXTURE_GEN_R: 11797117f1b4Smrg { 1180c1f859d4Smrg const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 1181c1f859d4Smrg if (texUnit) { 1182c1f859d4Smrg return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; 1183c1f859d4Smrg } 11847117f1b4Smrg } 1185c1f859d4Smrg return GL_FALSE; 11867117f1b4Smrg case GL_TEXTURE_GEN_S: 11877117f1b4Smrg { 1188c1f859d4Smrg const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 1189c1f859d4Smrg if (texUnit) { 1190c1f859d4Smrg return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; 1191c1f859d4Smrg } 11927117f1b4Smrg } 1193c1f859d4Smrg return GL_FALSE; 11947117f1b4Smrg case GL_TEXTURE_GEN_T: 11957117f1b4Smrg { 1196c1f859d4Smrg const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); 1197c1f859d4Smrg if (texUnit) { 1198c1f859d4Smrg return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; 1199c1f859d4Smrg } 12007117f1b4Smrg } 1201c1f859d4Smrg return GL_FALSE; 12027117f1b4Smrg 12037117f1b4Smrg /* 12047117f1b4Smrg * CLIENT STATE!!! 12057117f1b4Smrg */ 12067117f1b4Smrg case GL_VERTEX_ARRAY: 12077117f1b4Smrg return (ctx->Array.ArrayObj->Vertex.Enabled != 0); 12087117f1b4Smrg case GL_NORMAL_ARRAY: 12097117f1b4Smrg return (ctx->Array.ArrayObj->Normal.Enabled != 0); 12107117f1b4Smrg case GL_COLOR_ARRAY: 12117117f1b4Smrg return (ctx->Array.ArrayObj->Color.Enabled != 0); 12127117f1b4Smrg case GL_INDEX_ARRAY: 12137117f1b4Smrg return (ctx->Array.ArrayObj->Index.Enabled != 0); 12147117f1b4Smrg case GL_TEXTURE_COORD_ARRAY: 12157117f1b4Smrg return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled != 0); 12167117f1b4Smrg case GL_EDGE_FLAG_ARRAY: 12177117f1b4Smrg return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0); 12187117f1b4Smrg case GL_FOG_COORDINATE_ARRAY_EXT: 12197117f1b4Smrg CHECK_EXTENSION(EXT_fog_coord); 12207117f1b4Smrg return (ctx->Array.ArrayObj->FogCoord.Enabled != 0); 12217117f1b4Smrg case GL_SECONDARY_COLOR_ARRAY_EXT: 12227117f1b4Smrg CHECK_EXTENSION(EXT_secondary_color); 12237117f1b4Smrg return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0); 1224c1f859d4Smrg#if FEATURE_point_size_array 1225c1f859d4Smrg case GL_POINT_SIZE_ARRAY_OES: 1226c1f859d4Smrg return (ctx->Array.ArrayObj->PointSize.Enabled != 0); 1227c1f859d4Smrg#endif 12287117f1b4Smrg 12297117f1b4Smrg /* GL_EXT_histogram */ 12307117f1b4Smrg case GL_HISTOGRAM: 12317117f1b4Smrg CHECK_EXTENSION(EXT_histogram); 12327117f1b4Smrg return ctx->Pixel.HistogramEnabled; 12337117f1b4Smrg case GL_MINMAX: 12347117f1b4Smrg CHECK_EXTENSION(EXT_histogram); 12357117f1b4Smrg return ctx->Pixel.MinMaxEnabled; 12367117f1b4Smrg 12377117f1b4Smrg /* GL_SGI_color_table */ 12387117f1b4Smrg case GL_COLOR_TABLE_SGI: 12397117f1b4Smrg CHECK_EXTENSION(SGI_color_table); 12407117f1b4Smrg return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; 12417117f1b4Smrg case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: 12427117f1b4Smrg CHECK_EXTENSION(SGI_color_table); 12437117f1b4Smrg return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; 12447117f1b4Smrg case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: 12457117f1b4Smrg CHECK_EXTENSION(SGI_color_table); 12467117f1b4Smrg return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; 12477117f1b4Smrg 12487117f1b4Smrg /* GL_SGI_texture_color_table */ 12497117f1b4Smrg case GL_TEXTURE_COLOR_TABLE_SGI: 12507117f1b4Smrg CHECK_EXTENSION(SGI_texture_color_table); 12517117f1b4Smrg return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled; 12527117f1b4Smrg 12537117f1b4Smrg /* GL_EXT_convolution */ 12547117f1b4Smrg case GL_CONVOLUTION_1D: 12557117f1b4Smrg CHECK_EXTENSION(EXT_convolution); 12567117f1b4Smrg return ctx->Pixel.Convolution1DEnabled; 12577117f1b4Smrg case GL_CONVOLUTION_2D: 12587117f1b4Smrg CHECK_EXTENSION(EXT_convolution); 12597117f1b4Smrg return ctx->Pixel.Convolution2DEnabled; 12607117f1b4Smrg case GL_SEPARABLE_2D: 12617117f1b4Smrg CHECK_EXTENSION(EXT_convolution); 12627117f1b4Smrg return ctx->Pixel.Separable2DEnabled; 12637117f1b4Smrg 12647117f1b4Smrg /* GL_ARB_texture_cube_map */ 12657117f1b4Smrg case GL_TEXTURE_CUBE_MAP_ARB: 12667117f1b4Smrg CHECK_EXTENSION(ARB_texture_cube_map); 12677117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); 12687117f1b4Smrg 12697117f1b4Smrg /* GL_EXT_secondary_color */ 12707117f1b4Smrg case GL_COLOR_SUM_EXT: 12717117f1b4Smrg CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); 12727117f1b4Smrg return ctx->Fog.ColorSumEnabled; 12737117f1b4Smrg 12747117f1b4Smrg /* GL_ARB_multisample */ 12757117f1b4Smrg case GL_MULTISAMPLE_ARB: 12767117f1b4Smrg return ctx->Multisample.Enabled; 12777117f1b4Smrg case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: 12787117f1b4Smrg return ctx->Multisample.SampleAlphaToCoverage; 12797117f1b4Smrg case GL_SAMPLE_ALPHA_TO_ONE_ARB: 12807117f1b4Smrg return ctx->Multisample.SampleAlphaToOne; 12817117f1b4Smrg case GL_SAMPLE_COVERAGE_ARB: 12827117f1b4Smrg return ctx->Multisample.SampleCoverage; 12837117f1b4Smrg case GL_SAMPLE_COVERAGE_INVERT_ARB: 12847117f1b4Smrg return ctx->Multisample.SampleCoverageInvert; 12857117f1b4Smrg 12867117f1b4Smrg /* GL_IBM_rasterpos_clip */ 12877117f1b4Smrg case GL_RASTER_POSITION_UNCLIPPED_IBM: 12887117f1b4Smrg CHECK_EXTENSION(IBM_rasterpos_clip); 12897117f1b4Smrg return ctx->Transform.RasterPositionUnclipped; 12907117f1b4Smrg 12917117f1b4Smrg /* GL_NV_point_sprite */ 12927117f1b4Smrg case GL_POINT_SPRITE_NV: 12937117f1b4Smrg CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) 12947117f1b4Smrg return ctx->Point.PointSprite; 12957117f1b4Smrg 12967117f1b4Smrg#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program 12977117f1b4Smrg case GL_VERTEX_PROGRAM_ARB: 12987117f1b4Smrg CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); 12997117f1b4Smrg return ctx->VertexProgram.Enabled; 13007117f1b4Smrg case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: 13017117f1b4Smrg CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); 13027117f1b4Smrg return ctx->VertexProgram.PointSizeEnabled; 13037117f1b4Smrg case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: 13047117f1b4Smrg CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); 13057117f1b4Smrg return ctx->VertexProgram.TwoSideEnabled; 13067117f1b4Smrg#endif 13077117f1b4Smrg#if FEATURE_NV_vertex_program 13087117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY0_NV: 13097117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY1_NV: 13107117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY2_NV: 13117117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY3_NV: 13127117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY4_NV: 13137117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY5_NV: 13147117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY6_NV: 13157117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY7_NV: 13167117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY8_NV: 13177117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY9_NV: 13187117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY10_NV: 13197117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY11_NV: 13207117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY12_NV: 13217117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY13_NV: 13227117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY14_NV: 13237117f1b4Smrg case GL_VERTEX_ATTRIB_ARRAY15_NV: 13247117f1b4Smrg CHECK_EXTENSION(NV_vertex_program); 13257117f1b4Smrg { 13267117f1b4Smrg GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; 13274a49301eSmrg ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib)); 13287117f1b4Smrg return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0); 13297117f1b4Smrg } 13307117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB0_4_NV: 13317117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB1_4_NV: 13327117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB2_4_NV: 13337117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB3_4_NV: 13347117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB4_4_NV: 13357117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB5_4_NV: 13367117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB6_4_NV: 13377117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB7_4_NV: 13387117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB8_4_NV: 13397117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB9_4_NV: 13407117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB10_4_NV: 13417117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB11_4_NV: 13427117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB12_4_NV: 13437117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB13_4_NV: 13447117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB14_4_NV: 13457117f1b4Smrg case GL_MAP1_VERTEX_ATTRIB15_4_NV: 13467117f1b4Smrg CHECK_EXTENSION(NV_vertex_program); 13477117f1b4Smrg { 13487117f1b4Smrg const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); 13497117f1b4Smrg return ctx->Eval.Map1Attrib[map]; 13507117f1b4Smrg } 13517117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB0_4_NV: 13527117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB1_4_NV: 13537117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB2_4_NV: 13547117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB3_4_NV: 13557117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB4_4_NV: 13567117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB5_4_NV: 13577117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB6_4_NV: 13587117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB7_4_NV: 13597117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB8_4_NV: 13607117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB9_4_NV: 13617117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB10_4_NV: 13627117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB11_4_NV: 13637117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB12_4_NV: 13647117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB13_4_NV: 13657117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB14_4_NV: 13667117f1b4Smrg case GL_MAP2_VERTEX_ATTRIB15_4_NV: 13677117f1b4Smrg CHECK_EXTENSION(NV_vertex_program); 13687117f1b4Smrg { 13697117f1b4Smrg const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); 13707117f1b4Smrg return ctx->Eval.Map2Attrib[map]; 13717117f1b4Smrg } 13727117f1b4Smrg#endif /* FEATURE_NV_vertex_program */ 13737117f1b4Smrg 13747117f1b4Smrg#if FEATURE_NV_fragment_program 13757117f1b4Smrg case GL_FRAGMENT_PROGRAM_NV: 13767117f1b4Smrg CHECK_EXTENSION(NV_fragment_program); 13777117f1b4Smrg return ctx->FragmentProgram.Enabled; 13787117f1b4Smrg#endif /* FEATURE_NV_fragment_program */ 13797117f1b4Smrg 13807117f1b4Smrg /* GL_NV_texture_rectangle */ 13817117f1b4Smrg case GL_TEXTURE_RECTANGLE_NV: 13827117f1b4Smrg CHECK_EXTENSION(NV_texture_rectangle); 13837117f1b4Smrg return is_texture_enabled(ctx, TEXTURE_RECT_BIT); 13847117f1b4Smrg 13857117f1b4Smrg /* GL_EXT_stencil_two_side */ 13867117f1b4Smrg case GL_STENCIL_TEST_TWO_SIDE_EXT: 13877117f1b4Smrg CHECK_EXTENSION(EXT_stencil_two_side); 13887117f1b4Smrg return ctx->Stencil.TestTwoSide; 13897117f1b4Smrg 13907117f1b4Smrg#if FEATURE_ARB_fragment_program 13917117f1b4Smrg case GL_FRAGMENT_PROGRAM_ARB: 13927117f1b4Smrg return ctx->FragmentProgram.Enabled; 13937117f1b4Smrg#endif /* FEATURE_ARB_fragment_program */ 13947117f1b4Smrg 13957117f1b4Smrg /* GL_EXT_depth_bounds_test */ 13967117f1b4Smrg case GL_DEPTH_BOUNDS_TEST_EXT: 13977117f1b4Smrg CHECK_EXTENSION(EXT_depth_bounds_test); 13987117f1b4Smrg return ctx->Depth.BoundsTest; 13997117f1b4Smrg 14004a49301eSmrg /* GL_ARB_depth_clamp */ 14014a49301eSmrg case GL_DEPTH_CLAMP: 14024a49301eSmrg CHECK_EXTENSION(ARB_depth_clamp); 14034a49301eSmrg return ctx->Transform.DepthClamp; 14044a49301eSmrg 14057117f1b4Smrg#if FEATURE_ATI_fragment_shader 14067117f1b4Smrg case GL_FRAGMENT_SHADER_ATI: 14077117f1b4Smrg CHECK_EXTENSION(ATI_fragment_shader); 14087117f1b4Smrg return ctx->ATIFragmentShader.Enabled; 14097117f1b4Smrg#endif /* FEATURE_ATI_fragment_shader */ 14104a49301eSmrg 14114a49301eSmrg case GL_TEXTURE_CUBE_MAP_SEAMLESS: 14124a49301eSmrg CHECK_EXTENSION(ARB_seamless_cube_map); 14134a49301eSmrg return ctx->Texture.CubeMapSeamless; 14144a49301eSmrg 14157117f1b4Smrg default: 14167117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); 14177117f1b4Smrg return GL_FALSE; 14187117f1b4Smrg } 14197117f1b4Smrg} 1420