2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #include "bufferobj.h"
45 #include "multisample.h"
49 #include "simple_list.h"
54 #include "math/m_xform.h"
58 * Allocate a new attribute state node. These nodes have a
59 * "kind" value and a pointer to a struct of state data.
61 static struct gl_attrib_node
*
62 new_attrib_node( GLbitfield kind
)
64 struct gl_attrib_node
*an
= MALLOC_STRUCT(gl_attrib_node
);
73 _mesa_PushAttrib(GLbitfield mask
)
75 struct gl_attrib_node
*newnode
;
76 struct gl_attrib_node
*head
;
78 GET_CURRENT_CONTEXT(ctx
);
79 ASSERT_OUTSIDE_BEGIN_END(ctx
);
81 if (MESA_VERBOSE
& VERBOSE_API
)
82 _mesa_debug(ctx
, "glPushAttrib %x\n", (int) mask
);
84 if (ctx
->AttribStackDepth
>= MAX_ATTRIB_STACK_DEPTH
) {
85 _mesa_error( ctx
, GL_STACK_OVERFLOW
, "glPushAttrib" );
89 /* Build linked list of attribute nodes which save all attribute */
90 /* groups specified by the mask. */
93 if (mask
& GL_ACCUM_BUFFER_BIT
) {
94 struct gl_accum_attrib
*attr
;
95 attr
= MALLOC_STRUCT( gl_accum_attrib
);
96 MEMCPY( attr
, &ctx
->Accum
, sizeof(struct gl_accum_attrib
) );
97 newnode
= new_attrib_node( GL_ACCUM_BUFFER_BIT
);
103 if (mask
& GL_COLOR_BUFFER_BIT
) {
105 struct gl_colorbuffer_attrib
*attr
;
106 attr
= MALLOC_STRUCT( gl_colorbuffer_attrib
);
107 MEMCPY( attr
, &ctx
->Color
, sizeof(struct gl_colorbuffer_attrib
) );
108 /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */
109 for (i
= 0; i
< ctx
->Const
.MaxDrawBuffers
; i
++)
110 attr
->DrawBuffer
[i
] = ctx
->DrawBuffer
->ColorDrawBuffer
[i
];
111 newnode
= new_attrib_node( GL_COLOR_BUFFER_BIT
);
112 newnode
->data
= attr
;
113 newnode
->next
= head
;
117 if (mask
& GL_CURRENT_BIT
) {
118 struct gl_current_attrib
*attr
;
119 FLUSH_CURRENT( ctx
, 0 );
120 attr
= MALLOC_STRUCT( gl_current_attrib
);
121 MEMCPY( attr
, &ctx
->Current
, sizeof(struct gl_current_attrib
) );
122 newnode
= new_attrib_node( GL_CURRENT_BIT
);
123 newnode
->data
= attr
;
124 newnode
->next
= head
;
128 if (mask
& GL_DEPTH_BUFFER_BIT
) {
129 struct gl_depthbuffer_attrib
*attr
;
130 attr
= MALLOC_STRUCT( gl_depthbuffer_attrib
);
131 MEMCPY( attr
, &ctx
->Depth
, sizeof(struct gl_depthbuffer_attrib
) );
132 newnode
= new_attrib_node( GL_DEPTH_BUFFER_BIT
);
133 newnode
->data
= attr
;
134 newnode
->next
= head
;
138 if (mask
& GL_ENABLE_BIT
) {
139 struct gl_enable_attrib
*attr
;
141 attr
= MALLOC_STRUCT( gl_enable_attrib
);
142 /* Copy enable flags from all other attributes into the enable struct. */
143 attr
->AlphaTest
= ctx
->Color
.AlphaEnabled
;
144 attr
->AutoNormal
= ctx
->Eval
.AutoNormal
;
145 attr
->Blend
= ctx
->Color
.BlendEnabled
;
146 attr
->ClipPlanes
= ctx
->Transform
.ClipPlanesEnabled
;
147 attr
->ColorMaterial
= ctx
->Light
.ColorMaterialEnabled
;
148 for (i
= 0; i
< COLORTABLE_MAX
; i
++) {
149 attr
->ColorTable
[i
] = ctx
->Pixel
.ColorTableEnabled
[i
];
151 attr
->Convolution1D
= ctx
->Pixel
.Convolution1DEnabled
;
152 attr
->Convolution2D
= ctx
->Pixel
.Convolution2DEnabled
;
153 attr
->Separable2D
= ctx
->Pixel
.Separable2DEnabled
;
154 attr
->CullFace
= ctx
->Polygon
.CullFlag
;
155 attr
->DepthTest
= ctx
->Depth
.Test
;
156 attr
->Dither
= ctx
->Color
.DitherFlag
;
157 attr
->Fog
= ctx
->Fog
.Enabled
;
158 for (i
= 0; i
< ctx
->Const
.MaxLights
; i
++) {
159 attr
->Light
[i
] = ctx
->Light
.Light
[i
].Enabled
;
161 attr
->Lighting
= ctx
->Light
.Enabled
;
162 attr
->LineSmooth
= ctx
->Line
.SmoothFlag
;
163 attr
->LineStipple
= ctx
->Line
.StippleFlag
;
164 attr
->Histogram
= ctx
->Pixel
.HistogramEnabled
;
165 attr
->MinMax
= ctx
->Pixel
.MinMaxEnabled
;
166 attr
->IndexLogicOp
= ctx
->Color
.IndexLogicOpEnabled
;
167 attr
->ColorLogicOp
= ctx
->Color
.ColorLogicOpEnabled
;
168 attr
->Map1Color4
= ctx
->Eval
.Map1Color4
;
169 attr
->Map1Index
= ctx
->Eval
.Map1Index
;
170 attr
->Map1Normal
= ctx
->Eval
.Map1Normal
;
171 attr
->Map1TextureCoord1
= ctx
->Eval
.Map1TextureCoord1
;
172 attr
->Map1TextureCoord2
= ctx
->Eval
.Map1TextureCoord2
;
173 attr
->Map1TextureCoord3
= ctx
->Eval
.Map1TextureCoord3
;
174 attr
->Map1TextureCoord4
= ctx
->Eval
.Map1TextureCoord4
;
175 attr
->Map1Vertex3
= ctx
->Eval
.Map1Vertex3
;
176 attr
->Map1Vertex4
= ctx
->Eval
.Map1Vertex4
;
177 MEMCPY(attr
->Map1Attrib
, ctx
->Eval
.Map1Attrib
, sizeof(ctx
->Eval
.Map1Attrib
));
178 attr
->Map2Color4
= ctx
->Eval
.Map2Color4
;
179 attr
->Map2Index
= ctx
->Eval
.Map2Index
;
180 attr
->Map2Normal
= ctx
->Eval
.Map2Normal
;
181 attr
->Map2TextureCoord1
= ctx
->Eval
.Map2TextureCoord1
;
182 attr
->Map2TextureCoord2
= ctx
->Eval
.Map2TextureCoord2
;
183 attr
->Map2TextureCoord3
= ctx
->Eval
.Map2TextureCoord3
;
184 attr
->Map2TextureCoord4
= ctx
->Eval
.Map2TextureCoord4
;
185 attr
->Map2Vertex3
= ctx
->Eval
.Map2Vertex3
;
186 attr
->Map2Vertex4
= ctx
->Eval
.Map2Vertex4
;
187 MEMCPY(attr
->Map2Attrib
, ctx
->Eval
.Map2Attrib
, sizeof(ctx
->Eval
.Map2Attrib
));
188 attr
->Normalize
= ctx
->Transform
.Normalize
;
189 attr
->RasterPositionUnclipped
= ctx
->Transform
.RasterPositionUnclipped
;
190 attr
->PointSmooth
= ctx
->Point
.SmoothFlag
;
191 attr
->PointSprite
= ctx
->Point
.PointSprite
;
192 attr
->PolygonOffsetPoint
= ctx
->Polygon
.OffsetPoint
;
193 attr
->PolygonOffsetLine
= ctx
->Polygon
.OffsetLine
;
194 attr
->PolygonOffsetFill
= ctx
->Polygon
.OffsetFill
;
195 attr
->PolygonSmooth
= ctx
->Polygon
.SmoothFlag
;
196 attr
->PolygonStipple
= ctx
->Polygon
.StippleFlag
;
197 attr
->RescaleNormals
= ctx
->Transform
.RescaleNormals
;
198 attr
->Scissor
= ctx
->Scissor
.Enabled
;
199 attr
->Stencil
= ctx
->Stencil
.Enabled
;
200 attr
->StencilTwoSide
= ctx
->Stencil
.TestTwoSide
;
201 attr
->MultisampleEnabled
= ctx
->Multisample
.Enabled
;
202 attr
->SampleAlphaToCoverage
= ctx
->Multisample
.SampleAlphaToCoverage
;
203 attr
->SampleAlphaToOne
= ctx
->Multisample
.SampleAlphaToOne
;
204 attr
->SampleCoverage
= ctx
->Multisample
.SampleCoverage
;
205 attr
->SampleCoverageInvert
= ctx
->Multisample
.SampleCoverageInvert
;
206 for (i
=0; i
<MAX_TEXTURE_UNITS
; i
++) {
207 attr
->Texture
[i
] = ctx
->Texture
.Unit
[i
].Enabled
;
208 attr
->TexGen
[i
] = ctx
->Texture
.Unit
[i
].TexGenEnabled
;
209 attr
->TextureColorTable
[i
] = ctx
->Texture
.Unit
[i
].ColorTableEnabled
;
211 /* GL_NV_vertex_program */
212 attr
->VertexProgram
= ctx
->VertexProgram
.Enabled
;
213 attr
->VertexProgramPointSize
= ctx
->VertexProgram
.PointSizeEnabled
;
214 attr
->VertexProgramTwoSide
= ctx
->VertexProgram
.TwoSideEnabled
;
215 newnode
= new_attrib_node( GL_ENABLE_BIT
);
216 newnode
->data
= attr
;
217 newnode
->next
= head
;
221 if (mask
& GL_EVAL_BIT
) {
222 struct gl_eval_attrib
*attr
;
223 attr
= MALLOC_STRUCT( gl_eval_attrib
);
224 MEMCPY( attr
, &ctx
->Eval
, sizeof(struct gl_eval_attrib
) );
225 newnode
= new_attrib_node( GL_EVAL_BIT
);
226 newnode
->data
= attr
;
227 newnode
->next
= head
;
231 if (mask
& GL_FOG_BIT
) {
232 struct gl_fog_attrib
*attr
;
233 attr
= MALLOC_STRUCT( gl_fog_attrib
);
234 MEMCPY( attr
, &ctx
->Fog
, sizeof(struct gl_fog_attrib
) );
235 newnode
= new_attrib_node( GL_FOG_BIT
);
236 newnode
->data
= attr
;
237 newnode
->next
= head
;
241 if (mask
& GL_HINT_BIT
) {
242 struct gl_hint_attrib
*attr
;
243 attr
= MALLOC_STRUCT( gl_hint_attrib
);
244 MEMCPY( attr
, &ctx
->Hint
, sizeof(struct gl_hint_attrib
) );
245 newnode
= new_attrib_node( GL_HINT_BIT
);
246 newnode
->data
= attr
;
247 newnode
->next
= head
;
251 if (mask
& GL_LIGHTING_BIT
) {
252 struct gl_light_attrib
*attr
;
253 FLUSH_CURRENT(ctx
, 0); /* flush material changes */
254 attr
= MALLOC_STRUCT( gl_light_attrib
);
255 MEMCPY( attr
, &ctx
->Light
, sizeof(struct gl_light_attrib
) );
256 newnode
= new_attrib_node( GL_LIGHTING_BIT
);
257 newnode
->data
= attr
;
258 newnode
->next
= head
;
262 if (mask
& GL_LINE_BIT
) {
263 struct gl_line_attrib
*attr
;
264 attr
= MALLOC_STRUCT( gl_line_attrib
);
265 MEMCPY( attr
, &ctx
->Line
, sizeof(struct gl_line_attrib
) );
266 newnode
= new_attrib_node( GL_LINE_BIT
);
267 newnode
->data
= attr
;
268 newnode
->next
= head
;
272 if (mask
& GL_LIST_BIT
) {
273 struct gl_list_attrib
*attr
;
274 attr
= MALLOC_STRUCT( gl_list_attrib
);
275 MEMCPY( attr
, &ctx
->List
, sizeof(struct gl_list_attrib
) );
276 newnode
= new_attrib_node( GL_LIST_BIT
);
277 newnode
->data
= attr
;
278 newnode
->next
= head
;
282 if (mask
& GL_PIXEL_MODE_BIT
) {
283 struct gl_pixel_attrib
*attr
;
284 attr
= MALLOC_STRUCT( gl_pixel_attrib
);
285 MEMCPY( attr
, &ctx
->Pixel
, sizeof(struct gl_pixel_attrib
) );
286 /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */
287 attr
->ReadBuffer
= ctx
->ReadBuffer
->ColorReadBuffer
;
288 newnode
= new_attrib_node( GL_PIXEL_MODE_BIT
);
289 newnode
->data
= attr
;
290 newnode
->next
= head
;
294 if (mask
& GL_POINT_BIT
) {
295 struct gl_point_attrib
*attr
;
296 attr
= MALLOC_STRUCT( gl_point_attrib
);
297 MEMCPY( attr
, &ctx
->Point
, sizeof(struct gl_point_attrib
) );
298 newnode
= new_attrib_node( GL_POINT_BIT
);
299 newnode
->data
= attr
;
300 newnode
->next
= head
;
304 if (mask
& GL_POLYGON_BIT
) {
305 struct gl_polygon_attrib
*attr
;
306 attr
= MALLOC_STRUCT( gl_polygon_attrib
);
307 MEMCPY( attr
, &ctx
->Polygon
, sizeof(struct gl_polygon_attrib
) );
308 newnode
= new_attrib_node( GL_POLYGON_BIT
);
309 newnode
->data
= attr
;
310 newnode
->next
= head
;
314 if (mask
& GL_POLYGON_STIPPLE_BIT
) {
316 stipple
= (GLuint
*) MALLOC( 32*sizeof(GLuint
) );
317 MEMCPY( stipple
, ctx
->PolygonStipple
, 32*sizeof(GLuint
) );
318 newnode
= new_attrib_node( GL_POLYGON_STIPPLE_BIT
);
319 newnode
->data
= stipple
;
320 newnode
->next
= head
;
324 if (mask
& GL_SCISSOR_BIT
) {
325 struct gl_scissor_attrib
*attr
;
326 attr
= MALLOC_STRUCT( gl_scissor_attrib
);
327 MEMCPY( attr
, &ctx
->Scissor
, sizeof(struct gl_scissor_attrib
) );
328 newnode
= new_attrib_node( GL_SCISSOR_BIT
);
329 newnode
->data
= attr
;
330 newnode
->next
= head
;
334 if (mask
& GL_STENCIL_BUFFER_BIT
) {
335 struct gl_stencil_attrib
*attr
;
336 attr
= MALLOC_STRUCT( gl_stencil_attrib
);
337 MEMCPY( attr
, &ctx
->Stencil
, sizeof(struct gl_stencil_attrib
) );
338 newnode
= new_attrib_node( GL_STENCIL_BUFFER_BIT
);
339 newnode
->data
= attr
;
340 newnode
->next
= head
;
344 if (mask
& GL_TEXTURE_BIT
) {
345 struct gl_texture_attrib
*attr
;
348 _mesa_lock_context_textures(ctx
);
349 /* Bump the texture object reference counts so that they don't
350 * inadvertantly get deleted.
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
++;
357 ctx
->Texture
.Unit
[u
].CurrentRect
->RefCount
++;
358 ctx
->Texture
.Unit
[u
].Current1DArray
->RefCount
++;
359 ctx
->Texture
.Unit
[u
].Current2DArray
->RefCount
++;
361 attr
= MALLOC_STRUCT( gl_texture_attrib
);
362 MEMCPY( attr
, &ctx
->Texture
, sizeof(struct gl_texture_attrib
) );
363 /* copy state of the currently bound texture objects */
364 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
365 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved1D
,
366 attr
->Unit
[u
].Current1D
);
367 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved2D
,
368 attr
->Unit
[u
].Current2D
);
369 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved3D
,
370 attr
->Unit
[u
].Current3D
);
371 _mesa_copy_texture_object(&attr
->Unit
[u
].SavedCubeMap
,
372 attr
->Unit
[u
].CurrentCubeMap
);
373 _mesa_copy_texture_object(&attr
->Unit
[u
].SavedRect
,
374 attr
->Unit
[u
].CurrentRect
);
375 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved1DArray
,
376 attr
->Unit
[u
].Current1DArray
);
377 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved2DArray
,
378 attr
->Unit
[u
].Current2DArray
);
381 _mesa_unlock_context_textures(ctx
);
383 newnode
= new_attrib_node( GL_TEXTURE_BIT
);
384 newnode
->data
= attr
;
385 newnode
->next
= head
;
389 if (mask
& GL_TRANSFORM_BIT
) {
390 struct gl_transform_attrib
*attr
;
391 attr
= MALLOC_STRUCT( gl_transform_attrib
);
392 MEMCPY( attr
, &ctx
->Transform
, sizeof(struct gl_transform_attrib
) );
393 newnode
= new_attrib_node( GL_TRANSFORM_BIT
);
394 newnode
->data
= attr
;
395 newnode
->next
= head
;
399 if (mask
& GL_VIEWPORT_BIT
) {
400 struct gl_viewport_attrib
*attr
;
401 attr
= MALLOC_STRUCT( gl_viewport_attrib
);
402 MEMCPY( attr
, &ctx
->Viewport
, sizeof(struct gl_viewport_attrib
) );
403 newnode
= new_attrib_node( GL_VIEWPORT_BIT
);
404 newnode
->data
= attr
;
405 newnode
->next
= head
;
409 /* GL_ARB_multisample */
410 if (mask
& GL_MULTISAMPLE_BIT_ARB
) {
411 struct gl_multisample_attrib
*attr
;
412 attr
= MALLOC_STRUCT( gl_multisample_attrib
);
413 MEMCPY( attr
, &ctx
->Multisample
, sizeof(struct gl_multisample_attrib
) );
414 newnode
= new_attrib_node( GL_MULTISAMPLE_BIT_ARB
);
415 newnode
->data
= attr
;
416 newnode
->next
= head
;
420 ctx
->AttribStack
[ctx
->AttribStackDepth
] = head
;
421 ctx
->AttribStackDepth
++;
427 pop_enable_group(GLcontext
*ctx
, const struct gl_enable_attrib
*enable
)
431 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
432 if ((VALUE) != (NEWVALUE)) { \
433 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \
436 TEST_AND_UPDATE(ctx
->Color
.AlphaEnabled
, enable
->AlphaTest
, GL_ALPHA_TEST
);
437 TEST_AND_UPDATE(ctx
->Color
.BlendEnabled
, enable
->Blend
, GL_BLEND
);
439 for (i
=0;i
<MAX_CLIP_PLANES
;i
++) {
440 const GLuint mask
= 1 << i
;
441 if ((ctx
->Transform
.ClipPlanesEnabled
& mask
) != (enable
->ClipPlanes
& mask
))
442 _mesa_set_enable(ctx
, (GLenum
) (GL_CLIP_PLANE0
+ i
),
443 (GLboolean
) ((enable
->ClipPlanes
& mask
) ? GL_TRUE
: GL_FALSE
));
446 TEST_AND_UPDATE(ctx
->Light
.ColorMaterialEnabled
, enable
->ColorMaterial
,
448 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
],
449 enable
->ColorTable
[COLORTABLE_PRECONVOLUTION
],
451 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
],
452 enable
->ColorTable
[COLORTABLE_POSTCONVOLUTION
],
453 GL_POST_CONVOLUTION_COLOR_TABLE
);
454 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
],
455 enable
->ColorTable
[COLORTABLE_POSTCOLORMATRIX
],
456 GL_POST_COLOR_MATRIX_COLOR_TABLE
);
457 TEST_AND_UPDATE(ctx
->Polygon
.CullFlag
, enable
->CullFace
, GL_CULL_FACE
);
458 TEST_AND_UPDATE(ctx
->Depth
.Test
, enable
->DepthTest
, GL_DEPTH_TEST
);
459 TEST_AND_UPDATE(ctx
->Color
.DitherFlag
, enable
->Dither
, GL_DITHER
);
460 TEST_AND_UPDATE(ctx
->Pixel
.Convolution1DEnabled
, enable
->Convolution1D
,
462 TEST_AND_UPDATE(ctx
->Pixel
.Convolution2DEnabled
, enable
->Convolution2D
,
464 TEST_AND_UPDATE(ctx
->Pixel
.Separable2DEnabled
, enable
->Separable2D
,
466 TEST_AND_UPDATE(ctx
->Fog
.Enabled
, enable
->Fog
, GL_FOG
);
467 TEST_AND_UPDATE(ctx
->Light
.Enabled
, enable
->Lighting
, GL_LIGHTING
);
468 TEST_AND_UPDATE(ctx
->Line
.SmoothFlag
, enable
->LineSmooth
, GL_LINE_SMOOTH
);
469 TEST_AND_UPDATE(ctx
->Line
.StippleFlag
, enable
->LineStipple
,
471 TEST_AND_UPDATE(ctx
->Color
.IndexLogicOpEnabled
, enable
->IndexLogicOp
,
473 TEST_AND_UPDATE(ctx
->Color
.ColorLogicOpEnabled
, enable
->ColorLogicOp
,
476 TEST_AND_UPDATE(ctx
->Eval
.Map1Color4
, enable
->Map1Color4
, GL_MAP1_COLOR_4
);
477 TEST_AND_UPDATE(ctx
->Eval
.Map1Index
, enable
->Map1Index
, GL_MAP1_INDEX
);
478 TEST_AND_UPDATE(ctx
->Eval
.Map1Normal
, enable
->Map1Normal
, GL_MAP1_NORMAL
);
479 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord1
, enable
->Map1TextureCoord1
,
480 GL_MAP1_TEXTURE_COORD_1
);
481 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord2
, enable
->Map1TextureCoord2
,
482 GL_MAP1_TEXTURE_COORD_2
);
483 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord3
, enable
->Map1TextureCoord3
,
484 GL_MAP1_TEXTURE_COORD_3
);
485 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord4
, enable
->Map1TextureCoord4
,
486 GL_MAP1_TEXTURE_COORD_4
);
487 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex3
, enable
->Map1Vertex3
,
489 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex4
, enable
->Map1Vertex4
,
491 for (i
= 0; i
< 16; i
++) {
492 TEST_AND_UPDATE(ctx
->Eval
.Map1Attrib
[i
], enable
->Map1Attrib
[i
],
493 GL_MAP1_VERTEX_ATTRIB0_4_NV
+ i
);
496 TEST_AND_UPDATE(ctx
->Eval
.Map2Color4
, enable
->Map2Color4
, GL_MAP2_COLOR_4
);
497 TEST_AND_UPDATE(ctx
->Eval
.Map2Index
, enable
->Map2Index
, GL_MAP2_INDEX
);
498 TEST_AND_UPDATE(ctx
->Eval
.Map2Normal
, enable
->Map2Normal
, GL_MAP2_NORMAL
);
499 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord1
, enable
->Map2TextureCoord1
,
500 GL_MAP2_TEXTURE_COORD_1
);
501 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord2
, enable
->Map2TextureCoord2
,
502 GL_MAP2_TEXTURE_COORD_2
);
503 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord3
, enable
->Map2TextureCoord3
,
504 GL_MAP2_TEXTURE_COORD_3
);
505 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord4
, enable
->Map2TextureCoord4
,
506 GL_MAP2_TEXTURE_COORD_4
);
507 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex3
, enable
->Map2Vertex3
,
509 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex4
, enable
->Map2Vertex4
,
511 for (i
= 0; i
< 16; i
++) {
512 TEST_AND_UPDATE(ctx
->Eval
.Map2Attrib
[i
], enable
->Map2Attrib
[i
],
513 GL_MAP2_VERTEX_ATTRIB0_4_NV
+ i
);
516 TEST_AND_UPDATE(ctx
->Eval
.AutoNormal
, enable
->AutoNormal
, GL_AUTO_NORMAL
);
517 TEST_AND_UPDATE(ctx
->Transform
.Normalize
, enable
->Normalize
, GL_NORMALIZE
);
518 TEST_AND_UPDATE(ctx
->Transform
.RescaleNormals
, enable
->RescaleNormals
,
519 GL_RESCALE_NORMAL_EXT
);
520 TEST_AND_UPDATE(ctx
->Transform
.RasterPositionUnclipped
,
521 enable
->RasterPositionUnclipped
,
522 GL_RASTER_POSITION_UNCLIPPED_IBM
);
523 TEST_AND_UPDATE(ctx
->Point
.SmoothFlag
, enable
->PointSmooth
,
525 if (ctx
->Extensions
.NV_point_sprite
|| ctx
->Extensions
.ARB_point_sprite
) {
526 TEST_AND_UPDATE(ctx
->Point
.PointSprite
, enable
->PointSprite
,
529 TEST_AND_UPDATE(ctx
->Polygon
.OffsetPoint
, enable
->PolygonOffsetPoint
,
530 GL_POLYGON_OFFSET_POINT
);
531 TEST_AND_UPDATE(ctx
->Polygon
.OffsetLine
, enable
->PolygonOffsetLine
,
532 GL_POLYGON_OFFSET_LINE
);
533 TEST_AND_UPDATE(ctx
->Polygon
.OffsetFill
, enable
->PolygonOffsetFill
,
534 GL_POLYGON_OFFSET_FILL
);
535 TEST_AND_UPDATE(ctx
->Polygon
.SmoothFlag
, enable
->PolygonSmooth
,
537 TEST_AND_UPDATE(ctx
->Polygon
.StippleFlag
, enable
->PolygonStipple
,
539 TEST_AND_UPDATE(ctx
->Scissor
.Enabled
, enable
->Scissor
, GL_SCISSOR_TEST
);
540 TEST_AND_UPDATE(ctx
->Stencil
.Enabled
, enable
->Stencil
, GL_STENCIL_TEST
);
541 if (ctx
->Extensions
.EXT_stencil_two_side
) {
542 TEST_AND_UPDATE(ctx
->Stencil
.TestTwoSide
, enable
->StencilTwoSide
, GL_STENCIL_TEST_TWO_SIDE_EXT
);
544 TEST_AND_UPDATE(ctx
->Multisample
.Enabled
, enable
->MultisampleEnabled
,
546 TEST_AND_UPDATE(ctx
->Multisample
.SampleAlphaToCoverage
,
547 enable
->SampleAlphaToCoverage
,
548 GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
);
549 TEST_AND_UPDATE(ctx
->Multisample
.SampleAlphaToOne
,
550 enable
->SampleAlphaToOne
,
551 GL_SAMPLE_ALPHA_TO_ONE_ARB
);
552 TEST_AND_UPDATE(ctx
->Multisample
.SampleCoverage
,
553 enable
->SampleCoverage
,
554 GL_SAMPLE_COVERAGE_ARB
);
555 TEST_AND_UPDATE(ctx
->Multisample
.SampleCoverageInvert
,
556 enable
->SampleCoverageInvert
,
557 GL_SAMPLE_COVERAGE_INVERT_ARB
);
558 /* GL_ARB_vertex_program, GL_NV_vertex_program */
559 TEST_AND_UPDATE(ctx
->VertexProgram
.Enabled
,
560 enable
->VertexProgram
,
561 GL_VERTEX_PROGRAM_ARB
);
562 TEST_AND_UPDATE(ctx
->VertexProgram
.PointSizeEnabled
,
563 enable
->VertexProgramPointSize
,
564 GL_VERTEX_PROGRAM_POINT_SIZE_ARB
);
565 TEST_AND_UPDATE(ctx
->VertexProgram
.TwoSideEnabled
,
566 enable
->VertexProgramTwoSide
,
567 GL_VERTEX_PROGRAM_TWO_SIDE_ARB
);
569 #undef TEST_AND_UPDATE
571 /* texture unit enables */
572 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
573 if (ctx
->Texture
.Unit
[i
].Enabled
!= enable
->Texture
[i
]) {
574 ctx
->Texture
.Unit
[i
].Enabled
= enable
->Texture
[i
];
575 if (ctx
->Driver
.Enable
) {
576 if (ctx
->Driver
.ActiveTexture
) {
577 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
579 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_1D
,
580 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_1D_BIT
) );
581 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_2D
,
582 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_2D_BIT
) );
583 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_3D
,
584 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_3D_BIT
) );
585 if (ctx
->Extensions
.ARB_texture_cube_map
)
586 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_CUBE_MAP_ARB
,
587 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_CUBE_BIT
) );
588 if (ctx
->Extensions
.NV_texture_rectangle
)
589 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_RECTANGLE_NV
,
590 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_RECT_BIT
) );
594 if (ctx
->Texture
.Unit
[i
].TexGenEnabled
!= enable
->TexGen
[i
]) {
595 ctx
->Texture
.Unit
[i
].TexGenEnabled
= enable
->TexGen
[i
];
596 if (ctx
->Driver
.Enable
) {
597 if (ctx
->Driver
.ActiveTexture
) {
598 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
600 if (enable
->TexGen
[i
] & S_BIT
)
601 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_TRUE
);
603 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_FALSE
);
604 if (enable
->TexGen
[i
] & T_BIT
)
605 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_TRUE
);
607 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_FALSE
);
608 if (enable
->TexGen
[i
] & R_BIT
)
609 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_TRUE
);
611 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_FALSE
);
612 if (enable
->TexGen
[i
] & Q_BIT
)
613 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_TRUE
);
615 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_FALSE
);
619 /* GL_SGI_texture_color_table */
620 ctx
->Texture
.Unit
[i
].ColorTableEnabled
= enable
->TextureColorTable
[i
];
623 if (ctx
->Driver
.ActiveTexture
) {
624 (*ctx
->Driver
.ActiveTexture
)(ctx
, ctx
->Texture
.CurrentUnit
);
630 pop_texture_group(GLcontext
*ctx
, const struct gl_texture_attrib
*texAttrib
)
634 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
635 const struct gl_texture_unit
*unit
= &texAttrib
->Unit
[u
];
638 _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
+ u
);
639 _mesa_set_enable(ctx
, GL_TEXTURE_1D
,
640 (unit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
);
641 _mesa_set_enable(ctx
, GL_TEXTURE_2D
,
642 (unit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
);
643 _mesa_set_enable(ctx
, GL_TEXTURE_3D
,
644 (unit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
);
645 if (ctx
->Extensions
.ARB_texture_cube_map
) {
646 _mesa_set_enable(ctx
, GL_TEXTURE_CUBE_MAP_ARB
,
647 (unit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
);
649 if (ctx
->Extensions
.NV_texture_rectangle
) {
650 _mesa_set_enable(ctx
, GL_TEXTURE_RECTANGLE_NV
,
651 (unit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
);
653 if (ctx
->Extensions
.SGI_texture_color_table
) {
654 _mesa_set_enable(ctx
, GL_TEXTURE_COLOR_TABLE_SGI
,
655 unit
->ColorTableEnabled
);
657 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, unit
->EnvMode
);
658 _mesa_TexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, unit
->EnvColor
);
659 _mesa_TexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, unit
->GenModeS
);
660 _mesa_TexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, unit
->GenModeT
);
661 _mesa_TexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, unit
->GenModeR
);
662 _mesa_TexGeni(GL_Q
, GL_TEXTURE_GEN_MODE
, unit
->GenModeQ
);
663 _mesa_TexGenfv(GL_S
, GL_OBJECT_PLANE
, unit
->ObjectPlaneS
);
664 _mesa_TexGenfv(GL_T
, GL_OBJECT_PLANE
, unit
->ObjectPlaneT
);
665 _mesa_TexGenfv(GL_R
, GL_OBJECT_PLANE
, unit
->ObjectPlaneR
);
666 _mesa_TexGenfv(GL_Q
, GL_OBJECT_PLANE
, unit
->ObjectPlaneQ
);
667 /* Eye plane done differently to avoid re-transformation */
669 struct gl_texture_unit
*destUnit
= &ctx
->Texture
.Unit
[u
];
670 COPY_4FV(destUnit
->EyePlaneS
, unit
->EyePlaneS
);
671 COPY_4FV(destUnit
->EyePlaneT
, unit
->EyePlaneT
);
672 COPY_4FV(destUnit
->EyePlaneR
, unit
->EyePlaneR
);
673 COPY_4FV(destUnit
->EyePlaneQ
, unit
->EyePlaneQ
);
674 if (ctx
->Driver
.TexGen
) {
675 ctx
->Driver
.TexGen(ctx
, GL_S
, GL_EYE_PLANE
, unit
->EyePlaneS
);
676 ctx
->Driver
.TexGen(ctx
, GL_T
, GL_EYE_PLANE
, unit
->EyePlaneT
);
677 ctx
->Driver
.TexGen(ctx
, GL_R
, GL_EYE_PLANE
, unit
->EyePlaneR
);
678 ctx
->Driver
.TexGen(ctx
, GL_Q
, GL_EYE_PLANE
, unit
->EyePlaneQ
);
681 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_S
,
682 ((unit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
));
683 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_T
,
684 ((unit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
));
685 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_R
,
686 ((unit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
));
687 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_Q
,
688 ((unit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
));
689 if (ctx
->Extensions
.EXT_texture_lod_bias
) {
690 _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
691 GL_TEXTURE_LOD_BIAS_EXT
, unit
->LodBias
);
693 if (ctx
->Extensions
.EXT_texture_env_combine
||
694 ctx
->Extensions
.ARB_texture_env_combine
) {
695 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_COMBINE_RGB
,
696 unit
->Combine
.ModeRGB
);
697 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_COMBINE_ALPHA
,
698 unit
->Combine
.ModeA
);
699 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE0_RGB
,
700 unit
->Combine
.SourceRGB
[0]);
701 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE1_RGB
,
702 unit
->Combine
.SourceRGB
[1]);
703 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE2_RGB
,
704 unit
->Combine
.SourceRGB
[2]);
705 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE0_ALPHA
,
706 unit
->Combine
.SourceA
[0]);
707 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE1_ALPHA
,
708 unit
->Combine
.SourceA
[1]);
709 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE2_ALPHA
,
710 unit
->Combine
.SourceA
[2]);
711 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND0_RGB
,
712 unit
->Combine
.OperandRGB
[0]);
713 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND1_RGB
,
714 unit
->Combine
.OperandRGB
[1]);
715 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND2_RGB
,
716 unit
->Combine
.OperandRGB
[2]);
717 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND0_ALPHA
,
718 unit
->Combine
.OperandA
[0]);
719 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND1_ALPHA
,
720 unit
->Combine
.OperandA
[1]);
721 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND2_ALPHA
,
722 unit
->Combine
.OperandA
[2]);
723 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_RGB_SCALE
,
724 1 << unit
->Combine
.ScaleShiftRGB
);
725 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_ALPHA_SCALE
,
726 1 << unit
->Combine
.ScaleShiftA
);
729 /* Restore texture object state */
730 for (i
= 0; i
< NUM_TEXTURE_TARGETS
; i
++) {
732 const struct gl_texture_object
*obj
= NULL
;
733 GLfloat bordColor
[4];
737 target
= GL_TEXTURE_1D
;
738 obj
= &unit
->Saved1D
;
741 target
= GL_TEXTURE_2D
;
742 obj
= &unit
->Saved2D
;
745 target
= GL_TEXTURE_3D
;
746 obj
= &unit
->Saved3D
;
749 if (!ctx
->Extensions
.ARB_texture_cube_map
)
751 target
= GL_TEXTURE_CUBE_MAP_ARB
;
752 obj
= &unit
->SavedCubeMap
;
755 if (!ctx
->Extensions
.NV_texture_rectangle
)
757 target
= GL_TEXTURE_RECTANGLE_NV
;
758 obj
= &unit
->SavedRect
;
761 if (!ctx
->Extensions
.MESA_texture_array
)
763 target
= GL_TEXTURE_1D_ARRAY_EXT
;
764 obj
= &unit
->Saved1DArray
;
767 if (!ctx
->Extensions
.MESA_texture_array
)
769 target
= GL_TEXTURE_2D_ARRAY_EXT
;
770 obj
= &unit
->Saved2DArray
;
773 ; /* silence warnings */
776 _mesa_BindTexture(target
, obj
->Name
);
778 bordColor
[0] = CHAN_TO_FLOAT(obj
->BorderColor
[0]);
779 bordColor
[1] = CHAN_TO_FLOAT(obj
->BorderColor
[1]);
780 bordColor
[2] = CHAN_TO_FLOAT(obj
->BorderColor
[2]);
781 bordColor
[3] = CHAN_TO_FLOAT(obj
->BorderColor
[3]);
783 _mesa_TexParameterf(target
, GL_TEXTURE_PRIORITY
, obj
->Priority
);
784 _mesa_TexParameterfv(target
, GL_TEXTURE_BORDER_COLOR
, bordColor
);
785 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_S
, obj
->WrapS
);
786 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_T
, obj
->WrapT
);
787 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_R
, obj
->WrapR
);
788 _mesa_TexParameteri(target
, GL_TEXTURE_MIN_FILTER
, obj
->MinFilter
);
789 _mesa_TexParameteri(target
, GL_TEXTURE_MAG_FILTER
, obj
->MagFilter
);
790 _mesa_TexParameterf(target
, GL_TEXTURE_MIN_LOD
, obj
->MinLod
);
791 _mesa_TexParameterf(target
, GL_TEXTURE_MAX_LOD
, obj
->MaxLod
);
792 _mesa_TexParameterf(target
, GL_TEXTURE_LOD_BIAS
, obj
->LodBias
);
793 _mesa_TexParameteri(target
, GL_TEXTURE_BASE_LEVEL
, obj
->BaseLevel
);
794 if (target
!= GL_TEXTURE_RECTANGLE_ARB
)
795 _mesa_TexParameteri(target
, GL_TEXTURE_MAX_LEVEL
, obj
->MaxLevel
);
796 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
797 _mesa_TexParameterf(target
, GL_TEXTURE_MAX_ANISOTROPY_EXT
,
800 if (ctx
->Extensions
.SGIX_shadow
) {
801 _mesa_TexParameteri(target
, GL_TEXTURE_COMPARE_SGIX
,
803 _mesa_TexParameteri(target
, GL_TEXTURE_COMPARE_OPERATOR_SGIX
,
804 obj
->CompareOperator
);
806 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
807 _mesa_TexParameterf(target
, GL_SHADOW_AMBIENT_SGIX
,
813 _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
814 + texAttrib
->CurrentUnit
);
816 /* "un-bump" the texture object reference counts. We did that so they
817 * wouldn't inadvertantly get deleted while they were still referenced
818 * inside the attribute state stack.
820 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
821 ctx
->Texture
.Unit
[u
].Current1D
->RefCount
--;
822 ctx
->Texture
.Unit
[u
].Current2D
->RefCount
--;
823 ctx
->Texture
.Unit
[u
].Current3D
->RefCount
--;
824 ctx
->Texture
.Unit
[u
].CurrentCubeMap
->RefCount
--;
825 ctx
->Texture
.Unit
[u
].CurrentRect
->RefCount
--;
826 ctx
->Texture
.Unit
[u
].Current1DArray
->RefCount
--;
827 ctx
->Texture
.Unit
[u
].Current2DArray
->RefCount
--;
833 * This function is kind of long just because we have to call a lot
834 * of device driver functions to update device driver state.
836 * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions
837 * in order to restore GL state. This isn't terribly efficient but it
838 * ensures that dirty flags and any derived state gets updated correctly.
839 * We could at least check if the value to restore equals the current value
840 * and then skip the Mesa call.
843 _mesa_PopAttrib(void)
845 struct gl_attrib_node
*attr
, *next
;
846 GET_CURRENT_CONTEXT(ctx
);
847 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
849 if (ctx
->AttribStackDepth
== 0) {
850 _mesa_error( ctx
, GL_STACK_UNDERFLOW
, "glPopAttrib" );
854 ctx
->AttribStackDepth
--;
855 attr
= ctx
->AttribStack
[ctx
->AttribStackDepth
];
859 if (MESA_VERBOSE
& VERBOSE_API
) {
860 _mesa_debug(ctx
, "glPopAttrib %s\n",
861 _mesa_lookup_enum_by_nr(attr
->kind
));
864 switch (attr
->kind
) {
865 case GL_ACCUM_BUFFER_BIT
:
867 const struct gl_accum_attrib
*accum
;
868 accum
= (const struct gl_accum_attrib
*) attr
->data
;
869 _mesa_ClearAccum(accum
->ClearColor
[0],
870 accum
->ClearColor
[1],
871 accum
->ClearColor
[2],
872 accum
->ClearColor
[3]);
875 case GL_COLOR_BUFFER_BIT
:
877 const struct gl_colorbuffer_attrib
*color
;
878 color
= (const struct gl_colorbuffer_attrib
*) attr
->data
;
879 _mesa_ClearIndex((GLfloat
) color
->ClearIndex
);
880 _mesa_ClearColor(color
->ClearColor
[0],
881 color
->ClearColor
[1],
882 color
->ClearColor
[2],
883 color
->ClearColor
[3]);
884 _mesa_IndexMask(color
->IndexMask
);
885 _mesa_ColorMask((GLboolean
) (color
->ColorMask
[0] != 0),
886 (GLboolean
) (color
->ColorMask
[1] != 0),
887 (GLboolean
) (color
->ColorMask
[2] != 0),
888 (GLboolean
) (color
->ColorMask
[3] != 0));
890 /* Need to determine if more than one color output is
891 * specified. If so, call glDrawBuffersARB, else call
892 * glDrawBuffer(). This is a subtle, but essential point
893 * since GL_FRONT (for example) is illegal for the former
894 * function, but legal for the later.
896 GLboolean multipleBuffers
= GL_FALSE
;
897 if (ctx
->Extensions
.ARB_draw_buffers
) {
899 for (i
= 1; i
< ctx
->Const
.MaxDrawBuffers
; i
++) {
900 if (color
->DrawBuffer
[i
] != GL_NONE
) {
901 multipleBuffers
= GL_TRUE
;
906 /* Call the API_level functions, not _mesa_drawbuffers()
907 * since we need to do error checking on the pop'd
909 * Ex: if GL_FRONT were pushed, but we're popping with a
910 * user FBO bound, GL_FRONT will be illegal and we'll need
911 * to record that error. Per OpenGL ARB decision.
914 _mesa_DrawBuffersARB(ctx
->Const
.MaxDrawBuffers
,
917 _mesa_DrawBuffer(color
->DrawBuffer
[0]);
919 _mesa_set_enable(ctx
, GL_ALPHA_TEST
, color
->AlphaEnabled
);
920 _mesa_AlphaFunc(color
->AlphaFunc
, color
->AlphaRef
);
921 _mesa_set_enable(ctx
, GL_BLEND
, color
->BlendEnabled
);
922 _mesa_BlendFuncSeparateEXT(color
->BlendSrcRGB
,
926 /* This special case is because glBlendEquationSeparateEXT
927 * cannot take GL_LOGIC_OP as a parameter.
929 if ( color
->BlendEquationRGB
== color
->BlendEquationA
) {
930 _mesa_BlendEquation(color
->BlendEquationRGB
);
933 _mesa_BlendEquationSeparateEXT(color
->BlendEquationRGB
,
934 color
->BlendEquationA
);
936 _mesa_BlendColor(color
->BlendColor
[0],
937 color
->BlendColor
[1],
938 color
->BlendColor
[2],
939 color
->BlendColor
[3]);
940 _mesa_LogicOp(color
->LogicOp
);
941 _mesa_set_enable(ctx
, GL_COLOR_LOGIC_OP
,
942 color
->ColorLogicOpEnabled
);
943 _mesa_set_enable(ctx
, GL_INDEX_LOGIC_OP
,
944 color
->IndexLogicOpEnabled
);
945 _mesa_set_enable(ctx
, GL_DITHER
, color
->DitherFlag
);
949 FLUSH_CURRENT( ctx
, 0 );
950 MEMCPY( &ctx
->Current
, attr
->data
,
951 sizeof(struct gl_current_attrib
) );
953 case GL_DEPTH_BUFFER_BIT
:
955 const struct gl_depthbuffer_attrib
*depth
;
956 depth
= (const struct gl_depthbuffer_attrib
*) attr
->data
;
957 _mesa_DepthFunc(depth
->Func
);
958 _mesa_ClearDepth(depth
->Clear
);
959 _mesa_set_enable(ctx
, GL_DEPTH_TEST
, depth
->Test
);
960 _mesa_DepthMask(depth
->Mask
);
965 const struct gl_enable_attrib
*enable
;
966 enable
= (const struct gl_enable_attrib
*) attr
->data
;
967 pop_enable_group(ctx
, enable
);
968 ctx
->NewState
|= _NEW_ALL
;
972 MEMCPY( &ctx
->Eval
, attr
->data
, sizeof(struct gl_eval_attrib
) );
973 ctx
->NewState
|= _NEW_EVAL
;
977 const struct gl_fog_attrib
*fog
;
978 fog
= (const struct gl_fog_attrib
*) attr
->data
;
979 _mesa_set_enable(ctx
, GL_FOG
, fog
->Enabled
);
980 _mesa_Fogfv(GL_FOG_COLOR
, fog
->Color
);
981 _mesa_Fogf(GL_FOG_DENSITY
, fog
->Density
);
982 _mesa_Fogf(GL_FOG_START
, fog
->Start
);
983 _mesa_Fogf(GL_FOG_END
, fog
->End
);
984 _mesa_Fogf(GL_FOG_INDEX
, fog
->Index
);
985 _mesa_Fogi(GL_FOG_MODE
, fog
->Mode
);
990 const struct gl_hint_attrib
*hint
;
991 hint
= (const struct gl_hint_attrib
*) attr
->data
;
992 _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT
,
993 hint
->PerspectiveCorrection
);
994 _mesa_Hint(GL_POINT_SMOOTH_HINT
, hint
->PointSmooth
);
995 _mesa_Hint(GL_LINE_SMOOTH_HINT
, hint
->LineSmooth
);
996 _mesa_Hint(GL_POLYGON_SMOOTH_HINT
, hint
->PolygonSmooth
);
997 _mesa_Hint(GL_FOG_HINT
, hint
->Fog
);
998 _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT
,
999 hint
->ClipVolumeClipping
);
1000 if (ctx
->Extensions
.ARB_texture_compression
)
1001 _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB
,
1002 hint
->TextureCompression
);
1005 case GL_LIGHTING_BIT
:
1008 const struct gl_light_attrib
*light
;
1009 light
= (const struct gl_light_attrib
*) attr
->data
;
1010 /* lighting enable */
1011 _mesa_set_enable(ctx
, GL_LIGHTING
, light
->Enabled
);
1012 /* per-light state */
1013 if (_math_matrix_is_dirty(ctx
->ModelviewMatrixStack
.Top
))
1014 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1016 for (i
= 0; i
< ctx
->Const
.MaxLights
; i
++) {
1017 const struct gl_light
*l
= &light
->Light
[i
];
1018 _mesa_set_enable(ctx
, GL_LIGHT0
+ i
, l
->Enabled
);
1019 _mesa_light(ctx
, i
, GL_AMBIENT
, l
->Ambient
);
1020 _mesa_light(ctx
, i
, GL_DIFFUSE
, l
->Diffuse
);
1021 _mesa_light(ctx
, i
, GL_SPECULAR
, l
->Specular
);
1022 _mesa_light(ctx
, i
, GL_POSITION
, l
->EyePosition
);
1023 _mesa_light(ctx
, i
, GL_SPOT_DIRECTION
, l
->EyeDirection
);
1024 _mesa_light(ctx
, i
, GL_SPOT_EXPONENT
, &l
->SpotExponent
);
1025 _mesa_light(ctx
, i
, GL_SPOT_CUTOFF
, &l
->SpotCutoff
);
1026 _mesa_light(ctx
, i
, GL_CONSTANT_ATTENUATION
,
1027 &l
->ConstantAttenuation
);
1028 _mesa_light(ctx
, i
, GL_LINEAR_ATTENUATION
,
1029 &l
->LinearAttenuation
);
1030 _mesa_light(ctx
, i
, GL_QUADRATIC_ATTENUATION
,
1031 &l
->QuadraticAttenuation
);
1034 _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT
,
1035 light
->Model
.Ambient
);
1036 _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER
,
1037 (GLfloat
) light
->Model
.LocalViewer
);
1038 _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE
,
1039 (GLfloat
) light
->Model
.TwoSide
);
1040 _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL
,
1041 (GLfloat
) light
->Model
.ColorControl
);
1043 _mesa_ShadeModel(light
->ShadeModel
);
1044 /* color material */
1045 _mesa_ColorMaterial(light
->ColorMaterialFace
,
1046 light
->ColorMaterialMode
);
1047 _mesa_set_enable(ctx
, GL_COLOR_MATERIAL
,
1048 light
->ColorMaterialEnabled
);
1050 MEMCPY(&ctx
->Light
.Material
, &light
->Material
,
1051 sizeof(struct gl_material
));
1056 const struct gl_line_attrib
*line
;
1057 line
= (const struct gl_line_attrib
*) attr
->data
;
1058 _mesa_set_enable(ctx
, GL_LINE_SMOOTH
, line
->SmoothFlag
);
1059 _mesa_set_enable(ctx
, GL_LINE_STIPPLE
, line
->StippleFlag
);
1060 _mesa_LineStipple(line
->StippleFactor
, line
->StipplePattern
);
1061 _mesa_LineWidth(line
->Width
);
1065 MEMCPY( &ctx
->List
, attr
->data
, sizeof(struct gl_list_attrib
) );
1067 case GL_PIXEL_MODE_BIT
:
1068 MEMCPY( &ctx
->Pixel
, attr
->data
, sizeof(struct gl_pixel_attrib
) );
1069 /* XXX what other pixel state needs to be set by function calls? */
1070 _mesa_ReadBuffer(ctx
->Pixel
.ReadBuffer
);
1071 ctx
->NewState
|= _NEW_PIXEL
;
1075 const struct gl_point_attrib
*point
;
1076 point
= (const struct gl_point_attrib
*) attr
->data
;
1077 _mesa_PointSize(point
->Size
);
1078 _mesa_set_enable(ctx
, GL_POINT_SMOOTH
, point
->SmoothFlag
);
1079 if (ctx
->Extensions
.EXT_point_parameters
) {
1080 _mesa_PointParameterfv(GL_DISTANCE_ATTENUATION_EXT
,
1082 _mesa_PointParameterf(GL_POINT_SIZE_MIN_EXT
,
1084 _mesa_PointParameterf(GL_POINT_SIZE_MAX_EXT
,
1086 _mesa_PointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT
,
1089 if (ctx
->Extensions
.NV_point_sprite
1090 || ctx
->Extensions
.ARB_point_sprite
) {
1092 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
1093 _mesa_TexEnvi(GL_POINT_SPRITE_NV
, GL_COORD_REPLACE_NV
,
1094 (GLint
) point
->CoordReplace
[u
]);
1096 _mesa_set_enable(ctx
, GL_POINT_SPRITE_NV
,point
->PointSprite
);
1097 _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV
,
1098 ctx
->Point
.SpriteRMode
);
1099 _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN
,
1100 (GLfloat
)ctx
->Point
.SpriteOrigin
);
1104 case GL_POLYGON_BIT
:
1106 const struct gl_polygon_attrib
*polygon
;
1107 polygon
= (const struct gl_polygon_attrib
*) attr
->data
;
1108 _mesa_CullFace(polygon
->CullFaceMode
);
1109 _mesa_FrontFace(polygon
->FrontFace
);
1110 _mesa_PolygonMode(GL_FRONT
, polygon
->FrontMode
);
1111 _mesa_PolygonMode(GL_BACK
, polygon
->BackMode
);
1112 _mesa_PolygonOffset(polygon
->OffsetFactor
,
1113 polygon
->OffsetUnits
);
1114 _mesa_set_enable(ctx
, GL_POLYGON_SMOOTH
, polygon
->SmoothFlag
);
1115 _mesa_set_enable(ctx
, GL_POLYGON_STIPPLE
, polygon
->StippleFlag
);
1116 _mesa_set_enable(ctx
, GL_CULL_FACE
, polygon
->CullFlag
);
1117 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_POINT
,
1118 polygon
->OffsetPoint
);
1119 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_LINE
,
1120 polygon
->OffsetLine
);
1121 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_FILL
,
1122 polygon
->OffsetFill
);
1125 case GL_POLYGON_STIPPLE_BIT
:
1126 MEMCPY( ctx
->PolygonStipple
, attr
->data
, 32*sizeof(GLuint
) );
1127 ctx
->NewState
|= _NEW_POLYGONSTIPPLE
;
1128 if (ctx
->Driver
.PolygonStipple
)
1129 ctx
->Driver
.PolygonStipple( ctx
, (const GLubyte
*) attr
->data
);
1131 case GL_SCISSOR_BIT
:
1133 const struct gl_scissor_attrib
*scissor
;
1134 scissor
= (const struct gl_scissor_attrib
*) attr
->data
;
1135 _mesa_Scissor(scissor
->X
, scissor
->Y
,
1136 scissor
->Width
, scissor
->Height
);
1137 _mesa_set_enable(ctx
, GL_SCISSOR_TEST
, scissor
->Enabled
);
1140 case GL_STENCIL_BUFFER_BIT
:
1142 const struct gl_stencil_attrib
*stencil
;
1143 stencil
= (const struct gl_stencil_attrib
*) attr
->data
;
1144 _mesa_set_enable(ctx
, GL_STENCIL_TEST
, stencil
->Enabled
);
1145 _mesa_ClearStencil(stencil
->Clear
);
1146 if (ctx
->Extensions
.EXT_stencil_two_side
) {
1147 _mesa_set_enable(ctx
, GL_STENCIL_TEST_TWO_SIDE_EXT
,
1148 stencil
->TestTwoSide
);
1149 _mesa_ActiveStencilFaceEXT(stencil
->ActiveFace
1150 ? GL_BACK
: GL_FRONT
);
1153 _mesa_StencilFuncSeparate(GL_FRONT
,
1154 stencil
->Function
[0],
1156 stencil
->ValueMask
[0]);
1157 _mesa_StencilMaskSeparate(GL_FRONT
, stencil
->WriteMask
[0]);
1158 _mesa_StencilOpSeparate(GL_FRONT
, stencil
->FailFunc
[0],
1159 stencil
->ZFailFunc
[0],
1160 stencil
->ZPassFunc
[0]);
1162 _mesa_StencilFuncSeparate(GL_BACK
,
1163 stencil
->Function
[1],
1165 stencil
->ValueMask
[1]);
1166 _mesa_StencilMaskSeparate(GL_BACK
, stencil
->WriteMask
[1]);
1167 _mesa_StencilOpSeparate(GL_BACK
, stencil
->FailFunc
[1],
1168 stencil
->ZFailFunc
[1],
1169 stencil
->ZPassFunc
[1]);
1172 case GL_TRANSFORM_BIT
:
1175 const struct gl_transform_attrib
*xform
;
1176 xform
= (const struct gl_transform_attrib
*) attr
->data
;
1177 _mesa_MatrixMode(xform
->MatrixMode
);
1178 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
1179 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
1181 /* restore clip planes */
1182 for (i
= 0; i
< MAX_CLIP_PLANES
; i
++) {
1183 const GLuint mask
= 1 << 1;
1184 const GLfloat
*eyePlane
= xform
->EyeUserPlane
[i
];
1185 COPY_4V(ctx
->Transform
.EyeUserPlane
[i
], eyePlane
);
1186 if (xform
->ClipPlanesEnabled
& mask
) {
1187 _mesa_set_enable(ctx
, GL_CLIP_PLANE0
+ i
, GL_TRUE
);
1190 _mesa_set_enable(ctx
, GL_CLIP_PLANE0
+ i
, GL_FALSE
);
1192 if (ctx
->Driver
.ClipPlane
)
1193 ctx
->Driver
.ClipPlane( ctx
, GL_CLIP_PLANE0
+ i
, eyePlane
);
1196 /* normalize/rescale */
1197 if (xform
->Normalize
!= ctx
->Transform
.Normalize
)
1198 _mesa_set_enable(ctx
, GL_NORMALIZE
,ctx
->Transform
.Normalize
);
1199 if (xform
->RescaleNormals
!= ctx
->Transform
.RescaleNormals
)
1200 _mesa_set_enable(ctx
, GL_RESCALE_NORMAL_EXT
,
1201 ctx
->Transform
.RescaleNormals
);
1204 case GL_TEXTURE_BIT
:
1205 /* Take care of texture object reference counters */
1207 const struct gl_texture_attrib
*texture
;
1208 texture
= (const struct gl_texture_attrib
*) attr
->data
;
1209 pop_texture_group(ctx
, texture
);
1210 ctx
->NewState
|= _NEW_TEXTURE
;
1213 case GL_VIEWPORT_BIT
:
1215 const struct gl_viewport_attrib
*vp
;
1216 vp
= (const struct gl_viewport_attrib
*) attr
->data
;
1217 _mesa_Viewport(vp
->X
, vp
->Y
, vp
->Width
, vp
->Height
);
1218 _mesa_DepthRange(vp
->Near
, vp
->Far
);
1221 case GL_MULTISAMPLE_BIT_ARB
:
1223 const struct gl_multisample_attrib
*ms
;
1224 ms
= (const struct gl_multisample_attrib
*) attr
->data
;
1225 _mesa_SampleCoverageARB(ms
->SampleCoverageValue
,
1226 ms
->SampleCoverageInvert
);
1231 _mesa_problem( ctx
, "Bad attrib flag in PopAttrib");
1244 * Helper for incrementing/decrementing vertex buffer object reference
1245 * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group.
1248 adjust_buffer_object_ref_counts(struct gl_array_attrib
*array
, GLint step
)
1251 array
->ArrayObj
->Vertex
.BufferObj
->RefCount
+= step
;
1252 array
->ArrayObj
->Normal
.BufferObj
->RefCount
+= step
;
1253 array
->ArrayObj
->Color
.BufferObj
->RefCount
+= step
;
1254 array
->ArrayObj
->SecondaryColor
.BufferObj
->RefCount
+= step
;
1255 array
->ArrayObj
->FogCoord
.BufferObj
->RefCount
+= step
;
1256 array
->ArrayObj
->Index
.BufferObj
->RefCount
+= step
;
1257 array
->ArrayObj
->EdgeFlag
.BufferObj
->RefCount
+= step
;
1258 for (i
= 0; i
< MAX_TEXTURE_COORD_UNITS
; i
++)
1259 array
->ArrayObj
->TexCoord
[i
].BufferObj
->RefCount
+= step
;
1260 for (i
= 0; i
< VERT_ATTRIB_MAX
; i
++)
1261 array
->ArrayObj
->VertexAttrib
[i
].BufferObj
->RefCount
+= step
;
1263 array
->ArrayBufferObj
->RefCount
+= step
;
1264 array
->ElementArrayBufferObj
->RefCount
+= step
;
1268 #define GL_CLIENT_PACK_BIT (1<<20)
1269 #define GL_CLIENT_UNPACK_BIT (1<<21)
1273 _mesa_PushClientAttrib(GLbitfield mask
)
1275 struct gl_attrib_node
*newnode
;
1276 struct gl_attrib_node
*head
;
1278 GET_CURRENT_CONTEXT(ctx
);
1279 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1281 if (ctx
->ClientAttribStackDepth
>= MAX_CLIENT_ATTRIB_STACK_DEPTH
) {
1282 _mesa_error( ctx
, GL_STACK_OVERFLOW
, "glPushClientAttrib" );
1286 /* Build linked list of attribute nodes which save all attribute */
1287 /* groups specified by the mask. */
1290 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
1291 struct gl_pixelstore_attrib
*attr
;
1292 #if FEATURE_EXT_pixel_buffer_object
1293 ctx
->Pack
.BufferObj
->RefCount
++;
1294 ctx
->Unpack
.BufferObj
->RefCount
++;
1296 /* packing attribs */
1297 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
1298 MEMCPY( attr
, &ctx
->Pack
, sizeof(struct gl_pixelstore_attrib
) );
1299 newnode
= new_attrib_node( GL_CLIENT_PACK_BIT
);
1300 newnode
->data
= attr
;
1301 newnode
->next
= head
;
1303 /* unpacking attribs */
1304 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
1305 MEMCPY( attr
, &ctx
->Unpack
, sizeof(struct gl_pixelstore_attrib
) );
1306 newnode
= new_attrib_node( GL_CLIENT_UNPACK_BIT
);
1307 newnode
->data
= attr
;
1308 newnode
->next
= head
;
1311 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
1312 struct gl_array_attrib
*attr
;
1313 struct gl_array_object
*obj
;
1315 attr
= MALLOC_STRUCT( gl_array_attrib
);
1316 obj
= MALLOC_STRUCT( gl_array_object
);
1318 #if FEATURE_ARB_vertex_buffer_object
1319 /* increment ref counts since we're copying pointers to these objects */
1320 ctx
->Array
.ArrayBufferObj
->RefCount
++;
1321 ctx
->Array
.ElementArrayBufferObj
->RefCount
++;
1324 MEMCPY( attr
, &ctx
->Array
, sizeof(struct gl_array_attrib
) );
1325 MEMCPY( obj
, ctx
->Array
.ArrayObj
, sizeof(struct gl_array_object
) );
1327 attr
->ArrayObj
= obj
;
1329 newnode
= new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT
);
1330 newnode
->data
= attr
;
1331 newnode
->next
= head
;
1333 /* bump reference counts on buffer objects */
1334 adjust_buffer_object_ref_counts(&ctx
->Array
, 1);
1337 ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
] = head
;
1338 ctx
->ClientAttribStackDepth
++;
1345 _mesa_PopClientAttrib(void)
1347 struct gl_attrib_node
*attr
, *next
;
1349 GET_CURRENT_CONTEXT(ctx
);
1350 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
1352 if (ctx
->ClientAttribStackDepth
== 0) {
1353 _mesa_error( ctx
, GL_STACK_UNDERFLOW
, "glPopClientAttrib" );
1357 ctx
->ClientAttribStackDepth
--;
1358 attr
= ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
];
1361 switch (attr
->kind
) {
1362 case GL_CLIENT_PACK_BIT
:
1363 #if FEATURE_EXT_pixel_buffer_object
1364 ctx
->Pack
.BufferObj
->RefCount
--;
1365 if (ctx
->Pack
.BufferObj
->RefCount
<= 0) {
1366 _mesa_remove_buffer_object( ctx
, ctx
->Pack
.BufferObj
);
1367 (*ctx
->Driver
.DeleteBuffer
)( ctx
, ctx
->Pack
.BufferObj
);
1370 MEMCPY( &ctx
->Pack
, attr
->data
,
1371 sizeof(struct gl_pixelstore_attrib
) );
1372 ctx
->NewState
|= _NEW_PACKUNPACK
;
1374 case GL_CLIENT_UNPACK_BIT
:
1375 #if FEATURE_EXT_pixel_buffer_object
1376 ctx
->Unpack
.BufferObj
->RefCount
--;
1377 if (ctx
->Unpack
.BufferObj
->RefCount
<= 0) {
1378 _mesa_remove_buffer_object( ctx
, ctx
->Unpack
.BufferObj
);
1379 (*ctx
->Driver
.DeleteBuffer
)( ctx
, ctx
->Unpack
.BufferObj
);
1382 MEMCPY( &ctx
->Unpack
, attr
->data
,
1383 sizeof(struct gl_pixelstore_attrib
) );
1384 ctx
->NewState
|= _NEW_PACKUNPACK
;
1386 case GL_CLIENT_VERTEX_ARRAY_BIT
: {
1387 struct gl_array_attrib
* data
=
1388 (struct gl_array_attrib
*) attr
->data
;
1390 adjust_buffer_object_ref_counts(&ctx
->Array
, -1);
1392 ctx
->Array
.ActiveTexture
= data
->ActiveTexture
;
1393 ctx
->Array
.LockFirst
= data
->LockFirst
;
1394 ctx
->Array
.LockCount
= data
->LockCount
;
1396 _mesa_BindVertexArrayAPPLE( data
->ArrayObj
->Name
);
1398 #if FEATURE_ARB_vertex_buffer_object
1399 _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB
,
1400 data
->ArrayBufferObj
->Name
);
1401 _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
,
1402 data
->ElementArrayBufferObj
->Name
);
1405 MEMCPY( ctx
->Array
.ArrayObj
, data
->ArrayObj
,
1406 sizeof( struct gl_array_object
) );
1408 FREE( data
->ArrayObj
);
1410 /* FIXME: Should some bits in ctx->Array->NewState also be set
1411 * FIXME: here? It seems like it should be set to inclusive-or
1412 * FIXME: of the old ArrayObj->_Enabled and the new _Enabled.
1415 ctx
->NewState
|= _NEW_ARRAY
;
1419 _mesa_problem( ctx
, "Bad attrib flag in PopClientAttrib");
1431 void _mesa_init_attrib( GLcontext
*ctx
)
1433 /* Renderer and client attribute stacks */
1434 ctx
->AttribStackDepth
= 0;
1435 ctx
->ClientAttribStackDepth
= 0;