| Keith Whitwell | f4b02d1 | 2001-01-05 05:31:42 +0000 | [diff] [blame^] | 1 | /* $Id: enable.c,v 1.39 2001/01/05 05:31:42 keithw Exp $ */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * Mesa 3-D graphics library |
| Brian Paul | eb326f5 | 2000-10-21 01:29:12 +0000 | [diff] [blame] | 5 | * Version: 3.5 |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 6 | * |
| Brian Paul | eb326f5 | 2000-10-21 01:29:12 +0000 | [diff] [blame] | 7 | * Copyright (C) 1999-2000 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 | |
| 41 | #include "math/m_matrix.h" |
| 42 | #include "math/m_xform.h" |
| 43 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 44 | #endif |
| 45 | |
| 46 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 47 | static void |
| 48 | client_state( GLcontext *ctx, GLenum cap, GLboolean state ) |
| 49 | { |
| 50 | GLuint flag; |
| 51 | GLboolean *var; |
| 52 | |
| 53 | switch (cap) { |
| 54 | case GL_VERTEX_ARRAY: |
| 55 | var = &ctx->Array.Vertex.Enabled; |
| 56 | flag = _NEW_ARRAY_VERTEX; |
| 57 | break; |
| 58 | case GL_NORMAL_ARRAY: |
| 59 | var = &ctx->Array.Normal.Enabled; |
| 60 | flag = _NEW_ARRAY_NORMAL; |
| 61 | break; |
| 62 | case GL_COLOR_ARRAY: |
| 63 | var = &ctx->Array.Color.Enabled; |
| 64 | flag = _NEW_ARRAY_COLOR; |
| 65 | break; |
| 66 | case GL_INDEX_ARRAY: |
| 67 | var = &ctx->Array.Index.Enabled; |
| 68 | flag = _NEW_ARRAY_INDEX; |
| 69 | break; |
| 70 | case GL_TEXTURE_COORD_ARRAY: |
| 71 | var = &ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled; |
| 72 | flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture); |
| 73 | break; |
| 74 | case GL_EDGE_FLAG_ARRAY: |
| 75 | var = &ctx->Array.EdgeFlag.Enabled; |
| 76 | flag = _NEW_ARRAY_EDGEFLAG; |
| 77 | break; |
| 78 | case GL_FOG_COORDINATE_ARRAY_EXT: |
| 79 | var = &ctx->Array.FogCoord.Enabled; |
| 80 | flag = _NEW_ARRAY_FOGCOORD; |
| 81 | break; |
| 82 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
| 83 | var = &ctx->Array.SecondaryColor.Enabled; |
| 84 | flag = _NEW_ARRAY_SECONDARYCOLOR; |
| 85 | break; |
| 86 | default: |
| 87 | gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" ); |
| Keith Whitwell | f4b02d1 | 2001-01-05 05:31:42 +0000 | [diff] [blame^] | 88 | return; |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | if (*var == flag) |
| 92 | return; |
| 93 | |
| 94 | FLUSH_VERTICES(ctx, _NEW_ARRAY); |
| 95 | ctx->Array.NewState |= flag; |
| 96 | *var = state; |
| 97 | |
| 98 | if (state) |
| 99 | ctx->Array._Enabled |= flag; |
| 100 | else |
| 101 | ctx->Array._Enabled &= ~flag; |
| 102 | |
| 103 | if (ctx->Driver.Enable) { |
| 104 | (*ctx->Driver.Enable)( ctx, cap, state ); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | |
| 109 | |
| 110 | void |
| 111 | _mesa_EnableClientState( GLenum cap ) |
| 112 | { |
| 113 | GET_CURRENT_CONTEXT(ctx); |
| 114 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 115 | client_state( ctx, cap, GL_TRUE ); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | |
| 120 | void |
| 121 | _mesa_DisableClientState( GLenum cap ) |
| 122 | { |
| 123 | GET_CURRENT_CONTEXT(ctx); |
| 124 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 125 | client_state( ctx, cap, GL_FALSE ); |
| 126 | } |
| 127 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 128 | |
| 129 | /* |
| 130 | * Perform glEnable and glDisable calls. |
| 131 | */ |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 132 | void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 133 | { |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 134 | if (MESA_VERBOSE & VERBOSE_API) |
| 135 | fprintf(stderr, "%s %s (newstate is %x)\n", |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 136 | state ? "glEnable" : "glDisable", |
| 137 | gl_lookup_enum_by_nr(cap), |
| 138 | ctx->NewState); |
| 139 | |
| 140 | switch (cap) { |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 141 | case GL_ALPHA_TEST: |
| 142 | if (ctx->Color.AlphaEnabled == state) |
| 143 | return; |
| 144 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 145 | ctx->Color.AlphaEnabled = state; |
| 146 | break; |
| 147 | case GL_AUTO_NORMAL: |
| 148 | if (ctx->Eval.AutoNormal == state) |
| 149 | return; |
| 150 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 151 | ctx->Eval.AutoNormal = state; |
| 152 | break; |
| 153 | case GL_BLEND: |
| 154 | if (ctx->Color.BlendEnabled == state) |
| 155 | return; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 156 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 157 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 158 | ctx->Color.BlendEnabled = state; |
| 159 | /* The following needed to accomodate 1.0 RGB logic op blending */ |
| 160 | ctx->Color.ColorLogicOpEnabled = |
| 161 | (ctx->Color.BlendEquation == GL_LOGIC_OP && state); |
| 162 | break; |
| 163 | case GL_CLIP_PLANE0: |
| 164 | case GL_CLIP_PLANE1: |
| 165 | case GL_CLIP_PLANE2: |
| 166 | case GL_CLIP_PLANE3: |
| 167 | case GL_CLIP_PLANE4: |
| 168 | case GL_CLIP_PLANE5: { |
| 169 | GLuint p = cap-GL_CLIP_PLANE0; |
| 170 | |
| 171 | if (ctx->Transform.ClipEnabled[p] == state) |
| 172 | return; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 173 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 174 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 175 | ctx->Transform.ClipEnabled[p] = state; |
| 176 | |
| 177 | if (state) { |
| 178 | ctx->_Enabled |= ENABLE_USERCLIP; |
| 179 | ctx->Transform._AnyClip++; |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 180 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 181 | if (ctx->ProjectionMatrix.flags & MAT_DIRTY) { |
| 182 | _math_matrix_analyse( &ctx->ProjectionMatrix ); |
| 183 | } |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 184 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 185 | /* This derived state also calculated in clip.c and |
| 186 | * from gl_update_state() on changes to EyeUserPlane |
| 187 | * and ctx->ProjectionMatrix respectively. |
| 188 | */ |
| 189 | gl_transform_vector( ctx->Transform._ClipUserPlane[p], |
| 190 | ctx->Transform.EyeUserPlane[p], |
| 191 | ctx->ProjectionMatrix.inv ); |
| 192 | } else { |
| 193 | if (--ctx->Transform._AnyClip == 0) |
| 194 | ctx->_Enabled &= ~ENABLE_USERCLIP; |
| 195 | } |
| 196 | } |
| 197 | break; |
| 198 | case GL_COLOR_MATERIAL: |
| 199 | if (ctx->Light.ColorMaterialEnabled == state) |
| 200 | return; |
| 201 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
| 202 | ctx->Light.ColorMaterialEnabled = state; |
| 203 | if (state) { |
| 204 | FLUSH_CURRENT(ctx, 0); |
| 205 | gl_update_color_material( ctx, ctx->Current.Color ); |
| 206 | } |
| 207 | break; |
| 208 | case GL_CULL_FACE: |
| 209 | if (ctx->Polygon.CullFlag == state) |
| 210 | return; |
| 211 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 212 | ctx->Polygon.CullFlag = state; |
| 213 | break; |
| 214 | case GL_DEPTH_TEST: |
| 215 | if (state && ctx->Visual.DepthBits==0) { |
| 216 | _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); |
| 217 | return; |
| 218 | } |
| 219 | if (ctx->Depth.Test==state) |
| 220 | return; |
| 221 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
| 222 | ctx->Depth.Test = state; |
| 223 | break; |
| 224 | case GL_DITHER: |
| 225 | if (ctx->NoDither) { |
| 226 | state = GL_FALSE; /* MESA_NO_DITHER env var */ |
| 227 | } |
| 228 | if (ctx->Color.DitherFlag==state) |
| 229 | return; |
| 230 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 231 | ctx->Color.DitherFlag = state; |
| 232 | break; |
| 233 | case GL_FOG: |
| 234 | if (ctx->Fog.Enabled==state) |
| 235 | return; |
| 236 | FLUSH_VERTICES(ctx, _NEW_FOG); |
| 237 | ctx->Fog.Enabled = state; |
| 238 | ctx->_Enabled ^= ENABLE_FOG; |
| 239 | break; |
| 240 | case GL_HISTOGRAM: |
| 241 | if (!ctx->Extensions.EXT_histogram) { |
| 242 | gl_error(ctx, GL_INVALID_ENUM, "enable GL_HISTOGRAM"); |
| 243 | return; |
| 244 | } |
| 245 | if (ctx->Pixel.HistogramEnabled == state) |
| 246 | return; |
| 247 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 248 | ctx->Pixel.HistogramEnabled = state; |
| 249 | break; |
| 250 | case GL_LIGHT0: |
| 251 | case GL_LIGHT1: |
| 252 | case GL_LIGHT2: |
| 253 | case GL_LIGHT3: |
| 254 | case GL_LIGHT4: |
| 255 | case GL_LIGHT5: |
| 256 | case GL_LIGHT6: |
| 257 | case GL_LIGHT7: |
| 258 | if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) |
| 259 | return; |
| 260 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
| 261 | ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; |
| 262 | if (state) { |
| 263 | insert_at_tail(&ctx->Light.EnabledList, |
| 264 | &ctx->Light.Light[cap-GL_LIGHT0]); |
| 265 | } |
| 266 | else { |
| 267 | remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); |
| 268 | } |
| 269 | break; |
| 270 | case GL_LIGHTING: |
| 271 | if (ctx->Light.Enabled == state) |
| 272 | return; |
| 273 | FLUSH_VERTICES(ctx, _NEW_LIGHT); |
| 274 | ctx->Light.Enabled = state; |
| 275 | ctx->_Enabled ^= ENABLE_LIGHT; |
| 276 | break; |
| 277 | case GL_LINE_SMOOTH: |
| 278 | if (ctx->Line.SmoothFlag == state) |
| 279 | return; |
| 280 | FLUSH_VERTICES(ctx, _NEW_LINE); |
| 281 | ctx->Line.SmoothFlag = state; |
| 282 | ctx->_TriangleCaps ^= DD_LINE_SMOOTH; |
| 283 | break; |
| 284 | case GL_LINE_STIPPLE: |
| 285 | if (ctx->Line.StippleFlag == state) |
| 286 | return; |
| 287 | FLUSH_VERTICES(ctx, _NEW_LINE); |
| 288 | ctx->Line.StippleFlag = state; |
| 289 | ctx->_TriangleCaps ^= DD_LINE_STIPPLE; |
| 290 | break; |
| 291 | case GL_INDEX_LOGIC_OP: |
| 292 | if (ctx->Color.IndexLogicOpEnabled == state) |
| 293 | return; |
| 294 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 295 | ctx->Color.IndexLogicOpEnabled = state; |
| 296 | break; |
| 297 | case GL_COLOR_LOGIC_OP: |
| 298 | if (ctx->Color.ColorLogicOpEnabled == state) |
| 299 | return; |
| 300 | FLUSH_VERTICES(ctx, _NEW_COLOR); |
| 301 | ctx->Color.ColorLogicOpEnabled = state; |
| 302 | break; |
| 303 | case GL_MAP1_COLOR_4: |
| 304 | if (ctx->Eval.Map1Color4 == state) |
| 305 | return; |
| 306 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 307 | ctx->Eval.Map1Color4 = state; |
| 308 | break; |
| 309 | case GL_MAP1_INDEX: |
| 310 | if (ctx->Eval.Map1Index == state) |
| 311 | return; |
| 312 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 313 | ctx->Eval.Map1Index = state; |
| 314 | break; |
| 315 | case GL_MAP1_NORMAL: |
| 316 | if (ctx->Eval.Map1Normal == state) |
| 317 | return; |
| 318 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 319 | ctx->Eval.Map1Normal = state; |
| 320 | break; |
| 321 | case GL_MAP1_TEXTURE_COORD_1: |
| 322 | if (ctx->Eval.Map1TextureCoord1 == state) |
| 323 | return; |
| 324 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 325 | ctx->Eval.Map1TextureCoord1 = state; |
| 326 | break; |
| 327 | case GL_MAP1_TEXTURE_COORD_2: |
| 328 | if (ctx->Eval.Map1TextureCoord2 == state) |
| 329 | return; |
| 330 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 331 | ctx->Eval.Map1TextureCoord2 = state; |
| 332 | break; |
| 333 | case GL_MAP1_TEXTURE_COORD_3: |
| 334 | if (ctx->Eval.Map1TextureCoord3 == state) |
| 335 | return; |
| 336 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 337 | ctx->Eval.Map1TextureCoord3 = state; |
| 338 | break; |
| 339 | case GL_MAP1_TEXTURE_COORD_4: |
| 340 | if (ctx->Eval.Map1TextureCoord4 == state) |
| 341 | return; |
| 342 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 343 | ctx->Eval.Map1TextureCoord4 = state; |
| 344 | break; |
| 345 | case GL_MAP1_VERTEX_3: |
| 346 | if (ctx->Eval.Map1Vertex3 == state) |
| 347 | return; |
| 348 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 349 | ctx->Eval.Map1Vertex3 = state; |
| 350 | break; |
| 351 | case GL_MAP1_VERTEX_4: |
| 352 | if (ctx->Eval.Map1Vertex4 == state) |
| 353 | return; |
| 354 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 355 | ctx->Eval.Map1Vertex4 = state; |
| 356 | break; |
| 357 | case GL_MAP2_COLOR_4: |
| 358 | if (ctx->Eval.Map2Color4 == state) |
| 359 | return; |
| 360 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 361 | ctx->Eval.Map2Color4 = state; |
| 362 | break; |
| 363 | case GL_MAP2_INDEX: |
| 364 | if (ctx->Eval.Map2Index == state) |
| 365 | return; |
| 366 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 367 | ctx->Eval.Map2Index = state; |
| 368 | break; |
| 369 | case GL_MAP2_NORMAL: |
| 370 | if (ctx->Eval.Map2Normal == state) |
| 371 | return; |
| 372 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 373 | ctx->Eval.Map2Normal = state; |
| 374 | break; |
| 375 | case GL_MAP2_TEXTURE_COORD_1: |
| 376 | if (ctx->Eval.Map2TextureCoord1 == state) |
| 377 | return; |
| 378 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 379 | ctx->Eval.Map2TextureCoord1 = state; |
| 380 | break; |
| 381 | case GL_MAP2_TEXTURE_COORD_2: |
| 382 | if (ctx->Eval.Map2TextureCoord2 == state) |
| 383 | return; |
| 384 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 385 | ctx->Eval.Map2TextureCoord2 = state; |
| 386 | break; |
| 387 | case GL_MAP2_TEXTURE_COORD_3: |
| 388 | if (ctx->Eval.Map2TextureCoord3 == state) |
| 389 | return; |
| 390 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 391 | ctx->Eval.Map2TextureCoord3 = state; |
| 392 | break; |
| 393 | case GL_MAP2_TEXTURE_COORD_4: |
| 394 | if (ctx->Eval.Map2TextureCoord4 == state) |
| 395 | return; |
| 396 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 397 | ctx->Eval.Map2TextureCoord4 = state; |
| 398 | break; |
| 399 | case GL_MAP2_VERTEX_3: |
| 400 | if (ctx->Eval.Map2Vertex3 == state) |
| 401 | return; |
| 402 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 403 | ctx->Eval.Map2Vertex3 = state; |
| 404 | break; |
| 405 | case GL_MAP2_VERTEX_4: |
| 406 | if (ctx->Eval.Map2Vertex4 == state) |
| 407 | return; |
| 408 | FLUSH_VERTICES(ctx, _NEW_EVAL); |
| 409 | ctx->Eval.Map2Vertex4 = state; |
| 410 | break; |
| 411 | case GL_MINMAX: |
| 412 | if (ctx->Pixel.MinMaxEnabled == state) |
| 413 | return; |
| 414 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 415 | ctx->Pixel.MinMaxEnabled = state; |
| 416 | break; |
| 417 | case GL_NORMALIZE: |
| 418 | if (ctx->Transform.Normalize == state) |
| 419 | return; |
| 420 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 421 | ctx->Transform.Normalize = state; |
| 422 | ctx->_Enabled ^= ENABLE_NORMALIZE; |
| 423 | break; |
| 424 | case GL_POINT_SMOOTH: |
| 425 | if (ctx->Point.SmoothFlag==state) |
| 426 | return; |
| 427 | FLUSH_VERTICES(ctx, _NEW_POINT); |
| 428 | ctx->Point.SmoothFlag = state; |
| 429 | ctx->_TriangleCaps ^= DD_POINT_SMOOTH; |
| 430 | break; |
| 431 | case GL_POLYGON_SMOOTH: |
| 432 | if (ctx->Polygon.SmoothFlag==state) |
| 433 | return; |
| 434 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 435 | ctx->Polygon.SmoothFlag = state; |
| 436 | ctx->_TriangleCaps ^= DD_TRI_SMOOTH; |
| 437 | break; |
| 438 | case GL_POLYGON_STIPPLE: |
| 439 | if (ctx->Polygon.StippleFlag==state) |
| 440 | return; |
| 441 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 442 | ctx->Polygon.StippleFlag = state; |
| 443 | ctx->_TriangleCaps ^= DD_TRI_STIPPLE; |
| 444 | break; |
| 445 | case GL_POLYGON_OFFSET_POINT: |
| 446 | if (ctx->Polygon.OffsetPoint==state) |
| 447 | return; |
| 448 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 449 | ctx->Polygon.OffsetPoint = state; |
| 450 | break; |
| 451 | case GL_POLYGON_OFFSET_LINE: |
| 452 | if (ctx->Polygon.OffsetLine==state) |
| 453 | return; |
| 454 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 455 | ctx->Polygon.OffsetLine = state; |
| 456 | break; |
| 457 | case GL_POLYGON_OFFSET_FILL: |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 458 | /*case GL_POLYGON_OFFSET_EXT:*/ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 459 | if (ctx->Polygon.OffsetFill==state) |
| 460 | return; |
| 461 | FLUSH_VERTICES(ctx, _NEW_POLYGON); |
| 462 | ctx->Polygon.OffsetFill = state; |
| 463 | break; |
| 464 | case GL_RESCALE_NORMAL_EXT: |
| 465 | if (ctx->Transform.RescaleNormals == state) |
| 466 | return; |
| 467 | FLUSH_VERTICES(ctx, _NEW_TRANSFORM); |
| 468 | ctx->Transform.RescaleNormals = state; |
| 469 | ctx->_Enabled ^= ENABLE_RESCALE; |
| 470 | break; |
| 471 | case GL_SCISSOR_TEST: |
| 472 | if (ctx->Scissor.Enabled==state) |
| 473 | return; |
| 474 | FLUSH_VERTICES(ctx, _NEW_SCISSOR); |
| 475 | ctx->Scissor.Enabled = state; |
| 476 | break; |
| 477 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
| 478 | if (ctx->Texture.SharedPalette == state) |
| 479 | return; |
| 480 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 481 | ctx->Texture.SharedPalette = state; |
| 482 | break; |
| 483 | case GL_STENCIL_TEST: |
| 484 | if (state && ctx->Visual.StencilBits==0) { |
| 485 | _mesa_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer"); |
| 486 | return; |
| 487 | } |
| 488 | if (ctx->Stencil.Enabled==state) |
| 489 | return; |
| 490 | FLUSH_VERTICES(ctx, _NEW_STENCIL); |
| 491 | ctx->Stencil.Enabled = state; |
| 492 | ctx->_TriangleCaps ^= DD_STENCIL; |
| 493 | break; |
| 494 | case GL_TEXTURE_1D: { |
| 495 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 496 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| 497 | GLuint newenabled = texUnit->Enabled & ~TEXTURE0_1D; |
| 498 | if (state) |
| 499 | newenabled |= TEXTURE0_1D; |
| 500 | if (!ctx->Visual.RGBAflag || texUnit->Enabled == newenabled) |
| 501 | return; |
| 502 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 503 | texUnit->Enabled = newenabled; |
| 504 | break; |
| 505 | } |
| 506 | case GL_TEXTURE_2D: { |
| 507 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 508 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| 509 | GLuint newenabled = texUnit->Enabled & ~TEXTURE0_2D; |
| 510 | if (state) |
| 511 | newenabled |= TEXTURE0_2D; |
| 512 | if (!ctx->Visual.RGBAflag || texUnit->Enabled == newenabled) |
| 513 | return; |
| 514 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 515 | texUnit->Enabled = newenabled; |
| 516 | break; |
| 517 | } |
| 518 | case GL_TEXTURE_3D: { |
| 519 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 520 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| 521 | GLuint newenabled = texUnit->Enabled & ~TEXTURE0_3D; |
| 522 | if (state) |
| 523 | newenabled |= TEXTURE0_3D; |
| 524 | if (!ctx->Visual.RGBAflag || texUnit->Enabled == newenabled) |
| 525 | return; |
| 526 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 527 | texUnit->Enabled = newenabled; |
| 528 | break; |
| 529 | } |
| 530 | case GL_TEXTURE_GEN_Q: { |
| 531 | GLuint unit = ctx->Texture.CurrentUnit; |
| 532 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 533 | GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; |
| 534 | if (state) |
| 535 | newenabled |= Q_BIT; |
| 536 | if (texUnit->TexGenEnabled == newenabled) |
| 537 | return; |
| 538 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 539 | texUnit->TexGenEnabled = newenabled; |
| 540 | break; |
| 541 | } |
| 542 | case GL_TEXTURE_GEN_R: { |
| 543 | GLuint unit = ctx->Texture.CurrentUnit; |
| 544 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 545 | GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; |
| 546 | if (state) |
| 547 | newenabled |= R_BIT; |
| 548 | if (texUnit->TexGenEnabled == newenabled) |
| 549 | return; |
| 550 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 551 | texUnit->TexGenEnabled = newenabled; |
| 552 | break; |
| 553 | } |
| 554 | break; |
| 555 | case GL_TEXTURE_GEN_S: { |
| 556 | GLuint unit = ctx->Texture.CurrentUnit; |
| 557 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 558 | GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; |
| 559 | if (state) |
| 560 | newenabled |= S_BIT; |
| 561 | if (texUnit->TexGenEnabled == newenabled) |
| 562 | return; |
| 563 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 564 | texUnit->TexGenEnabled = newenabled; |
| 565 | break; |
| 566 | } |
| 567 | break; |
| 568 | case GL_TEXTURE_GEN_T: { |
| 569 | GLuint unit = ctx->Texture.CurrentUnit; |
| 570 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
| 571 | GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; |
| 572 | if (state) |
| 573 | newenabled |= T_BIT; |
| 574 | if (texUnit->TexGenEnabled == newenabled) |
| 575 | return; |
| 576 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 577 | texUnit->TexGenEnabled = newenabled; |
| 578 | break; |
| 579 | } |
| 580 | break; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 581 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 582 | /* |
| 583 | * CLIENT STATE!!! |
| 584 | */ |
| 585 | case GL_VERTEX_ARRAY: |
| 586 | case GL_NORMAL_ARRAY: |
| 587 | case GL_COLOR_ARRAY: |
| 588 | case GL_INDEX_ARRAY: |
| 589 | case GL_TEXTURE_COORD_ARRAY: |
| 590 | case GL_EDGE_FLAG_ARRAY: |
| 591 | case GL_FOG_COORDINATE_ARRAY_EXT: |
| 592 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
| 593 | client_state( ctx, cap, state ); |
| 594 | return; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 595 | |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 596 | /* GL_HP_occlusion_test */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 597 | case GL_OCCLUSION_TEST_HP: |
| 598 | if (!ctx->Extensions.HP_occlusion_test) { |
| 599 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 600 | return; |
| 601 | } |
| 602 | if (ctx->Depth.OcclusionTest == state) |
| 603 | return; |
| 604 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
| 605 | ctx->Depth.OcclusionTest = state; |
| 606 | if (state) |
| 607 | ctx->OcclusionResult = ctx->OcclusionResultSaved; |
| 608 | else |
| 609 | ctx->OcclusionResultSaved = ctx->OcclusionResult; |
| 610 | break; |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 611 | |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 612 | /* GL_SGIS_pixel_texture */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 613 | case GL_PIXEL_TEXTURE_SGIS: |
| 614 | if (!ctx->Extensions.SGIS_pixel_texture) { |
| 615 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 616 | return; |
| 617 | } |
| 618 | if (ctx->Pixel.PixelTextureEnabled == state) |
| 619 | return; |
| 620 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 621 | ctx->Pixel.PixelTextureEnabled = state; |
| 622 | break; |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 623 | |
| 624 | /* GL_SGIX_pixel_texture */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 625 | case GL_PIXEL_TEX_GEN_SGIX: |
| 626 | if (!ctx->Extensions.SGIX_pixel_texture) { |
| 627 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 628 | return; |
| 629 | } |
| 630 | if (ctx->Pixel.PixelTextureEnabled == state) |
| 631 | return; |
| 632 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 633 | ctx->Pixel.PixelTextureEnabled = state; |
| 634 | break; |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 635 | |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 636 | /* GL_SGI_color_table */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 637 | case GL_COLOR_TABLE_SGI: |
| 638 | if (!ctx->Extensions.SGI_color_table) { |
| 639 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 640 | return; |
| 641 | } |
| 642 | if (ctx->Pixel.ColorTableEnabled == state) |
| 643 | return; |
| 644 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 645 | ctx->Pixel.ColorTableEnabled = state; |
| 646 | break; |
| 647 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
| 648 | if (!ctx->Extensions.SGI_color_table) { |
| 649 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 650 | return; |
| 651 | } |
| 652 | if (ctx->Pixel.PostConvolutionColorTableEnabled == state) |
| 653 | return; |
| 654 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 655 | ctx->Pixel.PostConvolutionColorTableEnabled = state; |
| 656 | break; |
| 657 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
| 658 | if (!ctx->Extensions.SGI_color_table) { |
| 659 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 660 | return; |
| 661 | } |
| 662 | if (ctx->Pixel.PostColorMatrixColorTableEnabled == state) |
| 663 | return; |
| 664 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 665 | ctx->Pixel.PostColorMatrixColorTableEnabled = state; |
| 666 | break; |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 667 | |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 668 | /* GL_EXT_convolution */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 669 | case GL_CONVOLUTION_1D: |
| 670 | if (!ctx->Extensions.EXT_convolution) { |
| 671 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 672 | return; |
| 673 | } |
| 674 | if (ctx->Pixel.Convolution1DEnabled == state) |
| 675 | return; |
| 676 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 677 | ctx->Pixel.Convolution1DEnabled = state; |
| 678 | break; |
| 679 | case GL_CONVOLUTION_2D: |
| 680 | if (!ctx->Extensions.EXT_convolution) { |
| 681 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 682 | return; |
| 683 | } |
| 684 | if (ctx->Pixel.Convolution2DEnabled == state) |
| 685 | return; |
| 686 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 687 | ctx->Pixel.Convolution2DEnabled = state; |
| 688 | break; |
| 689 | case GL_SEPARABLE_2D: |
| 690 | if (!ctx->Extensions.EXT_convolution) { |
| 691 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 692 | return; |
| 693 | } |
| 694 | if (ctx->Pixel.Separable2DEnabled == state) |
| 695 | return; |
| 696 | FLUSH_VERTICES(ctx, _NEW_PIXEL); |
| 697 | ctx->Pixel.Separable2DEnabled = state; |
| 698 | break; |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 699 | |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 700 | /* GL_ARB_texture_cube_map */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 701 | case GL_TEXTURE_CUBE_MAP_ARB: { |
| 702 | const GLuint curr = ctx->Texture.CurrentUnit; |
| 703 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| 704 | GLuint newenabled = texUnit->Enabled & ~TEXTURE0_CUBE; |
| 705 | if (state) |
| 706 | newenabled |= TEXTURE0_CUBE; |
| 707 | if (!ctx->Extensions.ARB_texture_cube_map) { |
| 708 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 709 | return; |
| 710 | } |
| 711 | if (!ctx->Visual.RGBAflag || texUnit->Enabled == newenabled) |
| 712 | return; |
| 713 | FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
| 714 | texUnit->Enabled = newenabled; |
| 715 | break; |
| 716 | } |
| Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 717 | /* GL_EXT_secondary_color */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 718 | case GL_COLOR_SUM_EXT: |
| 719 | if (!ctx->Extensions.EXT_secondary_color) { |
| 720 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 721 | return; |
| 722 | } |
| 723 | if (ctx->Fog.ColorSumEnabled == state) |
| 724 | return; |
| 725 | FLUSH_VERTICES(ctx, _NEW_FOG); |
| 726 | ctx->Fog.ColorSumEnabled = state; |
| 727 | ctx->_TriangleCaps ^= DD_SEPERATE_SPECULAR; |
| 728 | break; |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame] | 729 | |
| 730 | /* GL_MESA_sprite_point */ |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 731 | case GL_SPRITE_POINT_MESA: |
| 732 | if (!ctx->Extensions.MESA_sprite_point) { |
| 733 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 734 | return; |
| 735 | } |
| 736 | if (ctx->Point.SpriteMode == state) |
| 737 | return; |
| 738 | FLUSH_VERTICES(ctx, _NEW_POINT); |
| 739 | ctx->Point.SpriteMode = state; |
| 740 | break; |
| Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 741 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 742 | default: |
| 743 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 744 | return; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | if (ctx->Driver.Enable) { |
| 748 | (*ctx->Driver.Enable)( ctx, cap, state ); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | |
| 753 | |
| 754 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 755 | void |
| 756 | _mesa_Enable( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 757 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 758 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | 376d022 | 2000-12-27 22:52:45 +0000 | [diff] [blame] | 759 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 760 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 761 | _mesa_set_enable( ctx, cap, GL_TRUE ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 762 | } |
| 763 | |
| 764 | |
| 765 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 766 | void |
| 767 | _mesa_Disable( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 768 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 769 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | 376d022 | 2000-12-27 22:52:45 +0000 | [diff] [blame] | 770 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 771 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 772 | _mesa_set_enable( ctx, cap, GL_FALSE ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 773 | } |
| 774 | |
| 775 | |
| 776 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 777 | GLboolean |
| 778 | _mesa_IsEnabled( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 779 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 780 | GET_CURRENT_CONTEXT(ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 781 | switch (cap) { |
| 782 | case GL_ALPHA_TEST: |
| 783 | return ctx->Color.AlphaEnabled; |
| 784 | case GL_AUTO_NORMAL: |
| 785 | return ctx->Eval.AutoNormal; |
| 786 | case GL_BLEND: |
| 787 | return ctx->Color.BlendEnabled; |
| 788 | case GL_CLIP_PLANE0: |
| 789 | case GL_CLIP_PLANE1: |
| 790 | case GL_CLIP_PLANE2: |
| 791 | case GL_CLIP_PLANE3: |
| 792 | case GL_CLIP_PLANE4: |
| 793 | case GL_CLIP_PLANE5: |
| 794 | return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0]; |
| 795 | case GL_COLOR_MATERIAL: |
| 796 | return ctx->Light.ColorMaterialEnabled; |
| 797 | case GL_CULL_FACE: |
| 798 | return ctx->Polygon.CullFlag; |
| 799 | case GL_DEPTH_TEST: |
| 800 | return ctx->Depth.Test; |
| 801 | case GL_DITHER: |
| 802 | return ctx->Color.DitherFlag; |
| 803 | case GL_FOG: |
| 804 | return ctx->Fog.Enabled; |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 805 | case GL_HISTOGRAM: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 806 | if (ctx->Extensions.EXT_histogram) { |
| Brian Paul | 8e05391 | 2000-08-30 18:21:06 +0000 | [diff] [blame] | 807 | return ctx->Pixel.HistogramEnabled; |
| 808 | } |
| 809 | else { |
| 810 | gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); |
| 811 | return GL_FALSE; |
| 812 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 813 | case GL_LIGHTING: |
| 814 | return ctx->Light.Enabled; |
| 815 | case GL_LIGHT0: |
| 816 | case GL_LIGHT1: |
| 817 | case GL_LIGHT2: |
| 818 | case GL_LIGHT3: |
| 819 | case GL_LIGHT4: |
| 820 | case GL_LIGHT5: |
| 821 | case GL_LIGHT6: |
| 822 | case GL_LIGHT7: |
| 823 | return ctx->Light.Light[cap-GL_LIGHT0].Enabled; |
| 824 | case GL_LINE_SMOOTH: |
| 825 | return ctx->Line.SmoothFlag; |
| 826 | case GL_LINE_STIPPLE: |
| 827 | return ctx->Line.StippleFlag; |
| 828 | case GL_INDEX_LOGIC_OP: |
| 829 | return ctx->Color.IndexLogicOpEnabled; |
| 830 | case GL_COLOR_LOGIC_OP: |
| 831 | return ctx->Color.ColorLogicOpEnabled; |
| 832 | case GL_MAP1_COLOR_4: |
| 833 | return ctx->Eval.Map1Color4; |
| 834 | case GL_MAP1_INDEX: |
| 835 | return ctx->Eval.Map1Index; |
| 836 | case GL_MAP1_NORMAL: |
| 837 | return ctx->Eval.Map1Normal; |
| 838 | case GL_MAP1_TEXTURE_COORD_1: |
| 839 | return ctx->Eval.Map1TextureCoord1; |
| 840 | case GL_MAP1_TEXTURE_COORD_2: |
| 841 | return ctx->Eval.Map1TextureCoord2; |
| 842 | case GL_MAP1_TEXTURE_COORD_3: |
| 843 | return ctx->Eval.Map1TextureCoord3; |
| 844 | case GL_MAP1_TEXTURE_COORD_4: |
| 845 | return ctx->Eval.Map1TextureCoord4; |
| 846 | case GL_MAP1_VERTEX_3: |
| 847 | return ctx->Eval.Map1Vertex3; |
| 848 | case GL_MAP1_VERTEX_4: |
| 849 | return ctx->Eval.Map1Vertex4; |
| 850 | case GL_MAP2_COLOR_4: |
| 851 | return ctx->Eval.Map2Color4; |
| 852 | case GL_MAP2_INDEX: |
| 853 | return ctx->Eval.Map2Index; |
| 854 | case GL_MAP2_NORMAL: |
| 855 | return ctx->Eval.Map2Normal; |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 856 | case GL_MAP2_TEXTURE_COORD_1: |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 857 | return ctx->Eval.Map2TextureCoord1; |
| 858 | case GL_MAP2_TEXTURE_COORD_2: |
| 859 | return ctx->Eval.Map2TextureCoord2; |
| 860 | case GL_MAP2_TEXTURE_COORD_3: |
| 861 | return ctx->Eval.Map2TextureCoord3; |
| 862 | case GL_MAP2_TEXTURE_COORD_4: |
| 863 | return ctx->Eval.Map2TextureCoord4; |
| 864 | case GL_MAP2_VERTEX_3: |
| 865 | return ctx->Eval.Map2Vertex3; |
| 866 | case GL_MAP2_VERTEX_4: |
| 867 | return ctx->Eval.Map2Vertex4; |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 868 | case GL_MINMAX: |
| 869 | return ctx->Pixel.MinMaxEnabled; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 870 | case GL_NORMALIZE: |
| 871 | return ctx->Transform.Normalize; |
| 872 | case GL_POINT_SMOOTH: |
| 873 | return ctx->Point.SmoothFlag; |
| 874 | case GL_POLYGON_SMOOTH: |
| 875 | return ctx->Polygon.SmoothFlag; |
| 876 | case GL_POLYGON_STIPPLE: |
| 877 | return ctx->Polygon.StippleFlag; |
| 878 | case GL_POLYGON_OFFSET_POINT: |
| 879 | return ctx->Polygon.OffsetPoint; |
| 880 | case GL_POLYGON_OFFSET_LINE: |
| 881 | return ctx->Polygon.OffsetLine; |
| 882 | case GL_POLYGON_OFFSET_FILL: |
| 883 | /*case GL_POLYGON_OFFSET_EXT:*/ |
| 884 | return ctx->Polygon.OffsetFill; |
| 885 | case GL_RESCALE_NORMAL_EXT: |
| 886 | return ctx->Transform.RescaleNormals; |
| 887 | case GL_SCISSOR_TEST: |
| 888 | return ctx->Scissor.Enabled; |
| 889 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
| 890 | return ctx->Texture.SharedPalette; |
| 891 | case GL_STENCIL_TEST: |
| 892 | return ctx->Stencil.Enabled; |
| 893 | case GL_TEXTURE_1D: |
| 894 | { |
| 895 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 896 | return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE; |
| 897 | } |
| 898 | case GL_TEXTURE_2D: |
| 899 | { |
| 900 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 901 | return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE; |
| 902 | } |
| 903 | case GL_TEXTURE_3D: |
| 904 | { |
| 905 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 65b5e1e | 1999-08-19 13:24:27 +0000 | [diff] [blame] | 906 | return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 907 | } |
| 908 | case GL_TEXTURE_GEN_Q: |
| 909 | { |
| 910 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 911 | return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; |
| 912 | } |
| 913 | case GL_TEXTURE_GEN_R: |
| 914 | { |
| 915 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 916 | return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; |
| 917 | } |
| 918 | case GL_TEXTURE_GEN_S: |
| 919 | { |
| 920 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 921 | return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; |
| 922 | } |
| 923 | case GL_TEXTURE_GEN_T: |
| 924 | { |
| 925 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 926 | return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; |
| 927 | } |
| 928 | |
| 929 | /* |
| 930 | * CLIENT STATE!!! |
| 931 | */ |
| 932 | case GL_VERTEX_ARRAY: |
| 933 | return ctx->Array.Vertex.Enabled; |
| 934 | case GL_NORMAL_ARRAY: |
| 935 | return ctx->Array.Normal.Enabled; |
| 936 | case GL_COLOR_ARRAY: |
| 937 | return ctx->Array.Color.Enabled; |
| 938 | case GL_INDEX_ARRAY: |
| 939 | return ctx->Array.Index.Enabled; |
| 940 | case GL_TEXTURE_COORD_ARRAY: |
| Brian Paul | 45224fa | 1999-09-07 22:31:30 +0000 | [diff] [blame] | 941 | return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 942 | case GL_EDGE_FLAG_ARRAY: |
| 943 | return ctx->Array.EdgeFlag.Enabled; |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 944 | |
| 945 | /* GL_HP_occlusion_test */ |
| 946 | case GL_OCCLUSION_TEST_HP: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 947 | if (ctx->Extensions.HP_occlusion_test) { |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 948 | return ctx->Depth.OcclusionTest; |
| 949 | } |
| 950 | else { |
| 951 | gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); |
| 952 | return GL_FALSE; |
| 953 | } |
| 954 | |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 955 | /* GL_SGIS_pixel_texture */ |
| 956 | case GL_PIXEL_TEXTURE_SGIS: |
| 957 | return ctx->Pixel.PixelTextureEnabled; |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 958 | |
| 959 | /* GL_SGIX_pixel_texture */ |
| 960 | case GL_PIXEL_TEX_GEN_SGIX: |
| 961 | return ctx->Pixel.PixelTextureEnabled; |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 962 | |
| 963 | /* GL_SGI_color_table */ |
| 964 | case GL_COLOR_TABLE_SGI: |
| 965 | return ctx->Pixel.ColorTableEnabled; |
| 966 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
| 967 | return ctx->Pixel.PostConvolutionColorTableEnabled; |
| 968 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
| 969 | return ctx->Pixel.PostColorMatrixColorTableEnabled; |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 970 | |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 971 | /* GL_EXT_convolution */ |
| 972 | case GL_CONVOLUTION_1D: |
| 973 | return ctx->Pixel.Convolution1DEnabled; |
| 974 | case GL_CONVOLUTION_2D: |
| 975 | return ctx->Pixel.Convolution2DEnabled; |
| 976 | case GL_SEPARABLE_2D: |
| 977 | return ctx->Pixel.Separable2DEnabled; |
| 978 | |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 979 | /* GL_ARB_texture_cube_map */ |
| 980 | case GL_TEXTURE_CUBE_MAP_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 981 | if (ctx->Extensions.ARB_texture_cube_map) { |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 982 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 983 | return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE; |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 984 | } |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 985 | else { |
| 986 | gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); |
| 987 | return GL_FALSE; |
| 988 | } |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 989 | |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame] | 990 | /* GL_MESA_sprite_point */ |
| 991 | case GL_SPRITE_POINT_MESA: |
| 992 | return ctx->Point.SpriteMode; |
| 993 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 994 | default: |
| 995 | gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); |
| 996 | return GL_FALSE; |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1003 | |
| 1004 | |
| 1005 | |