1 /* $Id: attrib.c,v 1.33 2000/11/05 18:40:57 keithw 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
;
139 attr
= MALLOC_STRUCT( gl_current_attrib
);
140 MEMCPY( attr
, &ctx
->Current
, sizeof(struct gl_current_attrib
) );
141 newnode
= new_attrib_node( GL_CURRENT_BIT
);
142 newnode
->data
= attr
;
143 newnode
->next
= head
;
147 if (mask
& GL_DEPTH_BUFFER_BIT
) {
148 struct gl_depthbuffer_attrib
*attr
;
149 attr
= MALLOC_STRUCT( gl_depthbuffer_attrib
);
150 MEMCPY( attr
, &ctx
->Depth
, sizeof(struct gl_depthbuffer_attrib
) );
151 newnode
= new_attrib_node( GL_DEPTH_BUFFER_BIT
);
152 newnode
->data
= attr
;
153 newnode
->next
= head
;
157 if (mask
& GL_ENABLE_BIT
) {
158 struct gl_enable_attrib
*attr
;
160 attr
= MALLOC_STRUCT( gl_enable_attrib
);
161 /* Copy enable flags from all other attributes into the enable struct. */
162 attr
->AlphaTest
= ctx
->Color
.AlphaEnabled
;
163 attr
->AutoNormal
= ctx
->Eval
.AutoNormal
;
164 attr
->Blend
= ctx
->Color
.BlendEnabled
;
165 for (i
=0;i
<MAX_CLIP_PLANES
;i
++) {
166 attr
->ClipPlane
[i
] = ctx
->Transform
.ClipEnabled
[i
];
168 attr
->ColorMaterial
= ctx
->Light
.ColorMaterialEnabled
;
169 attr
->Convolution1D
= ctx
->Pixel
.Convolution1DEnabled
;
170 attr
->Convolution2D
= ctx
->Pixel
.Convolution2DEnabled
;
171 attr
->Separable2D
= ctx
->Pixel
.Separable2DEnabled
;
172 attr
->CullFace
= ctx
->Polygon
.CullFlag
;
173 attr
->DepthTest
= ctx
->Depth
.Test
;
174 attr
->Dither
= ctx
->Color
.DitherFlag
;
175 attr
->Fog
= ctx
->Fog
.Enabled
;
176 for (i
=0;i
<MAX_LIGHTS
;i
++) {
177 attr
->Light
[i
] = ctx
->Light
.Light
[i
].Enabled
;
179 attr
->Lighting
= ctx
->Light
.Enabled
;
180 attr
->LineSmooth
= ctx
->Line
.SmoothFlag
;
181 attr
->LineStipple
= ctx
->Line
.StippleFlag
;
182 attr
->Histogram
= ctx
->Pixel
.HistogramEnabled
;
183 attr
->MinMax
= ctx
->Pixel
.MinMaxEnabled
;
184 attr
->IndexLogicOp
= ctx
->Color
.IndexLogicOpEnabled
;
185 attr
->ColorLogicOp
= ctx
->Color
.ColorLogicOpEnabled
;
186 attr
->Map1Color4
= ctx
->Eval
.Map1Color4
;
187 attr
->Map1Index
= ctx
->Eval
.Map1Index
;
188 attr
->Map1Normal
= ctx
->Eval
.Map1Normal
;
189 attr
->Map1TextureCoord1
= ctx
->Eval
.Map1TextureCoord1
;
190 attr
->Map1TextureCoord2
= ctx
->Eval
.Map1TextureCoord2
;
191 attr
->Map1TextureCoord3
= ctx
->Eval
.Map1TextureCoord3
;
192 attr
->Map1TextureCoord4
= ctx
->Eval
.Map1TextureCoord4
;
193 attr
->Map1Vertex3
= ctx
->Eval
.Map1Vertex3
;
194 attr
->Map1Vertex4
= ctx
->Eval
.Map1Vertex4
;
195 attr
->Map2Color4
= ctx
->Eval
.Map2Color4
;
196 attr
->Map2Index
= ctx
->Eval
.Map2Index
;
197 attr
->Map2Normal
= ctx
->Eval
.Map2Normal
;
198 attr
->Map2TextureCoord1
= ctx
->Eval
.Map2TextureCoord1
;
199 attr
->Map2TextureCoord2
= ctx
->Eval
.Map2TextureCoord2
;
200 attr
->Map2TextureCoord3
= ctx
->Eval
.Map2TextureCoord3
;
201 attr
->Map2TextureCoord4
= ctx
->Eval
.Map2TextureCoord4
;
202 attr
->Map2Vertex3
= ctx
->Eval
.Map2Vertex3
;
203 attr
->Map2Vertex4
= ctx
->Eval
.Map2Vertex4
;
204 attr
->Normalize
= ctx
->Transform
.Normalize
;
205 attr
->PixelTexture
= ctx
->Pixel
.PixelTextureEnabled
;
206 attr
->PointSmooth
= ctx
->Point
.SmoothFlag
;
207 attr
->PolygonOffsetPoint
= ctx
->Polygon
.OffsetPoint
;
208 attr
->PolygonOffsetLine
= ctx
->Polygon
.OffsetLine
;
209 attr
->PolygonOffsetFill
= ctx
->Polygon
.OffsetFill
;
210 attr
->PolygonSmooth
= ctx
->Polygon
.SmoothFlag
;
211 attr
->PolygonStipple
= ctx
->Polygon
.StippleFlag
;
212 attr
->RescaleNormals
= ctx
->Transform
.RescaleNormals
;
213 attr
->Scissor
= ctx
->Scissor
.Enabled
;
214 attr
->Stencil
= ctx
->Stencil
.Enabled
;
215 for (i
=0; i
<MAX_TEXTURE_UNITS
; i
++) {
216 attr
->Texture
[i
] = ctx
->Texture
.Unit
[i
].Enabled
;
217 attr
->TexGen
[i
] = ctx
->Texture
.Unit
[i
].TexGenEnabled
;
219 newnode
= new_attrib_node( GL_ENABLE_BIT
);
220 newnode
->data
= attr
;
221 newnode
->next
= head
;
225 if (mask
& GL_EVAL_BIT
) {
226 struct gl_eval_attrib
*attr
;
227 attr
= MALLOC_STRUCT( gl_eval_attrib
);
228 MEMCPY( attr
, &ctx
->Eval
, sizeof(struct gl_eval_attrib
) );
229 newnode
= new_attrib_node( GL_EVAL_BIT
);
230 newnode
->data
= attr
;
231 newnode
->next
= head
;
235 if (mask
& GL_FOG_BIT
) {
236 struct gl_fog_attrib
*attr
;
237 attr
= MALLOC_STRUCT( gl_fog_attrib
);
238 MEMCPY( attr
, &ctx
->Fog
, sizeof(struct gl_fog_attrib
) );
239 newnode
= new_attrib_node( GL_FOG_BIT
);
240 newnode
->data
= attr
;
241 newnode
->next
= head
;
245 if (mask
& GL_HINT_BIT
) {
246 struct gl_hint_attrib
*attr
;
247 attr
= MALLOC_STRUCT( gl_hint_attrib
);
248 MEMCPY( attr
, &ctx
->Hint
, sizeof(struct gl_hint_attrib
) );
249 newnode
= new_attrib_node( GL_HINT_BIT
);
250 newnode
->data
= attr
;
251 newnode
->next
= head
;
255 if (mask
& GL_LIGHTING_BIT
) {
256 struct gl_light_attrib
*attr
;
257 attr
= MALLOC_STRUCT( gl_light_attrib
);
258 MEMCPY( attr
, &ctx
->Light
, sizeof(struct gl_light_attrib
) );
259 newnode
= new_attrib_node( GL_LIGHTING_BIT
);
260 newnode
->data
= attr
;
261 newnode
->next
= head
;
265 if (mask
& GL_LINE_BIT
) {
266 struct gl_line_attrib
*attr
;
267 attr
= MALLOC_STRUCT( gl_line_attrib
);
268 MEMCPY( attr
, &ctx
->Line
, sizeof(struct gl_line_attrib
) );
269 newnode
= new_attrib_node( GL_LINE_BIT
);
270 newnode
->data
= attr
;
271 newnode
->next
= head
;
275 if (mask
& GL_LIST_BIT
) {
276 struct gl_list_attrib
*attr
;
277 attr
= MALLOC_STRUCT( gl_list_attrib
);
278 MEMCPY( attr
, &ctx
->List
, sizeof(struct gl_list_attrib
) );
279 newnode
= new_attrib_node( GL_LIST_BIT
);
280 newnode
->data
= attr
;
281 newnode
->next
= head
;
285 if (mask
& GL_PIXEL_MODE_BIT
) {
286 struct gl_pixel_attrib
*attr
;
287 attr
= MALLOC_STRUCT( gl_pixel_attrib
);
288 MEMCPY( attr
, &ctx
->Pixel
, sizeof(struct gl_pixel_attrib
) );
289 newnode
= new_attrib_node( GL_PIXEL_MODE_BIT
);
290 newnode
->data
= attr
;
291 newnode
->next
= head
;
295 if (mask
& GL_POINT_BIT
) {
296 struct gl_point_attrib
*attr
;
297 attr
= MALLOC_STRUCT( gl_point_attrib
);
298 MEMCPY( attr
, &ctx
->Point
, sizeof(struct gl_point_attrib
) );
299 newnode
= new_attrib_node( GL_POINT_BIT
);
300 newnode
->data
= attr
;
301 newnode
->next
= head
;
305 if (mask
& GL_POLYGON_BIT
) {
306 struct gl_polygon_attrib
*attr
;
307 attr
= MALLOC_STRUCT( gl_polygon_attrib
);
308 MEMCPY( attr
, &ctx
->Polygon
, sizeof(struct gl_polygon_attrib
) );
309 newnode
= new_attrib_node( GL_POLYGON_BIT
);
310 newnode
->data
= attr
;
311 newnode
->next
= head
;
315 if (mask
& GL_POLYGON_STIPPLE_BIT
) {
317 stipple
= (GLuint
*) MALLOC( 32*sizeof(GLuint
) );
318 MEMCPY( stipple
, ctx
->PolygonStipple
, 32*sizeof(GLuint
) );
319 newnode
= new_attrib_node( GL_POLYGON_STIPPLE_BIT
);
320 newnode
->data
= stipple
;
321 newnode
->next
= head
;
325 if (mask
& GL_SCISSOR_BIT
) {
326 struct gl_scissor_attrib
*attr
;
327 attr
= MALLOC_STRUCT( gl_scissor_attrib
);
328 MEMCPY( attr
, &ctx
->Scissor
, sizeof(struct gl_scissor_attrib
) );
329 newnode
= new_attrib_node( GL_SCISSOR_BIT
);
330 newnode
->data
= attr
;
331 newnode
->next
= head
;
335 if (mask
& GL_STENCIL_BUFFER_BIT
) {
336 struct gl_stencil_attrib
*attr
;
337 attr
= MALLOC_STRUCT( gl_stencil_attrib
);
338 MEMCPY( attr
, &ctx
->Stencil
, sizeof(struct gl_stencil_attrib
) );
339 newnode
= new_attrib_node( GL_STENCIL_BUFFER_BIT
);
340 newnode
->data
= attr
;
341 newnode
->next
= head
;
345 if (mask
& GL_TEXTURE_BIT
) {
346 struct gl_texture_attrib
*attr
;
348 /* Take care of texture object reference counters */
349 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
350 ctx
->Texture
.Unit
[u
].CurrentD
[1]->RefCount
++;
351 ctx
->Texture
.Unit
[u
].CurrentD
[2]->RefCount
++;
352 ctx
->Texture
.Unit
[u
].CurrentD
[3]->RefCount
++;
354 attr
= MALLOC_STRUCT( gl_texture_attrib
);
355 MEMCPY( attr
, &ctx
->Texture
, sizeof(struct gl_texture_attrib
) );
356 /* copy state of the currently bound texture objects */
357 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
358 copy_texobj_state(&attr
->Unit
[u
].Saved1D
, attr
->Unit
[u
].CurrentD
[1]);
359 copy_texobj_state(&attr
->Unit
[u
].Saved2D
, attr
->Unit
[u
].CurrentD
[2]);
360 copy_texobj_state(&attr
->Unit
[u
].Saved3D
, attr
->Unit
[u
].CurrentD
[3]);
361 copy_texobj_state(&attr
->Unit
[u
].SavedCubeMap
, attr
->Unit
[u
].CurrentCubeMap
);
363 newnode
= new_attrib_node( GL_TEXTURE_BIT
);
364 newnode
->data
= attr
;
365 newnode
->next
= head
;
369 if (mask
& GL_TRANSFORM_BIT
) {
370 struct gl_transform_attrib
*attr
;
371 attr
= MALLOC_STRUCT( gl_transform_attrib
);
372 MEMCPY( attr
, &ctx
->Transform
, sizeof(struct gl_transform_attrib
) );
373 newnode
= new_attrib_node( GL_TRANSFORM_BIT
);
374 newnode
->data
= attr
;
375 newnode
->next
= head
;
379 if (mask
& GL_VIEWPORT_BIT
) {
380 struct gl_viewport_attrib
*attr
;
381 attr
= MALLOC_STRUCT( gl_viewport_attrib
);
382 MEMCPY( attr
, &ctx
->Viewport
, sizeof(struct gl_viewport_attrib
) );
383 newnode
= new_attrib_node( GL_VIEWPORT_BIT
);
384 newnode
->data
= attr
;
385 newnode
->next
= head
;
389 ctx
->AttribStack
[ctx
->AttribStackDepth
] = head
;
390 ctx
->AttribStackDepth
++;
396 pop_enable_group(GLcontext
*ctx
, const struct gl_enable_attrib
*enable
)
400 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
401 if ((VALUE) != (NEWVALUE)) { \
402 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \
405 TEST_AND_UPDATE(ctx
->Color
.AlphaEnabled
, enable
->AlphaTest
, GL_ALPHA_TEST
);
406 TEST_AND_UPDATE(ctx
->Transform
.Normalize
, enable
->AutoNormal
, GL_NORMALIZE
);
407 TEST_AND_UPDATE(ctx
->Color
.BlendEnabled
, enable
->Blend
, GL_BLEND
);
409 for (i
=0;i
<MAX_CLIP_PLANES
;i
++) {
410 if (ctx
->Transform
.ClipEnabled
[i
] != enable
->ClipPlane
[i
])
411 _mesa_set_enable(ctx
, (GLenum
) (GL_CLIP_PLANE0
+ i
),
412 enable
->ClipPlane
[i
]);
415 TEST_AND_UPDATE(ctx
->Light
.ColorMaterialEnabled
, enable
->ColorMaterial
,
417 TEST_AND_UPDATE(ctx
->Polygon
.CullFlag
, enable
->CullFace
, GL_CULL_FACE
);
418 TEST_AND_UPDATE(ctx
->Depth
.Test
, enable
->DepthTest
, GL_DEPTH_TEST
);
419 TEST_AND_UPDATE(ctx
->Color
.DitherFlag
, enable
->Dither
, GL_DITHER
);
420 TEST_AND_UPDATE(ctx
->Pixel
.Convolution1DEnabled
, enable
->Convolution1D
,
422 TEST_AND_UPDATE(ctx
->Pixel
.Convolution2DEnabled
, enable
->Convolution2D
,
424 TEST_AND_UPDATE(ctx
->Pixel
.Separable2DEnabled
, enable
->Separable2D
,
426 TEST_AND_UPDATE(ctx
->Fog
.Enabled
, enable
->Fog
, GL_FOG
);
427 TEST_AND_UPDATE(ctx
->Light
.Enabled
, enable
->Lighting
, GL_LIGHTING
);
428 TEST_AND_UPDATE(ctx
->Line
.SmoothFlag
, enable
->LineSmooth
, GL_LINE_SMOOTH
);
429 TEST_AND_UPDATE(ctx
->Line
.StippleFlag
, enable
->LineStipple
,
431 TEST_AND_UPDATE(ctx
->Color
.IndexLogicOpEnabled
, enable
->IndexLogicOp
,
433 TEST_AND_UPDATE(ctx
->Color
.ColorLogicOpEnabled
, enable
->ColorLogicOp
,
435 TEST_AND_UPDATE(ctx
->Eval
.Map1Color4
, enable
->Map1Color4
, GL_MAP1_COLOR_4
);
436 TEST_AND_UPDATE(ctx
->Eval
.Map1Index
, enable
->Map1Index
, GL_MAP1_INDEX
);
437 TEST_AND_UPDATE(ctx
->Eval
.Map1Normal
, enable
->Map1Normal
, GL_MAP1_NORMAL
);
438 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord1
, enable
->Map1TextureCoord1
,
439 GL_MAP1_TEXTURE_COORD_1
);
440 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord2
, enable
->Map1TextureCoord2
,
441 GL_MAP1_TEXTURE_COORD_2
);
442 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord3
, enable
->Map1TextureCoord3
,
443 GL_MAP1_TEXTURE_COORD_3
);
444 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord4
, enable
->Map1TextureCoord4
,
445 GL_MAP1_TEXTURE_COORD_4
);
446 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex3
, enable
->Map1Vertex3
,
448 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex4
, enable
->Map1Vertex4
,
450 TEST_AND_UPDATE(ctx
->Eval
.Map2Color4
, enable
->Map2Color4
, GL_MAP2_COLOR_4
);
451 TEST_AND_UPDATE(ctx
->Eval
.Map2Index
, enable
->Map2Index
, GL_MAP2_INDEX
);
452 TEST_AND_UPDATE(ctx
->Eval
.Map2Normal
, enable
->Map2Normal
, GL_MAP2_NORMAL
);
453 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord1
, enable
->Map2TextureCoord1
,
454 GL_MAP2_TEXTURE_COORD_1
);
455 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord2
, enable
->Map2TextureCoord2
,
456 GL_MAP2_TEXTURE_COORD_2
);
457 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord3
, enable
->Map2TextureCoord3
,
458 GL_MAP2_TEXTURE_COORD_3
);
459 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord4
, enable
->Map2TextureCoord4
,
460 GL_MAP2_TEXTURE_COORD_4
);
461 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex3
, enable
->Map2Vertex3
,
463 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex4
, enable
->Map2Vertex4
,
465 TEST_AND_UPDATE(ctx
->Transform
.Normalize
, enable
->Normalize
, GL_NORMALIZE
);
466 TEST_AND_UPDATE(ctx
->Transform
.RescaleNormals
, enable
->RescaleNormals
,
467 GL_RESCALE_NORMAL_EXT
);
468 TEST_AND_UPDATE(ctx
->Pixel
.PixelTextureEnabled
, enable
->PixelTexture
,
470 TEST_AND_UPDATE(ctx
->Point
.SmoothFlag
, enable
->PointSmooth
,
472 TEST_AND_UPDATE(ctx
->Polygon
.OffsetPoint
, enable
->PolygonOffsetPoint
,
473 GL_POLYGON_OFFSET_POINT
);
474 TEST_AND_UPDATE(ctx
->Polygon
.OffsetLine
, enable
->PolygonOffsetLine
,
475 GL_POLYGON_OFFSET_LINE
);
476 TEST_AND_UPDATE(ctx
->Polygon
.OffsetFill
, enable
->PolygonOffsetFill
,
477 GL_POLYGON_OFFSET_FILL
);
478 TEST_AND_UPDATE(ctx
->Polygon
.SmoothFlag
, enable
->PolygonSmooth
,
480 TEST_AND_UPDATE(ctx
->Polygon
.StippleFlag
, enable
->PolygonStipple
,
482 TEST_AND_UPDATE(ctx
->Scissor
.Enabled
, enable
->Scissor
, GL_SCISSOR_TEST
);
483 TEST_AND_UPDATE(ctx
->Stencil
.Enabled
, enable
->Stencil
, GL_STENCIL_TEST
);
484 #undef TEST_AND_UPDATE
486 /* texture unit enables */
487 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
488 if (ctx
->Texture
.Unit
[i
].Enabled
!= enable
->Texture
[i
]) {
489 ctx
->Texture
.Unit
[i
].Enabled
= enable
->Texture
[i
];
490 if (ctx
->Driver
.Enable
) {
491 if (ctx
->Driver
.ActiveTexture
) {
492 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
494 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_1D
,
495 (GLboolean
) (enable
->Texture
[i
] & TEXTURE0_1D
) );
496 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_2D
,
497 (GLboolean
) (enable
->Texture
[i
] & TEXTURE0_2D
) );
498 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_3D
,
499 (GLboolean
) (enable
->Texture
[i
] & TEXTURE0_3D
) );
503 if (ctx
->Texture
.Unit
[i
].TexGenEnabled
!= enable
->TexGen
[i
]) {
504 ctx
->Texture
.Unit
[i
].TexGenEnabled
= enable
->TexGen
[i
];
505 if (ctx
->Driver
.Enable
) {
506 if (ctx
->Driver
.ActiveTexture
) {
507 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
509 if (enable
->TexGen
[i
] & S_BIT
)
510 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_TRUE
);
512 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_FALSE
);
513 if (enable
->TexGen
[i
] & T_BIT
)
514 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_TRUE
);
516 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_FALSE
);
517 if (enable
->TexGen
[i
] & R_BIT
)
518 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_TRUE
);
520 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_FALSE
);
521 if (enable
->TexGen
[i
] & Q_BIT
)
522 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_TRUE
);
524 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_FALSE
);
529 if (ctx
->Driver
.ActiveTexture
) {
530 (*ctx
->Driver
.ActiveTexture
)(ctx
, ctx
->Texture
.CurrentUnit
);
537 * This function is kind of long just because we have to call a lot
538 * of device driver functions to update device driver state.
541 _mesa_PopAttrib(void)
543 struct gl_attrib_node
*attr
, *next
;
544 GET_CURRENT_CONTEXT(ctx
);
546 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glPopAttrib");
549 if (ctx
->AttribStackDepth
==0) {
550 gl_error( ctx
, GL_STACK_UNDERFLOW
, "glPopAttrib" );
554 ctx
->AttribStackDepth
--;
555 attr
= ctx
->AttribStack
[ctx
->AttribStackDepth
];
559 if (MESA_VERBOSE
&VERBOSE_API
)
560 fprintf(stderr
, "glPopAttrib %s\n", gl_lookup_enum_by_nr(attr
->kind
));
562 switch (attr
->kind
) {
563 case GL_ACCUM_BUFFER_BIT
:
564 MEMCPY( &ctx
->Accum
, attr
->data
, sizeof(struct gl_accum_attrib
) );
565 ctx
->NewState
|= _NEW_ACCUM
;
567 case GL_COLOR_BUFFER_BIT
:
569 GLenum oldDrawBuffer
= ctx
->Color
.DrawBuffer
;
570 GLenum oldAlphaFunc
= ctx
->Color
.AlphaFunc
;
571 GLchan oldAlphaRef
= ctx
->Color
.AlphaRef
;
572 GLenum oldBlendSrc
= ctx
->Color
.BlendSrcRGB
;
573 GLenum oldBlendDst
= ctx
->Color
.BlendDstRGB
;
574 GLenum oldLogicOp
= ctx
->Color
.LogicOp
;
575 MEMCPY( &ctx
->Color
, attr
->data
,
576 sizeof(struct gl_colorbuffer_attrib
) );
577 ctx
->NewState
|= _NEW_COLOR
;
578 if (ctx
->Color
.DrawBuffer
!= oldDrawBuffer
) {
579 _mesa_DrawBuffer( ctx
->Color
.DrawBuffer
);
581 if ((ctx
->Color
.BlendSrcRGB
!= oldBlendSrc
||
582 ctx
->Color
.BlendDstRGB
!= oldBlendDst
) &&
583 ctx
->Driver
.BlendFunc
)
584 (*ctx
->Driver
.BlendFunc
)( ctx
, ctx
->Color
.BlendSrcRGB
,
585 ctx
->Color
.BlendDstRGB
);
586 if (ctx
->Color
.LogicOp
!= oldLogicOp
&&
587 ctx
->Driver
.LogicOpcode
) {
588 ctx
->Driver
.LogicOpcode( ctx
, ctx
->Color
.LogicOp
);
590 if (ctx
->Visual
.RGBAflag
) {
591 GLchan r
= (GLint
) (ctx
->Color
.ClearColor
[0] * CHAN_MAXF
);
592 GLchan g
= (GLint
) (ctx
->Color
.ClearColor
[1] * CHAN_MAXF
);
593 GLchan b
= (GLint
) (ctx
->Color
.ClearColor
[2] * CHAN_MAXF
);
594 GLchan a
= (GLint
) (ctx
->Color
.ClearColor
[3] * CHAN_MAXF
);
595 (*ctx
->Driver
.ClearColor
)( ctx
, r
, g
, b
, a
);
596 if ((ctx
->Color
.AlphaFunc
!= oldAlphaFunc
||
597 ctx
->Color
.AlphaRef
!= oldAlphaRef
) &&
598 ctx
->Driver
.AlphaFunc
)
599 (*ctx
->Driver
.AlphaFunc
)( ctx
, ctx
->Color
.AlphaFunc
,
600 ctx
->Color
.AlphaRef
/ CHAN_MAXF
);
601 if (ctx
->Driver
.ColorMask
) {
602 (*ctx
->Driver
.ColorMask
)(ctx
,
603 ctx
->Color
.ColorMask
[0],
604 ctx
->Color
.ColorMask
[1],
605 ctx
->Color
.ColorMask
[2],
606 ctx
->Color
.ColorMask
[3]);
610 (*ctx
->Driver
.ClearIndex
)( ctx
, ctx
->Color
.ClearIndex
);
615 MEMCPY( &ctx
->Current
, attr
->data
,
616 sizeof(struct gl_current_attrib
) );
618 case GL_DEPTH_BUFFER_BIT
:
620 GLboolean oldDepthTest
= ctx
->Depth
.Test
;
621 GLenum oldDepthFunc
= ctx
->Depth
.Func
;
622 GLboolean oldDepthMask
= ctx
->Depth
.Mask
;
623 GLfloat oldDepthClear
= ctx
->Depth
.Clear
;
624 MEMCPY( &ctx
->Depth
, attr
->data
,
625 sizeof(struct gl_depthbuffer_attrib
) );
626 ctx
->NewState
|= _NEW_DEPTH
;
627 if (ctx
->Depth
.Test
!= oldDepthTest
&& ctx
->Driver
.Enable
)
628 (*ctx
->Driver
.Enable
)( ctx
, GL_DEPTH_TEST
, ctx
->Depth
.Test
);
629 if (ctx
->Depth
.Func
!= oldDepthFunc
&& ctx
->Driver
.DepthFunc
)
630 (*ctx
->Driver
.DepthFunc
)( ctx
, ctx
->Depth
.Func
);
631 if (ctx
->Depth
.Mask
!= oldDepthMask
&& ctx
->Driver
.DepthMask
)
632 (*ctx
->Driver
.DepthMask
)( ctx
, ctx
->Depth
.Mask
);
633 if (ctx
->Depth
.Clear
!= oldDepthClear
&& ctx
->Driver
.ClearDepth
)
634 (*ctx
->Driver
.ClearDepth
)( ctx
, ctx
->Depth
.Clear
);
639 const struct gl_enable_attrib
*enable
;
640 enable
= (const struct gl_enable_attrib
*) attr
->data
;
641 pop_enable_group(ctx
, enable
);
642 ctx
->NewState
|= _NEW_ALL
;
646 MEMCPY( &ctx
->Eval
, attr
->data
, sizeof(struct gl_eval_attrib
) );
647 ctx
->NewState
|= _NEW_EVAL
;
651 GLboolean anyChange
= (GLboolean
) (memcmp( &ctx
->Fog
, attr
->data
, sizeof(struct gl_fog_attrib
) ) != 0);
652 MEMCPY( &ctx
->Fog
, attr
->data
, sizeof(struct gl_fog_attrib
) );
653 ctx
->NewState
|= _NEW_FOG
;
654 if (anyChange
&& ctx
->Driver
.Fogfv
) {
655 const GLfloat mode
= (GLfloat
) ctx
->Fog
.Mode
;
656 const GLfloat density
= ctx
->Fog
.Density
;
657 const GLfloat start
= ctx
->Fog
.Start
;
658 const GLfloat end
= ctx
->Fog
.End
;
659 const GLfloat index
= ctx
->Fog
.Index
;
660 (*ctx
->Driver
.Fogfv
)( ctx
, GL_FOG_MODE
, &mode
);
661 (*ctx
->Driver
.Fogfv
)( ctx
, GL_FOG_DENSITY
, &density
);
662 (*ctx
->Driver
.Fogfv
)( ctx
, GL_FOG_START
, &start
);
663 (*ctx
->Driver
.Fogfv
)( ctx
, GL_FOG_END
, &end
);
664 (*ctx
->Driver
.Fogfv
)( ctx
, GL_FOG_INDEX
, &index
);
665 (*ctx
->Driver
.Fogfv
)( ctx
, GL_FOG_COLOR
, ctx
->Fog
.Color
);
667 ctx
->_Enabled
&= ~ENABLE_FOG
;
668 if (ctx
->Fog
.Enabled
) ctx
->_Enabled
|= ENABLE_FOG
;
672 MEMCPY( &ctx
->Hint
, attr
->data
, sizeof(struct gl_hint_attrib
) );
673 ctx
->NewState
|= _NEW_HINT
;
674 if (ctx
->Driver
.Hint
) {
675 (*ctx
->Driver
.Hint
)( ctx
, GL_PERSPECTIVE_CORRECTION_HINT
,
676 ctx
->Hint
.PerspectiveCorrection
);
677 (*ctx
->Driver
.Hint
)( ctx
, GL_POINT_SMOOTH_HINT
,
678 ctx
->Hint
.PointSmooth
);
679 (*ctx
->Driver
.Hint
)( ctx
, GL_LINE_SMOOTH_HINT
,
680 ctx
->Hint
.LineSmooth
);
681 (*ctx
->Driver
.Hint
)( ctx
, GL_POLYGON_SMOOTH_HINT
,
682 ctx
->Hint
.PolygonSmooth
);
683 (*ctx
->Driver
.Hint
)( ctx
, GL_FOG_HINT
, ctx
->Hint
.Fog
);
686 case GL_LIGHTING_BIT
:
687 MEMCPY( &ctx
->Light
, attr
->data
, sizeof(struct gl_light_attrib
) );
688 ctx
->NewState
|= _NEW_LIGHT
;
689 if (ctx
->Driver
.Enable
) {
691 for (i
= 0; i
< MAX_LIGHTS
; i
++) {
692 GLenum light
= (GLenum
) (GL_LIGHT0
+ i
);
693 (*ctx
->Driver
.Enable
)( ctx
, light
, ctx
->Light
.Light
[i
].Enabled
);
695 (*ctx
->Driver
.Enable
)( ctx
, GL_LIGHTING
, ctx
->Light
.Enabled
);
697 if (ctx
->Light
.ShadeModel
== GL_FLAT
)
698 ctx
->_TriangleCaps
|= DD_FLATSHADE
;
700 ctx
->_TriangleCaps
&= ~DD_FLATSHADE
;
701 if (ctx
->Driver
.ShadeModel
)
702 (*ctx
->Driver
.ShadeModel
)(ctx
, ctx
->Light
.ShadeModel
);
703 ctx
->_Enabled
&= ~ENABLE_LIGHT
;
704 if (ctx
->Light
.Enabled
&& !is_empty_list(&ctx
->Light
.EnabledList
))
705 ctx
->_Enabled
|= ENABLE_LIGHT
;
708 MEMCPY( &ctx
->Line
, attr
->data
, sizeof(struct gl_line_attrib
) );
709 ctx
->NewState
|= _NEW_LINE
;
710 if (ctx
->Driver
.Enable
) {
711 (*ctx
->Driver
.Enable
)( ctx
, GL_LINE_SMOOTH
, ctx
->Line
.SmoothFlag
);
712 (*ctx
->Driver
.Enable
)( ctx
, GL_LINE_STIPPLE
, ctx
->Line
.StippleFlag
);
714 if (ctx
->Driver
.LineStipple
)
715 (*ctx
->Driver
.LineStipple
)(ctx
, ctx
->Line
.StippleFactor
,
716 ctx
->Line
.StipplePattern
);
717 if (ctx
->Driver
.LineWidth
)
718 (*ctx
->Driver
.LineWidth
)(ctx
, ctx
->Line
.Width
);
721 MEMCPY( &ctx
->List
, attr
->data
, sizeof(struct gl_list_attrib
) );
723 case GL_PIXEL_MODE_BIT
:
724 MEMCPY( &ctx
->Pixel
, attr
->data
, sizeof(struct gl_pixel_attrib
) );
725 ctx
->NewState
|= _NEW_PIXEL
;
728 MEMCPY( &ctx
->Point
, attr
->data
, sizeof(struct gl_point_attrib
) );
729 ctx
->NewState
|= _NEW_POINT
;
730 if (ctx
->Driver
.Enable
)
731 (*ctx
->Driver
.Enable
)( ctx
, GL_POINT_SMOOTH
, ctx
->Point
.SmoothFlag
);
735 GLenum oldFrontMode
= ctx
->Polygon
.FrontMode
;
736 GLenum oldBackMode
= ctx
->Polygon
.BackMode
;
737 MEMCPY( &ctx
->Polygon
, attr
->data
,
738 sizeof(struct gl_polygon_attrib
) );
739 ctx
->NewState
|= _NEW_POLYGON
;
740 if ((ctx
->Polygon
.FrontMode
!= oldFrontMode
||
741 ctx
->Polygon
.BackMode
!= oldBackMode
) &&
742 ctx
->Driver
.PolygonMode
) {
743 (*ctx
->Driver
.PolygonMode
)( ctx
, GL_FRONT
, ctx
->Polygon
.FrontMode
);
744 (*ctx
->Driver
.PolygonMode
)( ctx
, GL_BACK
, ctx
->Polygon
.BackMode
);
746 if (ctx
->Driver
.CullFace
)
747 ctx
->Driver
.CullFace( ctx
, ctx
->Polygon
.CullFaceMode
);
749 if (ctx
->Driver
.FrontFace
)
750 ctx
->Driver
.FrontFace( ctx
, ctx
->Polygon
.FrontFace
);
752 if (ctx
->Driver
.Enable
)
753 (*ctx
->Driver
.Enable
)( ctx
, GL_POLYGON_SMOOTH
, ctx
->Polygon
.SmoothFlag
);
756 case GL_POLYGON_STIPPLE_BIT
:
757 MEMCPY( ctx
->PolygonStipple
, attr
->data
, 32*sizeof(GLuint
) );
758 ctx
->NewState
|= _NEW_POLYGONSTIPPLE
;
759 if (ctx
->Driver
.PolygonStipple
)
760 ctx
->Driver
.PolygonStipple( ctx
, (const GLubyte
*) attr
->data
);
763 MEMCPY( &ctx
->Scissor
, attr
->data
,
764 sizeof(struct gl_scissor_attrib
) );
765 ctx
->NewState
|= _NEW_SCISSOR
;
766 if (ctx
->Driver
.Enable
)
767 (*ctx
->Driver
.Enable
)( ctx
, GL_SCISSOR_TEST
, ctx
->Scissor
.Enabled
);
768 if (ctx
->Driver
.Scissor
)
769 ctx
->Driver
.Scissor( ctx
, ctx
->Scissor
.X
, ctx
->Scissor
.Y
,
770 ctx
->Scissor
.Width
, ctx
->Scissor
.Height
);
772 case GL_STENCIL_BUFFER_BIT
:
773 MEMCPY( &ctx
->Stencil
, attr
->data
,
774 sizeof(struct gl_stencil_attrib
) );
775 ctx
->NewState
|= _NEW_STENCIL
;
776 if (ctx
->Driver
.StencilFunc
)
777 (*ctx
->Driver
.StencilFunc
)( ctx
, ctx
->Stencil
.Function
,
778 ctx
->Stencil
.Ref
, ctx
->Stencil
.ValueMask
);
779 if (ctx
->Driver
.StencilMask
)
780 (*ctx
->Driver
.StencilMask
)( ctx
, ctx
->Stencil
.WriteMask
);
781 if (ctx
->Driver
.StencilOp
)
782 (*ctx
->Driver
.StencilOp
)( ctx
, ctx
->Stencil
.FailFunc
,
783 ctx
->Stencil
.ZFailFunc
, ctx
->Stencil
.ZPassFunc
);
784 if (ctx
->Driver
.ClearStencil
)
785 (*ctx
->Driver
.ClearStencil
)( ctx
, ctx
->Stencil
.Clear
);
786 if (ctx
->Driver
.Enable
)
787 (*ctx
->Driver
.Enable
)( ctx
, GL_STENCIL_TEST
, ctx
->Stencil
.Enabled
);
788 ctx
->_TriangleCaps
&= ~DD_STENCIL
;
789 if (ctx
->Stencil
.Enabled
)
790 ctx
->_TriangleCaps
|= DD_STENCIL
;
793 case GL_TRANSFORM_BIT
:
794 MEMCPY( &ctx
->Transform
, attr
->data
,
795 sizeof(struct gl_transform_attrib
) );
796 ctx
->NewState
|= _NEW_TRANSFORM
;
797 if (ctx
->Driver
.Enable
) {
798 (*ctx
->Driver
.Enable
)( ctx
, GL_NORMALIZE
, ctx
->Transform
.Normalize
);
799 (*ctx
->Driver
.Enable
)( ctx
, GL_RESCALE_NORMAL_EXT
, ctx
->Transform
.RescaleNormals
);
801 ctx
->_Enabled
&= ~(ENABLE_NORMALIZE
|ENABLE_RESCALE
);
802 if (ctx
->Transform
.Normalize
) ctx
->_Enabled
|= ENABLE_NORMALIZE
;
803 if (ctx
->Transform
.RescaleNormals
) ctx
->_Enabled
|= ENABLE_RESCALE
;
806 /* Take care of texture object reference counters */
809 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
810 ctx
->Texture
.Unit
[u
].CurrentD
[1]->RefCount
--;
811 ctx
->Texture
.Unit
[u
].CurrentD
[2]->RefCount
--;
812 ctx
->Texture
.Unit
[u
].CurrentD
[3]->RefCount
--;
814 MEMCPY( &ctx
->Texture
, attr
->data
,
815 sizeof(struct gl_texture_attrib
) );
816 ctx
->NewState
|= _NEW_TEXTURE
;
817 /* restore state of the currently bound texture objects */
818 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
819 copy_texobj_state( ctx
->Texture
.Unit
[u
].CurrentD
[1],
820 &(ctx
->Texture
.Unit
[u
].Saved1D
) );
821 copy_texobj_state( ctx
->Texture
.Unit
[u
].CurrentD
[2],
822 &(ctx
->Texture
.Unit
[u
].Saved2D
) );
823 copy_texobj_state( ctx
->Texture
.Unit
[u
].CurrentD
[3],
824 &(ctx
->Texture
.Unit
[u
].Saved3D
) );
825 copy_texobj_state( ctx
->Texture
.Unit
[u
].CurrentCubeMap
,
826 &(ctx
->Texture
.Unit
[u
].SavedCubeMap
) );
828 gl_put_texobj_on_dirty_list( ctx
, ctx
->Texture
.Unit
[u
].CurrentD
[1] );
829 gl_put_texobj_on_dirty_list( ctx
, ctx
->Texture
.Unit
[u
].CurrentD
[2] );
830 gl_put_texobj_on_dirty_list( ctx
, ctx
->Texture
.Unit
[u
].CurrentD
[3] );
831 gl_put_texobj_on_dirty_list( ctx
, ctx
->Texture
.Unit
[u
].CurrentCubeMap
);
836 case GL_VIEWPORT_BIT
:
838 struct gl_viewport_attrib
*v
=
839 (struct gl_viewport_attrib
*)attr
->data
;
841 ctx
->NewState
|= _NEW_VIEWPORT
;
842 _mesa_Viewport( v
->X
, v
->Y
, v
->Width
, v
->Height
);
843 _mesa_DepthRange( v
->Near
, v
->Far
);
847 gl_problem( ctx
, "Bad attrib flag in PopAttrib");
859 #define GL_CLIENT_PACK_BIT (1<<20)
860 #define GL_CLIENT_UNPACK_BIT (1<<21)
864 _mesa_PushClientAttrib(GLbitfield mask
)
866 struct gl_attrib_node
*newnode
;
867 struct gl_attrib_node
*head
;
869 GET_CURRENT_CONTEXT(ctx
);
870 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glPushClientAttrib");
872 if (ctx
->ClientAttribStackDepth
>=MAX_CLIENT_ATTRIB_STACK_DEPTH
) {
873 gl_error( ctx
, GL_STACK_OVERFLOW
, "glPushClientAttrib" );
877 /* Build linked list of attribute nodes which save all attribute */
878 /* groups specified by the mask. */
881 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
882 struct gl_pixelstore_attrib
*attr
;
883 /* packing attribs */
884 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
885 MEMCPY( attr
, &ctx
->Pack
, sizeof(struct gl_pixelstore_attrib
) );
886 newnode
= new_attrib_node( GL_CLIENT_PACK_BIT
);
887 newnode
->data
= attr
;
888 newnode
->next
= head
;
890 /* unpacking attribs */
891 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
892 MEMCPY( attr
, &ctx
->Unpack
, sizeof(struct gl_pixelstore_attrib
) );
893 newnode
= new_attrib_node( GL_CLIENT_UNPACK_BIT
);
894 newnode
->data
= attr
;
895 newnode
->next
= head
;
898 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
899 struct gl_array_attrib
*attr
;
900 attr
= MALLOC_STRUCT( gl_array_attrib
);
901 MEMCPY( attr
, &ctx
->Array
, sizeof(struct gl_array_attrib
) );
902 newnode
= new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT
);
903 newnode
->data
= attr
;
904 newnode
->next
= head
;
908 ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
] = head
;
909 ctx
->ClientAttribStackDepth
++;
916 _mesa_PopClientAttrib(void)
918 struct gl_attrib_node
*attr
, *next
;
920 GET_CURRENT_CONTEXT(ctx
);
921 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glPopClientAttrib");
923 if (ctx
->ClientAttribStackDepth
==0) {
924 gl_error( ctx
, GL_STACK_UNDERFLOW
, "glPopClientAttrib" );
928 ctx
->ClientAttribStackDepth
--;
929 attr
= ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
];
932 switch (attr
->kind
) {
933 case GL_CLIENT_PACK_BIT
:
934 MEMCPY( &ctx
->Pack
, attr
->data
,
935 sizeof(struct gl_pixelstore_attrib
) );
937 case GL_CLIENT_UNPACK_BIT
:
938 MEMCPY( &ctx
->Unpack
, attr
->data
,
939 sizeof(struct gl_pixelstore_attrib
) );
941 case GL_CLIENT_VERTEX_ARRAY_BIT
:
942 MEMCPY( &ctx
->Array
, attr
->data
,
943 sizeof(struct gl_array_attrib
) );
946 gl_problem( ctx
, "Bad attrib flag in PopClientAttrib");
956 ctx
->NewState
= _NEW_ARRAY
;