| 1 | /* $Id: enable.c,v 1.3 2000-05-23 20:40:32 jeroen Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Mesa 3-D graphics library | 
|---|
| 5 | * Version:  3.3 | 
|---|
| 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 | /* $XFree86: xc/lib/GL/mesa/src/enable.c,v 1.3 1999/04/04 00:20:23 dawes Exp $ */ | 
|---|
| 29 |  | 
|---|
| 30 | #ifdef PC_HEADER | 
|---|
| 31 | #include "all.h" | 
|---|
| 32 | #else | 
|---|
| 33 | #include "glheader.h" | 
|---|
| 34 | #include "types.h" | 
|---|
| 35 | #include "context.h" | 
|---|
| 36 | #include "enable.h" | 
|---|
| 37 | #include "light.h" | 
|---|
| 38 | #include "macros.h" | 
|---|
| 39 | #include "matrix.h" | 
|---|
| 40 | #include "mmath.h" | 
|---|
| 41 | #include "simple_list.h" | 
|---|
| 42 | #include "vbfill.h" | 
|---|
| 43 | #include "xform.h" | 
|---|
| 44 | #include "enums.h" | 
|---|
| 45 | #endif | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | /* | 
|---|
| 50 | * Perform glEnable and glDisable calls. | 
|---|
| 51 | */ | 
|---|
| 52 | void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) | 
|---|
| 53 | { | 
|---|
| 54 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" ); | 
|---|
| 55 |  | 
|---|
| 56 | if (MESA_VERBOSE & VERBOSE_API) | 
|---|
| 57 | fprintf(stderr, "%s %s (newstate is %x)\n", | 
|---|
| 58 | state ? "glEnable" : "glDisable", | 
|---|
| 59 | gl_lookup_enum_by_nr(cap), | 
|---|
| 60 | ctx->NewState); | 
|---|
| 61 |  | 
|---|
| 62 | switch (cap) { | 
|---|
| 63 | case GL_ALPHA_TEST: | 
|---|
| 64 | if (ctx->Color.AlphaEnabled!=state) { | 
|---|
| 65 | ctx->Color.AlphaEnabled = state; | 
|---|
| 66 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 67 | } | 
|---|
| 68 | break; | 
|---|
| 69 | case GL_AUTO_NORMAL: | 
|---|
| 70 | ctx->Eval.AutoNormal = state; | 
|---|
| 71 | break; | 
|---|
| 72 | case GL_BLEND: | 
|---|
| 73 | if (ctx->Color.BlendEnabled!=state) { | 
|---|
| 74 | ctx->Color.BlendEnabled = state; | 
|---|
| 75 | /* The following needed to accomodate 1.0 RGB logic op blending */ | 
|---|
| 76 | if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) { | 
|---|
| 77 | ctx->Color.ColorLogicOpEnabled = GL_TRUE; | 
|---|
| 78 | } | 
|---|
| 79 | else { | 
|---|
| 80 | ctx->Color.ColorLogicOpEnabled = GL_FALSE; | 
|---|
| 81 | } | 
|---|
| 82 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 83 | } | 
|---|
| 84 | break; | 
|---|
| 85 | case GL_CLIP_PLANE0: | 
|---|
| 86 | case GL_CLIP_PLANE1: | 
|---|
| 87 | case GL_CLIP_PLANE2: | 
|---|
| 88 | case GL_CLIP_PLANE3: | 
|---|
| 89 | case GL_CLIP_PLANE4: | 
|---|
| 90 | case GL_CLIP_PLANE5: | 
|---|
| 91 | if (cap >= GL_CLIP_PLANE0 && | 
|---|
| 92 | cap <= GL_CLIP_PLANE5 && | 
|---|
| 93 | ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] != state) | 
|---|
| 94 | { | 
|---|
| 95 | GLuint p = cap-GL_CLIP_PLANE0; | 
|---|
| 96 |  | 
|---|
| 97 | ctx->Transform.ClipEnabled[p] = state; | 
|---|
| 98 | ctx->NewState |= NEW_USER_CLIP; | 
|---|
| 99 |  | 
|---|
| 100 | if (state) { | 
|---|
| 101 | ctx->Enabled |= ENABLE_USERCLIP; | 
|---|
| 102 | ctx->Transform.AnyClip++; | 
|---|
| 103 |  | 
|---|
| 104 | if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) { | 
|---|
| 105 | gl_matrix_analyze( &ctx->ProjectionMatrix ); | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 | gl_transform_vector( ctx->Transform.ClipUserPlane[p], | 
|---|
| 109 | ctx->Transform.EyeUserPlane[p], | 
|---|
| 110 | ctx->ProjectionMatrix.inv ); | 
|---|
| 111 | } else { | 
|---|
| 112 | if (--ctx->Transform.AnyClip == 0) | 
|---|
| 113 | ctx->Enabled &= ~ENABLE_USERCLIP; | 
|---|
| 114 | } | 
|---|
| 115 | } | 
|---|
| 116 | break; | 
|---|
| 117 | case GL_COLOR_MATERIAL: | 
|---|
| 118 | if (ctx->Light.ColorMaterialEnabled!=state) { | 
|---|
| 119 | ctx->Light.ColorMaterialEnabled = state; | 
|---|
| 120 | ctx->NewState |= NEW_LIGHTING; | 
|---|
| 121 | if (state) | 
|---|
| 122 | gl_update_color_material( ctx, ctx->Current.ByteColor ); | 
|---|
| 123 | } | 
|---|
| 124 | break; | 
|---|
| 125 | case GL_CULL_FACE: | 
|---|
| 126 | if (ctx->Polygon.CullFlag!=state) { | 
|---|
| 127 | ctx->Polygon.CullFlag = state; | 
|---|
| 128 | ctx->TriangleCaps ^= DD_TRI_CULL; | 
|---|
| 129 | ctx->NewState |= NEW_POLYGON; | 
|---|
| 130 | } | 
|---|
| 131 | break; | 
|---|
| 132 | case GL_DEPTH_TEST: | 
|---|
| 133 | if (state && ctx->Visual->DepthBits==0) { | 
|---|
| 134 | gl_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); | 
|---|
| 135 | return; | 
|---|
| 136 | } | 
|---|
| 137 | if (ctx->Depth.Test!=state) { | 
|---|
| 138 | ctx->Depth.Test = state; | 
|---|
| 139 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 140 | } | 
|---|
| 141 | break; | 
|---|
| 142 | case GL_DITHER: | 
|---|
| 143 | if (ctx->NoDither) { | 
|---|
| 144 | /* MESA_NO_DITHER env var */ | 
|---|
| 145 | state = GL_FALSE; | 
|---|
| 146 | } | 
|---|
| 147 | if (ctx->Color.DitherFlag!=state) { | 
|---|
| 148 | ctx->Color.DitherFlag = state; | 
|---|
| 149 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 150 | } | 
|---|
| 151 | break; | 
|---|
| 152 | case GL_FOG: | 
|---|
| 153 | if (ctx->Fog.Enabled!=state) { | 
|---|
| 154 | ctx->Fog.Enabled = state; | 
|---|
| 155 | ctx->Enabled ^= ENABLE_FOG; | 
|---|
| 156 | ctx->NewState |= NEW_FOG|NEW_RASTER_OPS; | 
|---|
| 157 | } | 
|---|
| 158 | break; | 
|---|
| 159 | case GL_LIGHT0: | 
|---|
| 160 | case GL_LIGHT1: | 
|---|
| 161 | case GL_LIGHT2: | 
|---|
| 162 | case GL_LIGHT3: | 
|---|
| 163 | case GL_LIGHT4: | 
|---|
| 164 | case GL_LIGHT5: | 
|---|
| 165 | case GL_LIGHT6: | 
|---|
| 166 | case GL_LIGHT7: | 
|---|
| 167 | if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state) | 
|---|
| 168 | { | 
|---|
| 169 | ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; | 
|---|
| 170 |  | 
|---|
| 171 | if (state) { | 
|---|
| 172 | insert_at_tail(&ctx->Light.EnabledList, | 
|---|
| 173 | &ctx->Light.Light[cap-GL_LIGHT0]); | 
|---|
| 174 | if (ctx->Light.Enabled) | 
|---|
| 175 | ctx->Enabled |= ENABLE_LIGHT; | 
|---|
| 176 | } else { | 
|---|
| 177 | remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); | 
|---|
| 178 | if (is_empty_list(&ctx->Light.EnabledList)) | 
|---|
| 179 | ctx->Enabled &= ~ENABLE_LIGHT; | 
|---|
| 180 | } | 
|---|
| 181 |  | 
|---|
| 182 | ctx->NewState |= NEW_LIGHTING; | 
|---|
| 183 | } | 
|---|
| 184 | break; | 
|---|
| 185 | case GL_LIGHTING: | 
|---|
| 186 | if (ctx->Light.Enabled!=state) { | 
|---|
| 187 | ctx->Light.Enabled = state; | 
|---|
| 188 | ctx->Enabled &= ~ENABLE_LIGHT; | 
|---|
| 189 | if (state) | 
|---|
| 190 | ctx->Enabled |= ENABLE_LIGHT; | 
|---|
| 191 | ctx->NewState |= NEW_LIGHTING; | 
|---|
| 192 | } | 
|---|
| 193 | break; | 
|---|
| 194 | case GL_LINE_SMOOTH: | 
|---|
| 195 | if (ctx->Line.SmoothFlag!=state) { | 
|---|
| 196 | ctx->Line.SmoothFlag = state; | 
|---|
| 197 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 198 | } | 
|---|
| 199 | break; | 
|---|
| 200 | case GL_LINE_STIPPLE: | 
|---|
| 201 | if (ctx->Line.StippleFlag!=state) { | 
|---|
| 202 | ctx->Line.StippleFlag = state; | 
|---|
| 203 | ctx->TriangleCaps ^= DD_LINE_STIPPLE; | 
|---|
| 204 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 205 | } | 
|---|
| 206 | break; | 
|---|
| 207 | case GL_INDEX_LOGIC_OP: | 
|---|
| 208 | if (ctx->Color.IndexLogicOpEnabled!=state) { | 
|---|
| 209 | ctx->Color.IndexLogicOpEnabled = state; | 
|---|
| 210 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 211 | } | 
|---|
| 212 | break; | 
|---|
| 213 | case GL_COLOR_LOGIC_OP: | 
|---|
| 214 | if (ctx->Color.ColorLogicOpEnabled!=state) { | 
|---|
| 215 | ctx->Color.ColorLogicOpEnabled = state; | 
|---|
| 216 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 217 | } | 
|---|
| 218 | break; | 
|---|
| 219 | case GL_MAP1_COLOR_4: | 
|---|
| 220 | ctx->Eval.Map1Color4 = state; | 
|---|
| 221 | break; | 
|---|
| 222 | case GL_MAP1_INDEX: | 
|---|
| 223 | ctx->Eval.Map1Index = state; | 
|---|
| 224 | break; | 
|---|
| 225 | case GL_MAP1_NORMAL: | 
|---|
| 226 | ctx->Eval.Map1Normal = state; | 
|---|
| 227 | break; | 
|---|
| 228 | case GL_MAP1_TEXTURE_COORD_1: | 
|---|
| 229 | ctx->Eval.Map1TextureCoord1 = state; | 
|---|
| 230 | break; | 
|---|
| 231 | case GL_MAP1_TEXTURE_COORD_2: | 
|---|
| 232 | ctx->Eval.Map1TextureCoord2 = state; | 
|---|
| 233 | break; | 
|---|
| 234 | case GL_MAP1_TEXTURE_COORD_3: | 
|---|
| 235 | ctx->Eval.Map1TextureCoord3 = state; | 
|---|
| 236 | break; | 
|---|
| 237 | case GL_MAP1_TEXTURE_COORD_4: | 
|---|
| 238 | ctx->Eval.Map1TextureCoord4 = state; | 
|---|
| 239 | break; | 
|---|
| 240 | case GL_MAP1_VERTEX_3: | 
|---|
| 241 | ctx->Eval.Map1Vertex3 = state; | 
|---|
| 242 | break; | 
|---|
| 243 | case GL_MAP1_VERTEX_4: | 
|---|
| 244 | ctx->Eval.Map1Vertex4 = state; | 
|---|
| 245 | break; | 
|---|
| 246 | case GL_MAP2_COLOR_4: | 
|---|
| 247 | ctx->Eval.Map2Color4 = state; | 
|---|
| 248 | break; | 
|---|
| 249 | case GL_MAP2_INDEX: | 
|---|
| 250 | ctx->Eval.Map2Index = state; | 
|---|
| 251 | break; | 
|---|
| 252 | case GL_MAP2_NORMAL: | 
|---|
| 253 | ctx->Eval.Map2Normal = state; | 
|---|
| 254 | break; | 
|---|
| 255 | case GL_MAP2_TEXTURE_COORD_1: | 
|---|
| 256 | ctx->Eval.Map2TextureCoord1 = state; | 
|---|
| 257 | break; | 
|---|
| 258 | case GL_MAP2_TEXTURE_COORD_2: | 
|---|
| 259 | ctx->Eval.Map2TextureCoord2 = state; | 
|---|
| 260 | break; | 
|---|
| 261 | case GL_MAP2_TEXTURE_COORD_3: | 
|---|
| 262 | ctx->Eval.Map2TextureCoord3 = state; | 
|---|
| 263 | break; | 
|---|
| 264 | case GL_MAP2_TEXTURE_COORD_4: | 
|---|
| 265 | ctx->Eval.Map2TextureCoord4 = state; | 
|---|
| 266 | break; | 
|---|
| 267 | case GL_MAP2_VERTEX_3: | 
|---|
| 268 | ctx->Eval.Map2Vertex3 = state; | 
|---|
| 269 | break; | 
|---|
| 270 | case GL_MAP2_VERTEX_4: | 
|---|
| 271 | ctx->Eval.Map2Vertex4 = state; | 
|---|
| 272 | break; | 
|---|
| 273 | case GL_NORMALIZE: | 
|---|
| 274 | if (ctx->Transform.Normalize != state) { | 
|---|
| 275 | ctx->Transform.Normalize = state; | 
|---|
| 276 | ctx->NewState |= NEW_NORMAL_TRANSFORM|NEW_LIGHTING; | 
|---|
| 277 | ctx->Enabled ^= ENABLE_NORMALIZE; | 
|---|
| 278 | } | 
|---|
| 279 | break; | 
|---|
| 280 | case GL_POINT_SMOOTH: | 
|---|
| 281 | if (ctx->Point.SmoothFlag!=state) { | 
|---|
| 282 | ctx->Point.SmoothFlag = state; | 
|---|
| 283 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 284 | } | 
|---|
| 285 | break; | 
|---|
| 286 | case GL_POLYGON_SMOOTH: | 
|---|
| 287 | if (ctx->Polygon.SmoothFlag!=state) { | 
|---|
| 288 | ctx->Polygon.SmoothFlag = state; | 
|---|
| 289 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 290 | } | 
|---|
| 291 | break; | 
|---|
| 292 | case GL_POLYGON_STIPPLE: | 
|---|
| 293 | if (ctx->Polygon.StippleFlag!=state) { | 
|---|
| 294 | ctx->Polygon.StippleFlag = state; | 
|---|
| 295 | ctx->TriangleCaps ^= DD_TRI_STIPPLE; | 
|---|
| 296 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 297 | } | 
|---|
| 298 | break; | 
|---|
| 299 | case GL_POLYGON_OFFSET_POINT: | 
|---|
| 300 | if (ctx->Polygon.OffsetPoint!=state) { | 
|---|
| 301 | ctx->Polygon.OffsetPoint = state; | 
|---|
| 302 | ctx->NewState |= NEW_POLYGON; | 
|---|
| 303 | } | 
|---|
| 304 | break; | 
|---|
| 305 | case GL_POLYGON_OFFSET_LINE: | 
|---|
| 306 | if (ctx->Polygon.OffsetLine!=state) { | 
|---|
| 307 | ctx->Polygon.OffsetLine = state; | 
|---|
| 308 | ctx->NewState |= NEW_POLYGON; | 
|---|
| 309 | } | 
|---|
| 310 | break; | 
|---|
| 311 | case GL_POLYGON_OFFSET_FILL: | 
|---|
| 312 | /*case GL_POLYGON_OFFSET_EXT:*/ | 
|---|
| 313 | if (ctx->Polygon.OffsetFill!=state) { | 
|---|
| 314 | ctx->Polygon.OffsetFill = state; | 
|---|
| 315 | ctx->NewState |= NEW_POLYGON; | 
|---|
| 316 | } | 
|---|
| 317 | break; | 
|---|
| 318 | case GL_RESCALE_NORMAL_EXT: | 
|---|
| 319 | if (ctx->Transform.RescaleNormals != state) { | 
|---|
| 320 | ctx->Transform.RescaleNormals = state; | 
|---|
| 321 | ctx->NewState |= NEW_NORMAL_TRANSFORM|NEW_LIGHTING; | 
|---|
| 322 | ctx->Enabled ^= ENABLE_RESCALE; | 
|---|
| 323 | } | 
|---|
| 324 | break; | 
|---|
| 325 | case GL_SCISSOR_TEST: | 
|---|
| 326 | if (ctx->Scissor.Enabled!=state) { | 
|---|
| 327 | ctx->Scissor.Enabled = state; | 
|---|
| 328 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 329 | } | 
|---|
| 330 | break; | 
|---|
| 331 | case GL_SHARED_TEXTURE_PALETTE_EXT: | 
|---|
| 332 | ctx->Texture.SharedPalette = state; | 
|---|
| 333 | break; | 
|---|
| 334 | case GL_STENCIL_TEST: | 
|---|
| 335 | if (state && ctx->Visual->StencilBits==0) { | 
|---|
| 336 | gl_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer"); | 
|---|
| 337 | return; | 
|---|
| 338 | } | 
|---|
| 339 | if (ctx->Stencil.Enabled!=state) { | 
|---|
| 340 | ctx->Stencil.Enabled = state; | 
|---|
| 341 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 342 | ctx->TriangleCaps ^= DD_STENCIL; | 
|---|
| 343 | } | 
|---|
| 344 | break; | 
|---|
| 345 | case GL_TEXTURE_1D: | 
|---|
| 346 | if (ctx->Visual->RGBAflag) { | 
|---|
| 347 | const GLuint curr = ctx->Texture.CurrentUnit; | 
|---|
| 348 | const GLuint flag = TEXTURE0_1D << (curr * 4); | 
|---|
| 349 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; | 
|---|
| 350 | ctx->NewState |= NEW_TEXTURE_ENABLE; | 
|---|
| 351 | if (state) { | 
|---|
| 352 | texUnit->Enabled |= TEXTURE0_1D; | 
|---|
| 353 | ctx->Enabled |= flag; | 
|---|
| 354 | } | 
|---|
| 355 | else { | 
|---|
| 356 | texUnit->Enabled &= ~TEXTURE0_1D; | 
|---|
| 357 | ctx->Enabled &= ~flag; | 
|---|
| 358 | } | 
|---|
| 359 | } | 
|---|
| 360 | break; | 
|---|
| 361 | case GL_TEXTURE_2D: | 
|---|
| 362 | if (ctx->Visual->RGBAflag) { | 
|---|
| 363 | const GLuint curr = ctx->Texture.CurrentUnit; | 
|---|
| 364 | const GLuint flag = TEXTURE0_2D << (curr * 4); | 
|---|
| 365 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; | 
|---|
| 366 | ctx->NewState |= NEW_TEXTURE_ENABLE; | 
|---|
| 367 | if (state) { | 
|---|
| 368 | texUnit->Enabled |= TEXTURE0_2D; | 
|---|
| 369 | ctx->Enabled |= flag; | 
|---|
| 370 | } | 
|---|
| 371 | else { | 
|---|
| 372 | texUnit->Enabled &= ~TEXTURE0_2D; | 
|---|
| 373 | ctx->Enabled &= ~flag; | 
|---|
| 374 | } | 
|---|
| 375 | } | 
|---|
| 376 | break; | 
|---|
| 377 | case GL_TEXTURE_3D: | 
|---|
| 378 | if (ctx->Visual->RGBAflag) { | 
|---|
| 379 | const GLuint curr = ctx->Texture.CurrentUnit; | 
|---|
| 380 | const GLuint flag = TEXTURE0_3D << (curr * 4); | 
|---|
| 381 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; | 
|---|
| 382 | ctx->NewState |= NEW_TEXTURE_ENABLE; | 
|---|
| 383 | if (state) { | 
|---|
| 384 | texUnit->Enabled |= TEXTURE0_3D; | 
|---|
| 385 | ctx->Enabled |= flag; | 
|---|
| 386 | } | 
|---|
| 387 | else { | 
|---|
| 388 | texUnit->Enabled &= ~TEXTURE0_3D; | 
|---|
| 389 | ctx->Enabled &= ~flag; | 
|---|
| 390 | } | 
|---|
| 391 | } | 
|---|
| 392 | break; | 
|---|
| 393 | case GL_TEXTURE_GEN_Q: | 
|---|
| 394 | { | 
|---|
| 395 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 396 | if (state) | 
|---|
| 397 | texUnit->TexGenEnabled |= Q_BIT; | 
|---|
| 398 | else | 
|---|
| 399 | texUnit->TexGenEnabled &= ~Q_BIT; | 
|---|
| 400 | ctx->NewState |= NEW_TEXTURING; | 
|---|
| 401 | } | 
|---|
| 402 | break; | 
|---|
| 403 | case GL_TEXTURE_GEN_R: | 
|---|
| 404 | { | 
|---|
| 405 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 406 | if (state) | 
|---|
| 407 | texUnit->TexGenEnabled |= R_BIT; | 
|---|
| 408 | else | 
|---|
| 409 | texUnit->TexGenEnabled &= ~R_BIT; | 
|---|
| 410 | ctx->NewState |= NEW_TEXTURING; | 
|---|
| 411 | } | 
|---|
| 412 | break; | 
|---|
| 413 | case GL_TEXTURE_GEN_S: | 
|---|
| 414 | { | 
|---|
| 415 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 416 | if (state) | 
|---|
| 417 | texUnit->TexGenEnabled |= S_BIT; | 
|---|
| 418 | else | 
|---|
| 419 | texUnit->TexGenEnabled &= ~S_BIT; | 
|---|
| 420 | ctx->NewState |= NEW_TEXTURING; | 
|---|
| 421 | } | 
|---|
| 422 | break; | 
|---|
| 423 | case GL_TEXTURE_GEN_T: | 
|---|
| 424 | { | 
|---|
| 425 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 426 | if (state) | 
|---|
| 427 | texUnit->TexGenEnabled |= T_BIT; | 
|---|
| 428 | else | 
|---|
| 429 | texUnit->TexGenEnabled &= ~T_BIT; | 
|---|
| 430 | ctx->NewState |= NEW_TEXTURING; | 
|---|
| 431 | } | 
|---|
| 432 | break; | 
|---|
| 433 |  | 
|---|
| 434 | /* | 
|---|
| 435 | * CLIENT STATE!!! | 
|---|
| 436 | */ | 
|---|
| 437 | case GL_VERTEX_ARRAY: | 
|---|
| 438 | ctx->Array.Vertex.Enabled = state; | 
|---|
| 439 | break; | 
|---|
| 440 | case GL_NORMAL_ARRAY: | 
|---|
| 441 | ctx->Array.Normal.Enabled = state; | 
|---|
| 442 | break; | 
|---|
| 443 | case GL_COLOR_ARRAY: | 
|---|
| 444 | ctx->Array.Color.Enabled = state; | 
|---|
| 445 | break; | 
|---|
| 446 | case GL_INDEX_ARRAY: | 
|---|
| 447 | ctx->Array.Index.Enabled = state; | 
|---|
| 448 | break; | 
|---|
| 449 | case GL_TEXTURE_COORD_ARRAY: | 
|---|
| 450 | ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state; | 
|---|
| 451 | break; | 
|---|
| 452 | case GL_EDGE_FLAG_ARRAY: | 
|---|
| 453 | ctx->Array.EdgeFlag.Enabled = state; | 
|---|
| 454 | break; | 
|---|
| 455 |  | 
|---|
| 456 | /* GL_HP_occlusion_test */ | 
|---|
| 457 | case GL_OCCLUSION_TEST_HP: | 
|---|
| 458 | if (ctx->Extensions.HaveHpOcclusionTest) { | 
|---|
| 459 | ctx->Depth.OcclusionTest = state; | 
|---|
| 460 | ctx->NewState |= NEW_RASTER_OPS; | 
|---|
| 461 | } | 
|---|
| 462 | else { | 
|---|
| 463 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); | 
|---|
| 464 | return; | 
|---|
| 465 | } | 
|---|
| 466 | break; | 
|---|
| 467 |  | 
|---|
| 468 | default: | 
|---|
| 469 | if (state) { | 
|---|
| 470 | gl_error( ctx, GL_INVALID_ENUM, "glEnable" ); | 
|---|
| 471 | } | 
|---|
| 472 | else { | 
|---|
| 473 | gl_error( ctx, GL_INVALID_ENUM, "glDisable" ); | 
|---|
| 474 | } | 
|---|
| 475 | return; | 
|---|
| 476 | } | 
|---|
| 477 |  | 
|---|
| 478 | if (ctx->Driver.Enable) { | 
|---|
| 479 | (*ctx->Driver.Enable)( ctx, cap, state ); | 
|---|
| 480 | } | 
|---|
| 481 | } | 
|---|
| 482 |  | 
|---|
| 483 |  | 
|---|
| 484 |  | 
|---|
| 485 |  | 
|---|
| 486 | void | 
|---|
| 487 | _mesa_Enable( GLenum cap ) | 
|---|
| 488 | { | 
|---|
| 489 | GET_CURRENT_CONTEXT(ctx); | 
|---|
| 490 | _mesa_set_enable( ctx, cap, GL_TRUE ); | 
|---|
| 491 | } | 
|---|
| 492 |  | 
|---|
| 493 |  | 
|---|
| 494 |  | 
|---|
| 495 | void | 
|---|
| 496 | _mesa_Disable( GLenum cap ) | 
|---|
| 497 | { | 
|---|
| 498 | GET_CURRENT_CONTEXT(ctx); | 
|---|
| 499 | _mesa_set_enable( ctx, cap, GL_FALSE ); | 
|---|
| 500 | } | 
|---|
| 501 |  | 
|---|
| 502 |  | 
|---|
| 503 |  | 
|---|
| 504 | GLboolean | 
|---|
| 505 | _mesa_IsEnabled( GLenum cap ) | 
|---|
| 506 | { | 
|---|
| 507 | GET_CURRENT_CONTEXT(ctx); | 
|---|
| 508 | switch (cap) { | 
|---|
| 509 | case GL_ALPHA_TEST: | 
|---|
| 510 | return ctx->Color.AlphaEnabled; | 
|---|
| 511 | case GL_AUTO_NORMAL: | 
|---|
| 512 | return ctx->Eval.AutoNormal; | 
|---|
| 513 | case GL_BLEND: | 
|---|
| 514 | return ctx->Color.BlendEnabled; | 
|---|
| 515 | case GL_CLIP_PLANE0: | 
|---|
| 516 | case GL_CLIP_PLANE1: | 
|---|
| 517 | case GL_CLIP_PLANE2: | 
|---|
| 518 | case GL_CLIP_PLANE3: | 
|---|
| 519 | case GL_CLIP_PLANE4: | 
|---|
| 520 | case GL_CLIP_PLANE5: | 
|---|
| 521 | return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0]; | 
|---|
| 522 | case GL_COLOR_MATERIAL: | 
|---|
| 523 | return ctx->Light.ColorMaterialEnabled; | 
|---|
| 524 | case GL_CULL_FACE: | 
|---|
| 525 | return ctx->Polygon.CullFlag; | 
|---|
| 526 | case GL_DEPTH_TEST: | 
|---|
| 527 | return ctx->Depth.Test; | 
|---|
| 528 | case GL_DITHER: | 
|---|
| 529 | return ctx->Color.DitherFlag; | 
|---|
| 530 | case GL_FOG: | 
|---|
| 531 | return ctx->Fog.Enabled; | 
|---|
| 532 | case GL_LIGHTING: | 
|---|
| 533 | return ctx->Light.Enabled; | 
|---|
| 534 | case GL_LIGHT0: | 
|---|
| 535 | case GL_LIGHT1: | 
|---|
| 536 | case GL_LIGHT2: | 
|---|
| 537 | case GL_LIGHT3: | 
|---|
| 538 | case GL_LIGHT4: | 
|---|
| 539 | case GL_LIGHT5: | 
|---|
| 540 | case GL_LIGHT6: | 
|---|
| 541 | case GL_LIGHT7: | 
|---|
| 542 | return ctx->Light.Light[cap-GL_LIGHT0].Enabled; | 
|---|
| 543 | case GL_LINE_SMOOTH: | 
|---|
| 544 | return ctx->Line.SmoothFlag; | 
|---|
| 545 | case GL_LINE_STIPPLE: | 
|---|
| 546 | return ctx->Line.StippleFlag; | 
|---|
| 547 | case GL_INDEX_LOGIC_OP: | 
|---|
| 548 | return ctx->Color.IndexLogicOpEnabled; | 
|---|
| 549 | case GL_COLOR_LOGIC_OP: | 
|---|
| 550 | return ctx->Color.ColorLogicOpEnabled; | 
|---|
| 551 | case GL_MAP1_COLOR_4: | 
|---|
| 552 | return ctx->Eval.Map1Color4; | 
|---|
| 553 | case GL_MAP1_INDEX: | 
|---|
| 554 | return ctx->Eval.Map1Index; | 
|---|
| 555 | case GL_MAP1_NORMAL: | 
|---|
| 556 | return ctx->Eval.Map1Normal; | 
|---|
| 557 | case GL_MAP1_TEXTURE_COORD_1: | 
|---|
| 558 | return ctx->Eval.Map1TextureCoord1; | 
|---|
| 559 | case GL_MAP1_TEXTURE_COORD_2: | 
|---|
| 560 | return ctx->Eval.Map1TextureCoord2; | 
|---|
| 561 | case GL_MAP1_TEXTURE_COORD_3: | 
|---|
| 562 | return ctx->Eval.Map1TextureCoord3; | 
|---|
| 563 | case GL_MAP1_TEXTURE_COORD_4: | 
|---|
| 564 | return ctx->Eval.Map1TextureCoord4; | 
|---|
| 565 | case GL_MAP1_VERTEX_3: | 
|---|
| 566 | return ctx->Eval.Map1Vertex3; | 
|---|
| 567 | case GL_MAP1_VERTEX_4: | 
|---|
| 568 | return ctx->Eval.Map1Vertex4; | 
|---|
| 569 | case GL_MAP2_COLOR_4: | 
|---|
| 570 | return ctx->Eval.Map2Color4; | 
|---|
| 571 | case GL_MAP2_INDEX: | 
|---|
| 572 | return ctx->Eval.Map2Index; | 
|---|
| 573 | case GL_MAP2_NORMAL: | 
|---|
| 574 | return ctx->Eval.Map2Normal; | 
|---|
| 575 | case GL_MAP2_TEXTURE_COORD_1: | 
|---|
| 576 | return ctx->Eval.Map2TextureCoord1; | 
|---|
| 577 | case GL_MAP2_TEXTURE_COORD_2: | 
|---|
| 578 | return ctx->Eval.Map2TextureCoord2; | 
|---|
| 579 | case GL_MAP2_TEXTURE_COORD_3: | 
|---|
| 580 | return ctx->Eval.Map2TextureCoord3; | 
|---|
| 581 | case GL_MAP2_TEXTURE_COORD_4: | 
|---|
| 582 | return ctx->Eval.Map2TextureCoord4; | 
|---|
| 583 | case GL_MAP2_VERTEX_3: | 
|---|
| 584 | return ctx->Eval.Map2Vertex3; | 
|---|
| 585 | case GL_MAP2_VERTEX_4: | 
|---|
| 586 | return ctx->Eval.Map2Vertex4; | 
|---|
| 587 | case GL_NORMALIZE: | 
|---|
| 588 | return ctx->Transform.Normalize; | 
|---|
| 589 | case GL_POINT_SMOOTH: | 
|---|
| 590 | return ctx->Point.SmoothFlag; | 
|---|
| 591 | case GL_POLYGON_SMOOTH: | 
|---|
| 592 | return ctx->Polygon.SmoothFlag; | 
|---|
| 593 | case GL_POLYGON_STIPPLE: | 
|---|
| 594 | return ctx->Polygon.StippleFlag; | 
|---|
| 595 | case GL_POLYGON_OFFSET_POINT: | 
|---|
| 596 | return ctx->Polygon.OffsetPoint; | 
|---|
| 597 | case GL_POLYGON_OFFSET_LINE: | 
|---|
| 598 | return ctx->Polygon.OffsetLine; | 
|---|
| 599 | case GL_POLYGON_OFFSET_FILL: | 
|---|
| 600 | /*case GL_POLYGON_OFFSET_EXT:*/ | 
|---|
| 601 | return ctx->Polygon.OffsetFill; | 
|---|
| 602 | case GL_RESCALE_NORMAL_EXT: | 
|---|
| 603 | return ctx->Transform.RescaleNormals; | 
|---|
| 604 | case GL_SCISSOR_TEST: | 
|---|
| 605 | return ctx->Scissor.Enabled; | 
|---|
| 606 | case GL_SHARED_TEXTURE_PALETTE_EXT: | 
|---|
| 607 | return ctx->Texture.SharedPalette; | 
|---|
| 608 | case GL_STENCIL_TEST: | 
|---|
| 609 | return ctx->Stencil.Enabled; | 
|---|
| 610 | case GL_TEXTURE_1D: | 
|---|
| 611 | { | 
|---|
| 612 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 613 | return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE; | 
|---|
| 614 | } | 
|---|
| 615 | case GL_TEXTURE_2D: | 
|---|
| 616 | { | 
|---|
| 617 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 618 | return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE; | 
|---|
| 619 | } | 
|---|
| 620 | case GL_TEXTURE_3D: | 
|---|
| 621 | { | 
|---|
| 622 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 623 | return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE; | 
|---|
| 624 | } | 
|---|
| 625 | case GL_TEXTURE_GEN_Q: | 
|---|
| 626 | { | 
|---|
| 627 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 628 | return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; | 
|---|
| 629 | } | 
|---|
| 630 | case GL_TEXTURE_GEN_R: | 
|---|
| 631 | { | 
|---|
| 632 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 633 | return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; | 
|---|
| 634 | } | 
|---|
| 635 | case GL_TEXTURE_GEN_S: | 
|---|
| 636 | { | 
|---|
| 637 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 638 | return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; | 
|---|
| 639 | } | 
|---|
| 640 | case GL_TEXTURE_GEN_T: | 
|---|
| 641 | { | 
|---|
| 642 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; | 
|---|
| 643 | return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; | 
|---|
| 644 | } | 
|---|
| 645 |  | 
|---|
| 646 | /* | 
|---|
| 647 | * CLIENT STATE!!! | 
|---|
| 648 | */ | 
|---|
| 649 | case GL_VERTEX_ARRAY: | 
|---|
| 650 | return ctx->Array.Vertex.Enabled; | 
|---|
| 651 | case GL_NORMAL_ARRAY: | 
|---|
| 652 | return ctx->Array.Normal.Enabled; | 
|---|
| 653 | case GL_COLOR_ARRAY: | 
|---|
| 654 | return ctx->Array.Color.Enabled; | 
|---|
| 655 | case GL_INDEX_ARRAY: | 
|---|
| 656 | return ctx->Array.Index.Enabled; | 
|---|
| 657 | case GL_TEXTURE_COORD_ARRAY: | 
|---|
| 658 | return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled; | 
|---|
| 659 | case GL_EDGE_FLAG_ARRAY: | 
|---|
| 660 | return ctx->Array.EdgeFlag.Enabled; | 
|---|
| 661 |  | 
|---|
| 662 | /* GL_HP_occlusion_test */ | 
|---|
| 663 | case GL_OCCLUSION_TEST_HP: | 
|---|
| 664 | if (ctx->Extensions.HaveHpOcclusionTest) { | 
|---|
| 665 | return ctx->Depth.OcclusionTest; | 
|---|
| 666 | } | 
|---|
| 667 | else { | 
|---|
| 668 | gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); | 
|---|
| 669 | return GL_FALSE; | 
|---|
| 670 | } | 
|---|
| 671 |  | 
|---|
| 672 | default: | 
|---|
| 673 | gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); | 
|---|
| 674 | return GL_FALSE; | 
|---|
| 675 | } | 
|---|
| 676 | } | 
|---|
| 677 |  | 
|---|
| 678 |  | 
|---|
| 679 |  | 
|---|
| 680 |  | 
|---|
| 681 | static void | 
|---|
| 682 | client_state( GLcontext *ctx, GLenum cap, GLboolean state ) | 
|---|
| 683 | { | 
|---|
| 684 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, | 
|---|
| 685 | (state | 
|---|
| 686 | ? "glEnableClientState" | 
|---|
| 687 | : "glDisableClientState") ); | 
|---|
| 688 |  | 
|---|
| 689 | switch (cap) { | 
|---|
| 690 | case GL_VERTEX_ARRAY: | 
|---|
| 691 | ctx->Array.Vertex.Enabled = state; | 
|---|
| 692 | break; | 
|---|
| 693 | case GL_NORMAL_ARRAY: | 
|---|
| 694 | ctx->Array.Normal.Enabled = state; | 
|---|
| 695 | break; | 
|---|
| 696 | case GL_COLOR_ARRAY: | 
|---|
| 697 | ctx->Array.Color.Enabled = state; | 
|---|
| 698 | break; | 
|---|
| 699 | case GL_INDEX_ARRAY: | 
|---|
| 700 | ctx->Array.Index.Enabled = state; | 
|---|
| 701 | break; | 
|---|
| 702 | case GL_TEXTURE_COORD_ARRAY: | 
|---|
| 703 | ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state; | 
|---|
| 704 | break; | 
|---|
| 705 | case GL_EDGE_FLAG_ARRAY: | 
|---|
| 706 | ctx->Array.EdgeFlag.Enabled = state; | 
|---|
| 707 | break; | 
|---|
| 708 | default: | 
|---|
| 709 | gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" ); | 
|---|
| 710 | } | 
|---|
| 711 |  | 
|---|
| 712 | ctx->NewState |= NEW_CLIENT_STATE; | 
|---|
| 713 | } | 
|---|
| 714 |  | 
|---|
| 715 |  | 
|---|
| 716 |  | 
|---|
| 717 | void | 
|---|
| 718 | _mesa_EnableClientState( GLenum cap ) | 
|---|
| 719 | { | 
|---|
| 720 | GET_CURRENT_CONTEXT(ctx); | 
|---|
| 721 | client_state( ctx, cap, GL_TRUE ); | 
|---|
| 722 | } | 
|---|
| 723 |  | 
|---|
| 724 |  | 
|---|
| 725 |  | 
|---|
| 726 | void | 
|---|
| 727 | _mesa_DisableClientState( GLenum cap ) | 
|---|
| 728 | { | 
|---|
| 729 | GET_CURRENT_CONTEXT(ctx); | 
|---|
| 730 | client_state( ctx, cap, GL_FALSE ); | 
|---|
| 731 | } | 
|---|
| 732 |  | 
|---|