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