Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file enable.c |
| 3 | * Enable/disable/query GL capabilities. |
| 4 | */ |
| 5 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 6 | /* |
| 7 | * Mesa 3-D graphics library |
Brian Paul | 813e56d | 2006-07-18 19:15:40 +0000 | [diff] [blame] | 8 | * Version: 6.5.1 |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 9 | * |
Brian Paul | 813e56d | 2006-07-18 19:15:40 +0000 | [diff] [blame] | 10 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 11 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 12 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 13 | * copy of this software and associated documentation files (the "Software"), |
| 14 | * to deal in the Software without restriction, including without limitation |
| 15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 16 | * and/or sell copies of the Software, and to permit persons to whom the |
| 17 | * Software is furnished to do so, subject to the following conditions: |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 18 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 19 | * The above copyright notice and this permission notice shall be included |
| 20 | * in all copies or substantial portions of the Software. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 21 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 23 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 25 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 26 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 27 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 28 | */ |
| 29 | |
| 30 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 31 | #include "glheader.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 32 | #include "context.h" |
| 33 | #include "enable.h" |
| 34 | #include "light.h" |
| 35 | #include "macros.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 36 | #include "simple_list.h" |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 37 | #include "mtypes.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 38 | #include "enums.h" |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 39 | #include "math/m_matrix.h" |
| 40 | #include "math/m_xform.h" |
Brian Paul | 3c63452 | 2002-10-24 23:57:19 +0000 | [diff] [blame] | 41 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 42 | |
| 43 | |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 44 | #define CHECK_EXTENSION(EXTNAME, CAP) \ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 45 | if (!ctx->Extensions.EXTNAME) { \ |
Brian Paul | 4e9676f | 2002-06-29 19:48:15 +0000 | [diff] [blame] | 46 | _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \ |
| 47 | state ? "Enable" : "Disable", CAP); \ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 48 | return; \ |
| 49 | } |
| 50 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 51 | |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 52 | /** |
| 53 | * Helper to enable/disable client-side state. |
| 54 | */ |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 55 | static void |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 56 | client_state(GLcontext *ctx, GLenum cap, GLboolean state) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 57 | { |
| 58 | GLuint flag; |
Keith Whitwell | 99efde4 | 2006-10-30 16:44:13 +0000 | [diff] [blame] | 59 | GLboolean *var; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 60 | |
| 61 | switch (cap) { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 62 | case GL_VERTEX_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 63 | var = &ctx->Array.ArrayObj->Vertex.Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 64 | flag = _NEW_ARRAY_VERTEX; |
| 65 | break; |
| 66 | case GL_NORMAL_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 67 | var = &ctx->Array.ArrayObj->Normal.Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 68 | flag = _NEW_ARRAY_NORMAL; |
| 69 | break; |
| 70 | case GL_COLOR_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 71 | var = &ctx->Array.ArrayObj->Color.Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 72 | flag = _NEW_ARRAY_COLOR0; |
| 73 | break; |
| 74 | case GL_INDEX_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 75 | var = &ctx->Array.ArrayObj->Index.Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 76 | flag = _NEW_ARRAY_INDEX; |
| 77 | break; |
| 78 | case GL_TEXTURE_COORD_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 79 | var = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 80 | flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); |
| 81 | break; |
| 82 | case GL_EDGE_FLAG_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 83 | var = &ctx->Array.ArrayObj->EdgeFlag.Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 84 | flag = _NEW_ARRAY_EDGEFLAG; |
| 85 | break; |
| 86 | case GL_FOG_COORDINATE_ARRAY_EXT: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 87 | var = &ctx->Array.ArrayObj->FogCoord.Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 88 | flag = _NEW_ARRAY_FOGCOORD; |
| 89 | break; |
| 90 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 91 | var = &ctx->Array.ArrayObj->SecondaryColor.Enabled; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 92 | flag = _NEW_ARRAY_COLOR1; |
| 93 | break; |
| 94 | |
Brian Paul | 8dfc5b9 | 2002-10-16 17:57:51 +0000 | [diff] [blame] | 95 | #if FEATURE_NV_vertex_program |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 96 | case GL_VERTEX_ATTRIB_ARRAY0_NV: |
| 97 | case GL_VERTEX_ATTRIB_ARRAY1_NV: |
| 98 | case GL_VERTEX_ATTRIB_ARRAY2_NV: |
| 99 | case GL_VERTEX_ATTRIB_ARRAY3_NV: |
| 100 | case GL_VERTEX_ATTRIB_ARRAY4_NV: |
| 101 | case GL_VERTEX_ATTRIB_ARRAY5_NV: |
| 102 | case GL_VERTEX_ATTRIB_ARRAY6_NV: |
| 103 | case GL_VERTEX_ATTRIB_ARRAY7_NV: |
| 104 | case GL_VERTEX_ATTRIB_ARRAY8_NV: |
| 105 | case GL_VERTEX_ATTRIB_ARRAY9_NV: |
| 106 | case GL_VERTEX_ATTRIB_ARRAY10_NV: |
| 107 | case GL_VERTEX_ATTRIB_ARRAY11_NV: |
| 108 | case GL_VERTEX_ATTRIB_ARRAY12_NV: |
| 109 | case GL_VERTEX_ATTRIB_ARRAY13_NV: |
| 110 | case GL_VERTEX_ATTRIB_ARRAY14_NV: |
| 111 | case GL_VERTEX_ATTRIB_ARRAY15_NV: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 112 | CHECK_EXTENSION(NV_vertex_program, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 113 | { |
| 114 | GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 115 | var = &ctx->Array.ArrayObj->VertexAttrib[n].Enabled; |
Brian Paul | b775272 | 2002-04-21 18:49:18 +0000 | [diff] [blame] | 116 | flag = _NEW_ARRAY_ATTRIB(n); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 117 | } |
| 118 | break; |
Brian Paul | 8dfc5b9 | 2002-10-16 17:57:51 +0000 | [diff] [blame] | 119 | #endif /* FEATURE_NV_vertex_program */ |
| 120 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 121 | default: |
Brian Paul | 4e9676f | 2002-06-29 19:48:15 +0000 | [diff] [blame] | 122 | _mesa_error( ctx, GL_INVALID_ENUM, |
| 123 | "glEnable/DisableClientState(0x%x)", cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 124 | return; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Alan Hourihane | 68c48df | 2002-04-19 08:38:23 +0000 | [diff] [blame] | 127 | if (*var == state) |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 128 | return; |
| 129 | |
| 130 | FLUSH_VERTICES(ctx, _NEW_ARRAY); |
| 131 | ctx->Array.NewState |= flag; |
| 132 | *var = state; |
| 133 | |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 134 | if (state) |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 135 | ctx->Array.ArrayObj->_Enabled |= flag; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 136 | else |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 137 | ctx->Array.ArrayObj->_Enabled &= ~flag; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 138 | |
| 139 | if (ctx->Driver.Enable) { |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 140 | ctx->Driver.Enable( ctx, cap, state ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | |
| 144 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 145 | /** |
| 146 | * Enable GL capability. |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 147 | * \param cap state to enable/disable. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 148 | * |
| 149 | * Get's the current context, assures that we're outside glBegin()/glEnd() and |
| 150 | * calls client_state(). |
| 151 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 152 | void GLAPIENTRY |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 153 | _mesa_EnableClientState( GLenum cap ) |
| 154 | { |
| 155 | GET_CURRENT_CONTEXT(ctx); |
| 156 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 157 | client_state( ctx, cap, GL_TRUE ); |
| 158 | } |
| 159 | |
| 160 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 161 | /** |
| 162 | * Disable GL capability. |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 163 | * \param cap state to enable/disable. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 164 | * |
| 165 | * Get's the current context, assures that we're outside glBegin()/glEnd() and |
| 166 | * calls client_state(). |
| 167 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 168 | void GLAPIENTRY |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 169 | _mesa_DisableClientState( GLenum cap ) |
| 170 | { |
| 171 | GET_CURRENT_CONTEXT(ctx); |
| 172 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 173 | client_state( ctx, cap, GL_FALSE ); |
| 174 | } |
| 175 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 176 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 177 | #undef CHECK_EXTENSION |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 178 | #define CHECK_EXTENSION(EXTNAME, CAP) \ |
| 179 | if (!ctx->Extensions.EXTNAME) { \ |
Brian Paul | 4e9676f | 2002-06-29 19:48:15 +0000 | [diff] [blame] | 180 | _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \ |
| 181 | state ? "Enable" : "Disable", CAP); \ |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 182 | return; \ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Brian Paul | efb2ade | 2004-08-18 18:45:25 +0000 | [diff] [blame] | 185 | #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ |
| 186 | if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ |
| 187 | _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \ |
| 188 | state ? "Enable" : "Disable", CAP); \ |
| 189 | return; \ |
| 190 | } |
| 191 | |
| 192 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 193 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 194 | /** |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 195 | * Helper function to enable or disable state. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 196 | * |
| 197 | * \param ctx GL context. |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 198 | * \param cap the state to enable/disable |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 199 | * \param state whether to enable or disable the specified capability. |
| 200 | * |
| 201 | * Updates the current context and flushes the vertices as needed. For |
| 202 | * capabilities associated with extensions it verifies that those extensions |
| 203 | * are effectivly present before updating. Notifies the driver via |
| 204 | * dd_function_table::Enable. |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 205 | */ |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 206 | void |
| 207 | _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 208 | { |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 209 | if (MESA_VERBOSE & VERBOSE_API) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 210 | _mesa_debug(ctx, "%s %s (newstate is %x)\n", |
Brian Paul | 9a33a11 | 2002-06-13 04:28:29 +0000 | [diff] [blame] | 211 | state ? "glEnable" : "glDisable", |
| 212 | _mesa_lookup_enum_by_nr(cap), |
| 213 | ctx->NewState); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 214 | |
| 215 | switch (cap) { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 216 | case GL_ALPHA_TEST: |
| 217 | if (ctx->Color.AlphaEnabled == state) |
| 218 | return; |
| 219 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 220 | ctx->Color.AlphaEnabled = state; |
| 221 | break; |
| 222 | case GL_AUTO_NORMAL: |
| 223 | if (ctx->Eval.AutoNormal == state) |
| 224 | return; |
| 225 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 226 | ctx->Eval.AutoNormal = state; |
| 227 | break; |
| 228 | case GL_BLEND: |
| 229 | if (ctx->Color.BlendEnabled == state) |
| 230 | return; |
| 231 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 232 | ctx->Color.BlendEnabled = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 233 | break; |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 234 | #if FEATURE_userclip |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 235 | case GL_CLIP_PLANE0: |
| 236 | case GL_CLIP_PLANE1: |
| 237 | case GL_CLIP_PLANE2: |
| 238 | case GL_CLIP_PLANE3: |
| 239 | case GL_CLIP_PLANE4: |
| 240 | case GL_CLIP_PLANE5: |
| 241 | { |
Brian Paul | 103bc0f | 2002-03-29 17:27:59 +0000 | [diff] [blame] | 242 | const GLuint p = cap - GL_CLIP_PLANE0; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 243 | |
Brian Paul | db07de0 | 2002-04-19 00:23:08 +0000 | [diff] [blame] | 244 | if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 245 | return; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 246 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 247 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 248 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 249 | if (state) { |
Brian Paul | 103bc0f | 2002-03-29 17:27:59 +0000 | [diff] [blame] | 250 | ctx->Transform.ClipPlanesEnabled |= (1 << p); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 251 | |
Brian Paul | 049e320 | 2005-06-30 14:22:23 +0000 | [diff] [blame] | 252 | if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) |
Brian Paul | 30f51ae | 2001-12-18 04:06:44 +0000 | [diff] [blame] | 253 | _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 254 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 255 | /* This derived state also calculated in clip.c and |
| 256 | * from _mesa_update_state() on changes to EyeUserPlane |
| 257 | * and ctx->ProjectionMatrix respectively. |
| 258 | */ |
| 259 | _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], |
| 260 | ctx->Transform.EyeUserPlane[p], |
Brian Paul | 30f51ae | 2001-12-18 04:06:44 +0000 | [diff] [blame] | 261 | ctx->ProjectionMatrixStack.Top->inv ); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 262 | } |
Brian Paul | f66de79 | 2002-03-28 22:45:45 +0000 | [diff] [blame] | 263 | else { |
Brian Paul | 103bc0f | 2002-03-29 17:27:59 +0000 | [diff] [blame] | 264 | ctx->Transform.ClipPlanesEnabled &= ~(1 << p); |
Brian Paul | f66de79 | 2002-03-28 22:45:45 +0000 | [diff] [blame] | 265 | } |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 266 | } |
| 267 | break; |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 268 | #endif |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 269 | case GL_COLOR_MATERIAL: |
| 270 | if (ctx->Light.ColorMaterialEnabled == state) |
| 271 | return; |
| 272 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
Brian Paul | d40f9fa | 2003-03-21 13:18:33 +0000 | [diff] [blame] | 273 | FLUSH_CURRENT(ctx, 0); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 274 | ctx->Light.ColorMaterialEnabled = state; |
| 275 | if (state) { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 276 | _mesa_update_color_material( ctx, |
| 277 | ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); |
| 278 | } |
| 279 | break; |
| 280 | case GL_CULL_FACE: |
| 281 | if (ctx->Polygon.CullFlag == state) |
| 282 | return; |
| 283 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 284 | ctx->Polygon.CullFlag = state; |
| 285 | break; |
Keith Whitwell | 352d4db | 2004-05-10 18:16:03 +0000 | [diff] [blame] | 286 | case GL_CULL_VERTEX_EXT: |
| 287 | CHECK_EXTENSION(EXT_cull_vertex, cap); |
| 288 | if (ctx->Transform.CullVertexFlag == state) |
| 289 | return; |
| 290 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 291 | ctx->Transform.CullVertexFlag = state; |
| 292 | break; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 293 | case GL_DEPTH_TEST: |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 294 | if (state && ctx->DrawBuffer->Visual.depthBits == 0) { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 295 | _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); |
| 296 | return; |
| 297 | } |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 298 | if (ctx->Depth.Test == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 299 | return; |
| 300 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
| 301 | ctx->Depth.Test = state; |
| 302 | break; |
| 303 | case GL_DITHER: |
| 304 | if (ctx->NoDither) { |
| 305 | state = GL_FALSE; /* MESA_NO_DITHER env var */ |
| 306 | } |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 307 | if (ctx->Color.DitherFlag == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 308 | return; |
| 309 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 310 | ctx->Color.DitherFlag = state; |
| 311 | break; |
| 312 | case GL_FOG: |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 313 | if (ctx->Fog.Enabled == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 314 | return; |
| 315 | FLUSH_VERTICES(ctx, _NEW_FOG); |
| 316 | ctx->Fog.Enabled = state; |
| 317 | break; |
| 318 | case GL_HISTOGRAM: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 319 | CHECK_EXTENSION(EXT_histogram, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 320 | if (ctx->Pixel.HistogramEnabled == state) |
| 321 | return; |
| 322 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 323 | ctx->Pixel.HistogramEnabled = state; |
| 324 | break; |
| 325 | case GL_LIGHT0: |
| 326 | case GL_LIGHT1: |
| 327 | case GL_LIGHT2: |
| 328 | case GL_LIGHT3: |
| 329 | case GL_LIGHT4: |
| 330 | case GL_LIGHT5: |
| 331 | case GL_LIGHT6: |
| 332 | case GL_LIGHT7: |
| 333 | if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) |
| 334 | return; |
| 335 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
| 336 | ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; |
| 337 | if (state) { |
| 338 | insert_at_tail(&ctx->Light.EnabledList, |
| 339 | &ctx->Light.Light[cap-GL_LIGHT0]); |
| 340 | } |
| 341 | else { |
| 342 | remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); |
| 343 | } |
| 344 | break; |
| 345 | case GL_LIGHTING: |
| 346 | if (ctx->Light.Enabled == state) |
| 347 | return; |
| 348 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
| 349 | ctx->Light.Enabled = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 350 | break; |
| 351 | case GL_LINE_SMOOTH: |
| 352 | if (ctx->Line.SmoothFlag == state) |
| 353 | return; |
| 354 | FLUSH_VERTICES(ctx, _NEW_LINE); |
| 355 | ctx->Line.SmoothFlag = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 356 | break; |
| 357 | case GL_LINE_STIPPLE: |
| 358 | if (ctx->Line.StippleFlag == state) |
| 359 | return; |
| 360 | FLUSH_VERTICES(ctx, _NEW_LINE); |
| 361 | ctx->Line.StippleFlag = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 362 | break; |
| 363 | case GL_INDEX_LOGIC_OP: |
| 364 | if (ctx->Color.IndexLogicOpEnabled == state) |
| 365 | return; |
| 366 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 367 | ctx->Color.IndexLogicOpEnabled = state; |
| 368 | break; |
| 369 | case GL_COLOR_LOGIC_OP: |
| 370 | if (ctx->Color.ColorLogicOpEnabled == state) |
| 371 | return; |
| 372 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 373 | ctx->Color.ColorLogicOpEnabled = state; |
| 374 | break; |
| 375 | case GL_MAP1_COLOR_4: |
| 376 | if (ctx->Eval.Map1Color4 == state) |
| 377 | return; |
| 378 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 379 | ctx->Eval.Map1Color4 = state; |
| 380 | break; |
| 381 | case GL_MAP1_INDEX: |
| 382 | if (ctx->Eval.Map1Index == state) |
| 383 | return; |
| 384 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 385 | ctx->Eval.Map1Index = state; |
| 386 | break; |
| 387 | case GL_MAP1_NORMAL: |
| 388 | if (ctx->Eval.Map1Normal == state) |
| 389 | return; |
| 390 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 391 | ctx->Eval.Map1Normal = state; |
| 392 | break; |
| 393 | case GL_MAP1_TEXTURE_COORD_1: |
| 394 | if (ctx->Eval.Map1TextureCoord1 == state) |
| 395 | return; |
| 396 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 397 | ctx->Eval.Map1TextureCoord1 = state; |
| 398 | break; |
| 399 | case GL_MAP1_TEXTURE_COORD_2: |
| 400 | if (ctx->Eval.Map1TextureCoord2 == state) |
| 401 | return; |
| 402 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 403 | ctx->Eval.Map1TextureCoord2 = state; |
| 404 | break; |
| 405 | case GL_MAP1_TEXTURE_COORD_3: |
| 406 | if (ctx->Eval.Map1TextureCoord3 == state) |
| 407 | return; |
| 408 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 409 | ctx->Eval.Map1TextureCoord3 = state; |
| 410 | break; |
| 411 | case GL_MAP1_TEXTURE_COORD_4: |
| 412 | if (ctx->Eval.Map1TextureCoord4 == state) |
| 413 | return; |
| 414 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 415 | ctx->Eval.Map1TextureCoord4 = state; |
| 416 | break; |
| 417 | case GL_MAP1_VERTEX_3: |
| 418 | if (ctx->Eval.Map1Vertex3 == state) |
| 419 | return; |
| 420 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 421 | ctx->Eval.Map1Vertex3 = state; |
| 422 | break; |
| 423 | case GL_MAP1_VERTEX_4: |
| 424 | if (ctx->Eval.Map1Vertex4 == state) |
| 425 | return; |
| 426 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 427 | ctx->Eval.Map1Vertex4 = state; |
| 428 | break; |
| 429 | case GL_MAP2_COLOR_4: |
| 430 | if (ctx->Eval.Map2Color4 == state) |
| 431 | return; |
| 432 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 433 | ctx->Eval.Map2Color4 = state; |
| 434 | break; |
| 435 | case GL_MAP2_INDEX: |
| 436 | if (ctx->Eval.Map2Index == state) |
| 437 | return; |
| 438 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 439 | ctx->Eval.Map2Index = state; |
| 440 | break; |
| 441 | case GL_MAP2_NORMAL: |
| 442 | if (ctx->Eval.Map2Normal == state) |
| 443 | return; |
| 444 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 445 | ctx->Eval.Map2Normal = state; |
| 446 | break; |
| 447 | case GL_MAP2_TEXTURE_COORD_1: |
| 448 | if (ctx->Eval.Map2TextureCoord1 == state) |
| 449 | return; |
| 450 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 451 | ctx->Eval.Map2TextureCoord1 = state; |
| 452 | break; |
| 453 | case GL_MAP2_TEXTURE_COORD_2: |
| 454 | if (ctx->Eval.Map2TextureCoord2 == state) |
| 455 | return; |
| 456 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 457 | ctx->Eval.Map2TextureCoord2 = state; |
| 458 | break; |
| 459 | case GL_MAP2_TEXTURE_COORD_3: |
| 460 | if (ctx->Eval.Map2TextureCoord3 == state) |
| 461 | return; |
| 462 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 463 | ctx->Eval.Map2TextureCoord3 = state; |
| 464 | break; |
| 465 | case GL_MAP2_TEXTURE_COORD_4: |
| 466 | if (ctx->Eval.Map2TextureCoord4 == state) |
| 467 | return; |
| 468 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 469 | ctx->Eval.Map2TextureCoord4 = state; |
| 470 | break; |
| 471 | case GL_MAP2_VERTEX_3: |
| 472 | if (ctx->Eval.Map2Vertex3 == state) |
| 473 | return; |
| 474 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 475 | ctx->Eval.Map2Vertex3 = state; |
| 476 | break; |
| 477 | case GL_MAP2_VERTEX_4: |
| 478 | if (ctx->Eval.Map2Vertex4 == state) |
| 479 | return; |
| 480 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 481 | ctx->Eval.Map2Vertex4 = state; |
| 482 | break; |
| 483 | case GL_MINMAX: |
| 484 | if (ctx->Pixel.MinMaxEnabled == state) |
| 485 | return; |
| 486 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 487 | ctx->Pixel.MinMaxEnabled = state; |
| 488 | break; |
| 489 | case GL_NORMALIZE: |
| 490 | if (ctx->Transform.Normalize == state) |
| 491 | return; |
| 492 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 493 | ctx->Transform.Normalize = state; |
| 494 | break; |
| 495 | case GL_POINT_SMOOTH: |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 496 | if (ctx->Point.SmoothFlag == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 497 | return; |
| 498 | FLUSH_VERTICES(ctx, _NEW_POINT); |
| 499 | ctx->Point.SmoothFlag = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 500 | break; |
| 501 | case GL_POLYGON_SMOOTH: |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 502 | if (ctx->Polygon.SmoothFlag == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 503 | return; |
| 504 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 505 | ctx->Polygon.SmoothFlag = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 506 | break; |
| 507 | case GL_POLYGON_STIPPLE: |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 508 | if (ctx->Polygon.StippleFlag == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 509 | return; |
| 510 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 511 | ctx->Polygon.StippleFlag = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 512 | break; |
| 513 | case GL_POLYGON_OFFSET_POINT: |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 514 | if (ctx->Polygon.OffsetPoint == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 515 | return; |
| 516 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 517 | ctx->Polygon.OffsetPoint = state; |
| 518 | break; |
| 519 | case GL_POLYGON_OFFSET_LINE: |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 520 | if (ctx->Polygon.OffsetLine == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 521 | return; |
| 522 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 523 | ctx->Polygon.OffsetLine = state; |
| 524 | break; |
| 525 | case GL_POLYGON_OFFSET_FILL: |
| 526 | /*case GL_POLYGON_OFFSET_EXT:*/ |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 527 | if (ctx->Polygon.OffsetFill == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 528 | return; |
| 529 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 530 | ctx->Polygon.OffsetFill = state; |
| 531 | break; |
| 532 | case GL_RESCALE_NORMAL_EXT: |
| 533 | if (ctx->Transform.RescaleNormals == state) |
| 534 | return; |
| 535 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 536 | ctx->Transform.RescaleNormals = state; |
| 537 | break; |
| 538 | case GL_SCISSOR_TEST: |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 539 | if (ctx->Scissor.Enabled == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 540 | return; |
| 541 | FLUSH_VERTICES(ctx, _NEW_SCISSOR); |
| 542 | ctx->Scissor.Enabled = state; |
| 543 | break; |
| 544 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
| 545 | if (ctx->Texture.SharedPalette == state) |
| 546 | return; |
| 547 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 548 | ctx->Texture.SharedPalette = state; |
| 549 | break; |
| 550 | case GL_STENCIL_TEST: |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 551 | if (state && ctx->DrawBuffer->Visual.stencilBits == 0) { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 552 | _mesa_warning(ctx, |
| 553 | "glEnable(GL_STENCIL_TEST) but no stencil buffer"); |
| 554 | return; |
| 555 | } |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 556 | if (ctx->Stencil.Enabled == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 557 | return; |
| 558 | FLUSH_VERTICES(ctx, _NEW_STENCIL); |
| 559 | ctx->Stencil.Enabled = state; |
| 560 | break; |
| 561 | case GL_TEXTURE_1D: { |
| 562 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 563 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 564 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 565 | if (state) |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 566 | newenabled |= TEXTURE_1D_BIT; |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 567 | if (!ctx->DrawBuffer->Visual.rgbMode |
| 568 | || texUnit->Enabled == newenabled) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 569 | return; |
| 570 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 571 | texUnit->Enabled = newenabled; |
| 572 | break; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 573 | } |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 574 | case GL_TEXTURE_2D: { |
| 575 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 576 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 577 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 578 | if (state) |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 579 | newenabled |= TEXTURE_2D_BIT; |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 580 | if (!ctx->DrawBuffer->Visual.rgbMode |
| 581 | || texUnit->Enabled == newenabled) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 582 | return; |
| 583 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 584 | texUnit->Enabled = newenabled; |
| 585 | break; |
| 586 | } |
| 587 | case GL_TEXTURE_3D: { |
| 588 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 589 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 590 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 591 | if (state) |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 592 | newenabled |= TEXTURE_3D_BIT; |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 593 | if (!ctx->DrawBuffer->Visual.rgbMode |
| 594 | || texUnit->Enabled == newenabled) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 595 | return; |
| 596 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 597 | texUnit->Enabled = newenabled; |
| 598 | break; |
| 599 | } |
| 600 | case GL_TEXTURE_GEN_Q: { |
| 601 | GLuint unit = ctx->Texture.CurrentUnit; |
| 602 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 603 | GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; |
| 604 | if (state) |
| 605 | newenabled |= Q_BIT; |
| 606 | if (texUnit->TexGenEnabled == newenabled) |
| 607 | return; |
| 608 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 609 | texUnit->TexGenEnabled = newenabled; |
| 610 | break; |
| 611 | } |
| 612 | case GL_TEXTURE_GEN_R: { |
| 613 | GLuint unit = ctx->Texture.CurrentUnit; |
| 614 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 615 | GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; |
| 616 | if (state) |
| 617 | newenabled |= R_BIT; |
| 618 | if (texUnit->TexGenEnabled == newenabled) |
| 619 | return; |
| 620 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 621 | texUnit->TexGenEnabled = newenabled; |
| 622 | break; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 623 | } |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 624 | case GL_TEXTURE_GEN_S: { |
| 625 | GLuint unit = ctx->Texture.CurrentUnit; |
| 626 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 627 | GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; |
| 628 | if (state) |
| 629 | newenabled |= S_BIT; |
| 630 | if (texUnit->TexGenEnabled == newenabled) |
| 631 | return; |
| 632 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 633 | texUnit->TexGenEnabled = newenabled; |
| 634 | break; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 635 | } |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 636 | case GL_TEXTURE_GEN_T: { |
| 637 | GLuint unit = ctx->Texture.CurrentUnit; |
| 638 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 639 | GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; |
| 640 | if (state) |
| 641 | newenabled |= T_BIT; |
| 642 | if (texUnit->TexGenEnabled == newenabled) |
| 643 | return; |
| 644 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 645 | texUnit->TexGenEnabled = newenabled; |
| 646 | break; |
| 647 | } |
Keith Whitwell | 46b0988 | 2001-02-16 18:14:41 +0000 | [diff] [blame] | 648 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 649 | /* |
| 650 | * CLIENT STATE!!! |
| 651 | */ |
| 652 | case GL_VERTEX_ARRAY: |
| 653 | case GL_NORMAL_ARRAY: |
| 654 | case GL_COLOR_ARRAY: |
| 655 | case GL_INDEX_ARRAY: |
| 656 | case GL_TEXTURE_COORD_ARRAY: |
| 657 | case GL_EDGE_FLAG_ARRAY: |
| 658 | case GL_FOG_COORDINATE_ARRAY_EXT: |
| 659 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
| 660 | client_state( ctx, cap, state ); |
| 661 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 662 | |
Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 663 | /* GL_SGI_color_table */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 664 | case GL_COLOR_TABLE_SGI: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 665 | CHECK_EXTENSION(SGI_color_table, cap); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 666 | if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 667 | return; |
| 668 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 669 | ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 670 | break; |
| 671 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 672 | CHECK_EXTENSION(SGI_color_table, cap); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 673 | if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 674 | return; |
| 675 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 676 | ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 677 | break; |
| 678 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 679 | CHECK_EXTENSION(SGI_color_table, cap); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 680 | if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 681 | return; |
| 682 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 683 | ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 684 | break; |
Brian Paul | 418ac00 | 2003-01-21 21:47:45 +0000 | [diff] [blame] | 685 | case GL_TEXTURE_COLOR_TABLE_SGI: |
| 686 | CHECK_EXTENSION(SGI_texture_color_table, cap); |
Brian Paul | 45b47d0 | 2003-01-26 14:37:15 +0000 | [diff] [blame] | 687 | if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state) |
Brian Paul | 418ac00 | 2003-01-21 21:47:45 +0000 | [diff] [blame] | 688 | return; |
| 689 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
Brian Paul | 45b47d0 | 2003-01-26 14:37:15 +0000 | [diff] [blame] | 690 | ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state; |
Brian Paul | 418ac00 | 2003-01-21 21:47:45 +0000 | [diff] [blame] | 691 | break; |
Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 692 | |
Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 693 | /* GL_EXT_convolution */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 694 | case GL_CONVOLUTION_1D: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 695 | CHECK_EXTENSION(EXT_convolution, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 696 | if (ctx->Pixel.Convolution1DEnabled == state) |
| 697 | return; |
| 698 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 699 | ctx->Pixel.Convolution1DEnabled = state; |
| 700 | break; |
| 701 | case GL_CONVOLUTION_2D: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 702 | CHECK_EXTENSION(EXT_convolution, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 703 | if (ctx->Pixel.Convolution2DEnabled == state) |
| 704 | return; |
| 705 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 706 | ctx->Pixel.Convolution2DEnabled = state; |
| 707 | break; |
| 708 | case GL_SEPARABLE_2D: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 709 | CHECK_EXTENSION(EXT_convolution, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 710 | if (ctx->Pixel.Separable2DEnabled == state) |
| 711 | return; |
| 712 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 713 | ctx->Pixel.Separable2DEnabled = state; |
| 714 | break; |
Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 715 | |
Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 716 | /* GL_ARB_texture_cube_map */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 717 | case GL_TEXTURE_CUBE_MAP_ARB: |
| 718 | { |
| 719 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 720 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 721 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT; |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 722 | CHECK_EXTENSION(ARB_texture_cube_map, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 723 | if (state) |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 724 | newenabled |= TEXTURE_CUBE_BIT; |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 725 | if (!ctx->DrawBuffer->Visual.rgbMode |
| 726 | || texUnit->Enabled == newenabled) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 727 | return; |
| 728 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 729 | texUnit->Enabled = newenabled; |
| 730 | } |
| 731 | break; |
| 732 | |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 733 | /* GL_EXT_secondary_color */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 734 | case GL_COLOR_SUM_EXT: |
Roland Scheidegger | da16813 | 2006-03-02 12:06:57 +0000 | [diff] [blame] | 735 | CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 736 | if (ctx->Fog.ColorSumEnabled == state) |
| 737 | return; |
| 738 | FLUSH_VERTICES(ctx, _NEW_FOG); |
| 739 | ctx->Fog.ColorSumEnabled = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 740 | break; |
Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame] | 741 | |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 742 | /* GL_ARB_multisample */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 743 | case GL_MULTISAMPLE_ARB: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 744 | CHECK_EXTENSION(ARB_multisample, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 745 | if (ctx->Multisample.Enabled == state) |
| 746 | return; |
| 747 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
| 748 | ctx->Multisample.Enabled = state; |
| 749 | break; |
| 750 | case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 751 | CHECK_EXTENSION(ARB_multisample, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 752 | if (ctx->Multisample.SampleAlphaToCoverage == state) |
| 753 | return; |
| 754 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
| 755 | ctx->Multisample.SampleAlphaToCoverage = state; |
| 756 | break; |
| 757 | case GL_SAMPLE_ALPHA_TO_ONE_ARB: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 758 | CHECK_EXTENSION(ARB_multisample, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 759 | if (ctx->Multisample.SampleAlphaToOne == state) |
| 760 | return; |
| 761 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
| 762 | ctx->Multisample.SampleAlphaToOne = state; |
| 763 | break; |
| 764 | case GL_SAMPLE_COVERAGE_ARB: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 765 | CHECK_EXTENSION(ARB_multisample, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 766 | if (ctx->Multisample.SampleCoverage == state) |
| 767 | return; |
| 768 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
| 769 | ctx->Multisample.SampleCoverage = state; |
| 770 | break; |
| 771 | case GL_SAMPLE_COVERAGE_INVERT_ARB: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 772 | CHECK_EXTENSION(ARB_multisample, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 773 | if (ctx->Multisample.SampleCoverageInvert == state) |
| 774 | return; |
| 775 | FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); |
| 776 | ctx->Multisample.SampleCoverageInvert = state; |
| 777 | break; |
Brian Paul | 8c2f6c5 | 2001-06-26 01:32:48 +0000 | [diff] [blame] | 778 | |
| 779 | /* GL_IBM_rasterpos_clip */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 780 | case GL_RASTER_POSITION_UNCLIPPED_IBM: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 781 | CHECK_EXTENSION(IBM_rasterpos_clip, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 782 | if (ctx->Transform.RasterPositionUnclipped == state) |
| 783 | return; |
| 784 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 785 | ctx->Transform.RasterPositionUnclipped = state; |
| 786 | break; |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 787 | |
Brian Paul | 6c408b4 | 2002-05-27 17:04:52 +0000 | [diff] [blame] | 788 | /* GL_NV_point_sprite */ |
| 789 | case GL_POINT_SPRITE_NV: |
Ian Romanick | 6373672 | 2003-08-23 00:12:46 +0000 | [diff] [blame] | 790 | CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); |
Brian Paul | 6c408b4 | 2002-05-27 17:04:52 +0000 | [diff] [blame] | 791 | if (ctx->Point.PointSprite == state) |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 792 | return; |
| 793 | FLUSH_VERTICES(ctx, _NEW_POINT); |
Brian Paul | 6c408b4 | 2002-05-27 17:04:52 +0000 | [diff] [blame] | 794 | ctx->Point.PointSprite = state; |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 795 | break; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 796 | |
Roland Scheidegger | 93da673 | 2006-03-01 23:11:14 +0000 | [diff] [blame] | 797 | #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program |
Roland Scheidegger | e1e03b3 | 2006-03-03 15:03:04 +0000 | [diff] [blame] | 798 | case GL_VERTEX_PROGRAM_ARB: |
| 799 | CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 800 | if (ctx->VertexProgram.Enabled == state) |
| 801 | return; |
Keith Whitwell | 3abf746 | 2004-01-23 14:46:27 +0000 | [diff] [blame] | 802 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 803 | ctx->VertexProgram.Enabled = state; |
| 804 | break; |
Roland Scheidegger | e1e03b3 | 2006-03-03 15:03:04 +0000 | [diff] [blame] | 805 | case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: |
| 806 | CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 807 | if (ctx->VertexProgram.PointSizeEnabled == state) |
| 808 | return; |
Keith Whitwell | 3abf746 | 2004-01-23 14:46:27 +0000 | [diff] [blame] | 809 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 810 | ctx->VertexProgram.PointSizeEnabled = state; |
| 811 | break; |
Roland Scheidegger | e1e03b3 | 2006-03-03 15:03:04 +0000 | [diff] [blame] | 812 | case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: |
| 813 | CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 814 | if (ctx->VertexProgram.TwoSideEnabled == state) |
| 815 | return; |
Keith Whitwell | 3abf746 | 2004-01-23 14:46:27 +0000 | [diff] [blame] | 816 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 817 | ctx->VertexProgram.TwoSideEnabled = state; |
| 818 | break; |
Roland Scheidegger | 93da673 | 2006-03-01 23:11:14 +0000 | [diff] [blame] | 819 | #endif |
| 820 | #if FEATURE_NV_vertex_program |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 821 | case GL_MAP1_VERTEX_ATTRIB0_4_NV: |
| 822 | case GL_MAP1_VERTEX_ATTRIB1_4_NV: |
| 823 | case GL_MAP1_VERTEX_ATTRIB2_4_NV: |
| 824 | case GL_MAP1_VERTEX_ATTRIB3_4_NV: |
| 825 | case GL_MAP1_VERTEX_ATTRIB4_4_NV: |
| 826 | case GL_MAP1_VERTEX_ATTRIB5_4_NV: |
| 827 | case GL_MAP1_VERTEX_ATTRIB6_4_NV: |
| 828 | case GL_MAP1_VERTEX_ATTRIB7_4_NV: |
| 829 | case GL_MAP1_VERTEX_ATTRIB8_4_NV: |
| 830 | case GL_MAP1_VERTEX_ATTRIB9_4_NV: |
| 831 | case GL_MAP1_VERTEX_ATTRIB10_4_NV: |
| 832 | case GL_MAP1_VERTEX_ATTRIB11_4_NV: |
| 833 | case GL_MAP1_VERTEX_ATTRIB12_4_NV: |
| 834 | case GL_MAP1_VERTEX_ATTRIB13_4_NV: |
| 835 | case GL_MAP1_VERTEX_ATTRIB14_4_NV: |
| 836 | case GL_MAP1_VERTEX_ATTRIB15_4_NV: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 837 | CHECK_EXTENSION(NV_vertex_program, cap); |
Brian Paul | bc42c19 | 2002-01-05 21:53:20 +0000 | [diff] [blame] | 838 | { |
| 839 | const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); |
| 840 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 841 | ctx->Eval.Map1Attrib[map] = state; |
| 842 | } |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 843 | break; |
| 844 | case GL_MAP2_VERTEX_ATTRIB0_4_NV: |
| 845 | case GL_MAP2_VERTEX_ATTRIB1_4_NV: |
| 846 | case GL_MAP2_VERTEX_ATTRIB2_4_NV: |
| 847 | case GL_MAP2_VERTEX_ATTRIB3_4_NV: |
| 848 | case GL_MAP2_VERTEX_ATTRIB4_4_NV: |
| 849 | case GL_MAP2_VERTEX_ATTRIB5_4_NV: |
| 850 | case GL_MAP2_VERTEX_ATTRIB6_4_NV: |
| 851 | case GL_MAP2_VERTEX_ATTRIB7_4_NV: |
| 852 | case GL_MAP2_VERTEX_ATTRIB8_4_NV: |
| 853 | case GL_MAP2_VERTEX_ATTRIB9_4_NV: |
| 854 | case GL_MAP2_VERTEX_ATTRIB10_4_NV: |
| 855 | case GL_MAP2_VERTEX_ATTRIB11_4_NV: |
| 856 | case GL_MAP2_VERTEX_ATTRIB12_4_NV: |
| 857 | case GL_MAP2_VERTEX_ATTRIB13_4_NV: |
| 858 | case GL_MAP2_VERTEX_ATTRIB14_4_NV: |
| 859 | case GL_MAP2_VERTEX_ATTRIB15_4_NV: |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 860 | CHECK_EXTENSION(NV_vertex_program, cap); |
Brian Paul | bc42c19 | 2002-01-05 21:53:20 +0000 | [diff] [blame] | 861 | { |
| 862 | const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); |
| 863 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 864 | ctx->Eval.Map2Attrib[map] = state; |
| 865 | } |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 866 | break; |
Brian Paul | 8dfc5b9 | 2002-10-16 17:57:51 +0000 | [diff] [blame] | 867 | #endif /* FEATURE_NV_vertex_program */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 868 | |
Brian Paul | 610d599 | 2003-01-14 04:55:45 +0000 | [diff] [blame] | 869 | #if FEATURE_NV_fragment_program |
| 870 | case GL_FRAGMENT_PROGRAM_NV: |
| 871 | CHECK_EXTENSION(NV_fragment_program, cap); |
| 872 | if (ctx->FragmentProgram.Enabled == state) |
| 873 | return; |
Keith Whitwell | 3abf746 | 2004-01-23 14:46:27 +0000 | [diff] [blame] | 874 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); |
Brian Paul | 610d599 | 2003-01-14 04:55:45 +0000 | [diff] [blame] | 875 | ctx->FragmentProgram.Enabled = state; |
| 876 | break; |
| 877 | #endif /* FEATURE_NV_fragment_program */ |
| 878 | |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 879 | /* GL_NV_texture_rectangle */ |
| 880 | case GL_TEXTURE_RECTANGLE_NV: |
Brian Paul | 5f60a0b | 2002-09-06 02:56:08 +0000 | [diff] [blame] | 881 | CHECK_EXTENSION(NV_texture_rectangle, cap); |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 882 | { |
| 883 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 884 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| 885 | GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT; |
Brian Paul | 02c03ef | 2002-06-18 16:53:46 +0000 | [diff] [blame] | 886 | CHECK_EXTENSION(NV_texture_rectangle, cap); |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 887 | if (state) |
| 888 | newenabled |= TEXTURE_RECT_BIT; |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 889 | if (!ctx->DrawBuffer->Visual.rgbMode |
| 890 | || texUnit->Enabled == newenabled) |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 891 | return; |
| 892 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 893 | texUnit->Enabled = newenabled; |
| 894 | } |
| 895 | break; |
| 896 | |
Brian Paul | 5f60a0b | 2002-09-06 02:56:08 +0000 | [diff] [blame] | 897 | /* GL_EXT_stencil_two_side */ |
| 898 | case GL_STENCIL_TEST_TWO_SIDE_EXT: |
| 899 | CHECK_EXTENSION(EXT_stencil_two_side, cap); |
| 900 | if (ctx->Stencil.TestTwoSide == state) |
| 901 | return; |
| 902 | FLUSH_VERTICES(ctx, _NEW_STENCIL); |
| 903 | ctx->Stencil.TestTwoSide = state; |
| 904 | break; |
| 905 | |
Brian Paul | 77eec61 | 2003-04-18 01:56:11 +0000 | [diff] [blame] | 906 | #if FEATURE_ARB_fragment_program |
| 907 | case GL_FRAGMENT_PROGRAM_ARB: |
| 908 | CHECK_EXTENSION(ARB_fragment_program, cap); |
| 909 | if (ctx->FragmentProgram.Enabled == state) |
| 910 | return; |
Keith Whitwell | 3abf746 | 2004-01-23 14:46:27 +0000 | [diff] [blame] | 911 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); |
Brian Paul | 77eec61 | 2003-04-18 01:56:11 +0000 | [diff] [blame] | 912 | ctx->FragmentProgram.Enabled = state; |
| 913 | break; |
| 914 | #endif /* FEATURE_ARB_fragment_program */ |
| 915 | |
Brian Paul | e5b244f | 2003-04-21 15:02:17 +0000 | [diff] [blame] | 916 | /* GL_EXT_depth_bounds_test */ |
| 917 | case GL_DEPTH_BOUNDS_TEST_EXT: |
| 918 | CHECK_EXTENSION(EXT_depth_bounds_test, cap); |
Brian Paul | e4b2356 | 2005-05-04 20:11:35 +0000 | [diff] [blame] | 919 | if (state && ctx->DrawBuffer->Visual.depthBits == 0) { |
Brian Paul | e5b244f | 2003-04-21 15:02:17 +0000 | [diff] [blame] | 920 | _mesa_warning(ctx, |
| 921 | "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer"); |
| 922 | return; |
| 923 | } |
| 924 | if (ctx->Depth.BoundsTest == state) |
| 925 | return; |
| 926 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
| 927 | ctx->Depth.BoundsTest = state; |
| 928 | break; |
| 929 | |
Brian Paul | 08ff059 | 2003-07-21 04:22:40 +0000 | [diff] [blame] | 930 | /* GL_MESA_program_debug */ |
| 931 | case GL_FRAGMENT_PROGRAM_CALLBACK_MESA: |
| 932 | CHECK_EXTENSION(MESA_program_debug, cap); |
| 933 | ctx->FragmentProgram.CallbackEnabled = state; |
| 934 | break; |
| 935 | case GL_VERTEX_PROGRAM_CALLBACK_MESA: |
| 936 | CHECK_EXTENSION(MESA_program_debug, cap); |
| 937 | ctx->VertexProgram.CallbackEnabled = state; |
| 938 | break; |
| 939 | |
Dave Airlie | 7f752fe | 2004-12-19 03:06:59 +0000 | [diff] [blame] | 940 | #if FEATURE_ATI_fragment_shader |
| 941 | case GL_FRAGMENT_SHADER_ATI: |
| 942 | CHECK_EXTENSION(ATI_fragment_shader, cap); |
| 943 | if (ctx->ATIFragmentShader.Enabled == state) |
| 944 | return; |
| 945 | FLUSH_VERTICES(ctx, _NEW_PROGRAM); |
| 946 | ctx->ATIFragmentShader.Enabled = state; |
| 947 | break; |
| 948 | #endif |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 949 | default: |
Brian Paul | 4e9676f | 2002-06-29 19:48:15 +0000 | [diff] [blame] | 950 | _mesa_error(ctx, GL_INVALID_ENUM, |
| 951 | "%s(0x%x)", state ? "glEnable" : "glDisable", cap); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 952 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | if (ctx->Driver.Enable) { |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 956 | ctx->Driver.Enable( ctx, cap, state ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 957 | } |
| 958 | } |
| 959 | |
| 960 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 961 | /** |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 962 | * Enable GL capability. Called by glEnable() |
| 963 | * \param cap state to enable. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 964 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 965 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 966 | _mesa_Enable( GLenum cap ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 967 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 968 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | 376d022 | 2000-12-27 22:52:45 +0000 | [diff] [blame] | 969 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 970 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 971 | _mesa_set_enable( ctx, cap, GL_TRUE ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 975 | /** |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 976 | * Disable GL capability. Called by glDisable() |
| 977 | * \param cap state to disable. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 978 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 979 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 980 | _mesa_Disable( GLenum cap ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 981 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 982 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | 376d022 | 2000-12-27 22:52:45 +0000 | [diff] [blame] | 983 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 984 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 985 | _mesa_set_enable( ctx, cap, GL_FALSE ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 989 | #undef CHECK_EXTENSION |
| 990 | #define CHECK_EXTENSION(EXTNAME) \ |
| 991 | if (!ctx->Extensions.EXTNAME) { \ |
| 992 | _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \ |
| 993 | return GL_FALSE; \ |
| 994 | } |
| 995 | |
Roland Scheidegger | da16813 | 2006-03-02 12:06:57 +0000 | [diff] [blame] | 996 | #undef CHECK_EXTENSION2 |
| 997 | #define CHECK_EXTENSION2(EXT1, EXT2) \ |
| 998 | if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ |
| 999 | _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \ |
| 1000 | return GL_FALSE; \ |
| 1001 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1002 | |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 1003 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1004 | /** |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 1005 | * Return simple enable/disable state. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1006 | * |
Brian | 8dcfcad7 | 2006-12-13 15:31:14 -0700 | [diff] [blame] | 1007 | * \param cap state variable to query. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1008 | * |
| 1009 | * Returns the state of the specified capability from the current GL context. |
| 1010 | * For the capabilities associated with extensions verifies that those |
| 1011 | * extensions are effectively present before reporting. |
| 1012 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1013 | GLboolean GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1014 | _mesa_IsEnabled( GLenum cap ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1015 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1016 | GET_CURRENT_CONTEXT(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1017 | switch (cap) { |
| 1018 | case GL_ALPHA_TEST: |
| 1019 | return ctx->Color.AlphaEnabled; |
| 1020 | case GL_AUTO_NORMAL: |
| 1021 | return ctx->Eval.AutoNormal; |
| 1022 | case GL_BLEND: |
| 1023 | return ctx->Color.BlendEnabled; |
| 1024 | case GL_CLIP_PLANE0: |
| 1025 | case GL_CLIP_PLANE1: |
| 1026 | case GL_CLIP_PLANE2: |
| 1027 | case GL_CLIP_PLANE3: |
| 1028 | case GL_CLIP_PLANE4: |
| 1029 | case GL_CLIP_PLANE5: |
Brian Paul | 103bc0f | 2002-03-29 17:27:59 +0000 | [diff] [blame] | 1030 | return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1031 | case GL_COLOR_MATERIAL: |
| 1032 | return ctx->Light.ColorMaterialEnabled; |
| 1033 | case GL_CULL_FACE: |
| 1034 | return ctx->Polygon.CullFlag; |
| 1035 | case GL_DEPTH_TEST: |
| 1036 | return ctx->Depth.Test; |
| 1037 | case GL_DITHER: |
| 1038 | return ctx->Color.DitherFlag; |
| 1039 | case GL_FOG: |
| 1040 | return ctx->Fog.Enabled; |
| 1041 | case GL_LIGHTING: |
| 1042 | return ctx->Light.Enabled; |
| 1043 | case GL_LIGHT0: |
| 1044 | case GL_LIGHT1: |
| 1045 | case GL_LIGHT2: |
| 1046 | case GL_LIGHT3: |
| 1047 | case GL_LIGHT4: |
| 1048 | case GL_LIGHT5: |
| 1049 | case GL_LIGHT6: |
| 1050 | case GL_LIGHT7: |
| 1051 | return ctx->Light.Light[cap-GL_LIGHT0].Enabled; |
| 1052 | case GL_LINE_SMOOTH: |
| 1053 | return ctx->Line.SmoothFlag; |
| 1054 | case GL_LINE_STIPPLE: |
| 1055 | return ctx->Line.StippleFlag; |
| 1056 | case GL_INDEX_LOGIC_OP: |
| 1057 | return ctx->Color.IndexLogicOpEnabled; |
| 1058 | case GL_COLOR_LOGIC_OP: |
| 1059 | return ctx->Color.ColorLogicOpEnabled; |
| 1060 | case GL_MAP1_COLOR_4: |
| 1061 | return ctx->Eval.Map1Color4; |
| 1062 | case GL_MAP1_INDEX: |
| 1063 | return ctx->Eval.Map1Index; |
| 1064 | case GL_MAP1_NORMAL: |
| 1065 | return ctx->Eval.Map1Normal; |
| 1066 | case GL_MAP1_TEXTURE_COORD_1: |
| 1067 | return ctx->Eval.Map1TextureCoord1; |
| 1068 | case GL_MAP1_TEXTURE_COORD_2: |
| 1069 | return ctx->Eval.Map1TextureCoord2; |
| 1070 | case GL_MAP1_TEXTURE_COORD_3: |
| 1071 | return ctx->Eval.Map1TextureCoord3; |
| 1072 | case GL_MAP1_TEXTURE_COORD_4: |
| 1073 | return ctx->Eval.Map1TextureCoord4; |
| 1074 | case GL_MAP1_VERTEX_3: |
| 1075 | return ctx->Eval.Map1Vertex3; |
| 1076 | case GL_MAP1_VERTEX_4: |
| 1077 | return ctx->Eval.Map1Vertex4; |
| 1078 | case GL_MAP2_COLOR_4: |
| 1079 | return ctx->Eval.Map2Color4; |
| 1080 | case GL_MAP2_INDEX: |
| 1081 | return ctx->Eval.Map2Index; |
| 1082 | case GL_MAP2_NORMAL: |
| 1083 | return ctx->Eval.Map2Normal; |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 1084 | case GL_MAP2_TEXTURE_COORD_1: |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1085 | return ctx->Eval.Map2TextureCoord1; |
| 1086 | case GL_MAP2_TEXTURE_COORD_2: |
| 1087 | return ctx->Eval.Map2TextureCoord2; |
| 1088 | case GL_MAP2_TEXTURE_COORD_3: |
| 1089 | return ctx->Eval.Map2TextureCoord3; |
| 1090 | case GL_MAP2_TEXTURE_COORD_4: |
| 1091 | return ctx->Eval.Map2TextureCoord4; |
| 1092 | case GL_MAP2_VERTEX_3: |
| 1093 | return ctx->Eval.Map2Vertex3; |
| 1094 | case GL_MAP2_VERTEX_4: |
| 1095 | return ctx->Eval.Map2Vertex4; |
| 1096 | case GL_NORMALIZE: |
| 1097 | return ctx->Transform.Normalize; |
| 1098 | case GL_POINT_SMOOTH: |
| 1099 | return ctx->Point.SmoothFlag; |
| 1100 | case GL_POLYGON_SMOOTH: |
| 1101 | return ctx->Polygon.SmoothFlag; |
| 1102 | case GL_POLYGON_STIPPLE: |
| 1103 | return ctx->Polygon.StippleFlag; |
| 1104 | case GL_POLYGON_OFFSET_POINT: |
| 1105 | return ctx->Polygon.OffsetPoint; |
| 1106 | case GL_POLYGON_OFFSET_LINE: |
| 1107 | return ctx->Polygon.OffsetLine; |
| 1108 | case GL_POLYGON_OFFSET_FILL: |
| 1109 | /*case GL_POLYGON_OFFSET_EXT:*/ |
| 1110 | return ctx->Polygon.OffsetFill; |
| 1111 | case GL_RESCALE_NORMAL_EXT: |
| 1112 | return ctx->Transform.RescaleNormals; |
| 1113 | case GL_SCISSOR_TEST: |
| 1114 | return ctx->Scissor.Enabled; |
| 1115 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
| 1116 | return ctx->Texture.SharedPalette; |
| 1117 | case GL_STENCIL_TEST: |
| 1118 | return ctx->Stencil.Enabled; |
| 1119 | case GL_TEXTURE_1D: |
| 1120 | { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1121 | const struct gl_texture_unit *texUnit; |
| 1122 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 1123 | return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1124 | } |
| 1125 | case GL_TEXTURE_2D: |
| 1126 | { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1127 | const struct gl_texture_unit *texUnit; |
| 1128 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 1129 | return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1130 | } |
| 1131 | case GL_TEXTURE_3D: |
| 1132 | { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1133 | const struct gl_texture_unit *texUnit; |
| 1134 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 1135 | return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1136 | } |
| 1137 | case GL_TEXTURE_GEN_Q: |
| 1138 | { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1139 | const struct gl_texture_unit *texUnit; |
| 1140 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1141 | return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; |
| 1142 | } |
| 1143 | case GL_TEXTURE_GEN_R: |
| 1144 | { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1145 | const struct gl_texture_unit *texUnit; |
| 1146 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1147 | return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; |
| 1148 | } |
| 1149 | case GL_TEXTURE_GEN_S: |
| 1150 | { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1151 | const struct gl_texture_unit *texUnit; |
| 1152 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1153 | return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; |
| 1154 | } |
| 1155 | case GL_TEXTURE_GEN_T: |
| 1156 | { |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1157 | const struct gl_texture_unit *texUnit; |
| 1158 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1159 | return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; |
| 1160 | } |
| 1161 | |
| 1162 | /* |
| 1163 | * CLIENT STATE!!! |
| 1164 | */ |
| 1165 | case GL_VERTEX_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1166 | return (ctx->Array.ArrayObj->Vertex.Enabled != 0); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1167 | case GL_NORMAL_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1168 | return (ctx->Array.ArrayObj->Normal.Enabled != 0); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1169 | case GL_COLOR_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1170 | return (ctx->Array.ArrayObj->Color.Enabled != 0); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1171 | case GL_INDEX_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1172 | return (ctx->Array.ArrayObj->Index.Enabled != 0); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1173 | case GL_TEXTURE_COORD_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1174 | return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled != 0); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1175 | case GL_EDGE_FLAG_ARRAY: |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1176 | return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0); |
Brian Paul | 6ee7a02 | 2002-01-22 18:40:46 +0000 | [diff] [blame] | 1177 | case GL_FOG_COORDINATE_ARRAY_EXT: |
| 1178 | CHECK_EXTENSION(EXT_fog_coord); |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1179 | return (ctx->Array.ArrayObj->FogCoord.Enabled != 0); |
Brian Paul | 6ee7a02 | 2002-01-22 18:40:46 +0000 | [diff] [blame] | 1180 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
| 1181 | CHECK_EXTENSION(EXT_secondary_color); |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1182 | return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0); |
Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 1183 | |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1184 | /* GL_EXT_histogram */ |
| 1185 | case GL_HISTOGRAM: |
| 1186 | CHECK_EXTENSION(EXT_histogram); |
| 1187 | return ctx->Pixel.HistogramEnabled; |
| 1188 | case GL_MINMAX: |
| 1189 | CHECK_EXTENSION(EXT_histogram); |
| 1190 | return ctx->Pixel.MinMaxEnabled; |
| 1191 | |
Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 1192 | /* GL_SGI_color_table */ |
| 1193 | case GL_COLOR_TABLE_SGI: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1194 | CHECK_EXTENSION(SGI_color_table); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 1195 | return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; |
Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 1196 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1197 | CHECK_EXTENSION(SGI_color_table); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 1198 | return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; |
Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 1199 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1200 | CHECK_EXTENSION(SGI_color_table); |
Brian | 7573b58 | 2007-03-16 09:36:12 -0600 | [diff] [blame^] | 1201 | return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; |
Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 1202 | |
Brian Paul | 45b47d0 | 2003-01-26 14:37:15 +0000 | [diff] [blame] | 1203 | /* GL_SGI_texture_color_table */ |
| 1204 | case GL_TEXTURE_COLOR_TABLE_SGI: |
| 1205 | CHECK_EXTENSION(SGI_texture_color_table); |
| 1206 | return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled; |
| 1207 | |
Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 1208 | /* GL_EXT_convolution */ |
| 1209 | case GL_CONVOLUTION_1D: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1210 | CHECK_EXTENSION(EXT_convolution); |
Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 1211 | return ctx->Pixel.Convolution1DEnabled; |
| 1212 | case GL_CONVOLUTION_2D: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1213 | CHECK_EXTENSION(EXT_convolution); |
Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 1214 | return ctx->Pixel.Convolution2DEnabled; |
| 1215 | case GL_SEPARABLE_2D: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1216 | CHECK_EXTENSION(EXT_convolution); |
Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 1217 | return ctx->Pixel.Separable2DEnabled; |
| 1218 | |
Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 1219 | /* GL_ARB_texture_cube_map */ |
| 1220 | case GL_TEXTURE_CUBE_MAP_ARB: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1221 | CHECK_EXTENSION(ARB_texture_cube_map); |
| 1222 | { |
| 1223 | const struct gl_texture_unit *texUnit; |
| 1224 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 1225 | return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE; |
Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 1226 | } |
Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 1227 | |
Roland Scheidegger | da16813 | 2006-03-02 12:06:57 +0000 | [diff] [blame] | 1228 | /* GL_EXT_secondary_color */ |
| 1229 | case GL_COLOR_SUM_EXT: |
| 1230 | CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); |
| 1231 | return ctx->Fog.ColorSumEnabled; |
| 1232 | |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 1233 | /* GL_ARB_multisample */ |
| 1234 | case GL_MULTISAMPLE_ARB: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1235 | CHECK_EXTENSION(ARB_multisample); |
| 1236 | return ctx->Multisample.Enabled; |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 1237 | case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1238 | CHECK_EXTENSION(ARB_multisample); |
| 1239 | return ctx->Multisample.SampleAlphaToCoverage; |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 1240 | case GL_SAMPLE_ALPHA_TO_ONE_ARB: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1241 | CHECK_EXTENSION(ARB_multisample); |
| 1242 | return ctx->Multisample.SampleAlphaToOne; |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 1243 | case GL_SAMPLE_COVERAGE_ARB: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1244 | CHECK_EXTENSION(ARB_multisample); |
| 1245 | return ctx->Multisample.SampleCoverage; |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 1246 | case GL_SAMPLE_COVERAGE_INVERT_ARB: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1247 | CHECK_EXTENSION(ARB_multisample); |
| 1248 | return ctx->Multisample.SampleCoverageInvert; |
Brian Paul | 736fcbe | 2001-05-29 15:23:48 +0000 | [diff] [blame] | 1249 | |
Brian Paul | 8c2f6c5 | 2001-06-26 01:32:48 +0000 | [diff] [blame] | 1250 | /* GL_IBM_rasterpos_clip */ |
| 1251 | case GL_RASTER_POSITION_UNCLIPPED_IBM: |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1252 | CHECK_EXTENSION(IBM_rasterpos_clip); |
| 1253 | return ctx->Transform.RasterPositionUnclipped; |
Brian Paul | 8c2f6c5 | 2001-06-26 01:32:48 +0000 | [diff] [blame] | 1254 | |
Brian Paul | 6c408b4 | 2002-05-27 17:04:52 +0000 | [diff] [blame] | 1255 | /* GL_NV_point_sprite */ |
| 1256 | case GL_POINT_SPRITE_NV: |
Roland Scheidegger | da16813 | 2006-03-02 12:06:57 +0000 | [diff] [blame] | 1257 | CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) |
Brian Paul | 6c408b4 | 2002-05-27 17:04:52 +0000 | [diff] [blame] | 1258 | return ctx->Point.PointSprite; |
Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame] | 1259 | |
Roland Scheidegger | 93da673 | 2006-03-01 23:11:14 +0000 | [diff] [blame] | 1260 | #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program |
Roland Scheidegger | da16813 | 2006-03-02 12:06:57 +0000 | [diff] [blame] | 1261 | case GL_VERTEX_PROGRAM_ARB: |
| 1262 | CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1263 | return ctx->VertexProgram.Enabled; |
Roland Scheidegger | da16813 | 2006-03-02 12:06:57 +0000 | [diff] [blame] | 1264 | case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: |
| 1265 | CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1266 | return ctx->VertexProgram.PointSizeEnabled; |
Roland Scheidegger | da16813 | 2006-03-02 12:06:57 +0000 | [diff] [blame] | 1267 | case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: |
| 1268 | CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1269 | return ctx->VertexProgram.TwoSideEnabled; |
Roland Scheidegger | 93da673 | 2006-03-01 23:11:14 +0000 | [diff] [blame] | 1270 | #endif |
| 1271 | #if FEATURE_NV_vertex_program |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1272 | case GL_VERTEX_ATTRIB_ARRAY0_NV: |
| 1273 | case GL_VERTEX_ATTRIB_ARRAY1_NV: |
| 1274 | case GL_VERTEX_ATTRIB_ARRAY2_NV: |
| 1275 | case GL_VERTEX_ATTRIB_ARRAY3_NV: |
| 1276 | case GL_VERTEX_ATTRIB_ARRAY4_NV: |
| 1277 | case GL_VERTEX_ATTRIB_ARRAY5_NV: |
| 1278 | case GL_VERTEX_ATTRIB_ARRAY6_NV: |
| 1279 | case GL_VERTEX_ATTRIB_ARRAY7_NV: |
| 1280 | case GL_VERTEX_ATTRIB_ARRAY8_NV: |
| 1281 | case GL_VERTEX_ATTRIB_ARRAY9_NV: |
| 1282 | case GL_VERTEX_ATTRIB_ARRAY10_NV: |
| 1283 | case GL_VERTEX_ATTRIB_ARRAY11_NV: |
| 1284 | case GL_VERTEX_ATTRIB_ARRAY12_NV: |
| 1285 | case GL_VERTEX_ATTRIB_ARRAY13_NV: |
| 1286 | case GL_VERTEX_ATTRIB_ARRAY14_NV: |
| 1287 | case GL_VERTEX_ATTRIB_ARRAY15_NV: |
| 1288 | CHECK_EXTENSION(NV_vertex_program); |
| 1289 | { |
| 1290 | GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1291 | return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0); |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1292 | } |
| 1293 | case GL_MAP1_VERTEX_ATTRIB0_4_NV: |
| 1294 | case GL_MAP1_VERTEX_ATTRIB1_4_NV: |
| 1295 | case GL_MAP1_VERTEX_ATTRIB2_4_NV: |
| 1296 | case GL_MAP1_VERTEX_ATTRIB3_4_NV: |
| 1297 | case GL_MAP1_VERTEX_ATTRIB4_4_NV: |
| 1298 | case GL_MAP1_VERTEX_ATTRIB5_4_NV: |
| 1299 | case GL_MAP1_VERTEX_ATTRIB6_4_NV: |
| 1300 | case GL_MAP1_VERTEX_ATTRIB7_4_NV: |
| 1301 | case GL_MAP1_VERTEX_ATTRIB8_4_NV: |
| 1302 | case GL_MAP1_VERTEX_ATTRIB9_4_NV: |
| 1303 | case GL_MAP1_VERTEX_ATTRIB10_4_NV: |
| 1304 | case GL_MAP1_VERTEX_ATTRIB11_4_NV: |
| 1305 | case GL_MAP1_VERTEX_ATTRIB12_4_NV: |
| 1306 | case GL_MAP1_VERTEX_ATTRIB13_4_NV: |
| 1307 | case GL_MAP1_VERTEX_ATTRIB14_4_NV: |
| 1308 | case GL_MAP1_VERTEX_ATTRIB15_4_NV: |
| 1309 | CHECK_EXTENSION(NV_vertex_program); |
Brian Paul | bc42c19 | 2002-01-05 21:53:20 +0000 | [diff] [blame] | 1310 | { |
| 1311 | const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); |
| 1312 | return ctx->Eval.Map1Attrib[map]; |
| 1313 | } |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1314 | case GL_MAP2_VERTEX_ATTRIB0_4_NV: |
| 1315 | case GL_MAP2_VERTEX_ATTRIB1_4_NV: |
| 1316 | case GL_MAP2_VERTEX_ATTRIB2_4_NV: |
| 1317 | case GL_MAP2_VERTEX_ATTRIB3_4_NV: |
| 1318 | case GL_MAP2_VERTEX_ATTRIB4_4_NV: |
| 1319 | case GL_MAP2_VERTEX_ATTRIB5_4_NV: |
| 1320 | case GL_MAP2_VERTEX_ATTRIB6_4_NV: |
| 1321 | case GL_MAP2_VERTEX_ATTRIB7_4_NV: |
| 1322 | case GL_MAP2_VERTEX_ATTRIB8_4_NV: |
| 1323 | case GL_MAP2_VERTEX_ATTRIB9_4_NV: |
| 1324 | case GL_MAP2_VERTEX_ATTRIB10_4_NV: |
| 1325 | case GL_MAP2_VERTEX_ATTRIB11_4_NV: |
| 1326 | case GL_MAP2_VERTEX_ATTRIB12_4_NV: |
| 1327 | case GL_MAP2_VERTEX_ATTRIB13_4_NV: |
| 1328 | case GL_MAP2_VERTEX_ATTRIB14_4_NV: |
| 1329 | case GL_MAP2_VERTEX_ATTRIB15_4_NV: |
| 1330 | CHECK_EXTENSION(NV_vertex_program); |
Brian Paul | bc42c19 | 2002-01-05 21:53:20 +0000 | [diff] [blame] | 1331 | { |
| 1332 | const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); |
| 1333 | return ctx->Eval.Map2Attrib[map]; |
| 1334 | } |
Brian Paul | 8dfc5b9 | 2002-10-16 17:57:51 +0000 | [diff] [blame] | 1335 | #endif /* FEATURE_NV_vertex_program */ |
Brian Paul | 86b8427 | 2001-12-14 02:50:01 +0000 | [diff] [blame] | 1336 | |
Brian Paul | 610d599 | 2003-01-14 04:55:45 +0000 | [diff] [blame] | 1337 | #if FEATURE_NV_fragment_program |
| 1338 | case GL_FRAGMENT_PROGRAM_NV: |
| 1339 | CHECK_EXTENSION(NV_fragment_program); |
| 1340 | return ctx->FragmentProgram.Enabled; |
| 1341 | #endif /* FEATURE_NV_fragment_program */ |
| 1342 | |
Brian Paul | 8afe7de | 2002-06-15 03:03:06 +0000 | [diff] [blame] | 1343 | /* GL_NV_texture_rectangle */ |
| 1344 | case GL_TEXTURE_RECTANGLE_NV: |
| 1345 | CHECK_EXTENSION(NV_texture_rectangle); |
| 1346 | { |
| 1347 | const struct gl_texture_unit *texUnit; |
| 1348 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1349 | return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE; |
| 1350 | } |
| 1351 | |
Brian Paul | 5f60a0b | 2002-09-06 02:56:08 +0000 | [diff] [blame] | 1352 | /* GL_EXT_stencil_two_side */ |
| 1353 | case GL_STENCIL_TEST_TWO_SIDE_EXT: |
| 1354 | CHECK_EXTENSION(EXT_stencil_two_side); |
| 1355 | return ctx->Stencil.TestTwoSide; |
| 1356 | |
Brian Paul | 77eec61 | 2003-04-18 01:56:11 +0000 | [diff] [blame] | 1357 | #if FEATURE_ARB_fragment_program |
| 1358 | case GL_FRAGMENT_PROGRAM_ARB: |
| 1359 | return ctx->FragmentProgram.Enabled; |
| 1360 | #endif /* FEATURE_ARB_fragment_program */ |
| 1361 | |
Brian Paul | e5b244f | 2003-04-21 15:02:17 +0000 | [diff] [blame] | 1362 | /* GL_EXT_depth_bounds_test */ |
| 1363 | case GL_DEPTH_BOUNDS_TEST_EXT: |
| 1364 | CHECK_EXTENSION(EXT_depth_bounds_test); |
| 1365 | return ctx->Depth.BoundsTest; |
| 1366 | |
Brian Paul | 08ff059 | 2003-07-21 04:22:40 +0000 | [diff] [blame] | 1367 | /* GL_MESA_program_debug */ |
| 1368 | case GL_FRAGMENT_PROGRAM_CALLBACK_MESA: |
| 1369 | CHECK_EXTENSION(MESA_program_debug); |
| 1370 | return ctx->FragmentProgram.CallbackEnabled; |
| 1371 | case GL_VERTEX_PROGRAM_CALLBACK_MESA: |
| 1372 | CHECK_EXTENSION(MESA_program_debug); |
| 1373 | return ctx->VertexProgram.CallbackEnabled; |
Dave Airlie | 7f752fe | 2004-12-19 03:06:59 +0000 | [diff] [blame] | 1374 | #if FEATURE_ATI_fragment_shader |
| 1375 | case GL_FRAGMENT_SHADER_ATI: |
| 1376 | CHECK_EXTENSION(ATI_fragment_shader); |
| 1377 | return ctx->ATIFragmentShader.Enabled; |
| 1378 | #endif /* FEATURE_ATI_fragment_shader */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1379 | default: |
Brian Paul | 4e9676f | 2002-06-29 19:48:15 +0000 | [diff] [blame] | 1380 | _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1381 | return GL_FALSE; |
| 1382 | } |
| 1383 | } |