Replaced Texture.CurrentD[] with separate Texture.Current1/2/3D vars.
[mesa.git] / src / mesa / main / attrib.c
1 /* $Id: attrib.c,v 1.35 2000/11/19 23:10:25 brianp 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 */
51 static struct gl_attrib_node *
52 new_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 */
66 static void
67 copy_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
96 void
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].Current1D->RefCount++;
354 ctx->Texture.Unit[u].Current2D->RefCount++;
355 ctx->Texture.Unit[u].Current3D->RefCount++;
356 ctx->Texture.Unit[u].CurrentCubeMap->RefCount++;
357 }
358 attr = MALLOC_STRUCT( gl_texture_attrib );
359 MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
360 /* copy state of the currently bound texture objects */
361 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
362 copy_texobj_state(&attr->Unit[u].Saved1D, attr->Unit[u].Current1D);
363 copy_texobj_state(&attr->Unit[u].Saved2D, attr->Unit[u].Current2D);
364 copy_texobj_state(&attr->Unit[u].Saved3D, attr->Unit[u].Current3D);
365 copy_texobj_state(&attr->Unit[u].SavedCubeMap, attr->Unit[u].CurrentCubeMap);
366 }
367 newnode = new_attrib_node( GL_TEXTURE_BIT );
368 newnode->data = attr;
369 newnode->next = head;
370 head = newnode;
371 }
372
373 if (mask & GL_TRANSFORM_BIT) {
374 struct gl_transform_attrib *attr;
375 attr = MALLOC_STRUCT( gl_transform_attrib );
376 MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) );
377 newnode = new_attrib_node( GL_TRANSFORM_BIT );
378 newnode->data = attr;
379 newnode->next = head;
380 head = newnode;
381 }
382
383 if (mask & GL_VIEWPORT_BIT) {
384 struct gl_viewport_attrib *attr;
385 attr = MALLOC_STRUCT( gl_viewport_attrib );
386 MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) );
387 newnode = new_attrib_node( GL_VIEWPORT_BIT );
388 newnode->data = attr;
389 newnode->next = head;
390 head = newnode;
391 }
392
393 ctx->AttribStack[ctx->AttribStackDepth] = head;
394 ctx->AttribStackDepth++;
395 }
396
397
398
399 static void
400 pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
401 {
402 GLuint i;
403
404 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
405 if ((VALUE) != (NEWVALUE)) { \
406 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \
407 }
408
409 TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST);
410 TEST_AND_UPDATE(ctx->Transform.Normalize, enable->AutoNormal, GL_NORMALIZE);
411 TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND);
412
413 for (i=0;i<MAX_CLIP_PLANES;i++) {
414 if (ctx->Transform.ClipEnabled[i] != enable->ClipPlane[i])
415 _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i),
416 enable->ClipPlane[i]);
417 }
418
419 TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial,
420 GL_COLOR_MATERIAL);
421 TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE);
422 TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST);
423 TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER);
424 TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D,
425 GL_CONVOLUTION_1D);
426 TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D,
427 GL_CONVOLUTION_2D);
428 TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D,
429 GL_SEPARABLE_2D);
430 TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG);
431 TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING);
432 TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH);
433 TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple,
434 GL_LINE_STIPPLE);
435 TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp,
436 GL_INDEX_LOGIC_OP);
437 TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp,
438 GL_COLOR_LOGIC_OP);
439 TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4);
440 TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX);
441 TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL);
442 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1,
443 GL_MAP1_TEXTURE_COORD_1);
444 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2,
445 GL_MAP1_TEXTURE_COORD_2);
446 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3,
447 GL_MAP1_TEXTURE_COORD_3);
448 TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4,
449 GL_MAP1_TEXTURE_COORD_4);
450 TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3,
451 GL_MAP1_VERTEX_3);
452 TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4,
453 GL_MAP1_VERTEX_4);
454 TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4);
455 TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX);
456 TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL);
457 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1,
458 GL_MAP2_TEXTURE_COORD_1);
459 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2,
460 GL_MAP2_TEXTURE_COORD_2);
461 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3,
462 GL_MAP2_TEXTURE_COORD_3);
463 TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4,
464 GL_MAP2_TEXTURE_COORD_4);
465 TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3,
466 GL_MAP2_VERTEX_3);
467 TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4,
468 GL_MAP2_VERTEX_4);
469 TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE);
470 TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals,
471 GL_RESCALE_NORMAL_EXT);
472 TEST_AND_UPDATE(ctx->Pixel.PixelTextureEnabled, enable->PixelTexture,
473 GL_POINT_SMOOTH);
474 TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth,
475 GL_POINT_SMOOTH);
476 TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint,
477 GL_POLYGON_OFFSET_POINT);
478 TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine,
479 GL_POLYGON_OFFSET_LINE);
480 TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill,
481 GL_POLYGON_OFFSET_FILL);
482 TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth,
483 GL_POLYGON_SMOOTH);
484 TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple,
485 GL_POLYGON_STIPPLE);
486 TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST);
487 TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST);
488 #undef TEST_AND_UPDATE
489
490 /* texture unit enables */
491 for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
492 if (ctx->Texture.Unit[i].Enabled != enable->Texture[i]) {
493 ctx->Texture.Unit[i].Enabled = enable->Texture[i];
494 if (ctx->Driver.Enable) {
495 if (ctx->Driver.ActiveTexture) {
496 (*ctx->Driver.ActiveTexture)(ctx, i);
497 }
498 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D,
499 (GLboolean) (enable->Texture[i] & TEXTURE0_1D) );
500 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D,
501 (GLboolean) (enable->Texture[i] & TEXTURE0_2D) );
502 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D,
503 (GLboolean) (enable->Texture[i] & TEXTURE0_3D) );
504 }
505 }
506
507 if (ctx->Texture.Unit[i].TexGenEnabled != enable->TexGen[i]) {
508 ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i];
509 if (ctx->Driver.Enable) {
510 if (ctx->Driver.ActiveTexture) {
511 (*ctx->Driver.ActiveTexture)(ctx, i);
512 }
513 if (enable->TexGen[i] & S_BIT)
514 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_TRUE);
515 else
516 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_FALSE);
517 if (enable->TexGen[i] & T_BIT)
518 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_TRUE);
519 else
520 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_FALSE);
521 if (enable->TexGen[i] & R_BIT)
522 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_TRUE);
523 else
524 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_FALSE);
525 if (enable->TexGen[i] & Q_BIT)
526 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_TRUE);
527 else
528 (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
529 }
530 }
531 }
532
533 if (ctx->Driver.ActiveTexture) {
534 (*ctx->Driver.ActiveTexture)(ctx, ctx->Texture.CurrentUnit);
535 }
536 }
537
538
539
540 /*
541 * This function is kind of long just because we have to call a lot
542 * of device driver functions to update device driver state.
543 */
544 void
545 _mesa_PopAttrib(void)
546 {
547 struct gl_attrib_node *attr, *next;
548 GET_CURRENT_CONTEXT(ctx);
549
550 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopAttrib");
551
552
553 if (ctx->AttribStackDepth==0) {
554 gl_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" );
555 return;
556 }
557
558 ctx->AttribStackDepth--;
559 attr = ctx->AttribStack[ctx->AttribStackDepth];
560
561 while (attr) {
562
563 if (MESA_VERBOSE&VERBOSE_API)
564 fprintf(stderr, "glPopAttrib %s\n", gl_lookup_enum_by_nr(attr->kind));
565
566 switch (attr->kind) {
567 case GL_ACCUM_BUFFER_BIT:
568 MEMCPY( &ctx->Accum, attr->data, sizeof(struct gl_accum_attrib) );
569 ctx->NewState |= _NEW_ACCUM;
570 break;
571 case GL_COLOR_BUFFER_BIT:
572 {
573 GLenum oldDrawBuffer = ctx->Color.DrawBuffer;
574 GLenum oldAlphaFunc = ctx->Color.AlphaFunc;
575 GLchan oldAlphaRef = ctx->Color.AlphaRef;
576 GLenum oldBlendSrc = ctx->Color.BlendSrcRGB;
577 GLenum oldBlendDst = ctx->Color.BlendDstRGB;
578 GLenum oldLogicOp = ctx->Color.LogicOp;
579 MEMCPY( &ctx->Color, attr->data,
580 sizeof(struct gl_colorbuffer_attrib) );
581 ctx->NewState |= _NEW_COLOR;
582 if (ctx->Color.DrawBuffer != oldDrawBuffer) {
583 _mesa_DrawBuffer( ctx->Color.DrawBuffer);
584 }
585 if ((ctx->Color.BlendSrcRGB != oldBlendSrc ||
586 ctx->Color.BlendDstRGB != oldBlendDst) &&
587 ctx->Driver.BlendFunc)
588 (*ctx->Driver.BlendFunc)( ctx, ctx->Color.BlendSrcRGB,
589 ctx->Color.BlendDstRGB);
590 if (ctx->Color.LogicOp != oldLogicOp &&
591 ctx->Driver.LogicOpcode) {
592 ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
593 }
594 if (ctx->Visual.RGBAflag) {
595 GLchan r = (GLint) (ctx->Color.ClearColor[0] * CHAN_MAXF);
596 GLchan g = (GLint) (ctx->Color.ClearColor[1] * CHAN_MAXF);
597 GLchan b = (GLint) (ctx->Color.ClearColor[2] * CHAN_MAXF);
598 GLchan a = (GLint) (ctx->Color.ClearColor[3] * CHAN_MAXF);
599 (*ctx->Driver.ClearColor)( ctx, r, g, b, a );
600 if ((ctx->Color.AlphaFunc != oldAlphaFunc ||
601 ctx->Color.AlphaRef != oldAlphaRef) &&
602 ctx->Driver.AlphaFunc)
603 (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc,
604 ctx->Color.AlphaRef / CHAN_MAXF);
605 if (ctx->Driver.ColorMask) {
606 (*ctx->Driver.ColorMask)(ctx,
607 ctx->Color.ColorMask[0],
608 ctx->Color.ColorMask[1],
609 ctx->Color.ColorMask[2],
610 ctx->Color.ColorMask[3]);
611 }
612 }
613 else {
614 (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex);
615 }
616 }
617 break;
618 case GL_CURRENT_BIT:
619 FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
620 MEMCPY( &ctx->Current, attr->data,
621 sizeof(struct gl_current_attrib) );
622 break;
623 case GL_DEPTH_BUFFER_BIT:
624 {
625 GLboolean oldDepthTest = ctx->Depth.Test;
626 GLenum oldDepthFunc = ctx->Depth.Func;
627 GLboolean oldDepthMask = ctx->Depth.Mask;
628 GLfloat oldDepthClear = ctx->Depth.Clear;
629 MEMCPY( &ctx->Depth, attr->data,
630 sizeof(struct gl_depthbuffer_attrib) );
631 ctx->NewState |= _NEW_DEPTH;
632 if (ctx->Depth.Test != oldDepthTest && ctx->Driver.Enable)
633 (*ctx->Driver.Enable)( ctx, GL_DEPTH_TEST, ctx->Depth.Test);
634 if (ctx->Depth.Func != oldDepthFunc && ctx->Driver.DepthFunc)
635 (*ctx->Driver.DepthFunc)( ctx, ctx->Depth.Func );
636 if (ctx->Depth.Mask != oldDepthMask && ctx->Driver.DepthMask)
637 (*ctx->Driver.DepthMask)( ctx, ctx->Depth.Mask );
638 if (ctx->Depth.Clear != oldDepthClear && ctx->Driver.ClearDepth)
639 (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear );
640 }
641 break;
642 case GL_ENABLE_BIT:
643 {
644 const struct gl_enable_attrib *enable;
645 enable = (const struct gl_enable_attrib *) attr->data;
646 pop_enable_group(ctx, enable);
647 ctx->NewState |= _NEW_ALL;
648 }
649 break;
650 case GL_EVAL_BIT:
651 MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) );
652 ctx->NewState |= _NEW_EVAL;
653 break;
654 case GL_FOG_BIT:
655 {
656 GLboolean anyChange = (GLboolean) (memcmp( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) ) != 0);
657 MEMCPY( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) );
658 ctx->NewState |= _NEW_FOG;
659 if (anyChange && ctx->Driver.Fogfv) {
660 const GLfloat mode = (GLfloat) ctx->Fog.Mode;
661 const GLfloat density = ctx->Fog.Density;
662 const GLfloat start = ctx->Fog.Start;
663 const GLfloat end = ctx->Fog.End;
664 const GLfloat index = ctx->Fog.Index;
665 (*ctx->Driver.Fogfv)( ctx, GL_FOG_MODE, &mode);
666 (*ctx->Driver.Fogfv)( ctx, GL_FOG_DENSITY, &density );
667 (*ctx->Driver.Fogfv)( ctx, GL_FOG_START, &start );
668 (*ctx->Driver.Fogfv)( ctx, GL_FOG_END, &end );
669 (*ctx->Driver.Fogfv)( ctx, GL_FOG_INDEX, &index );
670 (*ctx->Driver.Fogfv)( ctx, GL_FOG_COLOR, ctx->Fog.Color );
671 }
672 ctx->_Enabled &= ~ENABLE_FOG;
673 if (ctx->Fog.Enabled) ctx->_Enabled |= ENABLE_FOG;
674 }
675 break;
676 case GL_HINT_BIT:
677 MEMCPY( &ctx->Hint, attr->data, sizeof(struct gl_hint_attrib) );
678 ctx->NewState |= _NEW_HINT;
679 if (ctx->Driver.Hint) {
680 (*ctx->Driver.Hint)( ctx, GL_PERSPECTIVE_CORRECTION_HINT,
681 ctx->Hint.PerspectiveCorrection );
682 (*ctx->Driver.Hint)( ctx, GL_POINT_SMOOTH_HINT,
683 ctx->Hint.PointSmooth);
684 (*ctx->Driver.Hint)( ctx, GL_LINE_SMOOTH_HINT,
685 ctx->Hint.LineSmooth );
686 (*ctx->Driver.Hint)( ctx, GL_POLYGON_SMOOTH_HINT,
687 ctx->Hint.PolygonSmooth );
688 (*ctx->Driver.Hint)( ctx, GL_FOG_HINT, ctx->Hint.Fog );
689 }
690 break;
691 case GL_LIGHTING_BIT:
692 MEMCPY( &ctx->Light, attr->data, sizeof(struct gl_light_attrib) );
693 ctx->NewState |= _NEW_LIGHT;
694 if (ctx->Driver.Enable) {
695 GLuint i;
696 for (i = 0; i < MAX_LIGHTS; i++) {
697 GLenum light = (GLenum) (GL_LIGHT0 + i);
698 (*ctx->Driver.Enable)( ctx, light, ctx->Light.Light[i].Enabled );
699 }
700 (*ctx->Driver.Enable)( ctx, GL_LIGHTING, ctx->Light.Enabled );
701 }
702 if (ctx->Light.ShadeModel == GL_FLAT)
703 ctx->_TriangleCaps |= DD_FLATSHADE;
704 else
705 ctx->_TriangleCaps &= ~DD_FLATSHADE;
706 if (ctx->Driver.ShadeModel)
707 (*ctx->Driver.ShadeModel)(ctx, ctx->Light.ShadeModel);
708 ctx->_Enabled &= ~ENABLE_LIGHT;
709 if (ctx->Light.Enabled && !is_empty_list(&ctx->Light.EnabledList))
710 ctx->_Enabled |= ENABLE_LIGHT;
711 break;
712 case GL_LINE_BIT:
713 MEMCPY( &ctx->Line, attr->data, sizeof(struct gl_line_attrib) );
714 ctx->NewState |= _NEW_LINE;
715 if (ctx->Driver.Enable) {
716 (*ctx->Driver.Enable)( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
717 (*ctx->Driver.Enable)( ctx, GL_LINE_STIPPLE, ctx->Line.StippleFlag );
718 }
719 if (ctx->Driver.LineStipple)
720 (*ctx->Driver.LineStipple)(ctx, ctx->Line.StippleFactor,
721 ctx->Line.StipplePattern);
722 if (ctx->Driver.LineWidth)
723 (*ctx->Driver.LineWidth)(ctx, ctx->Line.Width);
724 break;
725 case GL_LIST_BIT:
726 MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );
727 break;
728 case GL_PIXEL_MODE_BIT:
729 MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
730 ctx->NewState |= _NEW_PIXEL;
731 break;
732 case GL_POINT_BIT:
733 MEMCPY( &ctx->Point, attr->data, sizeof(struct gl_point_attrib) );
734 ctx->NewState |= _NEW_POINT;
735 if (ctx->Driver.Enable)
736 (*ctx->Driver.Enable)( ctx, GL_POINT_SMOOTH, ctx->Point.SmoothFlag );
737 break;
738 case GL_POLYGON_BIT:
739 {
740 GLenum oldFrontMode = ctx->Polygon.FrontMode;
741 GLenum oldBackMode = ctx->Polygon.BackMode;
742 MEMCPY( &ctx->Polygon, attr->data,
743 sizeof(struct gl_polygon_attrib) );
744 ctx->NewState |= _NEW_POLYGON;
745 if ((ctx->Polygon.FrontMode != oldFrontMode ||
746 ctx->Polygon.BackMode != oldBackMode) &&
747 ctx->Driver.PolygonMode) {
748 (*ctx->Driver.PolygonMode)( ctx, GL_FRONT, ctx->Polygon.FrontMode);
749 (*ctx->Driver.PolygonMode)( ctx, GL_BACK, ctx->Polygon.BackMode);
750 }
751 if (ctx->Driver.CullFace)
752 ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
753
754 if (ctx->Driver.FrontFace)
755 ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
756
757 if (ctx->Driver.Enable)
758 (*ctx->Driver.Enable)( ctx, GL_POLYGON_SMOOTH, ctx->Polygon.SmoothFlag );
759 }
760 break;
761 case GL_POLYGON_STIPPLE_BIT:
762 MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );
763 ctx->NewState |= _NEW_POLYGONSTIPPLE;
764 if (ctx->Driver.PolygonStipple)
765 ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data );
766 break;
767 case GL_SCISSOR_BIT:
768 MEMCPY( &ctx->Scissor, attr->data,
769 sizeof(struct gl_scissor_attrib) );
770 ctx->NewState |= _NEW_SCISSOR;
771 if (ctx->Driver.Enable)
772 (*ctx->Driver.Enable)( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
773 if (ctx->Driver.Scissor)
774 ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
775 ctx->Scissor.Width, ctx->Scissor.Height );
776 break;
777 case GL_STENCIL_BUFFER_BIT:
778 MEMCPY( &ctx->Stencil, attr->data,
779 sizeof(struct gl_stencil_attrib) );
780 ctx->NewState |= _NEW_STENCIL;
781 if (ctx->Driver.StencilFunc)
782 (*ctx->Driver.StencilFunc)( ctx, ctx->Stencil.Function,
783 ctx->Stencil.Ref, ctx->Stencil.ValueMask);
784 if (ctx->Driver.StencilMask)
785 (*ctx->Driver.StencilMask)( ctx, ctx->Stencil.WriteMask );
786 if (ctx->Driver.StencilOp)
787 (*ctx->Driver.StencilOp)( ctx, ctx->Stencil.FailFunc,
788 ctx->Stencil.ZFailFunc, ctx->Stencil.ZPassFunc);
789 if (ctx->Driver.ClearStencil)
790 (*ctx->Driver.ClearStencil)( ctx, ctx->Stencil.Clear );
791 if (ctx->Driver.Enable)
792 (*ctx->Driver.Enable)( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
793 ctx->_TriangleCaps &= ~DD_STENCIL;
794 if (ctx->Stencil.Enabled)
795 ctx->_TriangleCaps |= DD_STENCIL;
796
797 break;
798 case GL_TRANSFORM_BIT:
799 MEMCPY( &ctx->Transform, attr->data,
800 sizeof(struct gl_transform_attrib) );
801 ctx->NewState |= _NEW_TRANSFORM;
802 if (ctx->Driver.Enable) {
803 (*ctx->Driver.Enable)( ctx, GL_NORMALIZE, ctx->Transform.Normalize );
804 (*ctx->Driver.Enable)( ctx, GL_RESCALE_NORMAL_EXT, ctx->Transform.RescaleNormals );
805 }
806 ctx->_Enabled &= ~(ENABLE_NORMALIZE|ENABLE_RESCALE);
807 if (ctx->Transform.Normalize) ctx->_Enabled |= ENABLE_NORMALIZE;
808 if (ctx->Transform.RescaleNormals) ctx->_Enabled |= ENABLE_RESCALE;
809 break;
810 case GL_TEXTURE_BIT:
811 /* Take care of texture object reference counters */
812 {
813 GLuint u;
814 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
815 ctx->Texture.Unit[u].Current1D->RefCount--;
816 ctx->Texture.Unit[u].Current2D->RefCount--;
817 ctx->Texture.Unit[u].Current3D->RefCount--;
818 ctx->Texture.Unit[u].CurrentCubeMap->RefCount--;
819 }
820 MEMCPY( &ctx->Texture, attr->data,
821 sizeof(struct gl_texture_attrib) );
822 ctx->NewState |= _NEW_TEXTURE;
823 /* restore state of the currently bound texture objects */
824 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
825 copy_texobj_state( ctx->Texture.Unit[u].Current1D,
826 &(ctx->Texture.Unit[u].Saved1D) );
827 copy_texobj_state( ctx->Texture.Unit[u].Current2D,
828 &(ctx->Texture.Unit[u].Saved2D) );
829 copy_texobj_state( ctx->Texture.Unit[u].Current3D,
830 &(ctx->Texture.Unit[u].Saved3D) );
831 copy_texobj_state( ctx->Texture.Unit[u].CurrentCubeMap,
832 &(ctx->Texture.Unit[u].SavedCubeMap) );
833
834 ctx->Texture.Unit[u].Current1D->Complete = GL_FALSE;
835 ctx->Texture.Unit[u].Current2D->Complete = GL_FALSE;
836 ctx->Texture.Unit[u].Current3D->Complete = GL_FALSE;
837 ctx->Texture.Unit[u].CurrentCubeMap->Complete = GL_FALSE;
838 }
839 }
840 break;
841 case GL_VIEWPORT_BIT:
842 {
843 struct gl_viewport_attrib *v =
844 (struct gl_viewport_attrib *)attr->data;
845
846 ctx->NewState |= _NEW_VIEWPORT;
847 _mesa_Viewport( v->X, v->Y, v->Width, v->Height );
848 _mesa_DepthRange( v->Near, v->Far );
849 break;
850 }
851 default:
852 gl_problem( ctx, "Bad attrib flag in PopAttrib");
853 break;
854 }
855
856 next = attr->next;
857 FREE( attr->data );
858 FREE( attr );
859 attr = next;
860 }
861 }
862
863
864 #define GL_CLIENT_PACK_BIT (1<<20)
865 #define GL_CLIENT_UNPACK_BIT (1<<21)
866
867
868 void
869 _mesa_PushClientAttrib(GLbitfield mask)
870 {
871 struct gl_attrib_node *newnode;
872 struct gl_attrib_node *head;
873
874 GET_CURRENT_CONTEXT(ctx);
875 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushClientAttrib");
876
877 if (ctx->ClientAttribStackDepth>=MAX_CLIENT_ATTRIB_STACK_DEPTH) {
878 gl_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" );
879 return;
880 }
881
882 /* Build linked list of attribute nodes which save all attribute */
883 /* groups specified by the mask. */
884 head = NULL;
885
886 if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
887 struct gl_pixelstore_attrib *attr;
888 /* packing attribs */
889 attr = MALLOC_STRUCT( gl_pixelstore_attrib );
890 MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
891 newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
892 newnode->data = attr;
893 newnode->next = head;
894 head = newnode;
895 /* unpacking attribs */
896 attr = MALLOC_STRUCT( gl_pixelstore_attrib );
897 MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
898 newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
899 newnode->data = attr;
900 newnode->next = head;
901 head = newnode;
902 }
903 if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
904 struct gl_array_attrib *attr;
905 attr = MALLOC_STRUCT( gl_array_attrib );
906 MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
907 newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );
908 newnode->data = attr;
909 newnode->next = head;
910 head = newnode;
911 }
912
913 ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
914 ctx->ClientAttribStackDepth++;
915 }
916
917
918
919
920 void
921 _mesa_PopClientAttrib(void)
922 {
923 struct gl_attrib_node *attr, *next;
924
925 GET_CURRENT_CONTEXT(ctx);
926 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopClientAttrib");
927
928 if (ctx->ClientAttribStackDepth==0) {
929 gl_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" );
930 return;
931 }
932
933 ctx->ClientAttribStackDepth--;
934 attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
935
936 while (attr) {
937 switch (attr->kind) {
938 case GL_CLIENT_PACK_BIT:
939 MEMCPY( &ctx->Pack, attr->data,
940 sizeof(struct gl_pixelstore_attrib) );
941 break;
942 case GL_CLIENT_UNPACK_BIT:
943 MEMCPY( &ctx->Unpack, attr->data,
944 sizeof(struct gl_pixelstore_attrib) );
945 break;
946 case GL_CLIENT_VERTEX_ARRAY_BIT:
947 MEMCPY( &ctx->Array, attr->data,
948 sizeof(struct gl_array_attrib) );
949 break;
950 default:
951 gl_problem( ctx, "Bad attrib flag in PopClientAttrib");
952 break;
953 }
954
955 next = attr->next;
956 FREE( attr->data );
957 FREE( attr );
958 attr = next;
959 }
960
961 ctx->NewState = _NEW_ARRAY;
962 }
963
964
965