attrib.c revision 23caf20169ac38436ee9c13914f1d6aa7cf6bb5e
1/* $Id: attrib.c,v 1.34 2000/11/16 21:05:34 keithw Exp $ */ 2 3/* 4 * Mesa 3-D graphics library 5 * Version: 3.5 6 * 7 * Copyright (C) 1999-2000 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 31#include "glheader.h" 32#include "attrib.h" 33#include "buffers.h" 34#include "context.h" 35#include "enable.h" 36#include "enums.h" 37#include "matrix.h" 38#include "mem.h" 39#include "simple_list.h" 40#include "texstate.h" 41#include "types.h" 42#endif 43 44 45 46 47/* 48 * Allocate a new attribute state node. These nodes have a 49 * "kind" value and a pointer to a struct of state data. 50 */ 51static struct gl_attrib_node * 52new_attrib_node( GLbitfield kind ) 53{ 54 struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node); 55 if (an) { 56 an->kind = kind; 57 } 58 return an; 59} 60 61 62 63/* 64 * Copy texture object state from one texture object to another. 65 */ 66static void 67copy_texobj_state( struct gl_texture_object *dest, 68 const struct gl_texture_object *src ) 69{ 70 /* 71 dest->Name = src->Name; 72 dest->Dimensions = src->Dimensions; 73 */ 74 dest->Priority = src->Priority; 75 dest->BorderColor[0] = src->BorderColor[0]; 76 dest->BorderColor[1] = src->BorderColor[1]; 77 dest->BorderColor[2] = src->BorderColor[2]; 78 dest->BorderColor[3] = src->BorderColor[3]; 79 dest->WrapS = src->WrapS; 80 dest->WrapT = src->WrapT; 81 dest->WrapR = src->WrapR; 82 dest->MinFilter = src->MinFilter; 83 dest->MagFilter = src->MagFilter; 84 dest->MinLod = src->MinLod; 85 dest->MaxLod = src->MaxLod; 86 dest->BaseLevel = src->BaseLevel; 87 dest->MaxLevel = src->MaxLevel; 88 dest->_P = src->_P; 89 dest->_M = src->_M; 90 dest->Palette = src->Palette; 91 dest->Complete = src->Complete; 92} 93 94 95 96void 97_mesa_PushAttrib(GLbitfield mask) 98{ 99 struct gl_attrib_node *newnode; 100 struct gl_attrib_node *head; 101 102 GET_CURRENT_CONTEXT(ctx); 103 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushAttrib"); 104 105 if (MESA_VERBOSE&VERBOSE_API) 106 fprintf(stderr, "glPushAttrib %x\n", (int)mask); 107 108 if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) { 109 gl_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); 110 return; 111 } 112 113 /* Build linked list of attribute nodes which save all attribute */ 114 /* groups specified by the mask. */ 115 head = NULL; 116 117 if (mask & GL_ACCUM_BUFFER_BIT) { 118 struct gl_accum_attrib *attr; 119 attr = MALLOC_STRUCT( gl_accum_attrib ); 120 MEMCPY( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); 121 newnode = new_attrib_node( GL_ACCUM_BUFFER_BIT ); 122 newnode->data = attr; 123 newnode->next = head; 124 head = newnode; 125 } 126 127 if (mask & GL_COLOR_BUFFER_BIT) { 128 struct gl_colorbuffer_attrib *attr; 129 attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); 130 MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); 131 newnode = new_attrib_node( GL_COLOR_BUFFER_BIT ); 132 newnode->data = attr; 133 newnode->next = head; 134 head = newnode; 135 } 136 137 if (mask & GL_CURRENT_BIT) { 138 struct gl_current_attrib *attr; 139 140 FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT ); 141 142 attr = MALLOC_STRUCT( gl_current_attrib ); 143 MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); 144 newnode = new_attrib_node( GL_CURRENT_BIT ); 145 newnode->data = attr; 146 newnode->next = head; 147 head = newnode; 148 } 149 150 if (mask & GL_DEPTH_BUFFER_BIT) { 151 struct gl_depthbuffer_attrib *attr; 152 attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); 153 MEMCPY( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); 154 newnode = new_attrib_node( GL_DEPTH_BUFFER_BIT ); 155 newnode->data = attr; 156 newnode->next = head; 157 head = newnode; 158 } 159 160 if (mask & GL_ENABLE_BIT) { 161 struct gl_enable_attrib *attr; 162 GLuint i; 163 attr = MALLOC_STRUCT( gl_enable_attrib ); 164 /* Copy enable flags from all other attributes into the enable struct. */ 165 attr->AlphaTest = ctx->Color.AlphaEnabled; 166 attr->AutoNormal = ctx->Eval.AutoNormal; 167 attr->Blend = ctx->Color.BlendEnabled; 168 for (i=0;i<MAX_CLIP_PLANES;i++) { 169 attr->ClipPlane[i] = ctx->Transform.ClipEnabled[i]; 170 } 171 attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; 172 attr->Convolution1D = ctx->Pixel.Convolution1DEnabled; 173 attr->Convolution2D = ctx->Pixel.Convolution2DEnabled; 174 attr->Separable2D = ctx->Pixel.Separable2DEnabled; 175 attr->CullFace = ctx->Polygon.CullFlag; 176 attr->DepthTest = ctx->Depth.Test; 177 attr->Dither = ctx->Color.DitherFlag; 178 attr->Fog = ctx->Fog.Enabled; 179 for (i=0;i<MAX_LIGHTS;i++) { 180 attr->Light[i] = ctx->Light.Light[i].Enabled; 181 } 182 attr->Lighting = ctx->Light.Enabled; 183 attr->LineSmooth = ctx->Line.SmoothFlag; 184 attr->LineStipple = ctx->Line.StippleFlag; 185 attr->Histogram = ctx->Pixel.HistogramEnabled; 186 attr->MinMax = ctx->Pixel.MinMaxEnabled; 187 attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; 188 attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; 189 attr->Map1Color4 = ctx->Eval.Map1Color4; 190 attr->Map1Index = ctx->Eval.Map1Index; 191 attr->Map1Normal = ctx->Eval.Map1Normal; 192 attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; 193 attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; 194 attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; 195 attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; 196 attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; 197 attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; 198 attr->Map2Color4 = ctx->Eval.Map2Color4; 199 attr->Map2Index = ctx->Eval.Map2Index; 200 attr->Map2Normal = ctx->Eval.Map2Normal; 201 attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; 202 attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; 203 attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; 204 attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; 205 attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; 206 attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; 207 attr->Normalize = ctx->Transform.Normalize; 208 attr->PixelTexture = ctx->Pixel.PixelTextureEnabled; 209 attr->PointSmooth = ctx->Point.SmoothFlag; 210 attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; 211 attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; 212 attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; 213 attr->PolygonSmooth = ctx->Polygon.SmoothFlag; 214 attr->PolygonStipple = ctx->Polygon.StippleFlag; 215 attr->RescaleNormals = ctx->Transform.RescaleNormals; 216 attr->Scissor = ctx->Scissor.Enabled; 217 attr->Stencil = ctx->Stencil.Enabled; 218 for (i=0; i<MAX_TEXTURE_UNITS; i++) { 219 attr->Texture[i] = ctx->Texture.Unit[i].Enabled; 220 attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; 221 } 222 newnode = new_attrib_node( GL_ENABLE_BIT ); 223 newnode->data = attr; 224 newnode->next = head; 225 head = newnode; 226 } 227 228 if (mask & GL_EVAL_BIT) { 229 struct gl_eval_attrib *attr; 230 attr = MALLOC_STRUCT( gl_eval_attrib ); 231 MEMCPY( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); 232 newnode = new_attrib_node( GL_EVAL_BIT ); 233 newnode->data = attr; 234 newnode->next = head; 235 head = newnode; 236 } 237 238 if (mask & GL_FOG_BIT) { 239 struct gl_fog_attrib *attr; 240 attr = MALLOC_STRUCT( gl_fog_attrib ); 241 MEMCPY( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); 242 newnode = new_attrib_node( GL_FOG_BIT ); 243 newnode->data = attr; 244 newnode->next = head; 245 head = newnode; 246 } 247 248 if (mask & GL_HINT_BIT) { 249 struct gl_hint_attrib *attr; 250 attr = MALLOC_STRUCT( gl_hint_attrib ); 251 MEMCPY( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); 252 newnode = new_attrib_node( GL_HINT_BIT ); 253 newnode->data = attr; 254 newnode->next = head; 255 head = newnode; 256 } 257 258 if (mask & GL_LIGHTING_BIT) { 259 struct gl_light_attrib *attr; 260 attr = MALLOC_STRUCT( gl_light_attrib ); 261 MEMCPY( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); 262 newnode = new_attrib_node( GL_LIGHTING_BIT ); 263 newnode->data = attr; 264 newnode->next = head; 265 head = newnode; 266 } 267 268 if (mask & GL_LINE_BIT) { 269 struct gl_line_attrib *attr; 270 attr = MALLOC_STRUCT( gl_line_attrib ); 271 MEMCPY( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); 272 newnode = new_attrib_node( GL_LINE_BIT ); 273 newnode->data = attr; 274 newnode->next = head; 275 head = newnode; 276 } 277 278 if (mask & GL_LIST_BIT) { 279 struct gl_list_attrib *attr; 280 attr = MALLOC_STRUCT( gl_list_attrib ); 281 MEMCPY( attr, &ctx->List, sizeof(struct gl_list_attrib) ); 282 newnode = new_attrib_node( GL_LIST_BIT ); 283 newnode->data = attr; 284 newnode->next = head; 285 head = newnode; 286 } 287 288 if (mask & GL_PIXEL_MODE_BIT) { 289 struct gl_pixel_attrib *attr; 290 attr = MALLOC_STRUCT( gl_pixel_attrib ); 291 MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); 292 newnode = new_attrib_node( GL_PIXEL_MODE_BIT ); 293 newnode->data = attr; 294 newnode->next = head; 295 head = newnode; 296 } 297 298 if (mask & GL_POINT_BIT) { 299 struct gl_point_attrib *attr; 300 attr = MALLOC_STRUCT( gl_point_attrib ); 301 MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); 302 newnode = new_attrib_node( GL_POINT_BIT ); 303 newnode->data = attr; 304 newnode->next = head; 305 head = newnode; 306 } 307 308 if (mask & GL_POLYGON_BIT) { 309 struct gl_polygon_attrib *attr; 310 attr = MALLOC_STRUCT( gl_polygon_attrib ); 311 MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); 312 newnode = new_attrib_node( GL_POLYGON_BIT ); 313 newnode->data = attr; 314 newnode->next = head; 315 head = newnode; 316 } 317 318 if (mask & GL_POLYGON_STIPPLE_BIT) { 319 GLuint *stipple; 320 stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) ); 321 MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); 322 newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT ); 323 newnode->data = stipple; 324 newnode->next = head; 325 head = newnode; 326 } 327 328 if (mask & GL_SCISSOR_BIT) { 329 struct gl_scissor_attrib *attr; 330 attr = MALLOC_STRUCT( gl_scissor_attrib ); 331 MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); 332 newnode = new_attrib_node( GL_SCISSOR_BIT ); 333 newnode->data = attr; 334 newnode->next = head; 335 head = newnode; 336 } 337 338 if (mask & GL_STENCIL_BUFFER_BIT) { 339 struct gl_stencil_attrib *attr; 340 attr = MALLOC_STRUCT( gl_stencil_attrib ); 341 MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); 342 newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT ); 343 newnode->data = attr; 344 newnode->next = head; 345 head = newnode; 346 } 347 348 if (mask & GL_TEXTURE_BIT) { 349 struct gl_texture_attrib *attr; 350 GLuint u; 351 /* Take care of texture object reference counters */ 352 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 353 ctx->Texture.Unit[u].CurrentD[1]->RefCount++; 354 ctx->Texture.Unit[u].CurrentD[2]->RefCount++; 355 ctx->Texture.Unit[u].CurrentD[3]->RefCount++; 356 } 357 attr = MALLOC_STRUCT( gl_texture_attrib ); 358 MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) ); 359 /* copy state of the currently bound texture objects */ 360 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 361 copy_texobj_state(&attr->Unit[u].Saved1D, attr->Unit[u].CurrentD[1]); 362 copy_texobj_state(&attr->Unit[u].Saved2D, attr->Unit[u].CurrentD[2]); 363 copy_texobj_state(&attr->Unit[u].Saved3D, attr->Unit[u].CurrentD[3]); 364 copy_texobj_state(&attr->Unit[u].SavedCubeMap, attr->Unit[u].CurrentCubeMap); 365 } 366 newnode = new_attrib_node( GL_TEXTURE_BIT ); 367 newnode->data = attr; 368 newnode->next = head; 369 head = newnode; 370 } 371 372 if (mask & GL_TRANSFORM_BIT) { 373 struct gl_transform_attrib *attr; 374 attr = MALLOC_STRUCT( gl_transform_attrib ); 375 MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); 376 newnode = new_attrib_node( GL_TRANSFORM_BIT ); 377 newnode->data = attr; 378 newnode->next = head; 379 head = newnode; 380 } 381 382 if (mask & GL_VIEWPORT_BIT) { 383 struct gl_viewport_attrib *attr; 384 attr = MALLOC_STRUCT( gl_viewport_attrib ); 385 MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); 386 newnode = new_attrib_node( GL_VIEWPORT_BIT ); 387 newnode->data = attr; 388 newnode->next = head; 389 head = newnode; 390 } 391 392 ctx->AttribStack[ctx->AttribStackDepth] = head; 393 ctx->AttribStackDepth++; 394} 395 396 397 398static void 399pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) 400{ 401 GLuint i; 402 403#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ 404 if ((VALUE) != (NEWVALUE)) { \ 405 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ 406 } 407 408 TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); 409 TEST_AND_UPDATE(ctx->Transform.Normalize, enable->AutoNormal, GL_NORMALIZE); 410 TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND); 411 412 for (i=0;i<MAX_CLIP_PLANES;i++) { 413 if (ctx->Transform.ClipEnabled[i] != enable->ClipPlane[i]) 414 _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i), 415 enable->ClipPlane[i]); 416 } 417 418 TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, 419 GL_COLOR_MATERIAL); 420 TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); 421 TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); 422 TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); 423 TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D, 424 GL_CONVOLUTION_1D); 425 TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D, 426 GL_CONVOLUTION_2D); 427 TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D, 428 GL_SEPARABLE_2D); 429 TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); 430 TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); 431 TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); 432 TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple, 433 GL_LINE_STIPPLE); 434 TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp, 435 GL_INDEX_LOGIC_OP); 436 TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, 437 GL_COLOR_LOGIC_OP); 438 TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); 439 TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); 440 TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); 441 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1, 442 GL_MAP1_TEXTURE_COORD_1); 443 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2, 444 GL_MAP1_TEXTURE_COORD_2); 445 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3, 446 GL_MAP1_TEXTURE_COORD_3); 447 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4, 448 GL_MAP1_TEXTURE_COORD_4); 449 TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3, 450 GL_MAP1_VERTEX_3); 451 TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, 452 GL_MAP1_VERTEX_4); 453 TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); 454 TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); 455 TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); 456 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1, 457 GL_MAP2_TEXTURE_COORD_1); 458 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2, 459 GL_MAP2_TEXTURE_COORD_2); 460 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3, 461 GL_MAP2_TEXTURE_COORD_3); 462 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4, 463 GL_MAP2_TEXTURE_COORD_4); 464 TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3, 465 GL_MAP2_VERTEX_3); 466 TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, 467 GL_MAP2_VERTEX_4); 468 TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); 469 TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, 470 GL_RESCALE_NORMAL_EXT); 471 TEST_AND_UPDATE(ctx->Pixel.PixelTextureEnabled, enable->PixelTexture, 472 GL_POINT_SMOOTH); 473 TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, 474 GL_POINT_SMOOTH); 475 TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, 476 GL_POLYGON_OFFSET_POINT); 477 TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, 478 GL_POLYGON_OFFSET_LINE); 479 TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill, 480 GL_POLYGON_OFFSET_FILL); 481 TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth, 482 GL_POLYGON_SMOOTH); 483 TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple, 484 GL_POLYGON_STIPPLE); 485 TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST); 486 TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST); 487#undef TEST_AND_UPDATE 488 489 /* texture unit enables */ 490 for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { 491 if (ctx->Texture.Unit[i].Enabled != enable->Texture[i]) { 492 ctx->Texture.Unit[i].Enabled = enable->Texture[i]; 493 if (ctx->Driver.Enable) { 494 if (ctx->Driver.ActiveTexture) { 495 (*ctx->Driver.ActiveTexture)(ctx, i); 496 } 497 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D, 498 (GLboolean) (enable->Texture[i] & TEXTURE0_1D) ); 499 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D, 500 (GLboolean) (enable->Texture[i] & TEXTURE0_2D) ); 501 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D, 502 (GLboolean) (enable->Texture[i] & TEXTURE0_3D) ); 503 } 504 } 505 506 if (ctx->Texture.Unit[i].TexGenEnabled != enable->TexGen[i]) { 507 ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i]; 508 if (ctx->Driver.Enable) { 509 if (ctx->Driver.ActiveTexture) { 510 (*ctx->Driver.ActiveTexture)(ctx, i); 511 } 512 if (enable->TexGen[i] & S_BIT) 513 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_TRUE); 514 else 515 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_FALSE); 516 if (enable->TexGen[i] & T_BIT) 517 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_TRUE); 518 else 519 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_FALSE); 520 if (enable->TexGen[i] & R_BIT) 521 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_TRUE); 522 else 523 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_FALSE); 524 if (enable->TexGen[i] & Q_BIT) 525 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_TRUE); 526 else 527 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE); 528 } 529 } 530 } 531 532 if (ctx->Driver.ActiveTexture) { 533 (*ctx->Driver.ActiveTexture)(ctx, ctx->Texture.CurrentUnit); 534 } 535} 536 537 538 539/* 540 * This function is kind of long just because we have to call a lot 541 * of device driver functions to update device driver state. 542 */ 543void 544_mesa_PopAttrib(void) 545{ 546 struct gl_attrib_node *attr, *next; 547 GET_CURRENT_CONTEXT(ctx); 548 549 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopAttrib"); 550 551 552 if (ctx->AttribStackDepth==0) { 553 gl_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); 554 return; 555 } 556 557 ctx->AttribStackDepth--; 558 attr = ctx->AttribStack[ctx->AttribStackDepth]; 559 560 while (attr) { 561 562 if (MESA_VERBOSE&VERBOSE_API) 563 fprintf(stderr, "glPopAttrib %s\n", gl_lookup_enum_by_nr(attr->kind)); 564 565 switch (attr->kind) { 566 case GL_ACCUM_BUFFER_BIT: 567 MEMCPY( &ctx->Accum, attr->data, sizeof(struct gl_accum_attrib) ); 568 ctx->NewState |= _NEW_ACCUM; 569 break; 570 case GL_COLOR_BUFFER_BIT: 571 { 572 GLenum oldDrawBuffer = ctx->Color.DrawBuffer; 573 GLenum oldAlphaFunc = ctx->Color.AlphaFunc; 574 GLchan oldAlphaRef = ctx->Color.AlphaRef; 575 GLenum oldBlendSrc = ctx->Color.BlendSrcRGB; 576 GLenum oldBlendDst = ctx->Color.BlendDstRGB; 577 GLenum oldLogicOp = ctx->Color.LogicOp; 578 MEMCPY( &ctx->Color, attr->data, 579 sizeof(struct gl_colorbuffer_attrib) ); 580 ctx->NewState |= _NEW_COLOR; 581 if (ctx->Color.DrawBuffer != oldDrawBuffer) { 582 _mesa_DrawBuffer( ctx->Color.DrawBuffer); 583 } 584 if ((ctx->Color.BlendSrcRGB != oldBlendSrc || 585 ctx->Color.BlendDstRGB != oldBlendDst) && 586 ctx->Driver.BlendFunc) 587 (*ctx->Driver.BlendFunc)( ctx, ctx->Color.BlendSrcRGB, 588 ctx->Color.BlendDstRGB); 589 if (ctx->Color.LogicOp != oldLogicOp && 590 ctx->Driver.LogicOpcode) { 591 ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp ); 592 } 593 if (ctx->Visual.RGBAflag) { 594 GLchan r = (GLint) (ctx->Color.ClearColor[0] * CHAN_MAXF); 595 GLchan g = (GLint) (ctx->Color.ClearColor[1] * CHAN_MAXF); 596 GLchan b = (GLint) (ctx->Color.ClearColor[2] * CHAN_MAXF); 597 GLchan a = (GLint) (ctx->Color.ClearColor[3] * CHAN_MAXF); 598 (*ctx->Driver.ClearColor)( ctx, r, g, b, a ); 599 if ((ctx->Color.AlphaFunc != oldAlphaFunc || 600 ctx->Color.AlphaRef != oldAlphaRef) && 601 ctx->Driver.AlphaFunc) 602 (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc, 603 ctx->Color.AlphaRef / CHAN_MAXF); 604 if (ctx->Driver.ColorMask) { 605 (*ctx->Driver.ColorMask)(ctx, 606 ctx->Color.ColorMask[0], 607 ctx->Color.ColorMask[1], 608 ctx->Color.ColorMask[2], 609 ctx->Color.ColorMask[3]); 610 } 611 } 612 else { 613 (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex); 614 } 615 } 616 break; 617 case GL_CURRENT_BIT: 618 FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT ); 619 MEMCPY( &ctx->Current, attr->data, 620 sizeof(struct gl_current_attrib) ); 621 break; 622 case GL_DEPTH_BUFFER_BIT: 623 { 624 GLboolean oldDepthTest = ctx->Depth.Test; 625 GLenum oldDepthFunc = ctx->Depth.Func; 626 GLboolean oldDepthMask = ctx->Depth.Mask; 627 GLfloat oldDepthClear = ctx->Depth.Clear; 628 MEMCPY( &ctx->Depth, attr->data, 629 sizeof(struct gl_depthbuffer_attrib) ); 630 ctx->NewState |= _NEW_DEPTH; 631 if (ctx->Depth.Test != oldDepthTest && ctx->Driver.Enable) 632 (*ctx->Driver.Enable)( ctx, GL_DEPTH_TEST, ctx->Depth.Test); 633 if (ctx->Depth.Func != oldDepthFunc && ctx->Driver.DepthFunc) 634 (*ctx->Driver.DepthFunc)( ctx, ctx->Depth.Func ); 635 if (ctx->Depth.Mask != oldDepthMask && ctx->Driver.DepthMask) 636 (*ctx->Driver.DepthMask)( ctx, ctx->Depth.Mask ); 637 if (ctx->Depth.Clear != oldDepthClear && ctx->Driver.ClearDepth) 638 (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear ); 639 } 640 break; 641 case GL_ENABLE_BIT: 642 { 643 const struct gl_enable_attrib *enable; 644 enable = (const struct gl_enable_attrib *) attr->data; 645 pop_enable_group(ctx, enable); 646 ctx->NewState |= _NEW_ALL; 647 } 648 break; 649 case GL_EVAL_BIT: 650 MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); 651 ctx->NewState |= _NEW_EVAL; 652 break; 653 case GL_FOG_BIT: 654 { 655 GLboolean anyChange = (GLboolean) (memcmp( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) ) != 0); 656 MEMCPY( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) ); 657 ctx->NewState |= _NEW_FOG; 658 if (anyChange && ctx->Driver.Fogfv) { 659 const GLfloat mode = (GLfloat) ctx->Fog.Mode; 660 const GLfloat density = ctx->Fog.Density; 661 const GLfloat start = ctx->Fog.Start; 662 const GLfloat end = ctx->Fog.End; 663 const GLfloat index = ctx->Fog.Index; 664 (*ctx->Driver.Fogfv)( ctx, GL_FOG_MODE, &mode); 665 (*ctx->Driver.Fogfv)( ctx, GL_FOG_DENSITY, &density ); 666 (*ctx->Driver.Fogfv)( ctx, GL_FOG_START, &start ); 667 (*ctx->Driver.Fogfv)( ctx, GL_FOG_END, &end ); 668 (*ctx->Driver.Fogfv)( ctx, GL_FOG_INDEX, &index ); 669 (*ctx->Driver.Fogfv)( ctx, GL_FOG_COLOR, ctx->Fog.Color ); 670 } 671 ctx->_Enabled &= ~ENABLE_FOG; 672 if (ctx->Fog.Enabled) ctx->_Enabled |= ENABLE_FOG; 673 } 674 break; 675 case GL_HINT_BIT: 676 MEMCPY( &ctx->Hint, attr->data, sizeof(struct gl_hint_attrib) ); 677 ctx->NewState |= _NEW_HINT; 678 if (ctx->Driver.Hint) { 679 (*ctx->Driver.Hint)( ctx, GL_PERSPECTIVE_CORRECTION_HINT, 680 ctx->Hint.PerspectiveCorrection ); 681 (*ctx->Driver.Hint)( ctx, GL_POINT_SMOOTH_HINT, 682 ctx->Hint.PointSmooth); 683 (*ctx->Driver.Hint)( ctx, GL_LINE_SMOOTH_HINT, 684 ctx->Hint.LineSmooth ); 685 (*ctx->Driver.Hint)( ctx, GL_POLYGON_SMOOTH_HINT, 686 ctx->Hint.PolygonSmooth ); 687 (*ctx->Driver.Hint)( ctx, GL_FOG_HINT, ctx->Hint.Fog ); 688 } 689 break; 690 case GL_LIGHTING_BIT: 691 MEMCPY( &ctx->Light, attr->data, sizeof(struct gl_light_attrib) ); 692 ctx->NewState |= _NEW_LIGHT; 693 if (ctx->Driver.Enable) { 694 GLuint i; 695 for (i = 0; i < MAX_LIGHTS; i++) { 696 GLenum light = (GLenum) (GL_LIGHT0 + i); 697 (*ctx->Driver.Enable)( ctx, light, ctx->Light.Light[i].Enabled ); 698 } 699 (*ctx->Driver.Enable)( ctx, GL_LIGHTING, ctx->Light.Enabled ); 700 } 701 if (ctx->Light.ShadeModel == GL_FLAT) 702 ctx->_TriangleCaps |= DD_FLATSHADE; 703 else 704 ctx->_TriangleCaps &= ~DD_FLATSHADE; 705 if (ctx->Driver.ShadeModel) 706 (*ctx->Driver.ShadeModel)(ctx, ctx->Light.ShadeModel); 707 ctx->_Enabled &= ~ENABLE_LIGHT; 708 if (ctx->Light.Enabled && !is_empty_list(&ctx->Light.EnabledList)) 709 ctx->_Enabled |= ENABLE_LIGHT; 710 break; 711 case GL_LINE_BIT: 712 MEMCPY( &ctx->Line, attr->data, sizeof(struct gl_line_attrib) ); 713 ctx->NewState |= _NEW_LINE; 714 if (ctx->Driver.Enable) { 715 (*ctx->Driver.Enable)( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag ); 716 (*ctx->Driver.Enable)( ctx, GL_LINE_STIPPLE, ctx->Line.StippleFlag ); 717 } 718 if (ctx->Driver.LineStipple) 719 (*ctx->Driver.LineStipple)(ctx, ctx->Line.StippleFactor, 720 ctx->Line.StipplePattern); 721 if (ctx->Driver.LineWidth) 722 (*ctx->Driver.LineWidth)(ctx, ctx->Line.Width); 723 break; 724 case GL_LIST_BIT: 725 MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); 726 break; 727 case GL_PIXEL_MODE_BIT: 728 MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); 729 ctx->NewState |= _NEW_PIXEL; 730 break; 731 case GL_POINT_BIT: 732 MEMCPY( &ctx->Point, attr->data, sizeof(struct gl_point_attrib) ); 733 ctx->NewState |= _NEW_POINT; 734 if (ctx->Driver.Enable) 735 (*ctx->Driver.Enable)( ctx, GL_POINT_SMOOTH, ctx->Point.SmoothFlag ); 736 break; 737 case GL_POLYGON_BIT: 738 { 739 GLenum oldFrontMode = ctx->Polygon.FrontMode; 740 GLenum oldBackMode = ctx->Polygon.BackMode; 741 MEMCPY( &ctx->Polygon, attr->data, 742 sizeof(struct gl_polygon_attrib) ); 743 ctx->NewState |= _NEW_POLYGON; 744 if ((ctx->Polygon.FrontMode != oldFrontMode || 745 ctx->Polygon.BackMode != oldBackMode) && 746 ctx->Driver.PolygonMode) { 747 (*ctx->Driver.PolygonMode)( ctx, GL_FRONT, ctx->Polygon.FrontMode); 748 (*ctx->Driver.PolygonMode)( ctx, GL_BACK, ctx->Polygon.BackMode); 749 } 750 if (ctx->Driver.CullFace) 751 ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode ); 752 753 if (ctx->Driver.FrontFace) 754 ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace ); 755 756 if (ctx->Driver.Enable) 757 (*ctx->Driver.Enable)( ctx, GL_POLYGON_SMOOTH, ctx->Polygon.SmoothFlag ); 758 } 759 break; 760 case GL_POLYGON_STIPPLE_BIT: 761 MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); 762 ctx->NewState |= _NEW_POLYGONSTIPPLE; 763 if (ctx->Driver.PolygonStipple) 764 ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); 765 break; 766 case GL_SCISSOR_BIT: 767 MEMCPY( &ctx->Scissor, attr->data, 768 sizeof(struct gl_scissor_attrib) ); 769 ctx->NewState |= _NEW_SCISSOR; 770 if (ctx->Driver.Enable) 771 (*ctx->Driver.Enable)( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled ); 772 if (ctx->Driver.Scissor) 773 ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, 774 ctx->Scissor.Width, ctx->Scissor.Height ); 775 break; 776 case GL_STENCIL_BUFFER_BIT: 777 MEMCPY( &ctx->Stencil, attr->data, 778 sizeof(struct gl_stencil_attrib) ); 779 ctx->NewState |= _NEW_STENCIL; 780 if (ctx->Driver.StencilFunc) 781 (*ctx->Driver.StencilFunc)( ctx, ctx->Stencil.Function, 782 ctx->Stencil.Ref, ctx->Stencil.ValueMask); 783 if (ctx->Driver.StencilMask) 784 (*ctx->Driver.StencilMask)( ctx, ctx->Stencil.WriteMask ); 785 if (ctx->Driver.StencilOp) 786 (*ctx->Driver.StencilOp)( ctx, ctx->Stencil.FailFunc, 787 ctx->Stencil.ZFailFunc, ctx->Stencil.ZPassFunc); 788 if (ctx->Driver.ClearStencil) 789 (*ctx->Driver.ClearStencil)( ctx, ctx->Stencil.Clear ); 790 if (ctx->Driver.Enable) 791 (*ctx->Driver.Enable)( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled ); 792 ctx->_TriangleCaps &= ~DD_STENCIL; 793 if (ctx->Stencil.Enabled) 794 ctx->_TriangleCaps |= DD_STENCIL; 795 796 break; 797 case GL_TRANSFORM_BIT: 798 MEMCPY( &ctx->Transform, attr->data, 799 sizeof(struct gl_transform_attrib) ); 800 ctx->NewState |= _NEW_TRANSFORM; 801 if (ctx->Driver.Enable) { 802 (*ctx->Driver.Enable)( ctx, GL_NORMALIZE, ctx->Transform.Normalize ); 803 (*ctx->Driver.Enable)( ctx, GL_RESCALE_NORMAL_EXT, ctx->Transform.RescaleNormals ); 804 } 805 ctx->_Enabled &= ~(ENABLE_NORMALIZE|ENABLE_RESCALE); 806 if (ctx->Transform.Normalize) ctx->_Enabled |= ENABLE_NORMALIZE; 807 if (ctx->Transform.RescaleNormals) ctx->_Enabled |= ENABLE_RESCALE; 808 break; 809 case GL_TEXTURE_BIT: 810 /* Take care of texture object reference counters */ 811 { 812 GLuint u; 813 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 814 ctx->Texture.Unit[u].CurrentD[1]->RefCount--; 815 ctx->Texture.Unit[u].CurrentD[2]->RefCount--; 816 ctx->Texture.Unit[u].CurrentD[3]->RefCount--; 817 } 818 MEMCPY( &ctx->Texture, attr->data, 819 sizeof(struct gl_texture_attrib) ); 820 ctx->NewState |= _NEW_TEXTURE; 821 /* restore state of the currently bound texture objects */ 822 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { 823 copy_texobj_state( ctx->Texture.Unit[u].CurrentD[1], 824 &(ctx->Texture.Unit[u].Saved1D) ); 825 copy_texobj_state( ctx->Texture.Unit[u].CurrentD[2], 826 &(ctx->Texture.Unit[u].Saved2D) ); 827 copy_texobj_state( ctx->Texture.Unit[u].CurrentD[3], 828 &(ctx->Texture.Unit[u].Saved3D) ); 829 copy_texobj_state( ctx->Texture.Unit[u].CurrentCubeMap, 830 &(ctx->Texture.Unit[u].SavedCubeMap) ); 831 832 gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[1] ); 833 gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[2] ); 834 gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentD[3] ); 835 gl_put_texobj_on_dirty_list( ctx, ctx->Texture.Unit[u].CurrentCubeMap ); 836 837 } 838 } 839 break; 840 case GL_VIEWPORT_BIT: 841 { 842 struct gl_viewport_attrib *v = 843 (struct gl_viewport_attrib *)attr->data; 844 845 ctx->NewState |= _NEW_VIEWPORT; 846 _mesa_Viewport( v->X, v->Y, v->Width, v->Height ); 847 _mesa_DepthRange( v->Near, v->Far ); 848 break; 849 } 850 default: 851 gl_problem( ctx, "Bad attrib flag in PopAttrib"); 852 break; 853 } 854 855 next = attr->next; 856 FREE( attr->data ); 857 FREE( attr ); 858 attr = next; 859 } 860} 861 862 863#define GL_CLIENT_PACK_BIT (1<<20) 864#define GL_CLIENT_UNPACK_BIT (1<<21) 865 866 867void 868_mesa_PushClientAttrib(GLbitfield mask) 869{ 870 struct gl_attrib_node *newnode; 871 struct gl_attrib_node *head; 872 873 GET_CURRENT_CONTEXT(ctx); 874 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushClientAttrib"); 875 876 if (ctx->ClientAttribStackDepth>=MAX_CLIENT_ATTRIB_STACK_DEPTH) { 877 gl_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); 878 return; 879 } 880 881 /* Build linked list of attribute nodes which save all attribute */ 882 /* groups specified by the mask. */ 883 head = NULL; 884 885 if (mask & GL_CLIENT_PIXEL_STORE_BIT) { 886 struct gl_pixelstore_attrib *attr; 887 /* packing attribs */ 888 attr = MALLOC_STRUCT( gl_pixelstore_attrib ); 889 MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) ); 890 newnode = new_attrib_node( GL_CLIENT_PACK_BIT ); 891 newnode->data = attr; 892 newnode->next = head; 893 head = newnode; 894 /* unpacking attribs */ 895 attr = MALLOC_STRUCT( gl_pixelstore_attrib ); 896 MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) ); 897 newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT ); 898 newnode->data = attr; 899 newnode->next = head; 900 head = newnode; 901 } 902 if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { 903 struct gl_array_attrib *attr; 904 attr = MALLOC_STRUCT( gl_array_attrib ); 905 MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) ); 906 newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT ); 907 newnode->data = attr; 908 newnode->next = head; 909 head = newnode; 910 } 911 912 ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; 913 ctx->ClientAttribStackDepth++; 914} 915 916 917 918 919void 920_mesa_PopClientAttrib(void) 921{ 922 struct gl_attrib_node *attr, *next; 923 924 GET_CURRENT_CONTEXT(ctx); 925 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopClientAttrib"); 926 927 if (ctx->ClientAttribStackDepth==0) { 928 gl_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); 929 return; 930 } 931 932 ctx->ClientAttribStackDepth--; 933 attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; 934 935 while (attr) { 936 switch (attr->kind) { 937 case GL_CLIENT_PACK_BIT: 938 MEMCPY( &ctx->Pack, attr->data, 939 sizeof(struct gl_pixelstore_attrib) ); 940 break; 941 case GL_CLIENT_UNPACK_BIT: 942 MEMCPY( &ctx->Unpack, attr->data, 943 sizeof(struct gl_pixelstore_attrib) ); 944 break; 945 case GL_CLIENT_VERTEX_ARRAY_BIT: 946 MEMCPY( &ctx->Array, attr->data, 947 sizeof(struct gl_array_attrib) ); 948 break; 949 default: 950 gl_problem( ctx, "Bad attrib flag in PopClientAttrib"); 951 break; 952 } 953 954 next = attr->next; 955 FREE( attr->data ); 956 FREE( attr ); 957 attr = next; 958 } 959 960 ctx->NewState = _NEW_ARRAY; 961} 962 963 964 965