Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
55 | pj | 1 | /* $Id: attrib.c,v 1.1 2003-02-28 11:41:58 pj Exp $ */ |
2 | |||
3 | /* |
||
4 | * Mesa 3-D graphics library |
||
5 | * Version: 4.1 |
||
6 | * |
||
7 | * Copyright (C) 1999-2002 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 | #include "glheader.h" |
||
28 | #include "imports.h" |
||
29 | #include "accum.h" |
||
30 | #include "attrib.h" |
||
31 | #include "blend.h" |
||
32 | #include "buffers.h" |
||
33 | #include "colormac.h" |
||
34 | #include "context.h" |
||
35 | #include "depth.h" |
||
36 | #include "enable.h" |
||
37 | #include "enums.h" |
||
38 | #include "fog.h" |
||
39 | #include "hint.h" |
||
40 | #include "light.h" |
||
41 | #include "lines.h" |
||
42 | #include "matrix.h" |
||
43 | #include "points.h" |
||
44 | #include "polygon.h" |
||
45 | #include "simple_list.h" |
||
46 | #include "stencil.h" |
||
47 | #include "texobj.h" |
||
48 | #include "texstate.h" |
||
49 | #include "mtypes.h" |
||
50 | #include "math/m_xform.h" |
||
51 | |||
52 | |||
53 | /* |
||
54 | * Allocate a new attribute state node. These nodes have a |
||
55 | * "kind" value and a pointer to a struct of state data. |
||
56 | */ |
||
57 | static struct gl_attrib_node * |
||
58 | new_attrib_node( GLbitfield kind ) |
||
59 | { |
||
60 | struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node); |
||
61 | if (an) { |
||
62 | an->kind = kind; |
||
63 | } |
||
64 | return an; |
||
65 | } |
||
66 | |||
67 | |||
68 | void |
||
69 | _mesa_PushAttrib(GLbitfield mask) |
||
70 | { |
||
71 | struct gl_attrib_node *newnode; |
||
72 | struct gl_attrib_node *head; |
||
73 | |||
74 | GET_CURRENT_CONTEXT(ctx); |
||
75 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
76 | |||
77 | if (MESA_VERBOSE & VERBOSE_API) |
||
78 | _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask); |
||
79 | |||
80 | if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) { |
||
81 | _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); |
||
82 | return; |
||
83 | } |
||
84 | |||
85 | /* Build linked list of attribute nodes which save all attribute */ |
||
86 | /* groups specified by the mask. */ |
||
87 | head = NULL; |
||
88 | |||
89 | if (mask & GL_ACCUM_BUFFER_BIT) { |
||
90 | struct gl_accum_attrib *attr; |
||
91 | attr = MALLOC_STRUCT( gl_accum_attrib ); |
||
92 | MEMCPY( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) ); |
||
93 | newnode = new_attrib_node( GL_ACCUM_BUFFER_BIT ); |
||
94 | newnode->data = attr; |
||
95 | newnode->next = head; |
||
96 | head = newnode; |
||
97 | } |
||
98 | |||
99 | if (mask & GL_COLOR_BUFFER_BIT) { |
||
100 | struct gl_colorbuffer_attrib *attr; |
||
101 | attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); |
||
102 | MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); |
||
103 | newnode = new_attrib_node( GL_COLOR_BUFFER_BIT ); |
||
104 | newnode->data = attr; |
||
105 | newnode->next = head; |
||
106 | head = newnode; |
||
107 | } |
||
108 | |||
109 | if (mask & GL_CURRENT_BIT) { |
||
110 | struct gl_current_attrib *attr; |
||
111 | FLUSH_CURRENT( ctx, 0 ); |
||
112 | attr = MALLOC_STRUCT( gl_current_attrib ); |
||
113 | MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) ); |
||
114 | newnode = new_attrib_node( GL_CURRENT_BIT ); |
||
115 | newnode->data = attr; |
||
116 | newnode->next = head; |
||
117 | head = newnode; |
||
118 | } |
||
119 | |||
120 | if (mask & GL_DEPTH_BUFFER_BIT) { |
||
121 | struct gl_depthbuffer_attrib *attr; |
||
122 | attr = MALLOC_STRUCT( gl_depthbuffer_attrib ); |
||
123 | MEMCPY( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) ); |
||
124 | newnode = new_attrib_node( GL_DEPTH_BUFFER_BIT ); |
||
125 | newnode->data = attr; |
||
126 | newnode->next = head; |
||
127 | head = newnode; |
||
128 | } |
||
129 | |||
130 | if (mask & GL_ENABLE_BIT) { |
||
131 | struct gl_enable_attrib *attr; |
||
132 | GLuint i; |
||
133 | attr = MALLOC_STRUCT( gl_enable_attrib ); |
||
134 | /* Copy enable flags from all other attributes into the enable struct. */ |
||
135 | attr->AlphaTest = ctx->Color.AlphaEnabled; |
||
136 | attr->AutoNormal = ctx->Eval.AutoNormal; |
||
137 | attr->Blend = ctx->Color.BlendEnabled; |
||
138 | attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled; |
||
139 | attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; |
||
140 | attr->Convolution1D = ctx->Pixel.Convolution1DEnabled; |
||
141 | attr->Convolution2D = ctx->Pixel.Convolution2DEnabled; |
||
142 | attr->Separable2D = ctx->Pixel.Separable2DEnabled; |
||
143 | attr->CullFace = ctx->Polygon.CullFlag; |
||
144 | attr->DepthTest = ctx->Depth.Test; |
||
145 | attr->Dither = ctx->Color.DitherFlag; |
||
146 | attr->Fog = ctx->Fog.Enabled; |
||
147 | for (i=0;i<MAX_LIGHTS;i++) { |
||
148 | attr->Light[i] = ctx->Light.Light[i].Enabled; |
||
149 | } |
||
150 | attr->Lighting = ctx->Light.Enabled; |
||
151 | attr->LineSmooth = ctx->Line.SmoothFlag; |
||
152 | attr->LineStipple = ctx->Line.StippleFlag; |
||
153 | attr->Histogram = ctx->Pixel.HistogramEnabled; |
||
154 | attr->MinMax = ctx->Pixel.MinMaxEnabled; |
||
155 | attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; |
||
156 | attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; |
||
157 | attr->Map1Color4 = ctx->Eval.Map1Color4; |
||
158 | attr->Map1Index = ctx->Eval.Map1Index; |
||
159 | attr->Map1Normal = ctx->Eval.Map1Normal; |
||
160 | attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1; |
||
161 | attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2; |
||
162 | attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3; |
||
163 | attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; |
||
164 | attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; |
||
165 | attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; |
||
166 | MEMCPY(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib)); |
||
167 | attr->Map2Color4 = ctx->Eval.Map2Color4; |
||
168 | attr->Map2Index = ctx->Eval.Map2Index; |
||
169 | attr->Map2Normal = ctx->Eval.Map2Normal; |
||
170 | attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1; |
||
171 | attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2; |
||
172 | attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3; |
||
173 | attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; |
||
174 | attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; |
||
175 | attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; |
||
176 | MEMCPY(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib)); |
||
177 | attr->Normalize = ctx->Transform.Normalize; |
||
178 | attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; |
||
179 | attr->PixelTexture = ctx->Pixel.PixelTextureEnabled; |
||
180 | attr->PointSmooth = ctx->Point.SmoothFlag; |
||
181 | attr->PointSprite = ctx->Point.PointSprite; |
||
182 | attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; |
||
183 | attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; |
||
184 | attr->PolygonOffsetFill = ctx->Polygon.OffsetFill; |
||
185 | attr->PolygonSmooth = ctx->Polygon.SmoothFlag; |
||
186 | attr->PolygonStipple = ctx->Polygon.StippleFlag; |
||
187 | attr->RescaleNormals = ctx->Transform.RescaleNormals; |
||
188 | attr->Scissor = ctx->Scissor.Enabled; |
||
189 | attr->Stencil = ctx->Stencil.Enabled; |
||
190 | attr->MultisampleEnabled = ctx->Multisample.Enabled; |
||
191 | attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage; |
||
192 | attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; |
||
193 | attr->SampleCoverage = ctx->Multisample.SampleCoverage; |
||
194 | attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert; |
||
195 | for (i=0; i<MAX_TEXTURE_UNITS; i++) { |
||
196 | attr->Texture[i] = ctx->Texture.Unit[i].Enabled; |
||
197 | attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; |
||
198 | } |
||
199 | /* GL_NV_vertex_program */ |
||
200 | attr->VertexProgram = ctx->VertexProgram.Enabled; |
||
201 | attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled; |
||
202 | attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled; |
||
203 | newnode = new_attrib_node( GL_ENABLE_BIT ); |
||
204 | newnode->data = attr; |
||
205 | newnode->next = head; |
||
206 | head = newnode; |
||
207 | } |
||
208 | |||
209 | if (mask & GL_EVAL_BIT) { |
||
210 | struct gl_eval_attrib *attr; |
||
211 | attr = MALLOC_STRUCT( gl_eval_attrib ); |
||
212 | MEMCPY( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) ); |
||
213 | newnode = new_attrib_node( GL_EVAL_BIT ); |
||
214 | newnode->data = attr; |
||
215 | newnode->next = head; |
||
216 | head = newnode; |
||
217 | } |
||
218 | |||
219 | if (mask & GL_FOG_BIT) { |
||
220 | struct gl_fog_attrib *attr; |
||
221 | attr = MALLOC_STRUCT( gl_fog_attrib ); |
||
222 | MEMCPY( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) ); |
||
223 | newnode = new_attrib_node( GL_FOG_BIT ); |
||
224 | newnode->data = attr; |
||
225 | newnode->next = head; |
||
226 | head = newnode; |
||
227 | } |
||
228 | |||
229 | if (mask & GL_HINT_BIT) { |
||
230 | struct gl_hint_attrib *attr; |
||
231 | attr = MALLOC_STRUCT( gl_hint_attrib ); |
||
232 | MEMCPY( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) ); |
||
233 | newnode = new_attrib_node( GL_HINT_BIT ); |
||
234 | newnode->data = attr; |
||
235 | newnode->next = head; |
||
236 | head = newnode; |
||
237 | } |
||
238 | |||
239 | if (mask & GL_LIGHTING_BIT) { |
||
240 | struct gl_light_attrib *attr; |
||
241 | FLUSH_CURRENT(ctx, 0); /* flush material changes */ |
||
242 | attr = MALLOC_STRUCT( gl_light_attrib ); |
||
243 | MEMCPY( attr, &ctx->Light, sizeof(struct gl_light_attrib) ); |
||
244 | newnode = new_attrib_node( GL_LIGHTING_BIT ); |
||
245 | newnode->data = attr; |
||
246 | newnode->next = head; |
||
247 | head = newnode; |
||
248 | } |
||
249 | |||
250 | if (mask & GL_LINE_BIT) { |
||
251 | struct gl_line_attrib *attr; |
||
252 | attr = MALLOC_STRUCT( gl_line_attrib ); |
||
253 | MEMCPY( attr, &ctx->Line, sizeof(struct gl_line_attrib) ); |
||
254 | newnode = new_attrib_node( GL_LINE_BIT ); |
||
255 | newnode->data = attr; |
||
256 | newnode->next = head; |
||
257 | head = newnode; |
||
258 | } |
||
259 | |||
260 | if (mask & GL_LIST_BIT) { |
||
261 | struct gl_list_attrib *attr; |
||
262 | attr = MALLOC_STRUCT( gl_list_attrib ); |
||
263 | MEMCPY( attr, &ctx->List, sizeof(struct gl_list_attrib) ); |
||
264 | newnode = new_attrib_node( GL_LIST_BIT ); |
||
265 | newnode->data = attr; |
||
266 | newnode->next = head; |
||
267 | head = newnode; |
||
268 | } |
||
269 | |||
270 | if (mask & GL_PIXEL_MODE_BIT) { |
||
271 | struct gl_pixel_attrib *attr; |
||
272 | attr = MALLOC_STRUCT( gl_pixel_attrib ); |
||
273 | MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) ); |
||
274 | newnode = new_attrib_node( GL_PIXEL_MODE_BIT ); |
||
275 | newnode->data = attr; |
||
276 | newnode->next = head; |
||
277 | head = newnode; |
||
278 | } |
||
279 | |||
280 | if (mask & GL_POINT_BIT) { |
||
281 | struct gl_point_attrib *attr; |
||
282 | attr = MALLOC_STRUCT( gl_point_attrib ); |
||
283 | MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) ); |
||
284 | newnode = new_attrib_node( GL_POINT_BIT ); |
||
285 | newnode->data = attr; |
||
286 | newnode->next = head; |
||
287 | head = newnode; |
||
288 | } |
||
289 | |||
290 | if (mask & GL_POLYGON_BIT) { |
||
291 | struct gl_polygon_attrib *attr; |
||
292 | attr = MALLOC_STRUCT( gl_polygon_attrib ); |
||
293 | MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) ); |
||
294 | newnode = new_attrib_node( GL_POLYGON_BIT ); |
||
295 | newnode->data = attr; |
||
296 | newnode->next = head; |
||
297 | head = newnode; |
||
298 | } |
||
299 | |||
300 | if (mask & GL_POLYGON_STIPPLE_BIT) { |
||
301 | GLuint *stipple; |
||
302 | stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) ); |
||
303 | MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) ); |
||
304 | newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT ); |
||
305 | newnode->data = stipple; |
||
306 | newnode->next = head; |
||
307 | head = newnode; |
||
308 | } |
||
309 | |||
310 | if (mask & GL_SCISSOR_BIT) { |
||
311 | struct gl_scissor_attrib *attr; |
||
312 | attr = MALLOC_STRUCT( gl_scissor_attrib ); |
||
313 | MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) ); |
||
314 | newnode = new_attrib_node( GL_SCISSOR_BIT ); |
||
315 | newnode->data = attr; |
||
316 | newnode->next = head; |
||
317 | head = newnode; |
||
318 | } |
||
319 | |||
320 | if (mask & GL_STENCIL_BUFFER_BIT) { |
||
321 | struct gl_stencil_attrib *attr; |
||
322 | attr = MALLOC_STRUCT( gl_stencil_attrib ); |
||
323 | MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) ); |
||
324 | newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT ); |
||
325 | newnode->data = attr; |
||
326 | newnode->next = head; |
||
327 | head = newnode; |
||
328 | } |
||
329 | |||
330 | if (mask & GL_TEXTURE_BIT) { |
||
331 | struct gl_texture_attrib *attr; |
||
332 | GLuint u; |
||
333 | /* Bump the texture object reference counts so that they don't |
||
334 | * inadvertantly get deleted. |
||
335 | */ |
||
336 | for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { |
||
337 | ctx->Texture.Unit[u].Current1D->RefCount++; |
||
338 | ctx->Texture.Unit[u].Current2D->RefCount++; |
||
339 | ctx->Texture.Unit[u].Current3D->RefCount++; |
||
340 | ctx->Texture.Unit[u].CurrentCubeMap->RefCount++; |
||
341 | ctx->Texture.Unit[u].CurrentRect->RefCount++; |
||
342 | } |
||
343 | attr = MALLOC_STRUCT( gl_texture_attrib ); |
||
344 | MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) ); |
||
345 | /* copy state of the currently bound texture objects */ |
||
346 | for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { |
||
347 | _mesa_copy_texture_object(&attr->Unit[u].Saved1D, |
||
348 | attr->Unit[u].Current1D); |
||
349 | _mesa_copy_texture_object(&attr->Unit[u].Saved2D, |
||
350 | attr->Unit[u].Current2D); |
||
351 | _mesa_copy_texture_object(&attr->Unit[u].Saved3D, |
||
352 | attr->Unit[u].Current3D); |
||
353 | _mesa_copy_texture_object(&attr->Unit[u].SavedCubeMap, |
||
354 | attr->Unit[u].CurrentCubeMap); |
||
355 | _mesa_copy_texture_object(&attr->Unit[u].SavedRect, |
||
356 | attr->Unit[u].CurrentRect); |
||
357 | } |
||
358 | newnode = new_attrib_node( GL_TEXTURE_BIT ); |
||
359 | newnode->data = attr; |
||
360 | newnode->next = head; |
||
361 | head = newnode; |
||
362 | } |
||
363 | |||
364 | if (mask & GL_TRANSFORM_BIT) { |
||
365 | struct gl_transform_attrib *attr; |
||
366 | attr = MALLOC_STRUCT( gl_transform_attrib ); |
||
367 | MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) ); |
||
368 | newnode = new_attrib_node( GL_TRANSFORM_BIT ); |
||
369 | newnode->data = attr; |
||
370 | newnode->next = head; |
||
371 | head = newnode; |
||
372 | } |
||
373 | |||
374 | if (mask & GL_VIEWPORT_BIT) { |
||
375 | struct gl_viewport_attrib *attr; |
||
376 | attr = MALLOC_STRUCT( gl_viewport_attrib ); |
||
377 | MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); |
||
378 | newnode = new_attrib_node( GL_VIEWPORT_BIT ); |
||
379 | newnode->data = attr; |
||
380 | newnode->next = head; |
||
381 | head = newnode; |
||
382 | } |
||
383 | |||
384 | /* GL_ARB_multisample */ |
||
385 | if (mask & GL_MULTISAMPLE_BIT_ARB) { |
||
386 | struct gl_multisample_attrib *attr; |
||
387 | attr = MALLOC_STRUCT( gl_multisample_attrib ); |
||
388 | MEMCPY( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) ); |
||
389 | newnode = new_attrib_node( GL_MULTISAMPLE_BIT_ARB ); |
||
390 | newnode->data = attr; |
||
391 | newnode->next = head; |
||
392 | head = newnode; |
||
393 | } |
||
394 | |||
395 | ctx->AttribStack[ctx->AttribStackDepth] = head; |
||
396 | ctx->AttribStackDepth++; |
||
397 | } |
||
398 | |||
399 | |||
400 | |||
401 | static void |
||
402 | pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) |
||
403 | { |
||
404 | GLuint i; |
||
405 | |||
406 | #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ |
||
407 | if ((VALUE) != (NEWVALUE)) { \ |
||
408 | _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ |
||
409 | } |
||
410 | |||
411 | TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); |
||
412 | TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND); |
||
413 | |||
414 | for (i=0;i<MAX_CLIP_PLANES;i++) { |
||
415 | const GLuint mask = 1 << i; |
||
416 | if ((ctx->Transform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask)) |
||
417 | _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i), |
||
418 | (GLboolean) ((enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE)); |
||
419 | } |
||
420 | |||
421 | TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, |
||
422 | GL_COLOR_MATERIAL); |
||
423 | TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); |
||
424 | TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); |
||
425 | TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); |
||
426 | TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D, |
||
427 | GL_CONVOLUTION_1D); |
||
428 | TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D, |
||
429 | GL_CONVOLUTION_2D); |
||
430 | TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D, |
||
431 | GL_SEPARABLE_2D); |
||
432 | TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); |
||
433 | TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); |
||
434 | TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); |
||
435 | TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple, |
||
436 | GL_LINE_STIPPLE); |
||
437 | TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp, |
||
438 | GL_INDEX_LOGIC_OP); |
||
439 | TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, |
||
440 | GL_COLOR_LOGIC_OP); |
||
441 | |||
442 | TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); |
||
443 | TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); |
||
444 | TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); |
||
445 | TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1, |
||
446 | GL_MAP1_TEXTURE_COORD_1); |
||
447 | TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2, |
||
448 | GL_MAP1_TEXTURE_COORD_2); |
||
449 | TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3, |
||
450 | GL_MAP1_TEXTURE_COORD_3); |
||
451 | TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4, |
||
452 | GL_MAP1_TEXTURE_COORD_4); |
||
453 | TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3, |
||
454 | GL_MAP1_VERTEX_3); |
||
455 | TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, |
||
456 | GL_MAP1_VERTEX_4); |
||
457 | for (i = 0; i < 16; i++) { |
||
458 | TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i], |
||
459 | GL_MAP1_VERTEX_ATTRIB0_4_NV + i); |
||
460 | } |
||
461 | |||
462 | TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); |
||
463 | TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); |
||
464 | TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); |
||
465 | TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1, |
||
466 | GL_MAP2_TEXTURE_COORD_1); |
||
467 | TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2, |
||
468 | GL_MAP2_TEXTURE_COORD_2); |
||
469 | TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3, |
||
470 | GL_MAP2_TEXTURE_COORD_3); |
||
471 | TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4, |
||
472 | GL_MAP2_TEXTURE_COORD_4); |
||
473 | TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3, |
||
474 | GL_MAP2_VERTEX_3); |
||
475 | TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, |
||
476 | GL_MAP2_VERTEX_4); |
||
477 | for (i = 0; i < 16; i++) { |
||
478 | TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i], |
||
479 | GL_MAP2_VERTEX_ATTRIB0_4_NV + i); |
||
480 | } |
||
481 | |||
482 | TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); |
||
483 | TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); |
||
484 | TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, |
||
485 | GL_RESCALE_NORMAL_EXT); |
||
486 | TEST_AND_UPDATE(ctx->Transform.RasterPositionUnclipped, |
||
487 | enable->RasterPositionUnclipped, |
||
488 | GL_RASTER_POSITION_UNCLIPPED_IBM); |
||
489 | TEST_AND_UPDATE(ctx->Pixel.PixelTextureEnabled, enable->PixelTexture, |
||
490 | GL_POINT_SMOOTH); |
||
491 | TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, |
||
492 | GL_POINT_SMOOTH); |
||
493 | if (ctx->Extensions.NV_point_sprite) { |
||
494 | TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite, |
||
495 | GL_POINT_SPRITE_NV); |
||
496 | } |
||
497 | TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, |
||
498 | GL_POLYGON_OFFSET_POINT); |
||
499 | TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, |
||
500 | GL_POLYGON_OFFSET_LINE); |
||
501 | TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill, |
||
502 | GL_POLYGON_OFFSET_FILL); |
||
503 | TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth, |
||
504 | GL_POLYGON_SMOOTH); |
||
505 | TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple, |
||
506 | GL_POLYGON_STIPPLE); |
||
507 | TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST); |
||
508 | TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST); |
||
509 | /* XXX two-sided stencil */ |
||
510 | TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled, |
||
511 | GL_MULTISAMPLE_ARB); |
||
512 | TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage, |
||
513 | enable->SampleAlphaToCoverage, |
||
514 | GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); |
||
515 | TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne, |
||
516 | enable->SampleAlphaToOne, |
||
517 | GL_SAMPLE_ALPHA_TO_ONE_ARB); |
||
518 | TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, |
||
519 | enable->SampleCoverage, |
||
520 | GL_SAMPLE_COVERAGE_ARB); |
||
521 | TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert, |
||
522 | enable->SampleCoverageInvert, |
||
523 | GL_SAMPLE_COVERAGE_INVERT_ARB); |
||
524 | /* GL_NV_vertex_program */ |
||
525 | TEST_AND_UPDATE(ctx->VertexProgram.Enabled, |
||
526 | enable->VertexProgram, |
||
527 | GL_VERTEX_PROGRAM_NV); |
||
528 | TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled, |
||
529 | enable->VertexProgramPointSize, |
||
530 | GL_VERTEX_PROGRAM_POINT_SIZE_NV); |
||
531 | TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled, |
||
532 | enable->VertexProgramTwoSide, |
||
533 | GL_VERTEX_PROGRAM_TWO_SIDE_NV); |
||
534 | |||
535 | #undef TEST_AND_UPDATE |
||
536 | |||
537 | /* texture unit enables */ |
||
538 | for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { |
||
539 | if (ctx->Texture.Unit[i].Enabled != enable->Texture[i]) { |
||
540 | ctx->Texture.Unit[i].Enabled = enable->Texture[i]; |
||
541 | if (ctx->Driver.Enable) { |
||
542 | if (ctx->Driver.ActiveTexture) { |
||
543 | (*ctx->Driver.ActiveTexture)(ctx, i); |
||
544 | } |
||
545 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D, |
||
546 | (GLboolean) (enable->Texture[i] & TEXTURE_1D_BIT) ); |
||
547 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D, |
||
548 | (GLboolean) (enable->Texture[i] & TEXTURE_2D_BIT) ); |
||
549 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D, |
||
550 | (GLboolean) (enable->Texture[i] & TEXTURE_3D_BIT) ); |
||
551 | if (ctx->Extensions.ARB_texture_cube_map) |
||
552 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_CUBE_MAP_ARB, |
||
553 | (GLboolean) (enable->Texture[i] & TEXTURE_CUBE_BIT) ); |
||
554 | if (ctx->Extensions.NV_texture_rectangle) |
||
555 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_RECTANGLE_NV, |
||
556 | (GLboolean) (enable->Texture[i] & TEXTURE_RECT_BIT) ); |
||
557 | } |
||
558 | } |
||
559 | |||
560 | if (ctx->Texture.Unit[i].TexGenEnabled != enable->TexGen[i]) { |
||
561 | ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i]; |
||
562 | if (ctx->Driver.Enable) { |
||
563 | if (ctx->Driver.ActiveTexture) { |
||
564 | (*ctx->Driver.ActiveTexture)(ctx, i); |
||
565 | } |
||
566 | if (enable->TexGen[i] & S_BIT) |
||
567 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_TRUE); |
||
568 | else |
||
569 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_FALSE); |
||
570 | if (enable->TexGen[i] & T_BIT) |
||
571 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_TRUE); |
||
572 | else |
||
573 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_FALSE); |
||
574 | if (enable->TexGen[i] & R_BIT) |
||
575 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_TRUE); |
||
576 | else |
||
577 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_FALSE); |
||
578 | if (enable->TexGen[i] & Q_BIT) |
||
579 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_TRUE); |
||
580 | else |
||
581 | (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE); |
||
582 | } |
||
583 | } |
||
584 | } |
||
585 | |||
586 | if (ctx->Driver.ActiveTexture) { |
||
587 | (*ctx->Driver.ActiveTexture)(ctx, ctx->Texture.CurrentUnit); |
||
588 | } |
||
589 | } |
||
590 | |||
591 | |||
592 | static void |
||
593 | pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) |
||
594 | { |
||
595 | GLuint u; |
||
596 | |||
597 | for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { |
||
598 | const struct gl_texture_unit *unit = &texAttrib->Unit[u]; |
||
599 | GLuint i; |
||
600 | |||
601 | _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); |
||
602 | _mesa_set_enable(ctx, GL_TEXTURE_1D, |
||
603 | (GLboolean) (unit->Enabled & TEXTURE_1D_BIT ? GL_TRUE : GL_FALSE)); |
||
604 | _mesa_set_enable(ctx, GL_TEXTURE_2D, |
||
605 | (GLboolean) (unit->Enabled & TEXTURE_2D_BIT ? GL_TRUE : GL_FALSE)); |
||
606 | _mesa_set_enable(ctx, GL_TEXTURE_3D, |
||
607 | (GLboolean) (unit->Enabled & TEXTURE_3D_BIT ? GL_TRUE : GL_FALSE)); |
||
608 | if (ctx->Extensions.ARB_texture_cube_map) { |
||
609 | _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB, |
||
610 | (GLboolean) (unit->Enabled & TEXTURE_CUBE_BIT ? GL_TRUE : GL_FALSE)); |
||
611 | } |
||
612 | if (ctx->Extensions.NV_texture_rectangle) { |
||
613 | _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV, |
||
614 | (GLboolean) (unit->Enabled & TEXTURE_RECT_BIT ? GL_TRUE : GL_FALSE)); |
||
615 | } |
||
616 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); |
||
617 | _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); |
||
618 | _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenModeS); |
||
619 | _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenModeT); |
||
620 | _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenModeR); |
||
621 | _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenModeQ); |
||
622 | _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->ObjectPlaneS); |
||
623 | _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->ObjectPlaneT); |
||
624 | _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->ObjectPlaneR); |
||
625 | _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->ObjectPlaneQ); |
||
626 | _mesa_TexGenfv(GL_S, GL_EYE_PLANE, unit->EyePlaneS); |
||
627 | _mesa_TexGenfv(GL_T, GL_EYE_PLANE, unit->EyePlaneT); |
||
628 | _mesa_TexGenfv(GL_R, GL_EYE_PLANE, unit->EyePlaneR); |
||
629 | _mesa_TexGenfv(GL_Q, GL_EYE_PLANE, unit->EyePlaneQ); |
||
630 | if (ctx->Extensions.EXT_texture_lod_bias) { |
||
631 | _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, |
||
632 | GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias); |
||
633 | } |
||
634 | if (ctx->Extensions.EXT_texture_env_combine || |
||
635 | ctx->Extensions.ARB_texture_env_combine) { |
||
636 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, |
||
637 | unit->CombineModeRGB); |
||
638 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, |
||
639 | unit->CombineModeA); |
||
640 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, |
||
641 | unit->CombineSourceRGB[0]); |
||
642 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, |
||
643 | unit->CombineSourceRGB[1]); |
||
644 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, |
||
645 | unit->CombineSourceRGB[2]); |
||
646 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, |
||
647 | unit->CombineSourceA[0]); |
||
648 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, |
||
649 | unit->CombineSourceA[1]); |
||
650 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, |
||
651 | unit->CombineSourceA[2]); |
||
652 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, |
||
653 | unit->CombineOperandRGB[0]); |
||
654 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, |
||
655 | unit->CombineOperandRGB[1]); |
||
656 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, |
||
657 | unit->CombineOperandRGB[2]); |
||
658 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, |
||
659 | unit->CombineOperandA[0]); |
||
660 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, |
||
661 | unit->CombineOperandA[1]); |
||
662 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, |
||
663 | unit->CombineOperandA[2]); |
||
664 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, |
||
665 | 1 << unit->CombineScaleShiftRGB); |
||
666 | _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, |
||
667 | 1 << unit->CombineScaleShiftA); |
||
668 | } |
||
669 | |||
670 | /* Restore texture object state */ |
||
671 | for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { |
||
672 | GLenum target = 0; |
||
673 | const struct gl_texture_object *obj = NULL; |
||
674 | GLfloat bordColor[4]; |
||
675 | |||
676 | switch (i) { |
||
677 | case 0: |
||
678 | target = GL_TEXTURE_1D; |
||
679 | obj = &unit->Saved1D; |
||
680 | break; |
||
681 | case 1: |
||
682 | target = GL_TEXTURE_2D; |
||
683 | obj = &unit->Saved2D; |
||
684 | break; |
||
685 | case 2: |
||
686 | target = GL_TEXTURE_3D; |
||
687 | obj = &unit->Saved3D; |
||
688 | break; |
||
689 | case 3: |
||
690 | if (!ctx->Extensions.ARB_texture_cube_map) |
||
691 | continue; |
||
692 | target = GL_TEXTURE_CUBE_MAP_ARB; |
||
693 | obj = &unit->SavedCubeMap; |
||
694 | break; |
||
695 | case 4: |
||
696 | if (!ctx->Extensions.NV_texture_rectangle) |
||
697 | continue; |
||
698 | target = GL_TEXTURE_RECTANGLE_NV; |
||
699 | obj = &unit->SavedRect; |
||
700 | break; |
||
701 | default: |
||
702 | ; /* silence warnings */ |
||
703 | } |
||
704 | |||
705 | _mesa_BindTexture(target, obj->Name); |
||
706 | |||
707 | bordColor[0] = CHAN_TO_FLOAT(obj->BorderColor[0]); |
||
708 | bordColor[1] = CHAN_TO_FLOAT(obj->BorderColor[1]); |
||
709 | bordColor[2] = CHAN_TO_FLOAT(obj->BorderColor[2]); |
||
710 | bordColor[3] = CHAN_TO_FLOAT(obj->BorderColor[3]); |
||
711 | |||
712 | _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); |
||
713 | _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, bordColor); |
||
714 | _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS); |
||
715 | _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT); |
||
716 | _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, obj->WrapR); |
||
717 | _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, obj->MinFilter); |
||
718 | _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter); |
||
719 | _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod); |
||
720 | _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod); |
||
721 | _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel); |
||
722 | _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel); |
||
723 | if (ctx->Extensions.EXT_texture_filter_anisotropic) { |
||
724 | _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, |
||
725 | obj->MaxAnisotropy); |
||
726 | } |
||
727 | if (ctx->Extensions.SGIX_shadow) { |
||
728 | _mesa_TexParameteri(target, GL_TEXTURE_COMPARE_SGIX, |
||
729 | obj->CompareFlag); |
||
730 | _mesa_TexParameteri(target, GL_TEXTURE_COMPARE_OPERATOR_SGIX, |
||
731 | obj->CompareOperator); |
||
732 | } |
||
733 | if (ctx->Extensions.SGIX_shadow_ambient) { |
||
734 | _mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX, |
||
735 | obj->ShadowAmbient); |
||
736 | } |
||
737 | |||
738 | } |
||
739 | } |
||
740 | _mesa_ActiveTextureARB(GL_TEXTURE0_ARB |
||
741 | + texAttrib->CurrentUnit); |
||
742 | |||
743 | /* "un-bump" the texture object reference counts. We did that so they |
||
744 | * wouldn't inadvertantly get deleted while they were still referenced |
||
745 | * inside the attribute state stack. |
||
746 | */ |
||
747 | for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { |
||
748 | ctx->Texture.Unit[u].Current1D->RefCount--; |
||
749 | ctx->Texture.Unit[u].Current2D->RefCount--; |
||
750 | ctx->Texture.Unit[u].Current3D->RefCount--; |
||
751 | ctx->Texture.Unit[u].CurrentCubeMap->RefCount--; |
||
752 | ctx->Texture.Unit[u].CurrentRect->RefCount--; |
||
753 | } |
||
754 | } |
||
755 | |||
756 | |||
757 | /* |
||
758 | * This function is kind of long just because we have to call a lot |
||
759 | * of device driver functions to update device driver state. |
||
760 | * |
||
761 | * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions |
||
762 | * in order to restore GL state. This isn't terribly efficient but it |
||
763 | * ensures that dirty flags and any derived state gets updated correctly. |
||
764 | * We could at least check if the value to restore equals the current value |
||
765 | * and then skip the Mesa call. |
||
766 | */ |
||
767 | void |
||
768 | _mesa_PopAttrib(void) |
||
769 | { |
||
770 | struct gl_attrib_node *attr, *next; |
||
771 | GET_CURRENT_CONTEXT(ctx); |
||
772 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
||
773 | |||
774 | if (ctx->AttribStackDepth == 0) { |
||
775 | _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" ); |
||
776 | return; |
||
777 | } |
||
778 | |||
779 | ctx->AttribStackDepth--; |
||
780 | attr = ctx->AttribStack[ctx->AttribStackDepth]; |
||
781 | |||
782 | while (attr) { |
||
783 | |||
784 | if (MESA_VERBOSE & VERBOSE_API) { |
||
785 | _mesa_debug(ctx, "glPopAttrib %s\n", |
||
786 | _mesa_lookup_enum_by_nr(attr->kind)); |
||
787 | } |
||
788 | |||
789 | switch (attr->kind) { |
||
790 | case GL_ACCUM_BUFFER_BIT: |
||
791 | { |
||
792 | const struct gl_accum_attrib *accum; |
||
793 | accum = (const struct gl_accum_attrib *) attr->data; |
||
794 | _mesa_ClearAccum(accum->ClearColor[0], |
||
795 | accum->ClearColor[1], |
||
796 | accum->ClearColor[2], |
||
797 | accum->ClearColor[3]); |
||
798 | } |
||
799 | break; |
||
800 | case GL_COLOR_BUFFER_BIT: |
||
801 | { |
||
802 | const struct gl_colorbuffer_attrib *color; |
||
803 | color = (const struct gl_colorbuffer_attrib *) attr->data; |
||
804 | _mesa_ClearIndex((GLfloat) color->ClearIndex); |
||
805 | _mesa_ClearColor(color->ClearColor[0], |
||
806 | color->ClearColor[1], |
||
807 | color->ClearColor[2], |
||
808 | color->ClearColor[3]); |
||
809 | _mesa_IndexMask(color->IndexMask); |
||
810 | _mesa_ColorMask((GLboolean) (color->ColorMask[0] != 0), |
||
811 | (GLboolean) (color->ColorMask[1] != 0), |
||
812 | (GLboolean) (color->ColorMask[2] != 0), |
||
813 | (GLboolean) (color->ColorMask[3] != 0)); |
||
814 | _mesa_DrawBuffer(color->DrawBuffer); |
||
815 | _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled); |
||
816 | _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef); |
||
817 | _mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled); |
||
818 | _mesa_BlendFuncSeparateEXT(color->BlendSrcRGB, |
||
819 | color->BlendDstRGB, |
||
820 | color->BlendSrcA, |
||
821 | color->BlendDstA); |
||
822 | _mesa_BlendEquation(color->BlendEquation); |
||
823 | _mesa_BlendColor(color->BlendColor[0], |
||
824 | color->BlendColor[1], |
||
825 | color->BlendColor[2], |
||
826 | color->BlendColor[3]); |
||
827 | _mesa_LogicOp(color->LogicOp); |
||
828 | _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP, |
||
829 | color->ColorLogicOpEnabled); |
||
830 | _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP, |
||
831 | color->IndexLogicOpEnabled); |
||
832 | _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag); |
||
833 | } |
||
834 | break; |
||
835 | case GL_CURRENT_BIT: |
||
836 | FLUSH_CURRENT( ctx, 0 ); |
||
837 | MEMCPY( &ctx->Current, attr->data, |
||
838 | sizeof(struct gl_current_attrib) ); |
||
839 | break; |
||
840 | case GL_DEPTH_BUFFER_BIT: |
||
841 | { |
||
842 | const struct gl_depthbuffer_attrib *depth; |
||
843 | depth = (const struct gl_depthbuffer_attrib *) attr->data; |
||
844 | _mesa_DepthFunc(depth->Func); |
||
845 | _mesa_ClearDepth(depth->Clear); |
||
846 | _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test); |
||
847 | _mesa_DepthMask(depth->Mask); |
||
848 | if (ctx->Extensions.HP_occlusion_test) |
||
849 | _mesa_set_enable(ctx, GL_OCCLUSION_TEST_HP, |
||
850 | depth->OcclusionTest); |
||
851 | } |
||
852 | break; |
||
853 | case GL_ENABLE_BIT: |
||
854 | { |
||
855 | const struct gl_enable_attrib *enable; |
||
856 | enable = (const struct gl_enable_attrib *) attr->data; |
||
857 | pop_enable_group(ctx, enable); |
||
858 | ctx->NewState |= _NEW_ALL; |
||
859 | } |
||
860 | break; |
||
861 | case GL_EVAL_BIT: |
||
862 | MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) ); |
||
863 | ctx->NewState |= _NEW_EVAL; |
||
864 | break; |
||
865 | case GL_FOG_BIT: |
||
866 | { |
||
867 | const struct gl_fog_attrib *fog; |
||
868 | fog = (const struct gl_fog_attrib *) attr->data; |
||
869 | _mesa_set_enable(ctx, GL_FOG, fog->Enabled); |
||
870 | _mesa_Fogfv(GL_FOG_COLOR, fog->Color); |
||
871 | _mesa_Fogf(GL_FOG_DENSITY, fog->Density); |
||
872 | _mesa_Fogf(GL_FOG_START, fog->Start); |
||
873 | _mesa_Fogf(GL_FOG_END, fog->End); |
||
874 | _mesa_Fogf(GL_FOG_INDEX, fog->Index); |
||
875 | _mesa_Fogi(GL_FOG_MODE, fog->Mode); |
||
876 | } |
||
877 | break; |
||
878 | case GL_HINT_BIT: |
||
879 | { |
||
880 | const struct gl_hint_attrib *hint; |
||
881 | hint = (const struct gl_hint_attrib *) attr->data; |
||
882 | _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT, |
||
883 | hint->PerspectiveCorrection ); |
||
884 | _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth); |
||
885 | _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth); |
||
886 | _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth); |
||
887 | _mesa_Hint(GL_FOG_HINT, hint->Fog); |
||
888 | _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, |
||
889 | hint->ClipVolumeClipping); |
||
890 | if (ctx->Extensions.ARB_texture_compression) |
||
891 | _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB, |
||
892 | hint->TextureCompression); |
||
893 | } |
||
894 | break; |
||
895 | case GL_LIGHTING_BIT: |
||
896 | { |
||
897 | GLuint i; |
||
898 | const struct gl_light_attrib *light; |
||
899 | light = (const struct gl_light_attrib *) attr->data; |
||
900 | /* lighting enable */ |
||
901 | _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled); |
||
902 | /* per-light state */ |
||
903 | |||
904 | if (ctx->ModelviewMatrixStack.Top->flags & MAT_DIRTY_INVERSE) |
||
905 | _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); |
||
906 | |||
907 | for (i = 0; i < MAX_LIGHTS; i++) { |
||
908 | GLenum lgt = (GLenum) (GL_LIGHT0 + i); |
||
909 | const struct gl_light *l = &light->Light[i]; |
||
910 | GLfloat tmp[4]; |
||
911 | _mesa_set_enable(ctx, lgt, l->Enabled); |
||
912 | _mesa_Lightfv( lgt, GL_AMBIENT, l->Ambient ); |
||
913 | _mesa_Lightfv( lgt, GL_DIFFUSE, l->Diffuse ); |
||
914 | _mesa_Lightfv( lgt, GL_SPECULAR, l->Specular ); |
||
915 | TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->inv, l->EyePosition ); |
||
916 | _mesa_Lightfv( lgt, GL_POSITION, tmp ); |
||
917 | TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->m, l->EyeDirection ); |
||
918 | _mesa_Lightfv( lgt, GL_SPOT_DIRECTION, tmp ); |
||
919 | _mesa_Lightfv( lgt, GL_SPOT_EXPONENT, &l->SpotExponent ); |
||
920 | _mesa_Lightfv( lgt, GL_SPOT_CUTOFF, &l->SpotCutoff ); |
||
921 | _mesa_Lightfv( lgt, GL_CONSTANT_ATTENUATION, |
||
922 | &l->ConstantAttenuation ); |
||
923 | _mesa_Lightfv( lgt, GL_LINEAR_ATTENUATION, |
||
924 | &l->LinearAttenuation ); |
||
925 | _mesa_Lightfv( lgt, GL_QUADRATIC_ATTENUATION, |
||
926 | &l->QuadraticAttenuation ); |
||
927 | } |
||
928 | /* light model */ |
||
929 | _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT, |
||
930 | light->Model.Ambient); |
||
931 | _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, |
||
932 | (GLfloat) light->Model.LocalViewer); |
||
933 | _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE, |
||
934 | (GLfloat) light->Model.TwoSide); |
||
935 | _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, |
||
936 | (GLfloat) light->Model.ColorControl); |
||
937 | /* materials */ |
||
938 | MEMCPY(ctx->Light.Material, light->Material, |
||
939 | 2 * sizeof(struct gl_material)); |
||
940 | /* shade model */ |
||
941 | _mesa_ShadeModel(light->ShadeModel); |
||
942 | /* color material */ |
||
943 | _mesa_ColorMaterial(light->ColorMaterialFace, |
||
944 | light->ColorMaterialMode); |
||
945 | _mesa_set_enable(ctx, GL_COLOR_MATERIAL, |
||
946 | light->ColorMaterialEnabled); |
||
947 | } |
||
948 | break; |
||
949 | case GL_LINE_BIT: |
||
950 | { |
||
951 | const struct gl_line_attrib *line; |
||
952 | line = (const struct gl_line_attrib *) attr->data; |
||
953 | _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag); |
||
954 | _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag); |
||
955 | _mesa_LineStipple(line->StippleFactor, line->StipplePattern); |
||
956 | _mesa_LineWidth(line->Width); |
||
957 | } |
||
958 | break; |
||
959 | case GL_LIST_BIT: |
||
960 | MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); |
||
961 | break; |
||
962 | case GL_PIXEL_MODE_BIT: |
||
963 | MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) ); |
||
964 | ctx->NewState |= _NEW_PIXEL; |
||
965 | break; |
||
966 | case GL_POINT_BIT: |
||
967 | { |
||
968 | const struct gl_point_attrib *point; |
||
969 | point = (const struct gl_point_attrib *) attr->data; |
||
970 | _mesa_PointSize(point->Size); |
||
971 | _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag); |
||
972 | if (ctx->Extensions.EXT_point_parameters) { |
||
973 | _mesa_PointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, |
||
974 | point->Params); |
||
975 | _mesa_PointParameterfEXT(GL_POINT_SIZE_MIN_EXT, |
||
976 | point->MinSize); |
||
977 | _mesa_PointParameterfEXT(GL_POINT_SIZE_MAX_EXT, |
||
978 | point->MaxSize); |
||
979 | _mesa_PointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT, |
||
980 | point->Threshold); |
||
981 | } |
||
982 | if (ctx->Extensions.NV_point_sprite) { |
||
983 | GLuint u; |
||
984 | for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { |
||
985 | _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, |
||
986 | (GLint) point->CoordReplace[u]); |
||
987 | } |
||
988 | _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite); |
||
989 | _mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV, |
||
990 | ctx->Point.SpriteRMode); |
||
991 | } |
||
992 | } |
||
993 | break; |
||
994 | case GL_POLYGON_BIT: |
||
995 | { |
||
996 | const struct gl_polygon_attrib *polygon; |
||
997 | polygon = (const struct gl_polygon_attrib *) attr->data; |
||
998 | _mesa_CullFace(polygon->CullFaceMode); |
||
999 | _mesa_FrontFace(polygon->FrontFace); |
||
1000 | _mesa_PolygonMode(GL_FRONT, polygon->FrontMode); |
||
1001 | _mesa_PolygonMode(GL_BACK, polygon->BackMode); |
||
1002 | _mesa_PolygonOffset(polygon->OffsetFactor, |
||
1003 | polygon->OffsetUnits); |
||
1004 | _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag); |
||
1005 | _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag); |
||
1006 | _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag); |
||
1007 | _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT, |
||
1008 | polygon->OffsetPoint); |
||
1009 | _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE, |
||
1010 | polygon->OffsetLine); |
||
1011 | _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, |
||
1012 | polygon->OffsetFill); |
||
1013 | } |
||
1014 | break; |
||
1015 | case GL_POLYGON_STIPPLE_BIT: |
||
1016 | MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); |
||
1017 | ctx->NewState |= _NEW_POLYGONSTIPPLE; |
||
1018 | if (ctx->Driver.PolygonStipple) |
||
1019 | ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); |
||
1020 | break; |
||
1021 | case GL_SCISSOR_BIT: |
||
1022 | { |
||
1023 | const struct gl_scissor_attrib *scissor; |
||
1024 | scissor = (const struct gl_scissor_attrib *) attr->data; |
||
1025 | _mesa_Scissor(scissor->X, scissor->Y, |
||
1026 | scissor->Width, scissor->Height); |
||
1027 | _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled); |
||
1028 | } |
||
1029 | break; |
||
1030 | case GL_STENCIL_BUFFER_BIT: |
||
1031 | { |
||
1032 | const GLint face = 0; /* XXX stencil two side */ |
||
1033 | const struct gl_stencil_attrib *stencil; |
||
1034 | stencil = (const struct gl_stencil_attrib *) attr->data; |
||
1035 | _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); |
||
1036 | _mesa_ClearStencil(stencil->Clear); |
||
1037 | _mesa_StencilFunc(stencil->Function[face], stencil->Ref[face], |
||
1038 | stencil->ValueMask[face]); |
||
1039 | _mesa_StencilMask(stencil->WriteMask[face]); |
||
1040 | _mesa_StencilOp(stencil->FailFunc[face], |
||
1041 | stencil->ZFailFunc[face], |
||
1042 | stencil->ZPassFunc[face]); |
||
1043 | } |
||
1044 | break; |
||
1045 | case GL_TRANSFORM_BIT: |
||
1046 | { |
||
1047 | GLuint i; |
||
1048 | const struct gl_transform_attrib *xform; |
||
1049 | xform = (const struct gl_transform_attrib *) attr->data; |
||
1050 | _mesa_MatrixMode(xform->MatrixMode); |
||
1051 | |||
1052 | if (ctx->ProjectionMatrixStack.Top->flags & MAT_DIRTY) |
||
1053 | _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); |
||
1054 | |||
1055 | /* restore clip planes */ |
||
1056 | for (i = 0; i < MAX_CLIP_PLANES; i++) { |
||
1057 | const GLuint mask = 1 << 1; |
||
1058 | const GLfloat *eyePlane = xform->EyeUserPlane[i]; |
||
1059 | COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane); |
||
1060 | if (xform->ClipPlanesEnabled & mask) { |
||
1061 | _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE); |
||
1062 | } |
||
1063 | else { |
||
1064 | _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE); |
||
1065 | } |
||
1066 | if (ctx->Driver.ClipPlane) |
||
1067 | ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane ); |
||
1068 | } |
||
1069 | |||
1070 | /* normalize/rescale */ |
||
1071 | if (xform->Normalize != ctx->Transform.Normalize) |
||
1072 | _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize); |
||
1073 | if (xform->RescaleNormals != ctx->Transform.RescaleNormals) |
||
1074 | _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT, |
||
1075 | ctx->Transform.RescaleNormals); |
||
1076 | } |
||
1077 | break; |
||
1078 | case GL_TEXTURE_BIT: |
||
1079 | /* Take care of texture object reference counters */ |
||
1080 | { |
||
1081 | const struct gl_texture_attrib *texture; |
||
1082 | texture = (const struct gl_texture_attrib *) attr->data; |
||
1083 | pop_texture_group(ctx, texture); |
||
1084 | ctx->NewState |= _NEW_TEXTURE; |
||
1085 | } |
||
1086 | break; |
||
1087 | case GL_VIEWPORT_BIT: |
||
1088 | { |
||
1089 | const struct gl_viewport_attrib *vp; |
||
1090 | vp = (const struct gl_viewport_attrib *) attr->data; |
||
1091 | _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height); |
||
1092 | _mesa_DepthRange(vp->Near, vp->Far); |
||
1093 | } |
||
1094 | break; |
||
1095 | case GL_MULTISAMPLE_BIT_ARB: |
||
1096 | { |
||
1097 | const struct gl_multisample_attrib *ms; |
||
1098 | ms = (const struct gl_multisample_attrib *) attr->data; |
||
1099 | _mesa_SampleCoverageARB(ms->SampleCoverageValue, |
||
1100 | ms->SampleCoverageInvert); |
||
1101 | } |
||
1102 | break; |
||
1103 | |||
1104 | default: |
||
1105 | _mesa_problem( ctx, "Bad attrib flag in PopAttrib"); |
||
1106 | break; |
||
1107 | } |
||
1108 | |||
1109 | next = attr->next; |
||
1110 | FREE( attr->data ); |
||
1111 | FREE( attr ); |
||
1112 | attr = next; |
||
1113 | } |
||
1114 | } |
||
1115 | |||
1116 | |||
1117 | #define GL_CLIENT_PACK_BIT (1<<20) |
||
1118 | #define GL_CLIENT_UNPACK_BIT (1<<21) |
||
1119 | |||
1120 | |||
1121 | void |
||
1122 | _mesa_PushClientAttrib(GLbitfield mask) |
||
1123 | { |
||
1124 | struct gl_attrib_node *newnode; |
||
1125 | struct gl_attrib_node *head; |
||
1126 | |||
1127 | GET_CURRENT_CONTEXT(ctx); |
||
1128 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
1129 | |||
1130 | if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) { |
||
1131 | _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" ); |
||
1132 | return; |
||
1133 | } |
||
1134 | |||
1135 | /* Build linked list of attribute nodes which save all attribute */ |
||
1136 | /* groups specified by the mask. */ |
||
1137 | head = NULL; |
||
1138 | |||
1139 | if (mask & GL_CLIENT_PIXEL_STORE_BIT) { |
||
1140 | struct gl_pixelstore_attrib *attr; |
||
1141 | /* packing attribs */ |
||
1142 | attr = MALLOC_STRUCT( gl_pixelstore_attrib ); |
||
1143 | MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) ); |
||
1144 | newnode = new_attrib_node( GL_CLIENT_PACK_BIT ); |
||
1145 | newnode->data = attr; |
||
1146 | newnode->next = head; |
||
1147 | head = newnode; |
||
1148 | /* unpacking attribs */ |
||
1149 | attr = MALLOC_STRUCT( gl_pixelstore_attrib ); |
||
1150 | MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) ); |
||
1151 | newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT ); |
||
1152 | newnode->data = attr; |
||
1153 | newnode->next = head; |
||
1154 | head = newnode; |
||
1155 | } |
||
1156 | if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { |
||
1157 | struct gl_array_attrib *attr; |
||
1158 | attr = MALLOC_STRUCT( gl_array_attrib ); |
||
1159 | MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) ); |
||
1160 | newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT ); |
||
1161 | newnode->data = attr; |
||
1162 | newnode->next = head; |
||
1163 | head = newnode; |
||
1164 | } |
||
1165 | |||
1166 | ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head; |
||
1167 | ctx->ClientAttribStackDepth++; |
||
1168 | } |
||
1169 | |||
1170 | |||
1171 | |||
1172 | |||
1173 | void |
||
1174 | _mesa_PopClientAttrib(void) |
||
1175 | { |
||
1176 | struct gl_attrib_node *attr, *next; |
||
1177 | |||
1178 | GET_CURRENT_CONTEXT(ctx); |
||
1179 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
||
1180 | |||
1181 | if (ctx->ClientAttribStackDepth == 0) { |
||
1182 | _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" ); |
||
1183 | return; |
||
1184 | } |
||
1185 | |||
1186 | ctx->ClientAttribStackDepth--; |
||
1187 | attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth]; |
||
1188 | |||
1189 | while (attr) { |
||
1190 | switch (attr->kind) { |
||
1191 | case GL_CLIENT_PACK_BIT: |
||
1192 | MEMCPY( &ctx->Pack, attr->data, |
||
1193 | sizeof(struct gl_pixelstore_attrib) ); |
||
1194 | ctx->NewState |= _NEW_PACKUNPACK; |
||
1195 | break; |
||
1196 | case GL_CLIENT_UNPACK_BIT: |
||
1197 | MEMCPY( &ctx->Unpack, attr->data, |
||
1198 | sizeof(struct gl_pixelstore_attrib) ); |
||
1199 | ctx->NewState |= _NEW_PACKUNPACK; |
||
1200 | break; |
||
1201 | case GL_CLIENT_VERTEX_ARRAY_BIT: |
||
1202 | MEMCPY( &ctx->Array, attr->data, |
||
1203 | sizeof(struct gl_array_attrib) ); |
||
1204 | ctx->NewState |= _NEW_ARRAY; |
||
1205 | break; |
||
1206 | default: |
||
1207 | _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib"); |
||
1208 | break; |
||
1209 | } |
||
1210 | |||
1211 | next = attr->next; |
||
1212 | FREE( attr->data ); |
||
1213 | FREE( attr ); |
||
1214 | attr = next; |
||
1215 | } |
||
1216 | } |