[3598] | 1 | /* $Id: enable.c,v 1.3 2000-05-23 20:40:32 jeroen Exp $ */
|
---|
[2938] | 2 |
|
---|
| 3 | /*
|
---|
| 4 | * Mesa 3-D graphics library
|
---|
[3598] | 5 | * Version: 3.3
|
---|
[2938] | 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
|
---|
[3598] | 33 | #include "glheader.h"
|
---|
[2962] | 34 | #include "types.h"
|
---|
[2938] | 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 | */
|
---|
[3598] | 52 | void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
|
---|
[2938] | 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",
|
---|
[3598] | 58 | state ? "glEnable" : "glDisable",
|
---|
| 59 | gl_lookup_enum_by_nr(cap),
|
---|
| 60 | ctx->NewState);
|
---|
[2938] | 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 | }
|
---|
[3598] | 68 | break;
|
---|
[2938] | 69 | case GL_AUTO_NORMAL:
|
---|
[3598] | 70 | ctx->Eval.AutoNormal = state;
|
---|
| 71 | break;
|
---|
[2938] | 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 | }
|
---|
[3598] | 84 | break;
|
---|
[2938] | 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:
|
---|
[3598] | 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;
|
---|
[2938] | 96 |
|
---|
[3598] | 97 | ctx->Transform.ClipEnabled[p] = state;
|
---|
| 98 | ctx->NewState |= NEW_USER_CLIP;
|
---|
[2938] | 99 |
|
---|
[3598] | 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;
|
---|
[2938] | 117 | case GL_COLOR_MATERIAL:
|
---|
| 118 | if (ctx->Light.ColorMaterialEnabled!=state) {
|
---|
| 119 | ctx->Light.ColorMaterialEnabled = state;
|
---|
[3598] | 120 | ctx->NewState |= NEW_LIGHTING;
|
---|
| 121 | if (state)
|
---|
| 122 | gl_update_color_material( ctx, ctx->Current.ByteColor );
|
---|
[2938] | 123 | }
|
---|
[3598] | 124 | break;
|
---|
[2938] | 125 | case GL_CULL_FACE:
|
---|
| 126 | if (ctx->Polygon.CullFlag!=state) {
|
---|
| 127 | ctx->Polygon.CullFlag = state;
|
---|
[3598] | 128 | ctx->TriangleCaps ^= DD_TRI_CULL;
|
---|
[2938] | 129 | ctx->NewState |= NEW_POLYGON;
|
---|
| 130 | }
|
---|
[3598] | 131 | break;
|
---|
[2938] | 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 | }
|
---|
[3598] | 137 | if (ctx->Depth.Test!=state) {
|
---|
[2938] | 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 | }
|
---|
[3598] | 151 | break;
|
---|
[2938] | 152 | case GL_FOG:
|
---|
[3598] | 153 | if (ctx->Fog.Enabled!=state) {
|
---|
[2938] | 154 | ctx->Fog.Enabled = state;
|
---|
[3598] | 155 | ctx->Enabled ^= ENABLE_FOG;
|
---|
[2938] | 156 | ctx->NewState |= NEW_FOG|NEW_RASTER_OPS;
|
---|
| 157 | }
|
---|
[3598] | 158 | break;
|
---|
[2938] | 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:
|
---|
[3598] | 167 | if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state)
|
---|
| 168 | {
|
---|
| 169 | ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
|
---|
[2938] | 170 |
|
---|
[3598] | 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 | }
|
---|
[2938] | 181 |
|
---|
[3598] | 182 | ctx->NewState |= NEW_LIGHTING;
|
---|
| 183 | }
|
---|
[2938] | 184 | break;
|
---|
| 185 | case GL_LIGHTING:
|
---|
| 186 | if (ctx->Light.Enabled!=state) {
|
---|
| 187 | ctx->Light.Enabled = state;
|
---|
[3598] | 188 | ctx->Enabled &= ~ENABLE_LIGHT;
|
---|
[2938] | 189 | if (state)
|
---|
[3598] | 190 | ctx->Enabled |= ENABLE_LIGHT;
|
---|
[2938] | 191 | ctx->NewState |= NEW_LIGHTING;
|
---|
| 192 | }
|
---|
| 193 | break;
|
---|
| 194 | case GL_LINE_SMOOTH:
|
---|
[3598] | 195 | if (ctx->Line.SmoothFlag!=state) {
|
---|
[2938] | 196 | ctx->Line.SmoothFlag = state;
|
---|
| 197 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
| 198 | }
|
---|
[3598] | 199 | break;
|
---|
[2938] | 200 | case GL_LINE_STIPPLE:
|
---|
[3598] | 201 | if (ctx->Line.StippleFlag!=state) {
|
---|
[2938] | 202 | ctx->Line.StippleFlag = state;
|
---|
[3598] | 203 | ctx->TriangleCaps ^= DD_LINE_STIPPLE;
|
---|
[2938] | 204 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
| 205 | }
|
---|
[3598] | 206 | break;
|
---|
[2938] | 207 | case GL_INDEX_LOGIC_OP:
|
---|
| 208 | if (ctx->Color.IndexLogicOpEnabled!=state) {
|
---|
[3598] | 209 | ctx->Color.IndexLogicOpEnabled = state;
|
---|
[2938] | 210 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
| 211 | }
|
---|
[3598] | 212 | break;
|
---|
[2938] | 213 | case GL_COLOR_LOGIC_OP:
|
---|
| 214 | if (ctx->Color.ColorLogicOpEnabled!=state) {
|
---|
[3598] | 215 | ctx->Color.ColorLogicOpEnabled = state;
|
---|
[2938] | 216 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
| 217 | }
|
---|
[3598] | 218 | break;
|
---|
[2938] | 219 | case GL_MAP1_COLOR_4:
|
---|
[3598] | 220 | ctx->Eval.Map1Color4 = state;
|
---|
| 221 | break;
|
---|
[2938] | 222 | case GL_MAP1_INDEX:
|
---|
[3598] | 223 | ctx->Eval.Map1Index = state;
|
---|
| 224 | break;
|
---|
[2938] | 225 | case GL_MAP1_NORMAL:
|
---|
[3598] | 226 | ctx->Eval.Map1Normal = state;
|
---|
| 227 | break;
|
---|
[2938] | 228 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
[3598] | 229 | ctx->Eval.Map1TextureCoord1 = state;
|
---|
| 230 | break;
|
---|
[2938] | 231 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
[3598] | 232 | ctx->Eval.Map1TextureCoord2 = state;
|
---|
| 233 | break;
|
---|
[2938] | 234 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
[3598] | 235 | ctx->Eval.Map1TextureCoord3 = state;
|
---|
| 236 | break;
|
---|
[2938] | 237 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
[3598] | 238 | ctx->Eval.Map1TextureCoord4 = state;
|
---|
| 239 | break;
|
---|
[2938] | 240 | case GL_MAP1_VERTEX_3:
|
---|
[3598] | 241 | ctx->Eval.Map1Vertex3 = state;
|
---|
| 242 | break;
|
---|
[2938] | 243 | case GL_MAP1_VERTEX_4:
|
---|
[3598] | 244 | ctx->Eval.Map1Vertex4 = state;
|
---|
| 245 | break;
|
---|
[2938] | 246 | case GL_MAP2_COLOR_4:
|
---|
[3598] | 247 | ctx->Eval.Map2Color4 = state;
|
---|
| 248 | break;
|
---|
[2938] | 249 | case GL_MAP2_INDEX:
|
---|
[3598] | 250 | ctx->Eval.Map2Index = state;
|
---|
| 251 | break;
|
---|
[2938] | 252 | case GL_MAP2_NORMAL:
|
---|
[3598] | 253 | ctx->Eval.Map2Normal = state;
|
---|
| 254 | break;
|
---|
[2938] | 255 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
[3598] | 256 | ctx->Eval.Map2TextureCoord1 = state;
|
---|
| 257 | break;
|
---|
[2938] | 258 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
[3598] | 259 | ctx->Eval.Map2TextureCoord2 = state;
|
---|
| 260 | break;
|
---|
[2938] | 261 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
[3598] | 262 | ctx->Eval.Map2TextureCoord3 = state;
|
---|
| 263 | break;
|
---|
[2938] | 264 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
[3598] | 265 | ctx->Eval.Map2TextureCoord4 = state;
|
---|
| 266 | break;
|
---|
[2938] | 267 | case GL_MAP2_VERTEX_3:
|
---|
[3598] | 268 | ctx->Eval.Map2Vertex3 = state;
|
---|
| 269 | break;
|
---|
[2938] | 270 | case GL_MAP2_VERTEX_4:
|
---|
[3598] | 271 | ctx->Eval.Map2Vertex4 = state;
|
---|
| 272 | break;
|
---|
[2938] | 273 | case GL_NORMALIZE:
|
---|
[3598] | 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;
|
---|
[2938] | 280 | case GL_POINT_SMOOTH:
|
---|
[3598] | 281 | if (ctx->Point.SmoothFlag!=state) {
|
---|
[2938] | 282 | ctx->Point.SmoothFlag = state;
|
---|
| 283 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
| 284 | }
|
---|
[3598] | 285 | break;
|
---|
[2938] | 286 | case GL_POLYGON_SMOOTH:
|
---|
[3598] | 287 | if (ctx->Polygon.SmoothFlag!=state) {
|
---|
[2938] | 288 | ctx->Polygon.SmoothFlag = state;
|
---|
| 289 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
| 290 | }
|
---|
[3598] | 291 | break;
|
---|
[2938] | 292 | case GL_POLYGON_STIPPLE:
|
---|
[3598] | 293 | if (ctx->Polygon.StippleFlag!=state) {
|
---|
[2938] | 294 | ctx->Polygon.StippleFlag = state;
|
---|
[3598] | 295 | ctx->TriangleCaps ^= DD_TRI_STIPPLE;
|
---|
[2938] | 296 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
| 297 | }
|
---|
[3598] | 298 | break;
|
---|
[2938] | 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:
|
---|
[3598] | 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 | }
|
---|
[2938] | 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 | }
|
---|
[3598] | 330 | break;
|
---|
[2938] | 331 | case GL_SHARED_TEXTURE_PALETTE_EXT:
|
---|
| 332 | ctx->Texture.SharedPalette = state;
|
---|
| 333 | break;
|
---|
| 334 | case GL_STENCIL_TEST:
|
---|
[3598] | 335 | if (state && ctx->Visual->StencilBits==0) {
|
---|
[2938] | 336 | gl_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
|
---|
| 337 | return;
|
---|
[3598] | 338 | }
|
---|
| 339 | if (ctx->Stencil.Enabled!=state) {
|
---|
[2938] | 340 | ctx->Stencil.Enabled = state;
|
---|
| 341 | ctx->NewState |= NEW_RASTER_OPS;
|
---|
[3598] | 342 | ctx->TriangleCaps ^= DD_STENCIL;
|
---|
[2938] | 343 | }
|
---|
[3598] | 344 | break;
|
---|
[2938] | 345 | case GL_TEXTURE_1D:
|
---|
| 346 | if (ctx->Visual->RGBAflag) {
|
---|
[3598] | 347 | const GLuint curr = ctx->Texture.CurrentUnit;
|
---|
| 348 | const GLuint flag = TEXTURE0_1D << (curr * 4);
|
---|
[2938] | 349 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
|
---|
[3598] | 350 | ctx->NewState |= NEW_TEXTURE_ENABLE;
|
---|
[2938] | 351 | if (state) {
|
---|
[3598] | 352 | texUnit->Enabled |= TEXTURE0_1D;
|
---|
| 353 | ctx->Enabled |= flag;
|
---|
| 354 | }
|
---|
[2938] | 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) {
|
---|
[3598] | 363 | const GLuint curr = ctx->Texture.CurrentUnit;
|
---|
| 364 | const GLuint flag = TEXTURE0_2D << (curr * 4);
|
---|
[2938] | 365 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
|
---|
[3598] | 366 | ctx->NewState |= NEW_TEXTURE_ENABLE;
|
---|
[2938] | 367 | if (state) {
|
---|
[3598] | 368 | texUnit->Enabled |= TEXTURE0_2D;
|
---|
| 369 | ctx->Enabled |= flag;
|
---|
| 370 | }
|
---|
[2938] | 371 | else {
|
---|
| 372 | texUnit->Enabled &= ~TEXTURE0_2D;
|
---|
| 373 | ctx->Enabled &= ~flag;
|
---|
| 374 | }
|
---|
| 375 | }
|
---|
[3598] | 376 | break;
|
---|
[2938] | 377 | case GL_TEXTURE_3D:
|
---|
| 378 | if (ctx->Visual->RGBAflag) {
|
---|
[3598] | 379 | const GLuint curr = ctx->Texture.CurrentUnit;
|
---|
| 380 | const GLuint flag = TEXTURE0_3D << (curr * 4);
|
---|
[2938] | 381 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
|
---|
[3598] | 382 | ctx->NewState |= NEW_TEXTURE_ENABLE;
|
---|
[2938] | 383 | if (state) {
|
---|
[3598] | 384 | texUnit->Enabled |= TEXTURE0_3D;
|
---|
| 385 | ctx->Enabled |= flag;
|
---|
| 386 | }
|
---|
[2938] | 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 | }
|
---|
[3598] | 402 | break;
|
---|
[2938] | 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 | }
|
---|
[3598] | 412 | break;
|
---|
[2938] | 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 | }
|
---|
[3598] | 422 | break;
|
---|
[2938] | 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 | }
|
---|
[3598] | 432 | break;
|
---|
[2938] | 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 |
|
---|
[3598] | 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 |
|
---|
[2938] | 468 | default:
|
---|
[3598] | 469 | if (state) {
|
---|
| 470 | gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
|
---|
| 471 | }
|
---|
| 472 | else {
|
---|
| 473 | gl_error( ctx, GL_INVALID_ENUM, "glDisable" );
|
---|
| 474 | }
|
---|
[2938] | 475 | return;
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | if (ctx->Driver.Enable) {
|
---|
| 479 | (*ctx->Driver.Enable)( ctx, cap, state );
|
---|
| 480 | }
|
---|
| 481 | }
|
---|
| 482 |
|
---|
| 483 |
|
---|
| 484 |
|
---|
| 485 |
|
---|
[3598] | 486 | void
|
---|
| 487 | _mesa_Enable( GLenum cap )
|
---|
[2938] | 488 | {
|
---|
[3598] | 489 | GET_CURRENT_CONTEXT(ctx);
|
---|
| 490 | _mesa_set_enable( ctx, cap, GL_TRUE );
|
---|
[2938] | 491 | }
|
---|
| 492 |
|
---|
| 493 |
|
---|
| 494 |
|
---|
[3598] | 495 | void
|
---|
| 496 | _mesa_Disable( GLenum cap )
|
---|
[2938] | 497 | {
|
---|
[3598] | 498 | GET_CURRENT_CONTEXT(ctx);
|
---|
| 499 | _mesa_set_enable( ctx, cap, GL_FALSE );
|
---|
[2938] | 500 | }
|
---|
| 501 |
|
---|
| 502 |
|
---|
| 503 |
|
---|
[3598] | 504 | GLboolean
|
---|
| 505 | _mesa_IsEnabled( GLenum cap )
|
---|
[2938] | 506 | {
|
---|
[3598] | 507 | GET_CURRENT_CONTEXT(ctx);
|
---|
[2938] | 508 | switch (cap) {
|
---|
| 509 | case GL_ALPHA_TEST:
|
---|
| 510 | return ctx->Color.AlphaEnabled;
|
---|
| 511 | case GL_AUTO_NORMAL:
|
---|
[3598] | 512 | return ctx->Eval.AutoNormal;
|
---|
[2938] | 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:
|
---|
[3598] | 521 | return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
|
---|
[2938] | 522 | case GL_COLOR_MATERIAL:
|
---|
[3598] | 523 | return ctx->Light.ColorMaterialEnabled;
|
---|
[2938] | 524 | case GL_CULL_FACE:
|
---|
| 525 | return ctx->Polygon.CullFlag;
|
---|
| 526 | case GL_DEPTH_TEST:
|
---|
| 527 | return ctx->Depth.Test;
|
---|
| 528 | case GL_DITHER:
|
---|
[3598] | 529 | return ctx->Color.DitherFlag;
|
---|
[2938] | 530 | case GL_FOG:
|
---|
[3598] | 531 | return ctx->Fog.Enabled;
|
---|
[2938] | 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:
|
---|
[3598] | 544 | return ctx->Line.SmoothFlag;
|
---|
[2938] | 545 | case GL_LINE_STIPPLE:
|
---|
[3598] | 546 | return ctx->Line.StippleFlag;
|
---|
[2938] | 547 | case GL_INDEX_LOGIC_OP:
|
---|
[3598] | 548 | return ctx->Color.IndexLogicOpEnabled;
|
---|
[2938] | 549 | case GL_COLOR_LOGIC_OP:
|
---|
[3598] | 550 | return ctx->Color.ColorLogicOpEnabled;
|
---|
[2938] | 551 | case GL_MAP1_COLOR_4:
|
---|
[3598] | 552 | return ctx->Eval.Map1Color4;
|
---|
[2938] | 553 | case GL_MAP1_INDEX:
|
---|
[3598] | 554 | return ctx->Eval.Map1Index;
|
---|
[2938] | 555 | case GL_MAP1_NORMAL:
|
---|
[3598] | 556 | return ctx->Eval.Map1Normal;
|
---|
[2938] | 557 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
[3598] | 558 | return ctx->Eval.Map1TextureCoord1;
|
---|
[2938] | 559 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
[3598] | 560 | return ctx->Eval.Map1TextureCoord2;
|
---|
[2938] | 561 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
[3598] | 562 | return ctx->Eval.Map1TextureCoord3;
|
---|
[2938] | 563 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
[3598] | 564 | return ctx->Eval.Map1TextureCoord4;
|
---|
[2938] | 565 | case GL_MAP1_VERTEX_3:
|
---|
[3598] | 566 | return ctx->Eval.Map1Vertex3;
|
---|
[2938] | 567 | case GL_MAP1_VERTEX_4:
|
---|
[3598] | 568 | return ctx->Eval.Map1Vertex4;
|
---|
[2938] | 569 | case GL_MAP2_COLOR_4:
|
---|
[3598] | 570 | return ctx->Eval.Map2Color4;
|
---|
[2938] | 571 | case GL_MAP2_INDEX:
|
---|
[3598] | 572 | return ctx->Eval.Map2Index;
|
---|
[2938] | 573 | case GL_MAP2_NORMAL:
|
---|
[3598] | 574 | return ctx->Eval.Map2Normal;
|
---|
[2938] | 575 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
[3598] | 576 | return ctx->Eval.Map2TextureCoord1;
|
---|
[2938] | 577 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
[3598] | 578 | return ctx->Eval.Map2TextureCoord2;
|
---|
[2938] | 579 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
[3598] | 580 | return ctx->Eval.Map2TextureCoord3;
|
---|
[2938] | 581 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
[3598] | 582 | return ctx->Eval.Map2TextureCoord4;
|
---|
[2938] | 583 | case GL_MAP2_VERTEX_3:
|
---|
[3598] | 584 | return ctx->Eval.Map2Vertex3;
|
---|
[2938] | 585 | case GL_MAP2_VERTEX_4:
|
---|
[3598] | 586 | return ctx->Eval.Map2Vertex4;
|
---|
[2938] | 587 | case GL_NORMALIZE:
|
---|
[3598] | 588 | return ctx->Transform.Normalize;
|
---|
[2938] | 589 | case GL_POINT_SMOOTH:
|
---|
[3598] | 590 | return ctx->Point.SmoothFlag;
|
---|
[2938] | 591 | case GL_POLYGON_SMOOTH:
|
---|
[3598] | 592 | return ctx->Polygon.SmoothFlag;
|
---|
[2938] | 593 | case GL_POLYGON_STIPPLE:
|
---|
[3598] | 594 | return ctx->Polygon.StippleFlag;
|
---|
[2938] | 595 | case GL_POLYGON_OFFSET_POINT:
|
---|
[3598] | 596 | return ctx->Polygon.OffsetPoint;
|
---|
[2938] | 597 | case GL_POLYGON_OFFSET_LINE:
|
---|
[3598] | 598 | return ctx->Polygon.OffsetLine;
|
---|
[2938] | 599 | case GL_POLYGON_OFFSET_FILL:
|
---|
| 600 | /*case GL_POLYGON_OFFSET_EXT:*/
|
---|
[3598] | 601 | return ctx->Polygon.OffsetFill;
|
---|
[2938] | 602 | case GL_RESCALE_NORMAL_EXT:
|
---|
| 603 | return ctx->Transform.RescaleNormals;
|
---|
| 604 | case GL_SCISSOR_TEST:
|
---|
[3598] | 605 | return ctx->Scissor.Enabled;
|
---|
[2938] | 606 | case GL_SHARED_TEXTURE_PALETTE_EXT:
|
---|
| 607 | return ctx->Texture.SharedPalette;
|
---|
| 608 | case GL_STENCIL_TEST:
|
---|
[3598] | 609 | return ctx->Stencil.Enabled;
|
---|
[2938] | 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;
|
---|
[3598] | 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 |
|
---|
[2938] | 672 | default:
|
---|
[3598] | 673 | gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
|
---|
| 674 | return GL_FALSE;
|
---|
[2938] | 675 | }
|
---|
| 676 | }
|
---|
| 677 |
|
---|
| 678 |
|
---|
| 679 |
|
---|
| 680 |
|
---|
[3598] | 681 | static void
|
---|
| 682 | client_state( GLcontext *ctx, GLenum cap, GLboolean state )
|
---|
[2938] | 683 | {
|
---|
| 684 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx,
|
---|
[3598] | 685 | (state
|
---|
| 686 | ? "glEnableClientState"
|
---|
| 687 | : "glDisableClientState") );
|
---|
[2938] | 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 |
|
---|
[3598] | 717 | void
|
---|
| 718 | _mesa_EnableClientState( GLenum cap )
|
---|
[2938] | 719 | {
|
---|
[3598] | 720 | GET_CURRENT_CONTEXT(ctx);
|
---|
| 721 | client_state( ctx, cap, GL_TRUE );
|
---|
[2938] | 722 | }
|
---|
| 723 |
|
---|
| 724 |
|
---|
| 725 |
|
---|
[3598] | 726 | void
|
---|
| 727 | _mesa_DisableClientState( GLenum cap )
|
---|
[2938] | 728 | {
|
---|
[3598] | 729 | GET_CURRENT_CONTEXT(ctx);
|
---|
| 730 | client_state( ctx, cap, GL_FALSE );
|
---|
[2938] | 731 | }
|
---|
| 732 |
|
---|