1 /* $Id: attrib.c,v 1.35 2000/11/19 23:10:25 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
39 #include "simple_list.h"
48 * Allocate a new attribute state node. These nodes have a
49 * "kind" value and a pointer to a struct of state data.
51 static struct gl_attrib_node
*
52 new_attrib_node( GLbitfield kind
)
54 struct gl_attrib_node
*an
= MALLOC_STRUCT(gl_attrib_node
);
64 * Copy texture object state from one texture object to another.
67 copy_texobj_state( struct gl_texture_object
*dest
,
68 const struct gl_texture_object
*src
)
71 dest->Name = src->Name;
72 dest->Dimensions = src->Dimensions;
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
;
90 dest
->Palette
= src
->Palette
;
91 dest
->Complete
= src
->Complete
;
97 _mesa_PushAttrib(GLbitfield mask
)
99 struct gl_attrib_node
*newnode
;
100 struct gl_attrib_node
*head
;
102 GET_CURRENT_CONTEXT(ctx
);
103 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glPushAttrib");
105 if (MESA_VERBOSE
&VERBOSE_API
)
106 fprintf(stderr
, "glPushAttrib %x\n", (int)mask
);
108 if (ctx
->AttribStackDepth
>=MAX_ATTRIB_STACK_DEPTH
) {
109 gl_error( ctx
, GL_STACK_OVERFLOW
, "glPushAttrib" );
113 /* Build linked list of attribute nodes which save all attribute */
114 /* groups specified by the mask. */
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
;
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
;
137 if (mask
& GL_CURRENT_BIT
) {
138 struct gl_current_attrib
*attr
;
140 FLUSH_TNL( ctx
, FLUSH_UPDATE_CURRENT
);
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
;
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
;
160 if (mask
& GL_ENABLE_BIT
) {
161 struct gl_enable_attrib
*attr
;
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
];
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
;
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
;
222 newnode
= new_attrib_node( GL_ENABLE_BIT
);
223 newnode
->data
= attr
;
224 newnode
->next
= head
;
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
;
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
;
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
;
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
;
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
;
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
;
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
;
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
;
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
;
318 if (mask
& GL_POLYGON_STIPPLE_BIT
) {
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
;
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
;
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
;
348 if (mask
& GL_TEXTURE_BIT
) {
349 struct gl_texture_attrib
*attr
;
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
++;
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
);
367 newnode
= new_attrib_node( GL_TEXTURE_BIT
);
368 newnode
->data
= attr
;
369 newnode
->next
= head
;
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
;
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
;
393 ctx
->AttribStack
[ctx
->AttribStackDepth
] = head
;
394 ctx
->AttribStackDepth
++;
400 pop_enable_group(GLcontext
*ctx
, const struct gl_enable_attrib
*enable
)
404 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
405 if ((VALUE) != (NEWVALUE)) { \
406 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \
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
);
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
]);
419 TEST_AND_UPDATE(ctx
->Light
.ColorMaterialEnabled
, enable
->ColorMaterial
,
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
,
426 TEST_AND_UPDATE(ctx
->Pixel
.Convolution2DEnabled
, enable
->Convolution2D
,
428 TEST_AND_UPDATE(ctx
->Pixel
.Separable2DEnabled
, enable
->Separable2D
,
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
,
435 TEST_AND_UPDATE(ctx
->Color
.IndexLogicOpEnabled
, enable
->IndexLogicOp
,
437 TEST_AND_UPDATE(ctx
->Color
.ColorLogicOpEnabled
, enable
->ColorLogicOp
,
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
,
452 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex4
, enable
->Map1Vertex4
,
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
,
467 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex4
, enable
->Map2Vertex4
,
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
,
474 TEST_AND_UPDATE(ctx
->Point
.SmoothFlag
, enable
->PointSmooth
,
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
,
484 TEST_AND_UPDATE(ctx
->Polygon
.StippleFlag
, enable
->PolygonStipple
,
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
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
);
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
) );
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
);
513 if (enable
->TexGen
[i
] & S_BIT
)
514 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_TRUE
);
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
);
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
);
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
);
528 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_FALSE
);
533 if (ctx
->Driver
.ActiveTexture
) {
534 (*ctx
->Driver
.ActiveTexture
)(ctx
, ctx
->Texture
.CurrentUnit
);
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.
545 _mesa_PopAttrib(void)
547 struct gl_attrib_node
*attr
, *next
;
548 GET_CURRENT_CONTEXT(ctx
);
550 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glPopAttrib");
553 if (ctx
->AttribStackDepth
==0) {
554 gl_error( ctx
, GL_STACK_UNDERFLOW
, "glPopAttrib" );
558 ctx
->AttribStackDepth
--;
559 attr
= ctx
->AttribStack
[ctx
->AttribStackDepth
];
563 if (MESA_VERBOSE
&VERBOSE_API
)
564 fprintf(stderr
, "glPopAttrib %s\n", gl_lookup_enum_by_nr(attr
->kind
));
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
;
571 case GL_COLOR_BUFFER_BIT
:
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
);
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
);
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]);
614 (*ctx
->Driver
.ClearIndex
)( ctx
, ctx
->Color
.ClearIndex
);
619 FLUSH_TNL( ctx
, FLUSH_UPDATE_CURRENT
);
620 MEMCPY( &ctx
->Current
, attr
->data
,
621 sizeof(struct gl_current_attrib
) );
623 case GL_DEPTH_BUFFER_BIT
:
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
);
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
;
651 MEMCPY( &ctx
->Eval
, attr
->data
, sizeof(struct gl_eval_attrib
) );
652 ctx
->NewState
|= _NEW_EVAL
;
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
);
672 ctx
->_Enabled
&= ~ENABLE_FOG
;
673 if (ctx
->Fog
.Enabled
) ctx
->_Enabled
|= ENABLE_FOG
;
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
);
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
) {
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
);
700 (*ctx
->Driver
.Enable
)( ctx
, GL_LIGHTING
, ctx
->Light
.Enabled
);
702 if (ctx
->Light
.ShadeModel
== GL_FLAT
)
703 ctx
->_TriangleCaps
|= DD_FLATSHADE
;
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
;
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
);
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
);
726 MEMCPY( &ctx
->List
, attr
->data
, sizeof(struct gl_list_attrib
) );
728 case GL_PIXEL_MODE_BIT
:
729 MEMCPY( &ctx
->Pixel
, attr
->data
, sizeof(struct gl_pixel_attrib
) );
730 ctx
->NewState
|= _NEW_PIXEL
;
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
);
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
);
751 if (ctx
->Driver
.CullFace
)
752 ctx
->Driver
.CullFace( ctx
, ctx
->Polygon
.CullFaceMode
);
754 if (ctx
->Driver
.FrontFace
)
755 ctx
->Driver
.FrontFace( ctx
, ctx
->Polygon
.FrontFace
);
757 if (ctx
->Driver
.Enable
)
758 (*ctx
->Driver
.Enable
)( ctx
, GL_POLYGON_SMOOTH
, ctx
->Polygon
.SmoothFlag
);
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
);
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
);
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
;
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
);
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
;
811 /* Take care of texture object reference counters */
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
--;
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
) );
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
;
841 case GL_VIEWPORT_BIT
:
843 struct gl_viewport_attrib
*v
=
844 (struct gl_viewport_attrib
*)attr
->data
;
846 ctx
->NewState
|= _NEW_VIEWPORT
;
847 _mesa_Viewport( v
->X
, v
->Y
, v
->Width
, v
->Height
);
848 _mesa_DepthRange( v
->Near
, v
->Far
);
852 gl_problem( ctx
, "Bad attrib flag in PopAttrib");
864 #define GL_CLIENT_PACK_BIT (1<<20)
865 #define GL_CLIENT_UNPACK_BIT (1<<21)
869 _mesa_PushClientAttrib(GLbitfield mask
)
871 struct gl_attrib_node
*newnode
;
872 struct gl_attrib_node
*head
;
874 GET_CURRENT_CONTEXT(ctx
);
875 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glPushClientAttrib");
877 if (ctx
->ClientAttribStackDepth
>=MAX_CLIENT_ATTRIB_STACK_DEPTH
) {
878 gl_error( ctx
, GL_STACK_OVERFLOW
, "glPushClientAttrib" );
882 /* Build linked list of attribute nodes which save all attribute */
883 /* groups specified by the mask. */
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
;
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
;
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
;
913 ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
] = head
;
914 ctx
->ClientAttribStackDepth
++;
921 _mesa_PopClientAttrib(void)
923 struct gl_attrib_node
*attr
, *next
;
925 GET_CURRENT_CONTEXT(ctx
);
926 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glPopClientAttrib");
928 if (ctx
->ClientAttribStackDepth
==0) {
929 gl_error( ctx
, GL_STACK_UNDERFLOW
, "glPopClientAttrib" );
933 ctx
->ClientAttribStackDepth
--;
934 attr
= ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
];
937 switch (attr
->kind
) {
938 case GL_CLIENT_PACK_BIT
:
939 MEMCPY( &ctx
->Pack
, attr
->data
,
940 sizeof(struct gl_pixelstore_attrib
) );
942 case GL_CLIENT_UNPACK_BIT
:
943 MEMCPY( &ctx
->Unpack
, attr
->data
,
944 sizeof(struct gl_pixelstore_attrib
) );
946 case GL_CLIENT_VERTEX_ARRAY_BIT
:
947 MEMCPY( &ctx
->Array
, attr
->data
,
948 sizeof(struct gl_array_attrib
) );
951 gl_problem( ctx
, "Bad attrib flag in PopClientAttrib");
961 ctx
->NewState
= _NEW_ARRAY
;