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