Debian Codegraph @

debian/external_deps/fetk/sg/src/gl/attrib.c

raw
1 /* $Id: attrib.c,v 1.2 2000/10/27 15:21:40 mholst Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 2.2
6 * Copyright (C) 1995-1997 Brian Paul
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include "attrib.h"
26 #include "context.h"
27 #include "draw.h"
28 #include "dlist.h"
29 #include "macros.h"
30 #include "misc.h"
31 #include "types.h"
32
33
34 #define MALLOC_STRUCT(T) (struct T *) malloc( sizeof(struct T) )
35
36
37
38 static struct gl_attrib_node *new_attrib_node( GLbitfield kind )
39 {
40 struct gl_attrib_node *an;
41
42 an = (struct gl_attrib_node *) malloc( sizeof(struct gl_attrib_node) );
43 if (an) {
44 an->kind = kind;
45 }
46 return an;
47 }
48
49
50
51 void gl_PushAttrib( GLcontext* ctx, GLbitfield mask )
52 {
53 struct gl_attrib_node *newnode;
54 struct gl_attrib_node *head;
55
56 if (INSIDE_BEGIN_END(ctx)) {
57 gl_error( ctx, GL_INVALID_OPERATION, "glPushAttrib" );
58 return;
59 }
60
61 if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) {
62 gl_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" );
63 return;
64 }
65
66 /* Build linked list of attribute nodes which save all attribute */
67 /* groups specified by the mask. */
68 head = NULL;
69
70 if (mask & GL_ACCUM_BUFFER_BIT) {
71 struct gl_accum_attrib *attr;
72
73 attr = MALLOC_STRUCT( gl_accum_attrib );
74 MEMCPY( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) );
75 newnode = new_attrib_node( GL_ACCUM_BUFFER_BIT );
76 newnode->data = attr;
77 newnode->next = head;
78 head = newnode;
79 }
80
81 if (mask & GL_COLOR_BUFFER_BIT) {
82 struct gl_colorbuffer_attrib *attr;
83 attr = MALLOC_STRUCT( gl_colorbuffer_attrib );
84 MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) );
85 newnode = new_attrib_node( GL_COLOR_BUFFER_BIT );
86 newnode->data = attr;
87 newnode->next = head;
88 head = newnode;
89 }
90
91 if (mask & GL_CURRENT_BIT) {
92 struct gl_current_attrib *attr;
93 attr = MALLOC_STRUCT( gl_current_attrib );
94 MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) );
95 newnode = new_attrib_node( GL_CURRENT_BIT );
96 newnode->data = attr;
97 newnode->next = head;
98 head = newnode;
99 }
100
101 if (mask & GL_DEPTH_BUFFER_BIT) {
102 struct gl_depthbuffer_attrib *attr;
103 attr = MALLOC_STRUCT( gl_depthbuffer_attrib );
104 MEMCPY( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) );
105 newnode = new_attrib_node( GL_DEPTH_BUFFER_BIT );
106 newnode->data = attr;
107 newnode->next = head;
108 head = newnode;
109 }
110
111 if (mask & GL_ENABLE_BIT) {
112 struct gl_enable_attrib *attr;
113 GLuint i;
114 attr = MALLOC_STRUCT( gl_enable_attrib );
115 /* Copy enable flags from all other attributes into the enable struct. */
116 attr->AlphaTest = ctx->Color.AlphaEnabled;
117 attr->AutoNormal = ctx->Eval.AutoNormal;
118 attr->Blend = ctx->Color.BlendEnabled;
119 for (i=0;i<MAX_CLIP_PLANES;i++) {
120 attr->ClipPlane[i] = ctx->Transform.ClipEnabled[i];
121 }
122 attr->ColorMaterial = ctx->Light.ColorMaterialEnabled;
123 attr->CullFace = ctx->Polygon.CullFlag;
124 attr->DepthTest = ctx->Depth.Test;
125 attr->Dither = ctx->Color.DitherFlag;
126 attr->Fog = ctx->Fog.Enabled;
127 for (i=0;i<MAX_LIGHTS;i++) {
128 attr->Light[i] = ctx->Light.Light[i].Enabled;
129 }
130 attr->Lighting = ctx->Light.Enabled;
131 attr->LineSmooth = ctx->Line.SmoothFlag;
132 attr->LineStipple = ctx->Line.StippleFlag;
133 attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled;
134 attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled;
135 attr->Map1Color4 = ctx->Eval.Map1Color4;
136 attr->Map1Index = ctx->Eval.Map1Index;
137 attr->Map1Normal = ctx->Eval.Map1Normal;
138 attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1;
139 attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2;
140 attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3;
141 attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4;
142 attr->Map1Vertex3 = ctx->Eval.Map1Vertex3;
143 attr->Map1Vertex4 = ctx->Eval.Map1Vertex4;
144 attr->Map2Color4 = ctx->Eval.Map2Color4;
145 attr->Map2Index = ctx->Eval.Map2Index;
146 attr->Map2Normal = ctx->Eval.Map2Normal;
147 attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1;
148 attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2;
149 attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3;
150 attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4;
151 attr->Map2Vertex3 = ctx->Eval.Map2Vertex3;
152 attr->Map2Vertex4 = ctx->Eval.Map2Vertex4;
153 attr->Normalize = ctx->Transform.Normalize;
154 attr->PointSmooth = ctx->Point.SmoothFlag;
155 attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint;
156 attr->PolygonOffsetLine = ctx->Polygon.OffsetLine;
157 attr->PolygonOffsetFill = ctx->Polygon.OffsetFill;
158 attr->PolygonSmooth = ctx->Polygon.SmoothFlag;
159 attr->PolygonStipple = ctx->Polygon.StippleFlag;
160 attr->Scissor = ctx->Scissor.Enabled;
161 attr->Stencil = ctx->Stencil.Enabled;
162 attr->Texture = ctx->Texture.Enabled;
163 attr->TexGen = ctx->Texture.TexGenEnabled;
164 newnode = new_attrib_node( GL_ENABLE_BIT );
165 newnode->data = attr;
166 newnode->next = head;
167 head = newnode;
168 }
169
170 if (mask & GL_EVAL_BIT) {
171 struct gl_eval_attrib *attr;
172 attr = MALLOC_STRUCT( gl_eval_attrib );
173 MEMCPY( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) );
174 newnode = new_attrib_node( GL_EVAL_BIT );
175 newnode->data = attr;
176 newnode->next = head;
177 head = newnode;
178 }
179
180 if (mask & GL_FOG_BIT) {
181 struct gl_fog_attrib *attr;
182 attr = MALLOC_STRUCT( gl_fog_attrib );
183 MEMCPY( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) );
184 newnode = new_attrib_node( GL_FOG_BIT );
185 newnode->data = attr;
186 newnode->next = head;
187 head = newnode;
188 }
189
190 if (mask & GL_HINT_BIT) {
191 struct gl_hint_attrib *attr;
192 attr = MALLOC_STRUCT( gl_hint_attrib );
193 MEMCPY( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) );
194 newnode = new_attrib_node( GL_HINT_BIT );
195 newnode->data = attr;
196 newnode->next = head;
197 head = newnode;
198 }
199
200 if (mask & GL_LIGHTING_BIT) {
201 struct gl_light_attrib *attr;
202 attr = MALLOC_STRUCT( gl_light_attrib );
203 MEMCPY( attr, &ctx->Light, sizeof(struct gl_light_attrib) );
204 newnode = new_attrib_node( GL_LIGHTING_BIT );
205 newnode->data = attr;
206 newnode->next = head;
207 head = newnode;
208 }
209
210 if (mask & GL_LINE_BIT) {
211 struct gl_line_attrib *attr;
212 attr = MALLOC_STRUCT( gl_line_attrib );
213 MEMCPY( attr, &ctx->Line, sizeof(struct gl_line_attrib) );
214 newnode = new_attrib_node( GL_LINE_BIT );
215 newnode->data = attr;
216 newnode->next = head;
217 head = newnode;
218 }
219
220 if (mask & GL_LIST_BIT) {
221 struct gl_list_attrib *attr;
222 attr = MALLOC_STRUCT( gl_list_attrib );
223 MEMCPY( attr, &ctx->List, sizeof(struct gl_list_attrib) );
224 newnode = new_attrib_node( GL_LIST_BIT );
225 newnode->data = attr;
226 newnode->next = head;
227 head = newnode;
228 }
229
230 if (mask & GL_PIXEL_MODE_BIT) {
231 struct gl_pixel_attrib *attr;
232 attr = MALLOC_STRUCT( gl_pixel_attrib );
233 MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) );
234 newnode = new_attrib_node( GL_PIXEL_MODE_BIT );
235 newnode->data = attr;
236 newnode->next = head;
237 head = newnode;
238 }
239
240 if (mask & GL_POINT_BIT) {
241 struct gl_point_attrib *attr;
242 attr = MALLOC_STRUCT( gl_point_attrib );
243 MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) );
244 newnode = new_attrib_node( GL_POINT_BIT );
245 newnode->data = attr;
246 newnode->next = head;
247 head = newnode;
248 }
249
250 if (mask & GL_POLYGON_BIT) {
251 struct gl_polygon_attrib *attr;
252 attr = MALLOC_STRUCT( gl_polygon_attrib );
253 MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) );
254 newnode = new_attrib_node( GL_POLYGON_BIT );
255 newnode->data = attr;
256 newnode->next = head;
257 head = newnode;
258 }
259
260 if (mask & GL_POLYGON_STIPPLE_BIT) {
261 GLuint *stipple;
262 stipple = (GLuint *) malloc( 32*sizeof(GLuint) );
263 MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
264 newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT );
265 newnode->data = stipple;
266 newnode->next = head;
267 head = newnode;
268 }
269
270 if (mask & GL_SCISSOR_BIT) {
271 struct gl_scissor_attrib *attr;
272 attr = MALLOC_STRUCT( gl_scissor_attrib );
273 MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) );
274 newnode = new_attrib_node( GL_SCISSOR_BIT );
275 newnode->data = attr;
276 newnode->next = head;
277 head = newnode;
278 }
279
280 if (mask & GL_STENCIL_BUFFER_BIT) {
281 struct gl_stencil_attrib *attr;
282 attr = MALLOC_STRUCT( gl_stencil_attrib );
283 MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) );
284 newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT );
285 newnode->data = attr;
286 newnode->next = head;
287 head = newnode;
288 }
289
290 if (mask & GL_TEXTURE_BIT) {
291 struct gl_texture_attrib *attr;
292 attr = MALLOC_STRUCT( gl_texture_attrib );
293 MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
294 newnode = new_attrib_node( GL_TEXTURE_BIT );
295 newnode->data = attr;
296 newnode->next = head;
297 head = newnode;
298 }
299
300 if (mask & GL_TRANSFORM_BIT) {
301 struct gl_transform_attrib *attr;
302 attr = MALLOC_STRUCT( gl_transform_attrib );
303 MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) );
304 newnode = new_attrib_node( GL_TRANSFORM_BIT );
305 newnode->data = attr;
306 newnode->next = head;
307 head = newnode;
308 }
309
310 if (mask & GL_VIEWPORT_BIT) {
311 struct gl_viewport_attrib *attr;
312 attr = MALLOC_STRUCT( gl_viewport_attrib );
313 MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) );
314 newnode = new_attrib_node( GL_VIEWPORT_BIT );
315 newnode->data = attr;
316 newnode->next = head;
317 head = newnode;
318 }
319
320 /* etc... */
321
322 ctx->AttribStack[ctx->AttribStackDepth] = head;
323 ctx->AttribStackDepth++;
324 }
325
326
327
328 void gl_PopAttrib( GLcontext* ctx )
329 {
330 struct gl_attrib_node *attr, *next;
331 struct gl_enable_attrib *enable;
332 GLuint i, oldDrawBuffer;
333
334 if (INSIDE_BEGIN_END(ctx)) {
335 gl_error( ctx, GL_INVALID_OPERATION, "glPopAttrib" );
336 return;
337 }
338
339 if (ctx->AttribStackDepth==0) {
340 gl_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" );
341 return;
342 }
343
344 ctx->AttribStackDepth--;
345 attr = ctx->AttribStack[ctx->AttribStackDepth];
346
347 while (attr) {
348 switch (attr->kind) {
349 case GL_ACCUM_BUFFER_BIT:
350 MEMCPY( &ctx->Accum, attr->data, sizeof(struct gl_accum_attrib) );
351 break;
352 case GL_COLOR_BUFFER_BIT:
353 oldDrawBuffer = ctx->Color.DrawBuffer;
354 MEMCPY( &ctx->Color, attr->data,
355 sizeof(struct gl_colorbuffer_attrib) );
356 if (ctx->Color.DrawBuffer != oldDrawBuffer) {
357 gl_DrawBuffer(ctx, ctx->Color.DrawBuffer);
358 }
359 break;
360 case GL_CURRENT_BIT:
361 MEMCPY( &ctx->Current, attr->data,
362 sizeof(struct gl_current_attrib) );
363 break;
364 case GL_DEPTH_BUFFER_BIT:
365 MEMCPY( &ctx->Depth, attr->data,
366 sizeof(struct gl_depthbuffer_attrib) );
367 break;
368 case GL_ENABLE_BIT:
369 enable = (struct gl_enable_attrib *) attr->data;
370 ctx->Color.AlphaEnabled = enable->AlphaTest;
371 ctx->Transform.Normalize = enable->AutoNormal;
372 ctx->Color.BlendEnabled = enable->Blend;
373 for (i=0;i<MAX_CLIP_PLANES;i++) {
374 ctx->Transform.ClipEnabled[i] = enable->ClipPlane[i];
375 }
376 ctx->Light.ColorMaterialEnabled = enable->ColorMaterial;
377 ctx->Polygon.CullFlag = enable->CullFace;
378 ctx->Depth.Test = enable->DepthTest;
379 ctx->Color.DitherFlag = enable->Dither;
380 ctx->Fog.Enabled = enable->Fog;
381 ctx->Light.Enabled = enable->Lighting;
382 ctx->Line.SmoothFlag = enable->LineSmooth;
383 ctx->Line.StippleFlag = enable->LineStipple;
384 ctx->Color.IndexLogicOpEnabled = enable->IndexLogicOp;
385 ctx->Color.ColorLogicOpEnabled = enable->ColorLogicOp;
386 ctx->Eval.Map1Color4 = enable->Map1Color4;
387 ctx->Eval.Map1Index = enable->Map1Index;
388 ctx->Eval.Map1Normal = enable->Map1Normal;
389 ctx->Eval.Map1TextureCoord1 = enable->Map1TextureCoord1;
390 ctx->Eval.Map1TextureCoord2 = enable->Map1TextureCoord2;
391 ctx->Eval.Map1TextureCoord3 = enable->Map1TextureCoord3;
392 ctx->Eval.Map1TextureCoord4 = enable->Map1TextureCoord4;
393 ctx->Eval.Map1Vertex3 = enable->Map1Vertex3;
394 ctx->Eval.Map1Vertex4 = enable->Map1Vertex4;
395 ctx->Eval.Map2Color4 = enable->Map2Color4;
396 ctx->Eval.Map2Index = enable->Map2Index;
397 ctx->Eval.Map2Normal = enable->Map2Normal;
398 ctx->Eval.Map2TextureCoord1 = enable->Map2TextureCoord1;
399 ctx->Eval.Map2TextureCoord2 = enable->Map2TextureCoord2;
400 ctx->Eval.Map2TextureCoord3 = enable->Map2TextureCoord3;
401 ctx->Eval.Map2TextureCoord4 = enable->Map2TextureCoord4;
402 ctx->Eval.Map2Vertex3 = enable->Map2Vertex3;
403 ctx->Eval.Map2Vertex4 = enable->Map2Vertex4;
404 ctx->Transform.Normalize = enable->Normalize;
405 ctx->Point.SmoothFlag = enable->PointSmooth;
406 ctx->Polygon.OffsetPoint = enable->PolygonOffsetPoint;
407 ctx->Polygon.OffsetLine = enable->PolygonOffsetLine;
408 ctx->Polygon.OffsetFill = enable->PolygonOffsetFill;
409 ctx->Polygon.OffsetAny = ctx->Polygon.OffsetPoint ||
410 ctx->Polygon.OffsetLine ||
411 ctx->Polygon.OffsetFill;
412 ctx->Polygon.SmoothFlag = enable->PolygonSmooth;
413 ctx->Polygon.StippleFlag = enable->PolygonStipple;
414 ctx->Scissor.Enabled = enable->Scissor;
415 ctx->Stencil.Enabled = enable->Stencil;
416 ctx->Texture.Enabled = enable->Texture;
417 ctx->Texture.TexGenEnabled = enable->TexGen;
418 break;
419 case GL_EVAL_BIT:
420 MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) );
421 break;
422 case GL_FOG_BIT:
423 MEMCPY( &ctx->Fog, attr->data, sizeof(struct gl_fog_attrib) );
424 break;
425 case GL_HINT_BIT:
426 MEMCPY( &ctx->Hint, attr->data, sizeof(struct gl_hint_attrib) );
427 break;
428 case GL_LIGHTING_BIT:
429 MEMCPY( &ctx->Light, attr->data, sizeof(struct gl_light_attrib) );
430 break;
431 case GL_LINE_BIT:
432 MEMCPY( &ctx->Line, attr->data, sizeof(struct gl_line_attrib) );
433 break;
434 case GL_LIST_BIT:
435 MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );
436 break;
437 case GL_PIXEL_MODE_BIT:
438 MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
439 break;
440 case GL_POINT_BIT:
441 MEMCPY( &ctx->Point, attr->data, sizeof(struct gl_point_attrib) );
442 break;
443 case GL_POLYGON_BIT:
444 MEMCPY( &ctx->Polygon, attr->data,
445 sizeof(struct gl_polygon_attrib) );
446 break;
447 case GL_POLYGON_STIPPLE_BIT:
448 MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );
449 break;
450 case GL_SCISSOR_BIT:
451 MEMCPY( &ctx->Scissor, attr->data,
452 sizeof(struct gl_scissor_attrib) );
453 break;
454 case GL_STENCIL_BUFFER_BIT:
455 MEMCPY( &ctx->Stencil, attr->data,
456 sizeof(struct gl_stencil_attrib) );
457 break;
458 case GL_TRANSFORM_BIT:
459 MEMCPY( &ctx->Transform, attr->data,
460 sizeof(struct gl_transform_attrib) );
461 break;
462 case GL_TEXTURE_BIT:
463 MEMCPY( &ctx->Texture, attr->data,
464 sizeof(struct gl_texture_attrib) );
465 break;
466 case GL_VIEWPORT_BIT:
467 MEMCPY( &ctx->Viewport, attr->data,
468 sizeof(struct gl_viewport_attrib) );
469 break;
470 default:
471 abort();
472 break;
473 }
474
475 next = attr->next;
476 free( (void *) attr->data );
477 free( (void *) attr );
478 attr = next;
479 }
480
481 ctx->NewState = NEW_ALL;
482 }
483
484
485 #define GL_CLIENT_PACK_BIT (1<<20)
486 #define GL_CLIENT_UNPACK_BIT (1<<21)
487
488
489 void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask )
490 {
491 struct gl_attrib_node *newnode;
492 struct gl_attrib_node *head;
493
494 if (INSIDE_BEGIN_END(ctx)) {
495 gl_error( ctx, GL_INVALID_OPERATION, "glPushClientAttrib" );
496 return;
497 }
498
499 if (ctx->ClientAttribStackDepth>=MAX_CLIENT_ATTRIB_STACK_DEPTH) {
500 gl_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" );
501 return;
502 }
503
504 /* Build linked list of attribute nodes which save all attribute */
505 /* groups specified by the mask. */
506 head = NULL;
507
508 if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
509 struct gl_pixelstore_attrib *attr;
510 /* packing attribs */
511 attr = MALLOC_STRUCT( gl_pixelstore_attrib );
512 MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
513 newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
514 newnode->data = attr;
515 newnode->next = head;
516 head = newnode;
517 /* unpacking attribs */
518 attr = MALLOC_STRUCT( gl_pixelstore_attrib );
519 MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
520 newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
521 newnode->data = attr;
522 newnode->next = head;
523 head = newnode;
524 }
525 if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
526 struct gl_array_attrib *attr;
527 attr = MALLOC_STRUCT( gl_array_attrib );
528 MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
529 newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );
530 newnode->data = attr;
531 newnode->next = head;
532 head = newnode;
533 }
534
535 /* etc... */
536
537 ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
538 ctx->ClientAttribStackDepth++;
539 }
540
541
542
543
544 void gl_PopClientAttrib( GLcontext *ctx )
545 {
546 struct gl_attrib_node *attr, *next;
547
548 if (INSIDE_BEGIN_END(ctx)) {
549 gl_error( ctx, GL_INVALID_OPERATION, "glPopClientAttrib" );
550 return;
551 }
552
553 if (ctx->ClientAttribStackDepth==0) {
554 gl_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" );
555 return;
556 }
557
558 ctx->ClientAttribStackDepth--;
559 attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
560
561 while (attr) {
562 switch (attr->kind) {
563 case GL_CLIENT_PACK_BIT:
564 MEMCPY( &ctx->Pack, attr->data,
565 sizeof(struct gl_pixelstore_attrib) );
566 break;
567 case GL_CLIENT_UNPACK_BIT:
568 MEMCPY( &ctx->Unpack, attr->data,
569 sizeof(struct gl_pixelstore_attrib) );
570 break;
571 case GL_CLIENT_VERTEX_ARRAY_BIT:
572 MEMCPY( &ctx->Array, attr->data,
573 sizeof(struct gl_array_attrib) );
574 break;
575 default:
576 abort();
577 break;
578 }
579
580 next = attr->next;
581 free( (void *) attr->data );
582 free( (void *) attr );
583 attr = next;
584 }
585
586 ctx->NewState = NEW_ALL;
587 }
588