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