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