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"
46 #include "simple_list.h"
51 #include "math/m_xform.h"
55 * Allocate a new attribute state node. These nodes have a
56 * "kind" value and a pointer to a struct of state data.
58 static struct gl_attrib_node
*
59 new_attrib_node( GLbitfield kind
)
61 struct gl_attrib_node
*an
= MALLOC_STRUCT(gl_attrib_node
);
70 _mesa_PushAttrib(GLbitfield mask
)
72 struct gl_attrib_node
*newnode
;
73 struct gl_attrib_node
*head
;
75 GET_CURRENT_CONTEXT(ctx
);
76 ASSERT_OUTSIDE_BEGIN_END(ctx
);
78 if (MESA_VERBOSE
& VERBOSE_API
)
79 _mesa_debug(ctx
, "glPushAttrib %x\n", (int) mask
);
81 if (ctx
->AttribStackDepth
>= MAX_ATTRIB_STACK_DEPTH
) {
82 _mesa_error( ctx
, GL_STACK_OVERFLOW
, "glPushAttrib" );
86 /* Build linked list of attribute nodes which save all attribute */
87 /* groups specified by the mask. */
90 if (mask
& GL_ACCUM_BUFFER_BIT
) {
91 struct gl_accum_attrib
*attr
;
92 attr
= MALLOC_STRUCT( gl_accum_attrib
);
93 MEMCPY( attr
, &ctx
->Accum
, sizeof(struct gl_accum_attrib
) );
94 newnode
= new_attrib_node( GL_ACCUM_BUFFER_BIT
);
100 if (mask
& GL_COLOR_BUFFER_BIT
) {
102 struct gl_colorbuffer_attrib
*attr
;
103 attr
= MALLOC_STRUCT( gl_colorbuffer_attrib
);
104 MEMCPY( attr
, &ctx
->Color
, sizeof(struct gl_colorbuffer_attrib
) );
105 /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */
106 for (i
= 0; i
< ctx
->Const
.MaxDrawBuffers
; i
++)
107 attr
->DrawBuffer
[i
] = ctx
->DrawBuffer
->ColorDrawBuffer
[i
];
108 newnode
= new_attrib_node( GL_COLOR_BUFFER_BIT
);
109 newnode
->data
= attr
;
110 newnode
->next
= head
;
114 if (mask
& GL_CURRENT_BIT
) {
115 struct gl_current_attrib
*attr
;
116 FLUSH_CURRENT( ctx
, 0 );
117 attr
= MALLOC_STRUCT( gl_current_attrib
);
118 MEMCPY( attr
, &ctx
->Current
, sizeof(struct gl_current_attrib
) );
119 newnode
= new_attrib_node( GL_CURRENT_BIT
);
120 newnode
->data
= attr
;
121 newnode
->next
= head
;
125 if (mask
& GL_DEPTH_BUFFER_BIT
) {
126 struct gl_depthbuffer_attrib
*attr
;
127 attr
= MALLOC_STRUCT( gl_depthbuffer_attrib
);
128 MEMCPY( attr
, &ctx
->Depth
, sizeof(struct gl_depthbuffer_attrib
) );
129 newnode
= new_attrib_node( GL_DEPTH_BUFFER_BIT
);
130 newnode
->data
= attr
;
131 newnode
->next
= head
;
135 if (mask
& GL_ENABLE_BIT
) {
136 struct gl_enable_attrib
*attr
;
138 attr
= MALLOC_STRUCT( gl_enable_attrib
);
139 /* Copy enable flags from all other attributes into the enable struct. */
140 attr
->AlphaTest
= ctx
->Color
.AlphaEnabled
;
141 attr
->AutoNormal
= ctx
->Eval
.AutoNormal
;
142 attr
->Blend
= ctx
->Color
.BlendEnabled
;
143 attr
->ClipPlanes
= ctx
->Transform
.ClipPlanesEnabled
;
144 attr
->ColorMaterial
= ctx
->Light
.ColorMaterialEnabled
;
145 for (i
= 0; i
< COLORTABLE_MAX
; i
++) {
146 attr
->ColorTable
[i
] = ctx
->Pixel
.ColorTableEnabled
[i
];
148 attr
->Convolution1D
= ctx
->Pixel
.Convolution1DEnabled
;
149 attr
->Convolution2D
= ctx
->Pixel
.Convolution2DEnabled
;
150 attr
->Separable2D
= ctx
->Pixel
.Separable2DEnabled
;
151 attr
->CullFace
= ctx
->Polygon
.CullFlag
;
152 attr
->DepthTest
= ctx
->Depth
.Test
;
153 attr
->Dither
= ctx
->Color
.DitherFlag
;
154 attr
->Fog
= ctx
->Fog
.Enabled
;
155 for (i
= 0; i
< ctx
->Const
.MaxLights
; i
++) {
156 attr
->Light
[i
] = ctx
->Light
.Light
[i
].Enabled
;
158 attr
->Lighting
= ctx
->Light
.Enabled
;
159 attr
->LineSmooth
= ctx
->Line
.SmoothFlag
;
160 attr
->LineStipple
= ctx
->Line
.StippleFlag
;
161 attr
->Histogram
= ctx
->Pixel
.HistogramEnabled
;
162 attr
->MinMax
= ctx
->Pixel
.MinMaxEnabled
;
163 attr
->IndexLogicOp
= ctx
->Color
.IndexLogicOpEnabled
;
164 attr
->ColorLogicOp
= ctx
->Color
.ColorLogicOpEnabled
;
165 attr
->Map1Color4
= ctx
->Eval
.Map1Color4
;
166 attr
->Map1Index
= ctx
->Eval
.Map1Index
;
167 attr
->Map1Normal
= ctx
->Eval
.Map1Normal
;
168 attr
->Map1TextureCoord1
= ctx
->Eval
.Map1TextureCoord1
;
169 attr
->Map1TextureCoord2
= ctx
->Eval
.Map1TextureCoord2
;
170 attr
->Map1TextureCoord3
= ctx
->Eval
.Map1TextureCoord3
;
171 attr
->Map1TextureCoord4
= ctx
->Eval
.Map1TextureCoord4
;
172 attr
->Map1Vertex3
= ctx
->Eval
.Map1Vertex3
;
173 attr
->Map1Vertex4
= ctx
->Eval
.Map1Vertex4
;
174 MEMCPY(attr
->Map1Attrib
, ctx
->Eval
.Map1Attrib
, sizeof(ctx
->Eval
.Map1Attrib
));
175 attr
->Map2Color4
= ctx
->Eval
.Map2Color4
;
176 attr
->Map2Index
= ctx
->Eval
.Map2Index
;
177 attr
->Map2Normal
= ctx
->Eval
.Map2Normal
;
178 attr
->Map2TextureCoord1
= ctx
->Eval
.Map2TextureCoord1
;
179 attr
->Map2TextureCoord2
= ctx
->Eval
.Map2TextureCoord2
;
180 attr
->Map2TextureCoord3
= ctx
->Eval
.Map2TextureCoord3
;
181 attr
->Map2TextureCoord4
= ctx
->Eval
.Map2TextureCoord4
;
182 attr
->Map2Vertex3
= ctx
->Eval
.Map2Vertex3
;
183 attr
->Map2Vertex4
= ctx
->Eval
.Map2Vertex4
;
184 MEMCPY(attr
->Map2Attrib
, ctx
->Eval
.Map2Attrib
, sizeof(ctx
->Eval
.Map2Attrib
));
185 attr
->Normalize
= ctx
->Transform
.Normalize
;
186 attr
->RasterPositionUnclipped
= ctx
->Transform
.RasterPositionUnclipped
;
187 attr
->PointSmooth
= ctx
->Point
.SmoothFlag
;
188 attr
->PointSprite
= ctx
->Point
.PointSprite
;
189 attr
->PolygonOffsetPoint
= ctx
->Polygon
.OffsetPoint
;
190 attr
->PolygonOffsetLine
= ctx
->Polygon
.OffsetLine
;
191 attr
->PolygonOffsetFill
= ctx
->Polygon
.OffsetFill
;
192 attr
->PolygonSmooth
= ctx
->Polygon
.SmoothFlag
;
193 attr
->PolygonStipple
= ctx
->Polygon
.StippleFlag
;
194 attr
->RescaleNormals
= ctx
->Transform
.RescaleNormals
;
195 attr
->Scissor
= ctx
->Scissor
.Enabled
;
196 attr
->Stencil
= ctx
->Stencil
.Enabled
;
197 attr
->StencilTwoSide
= ctx
->Stencil
.TestTwoSide
;
198 attr
->MultisampleEnabled
= ctx
->Multisample
.Enabled
;
199 attr
->SampleAlphaToCoverage
= ctx
->Multisample
.SampleAlphaToCoverage
;
200 attr
->SampleAlphaToOne
= ctx
->Multisample
.SampleAlphaToOne
;
201 attr
->SampleCoverage
= ctx
->Multisample
.SampleCoverage
;
202 attr
->SampleCoverageInvert
= ctx
->Multisample
.SampleCoverageInvert
;
203 for (i
=0; i
<MAX_TEXTURE_UNITS
; i
++) {
204 attr
->Texture
[i
] = ctx
->Texture
.Unit
[i
].Enabled
;
205 attr
->TexGen
[i
] = ctx
->Texture
.Unit
[i
].TexGenEnabled
;
206 attr
->TextureColorTable
[i
] = ctx
->Texture
.Unit
[i
].ColorTableEnabled
;
208 /* GL_NV_vertex_program */
209 attr
->VertexProgram
= ctx
->VertexProgram
.Enabled
;
210 attr
->VertexProgramPointSize
= ctx
->VertexProgram
.PointSizeEnabled
;
211 attr
->VertexProgramTwoSide
= ctx
->VertexProgram
.TwoSideEnabled
;
212 newnode
= new_attrib_node( GL_ENABLE_BIT
);
213 newnode
->data
= attr
;
214 newnode
->next
= head
;
218 if (mask
& GL_EVAL_BIT
) {
219 struct gl_eval_attrib
*attr
;
220 attr
= MALLOC_STRUCT( gl_eval_attrib
);
221 MEMCPY( attr
, &ctx
->Eval
, sizeof(struct gl_eval_attrib
) );
222 newnode
= new_attrib_node( GL_EVAL_BIT
);
223 newnode
->data
= attr
;
224 newnode
->next
= head
;
228 if (mask
& GL_FOG_BIT
) {
229 struct gl_fog_attrib
*attr
;
230 attr
= MALLOC_STRUCT( gl_fog_attrib
);
231 MEMCPY( attr
, &ctx
->Fog
, sizeof(struct gl_fog_attrib
) );
232 newnode
= new_attrib_node( GL_FOG_BIT
);
233 newnode
->data
= attr
;
234 newnode
->next
= head
;
238 if (mask
& GL_HINT_BIT
) {
239 struct gl_hint_attrib
*attr
;
240 attr
= MALLOC_STRUCT( gl_hint_attrib
);
241 MEMCPY( attr
, &ctx
->Hint
, sizeof(struct gl_hint_attrib
) );
242 newnode
= new_attrib_node( GL_HINT_BIT
);
243 newnode
->data
= attr
;
244 newnode
->next
= head
;
248 if (mask
& GL_LIGHTING_BIT
) {
249 struct gl_light_attrib
*attr
;
250 FLUSH_CURRENT(ctx
, 0); /* flush material changes */
251 attr
= MALLOC_STRUCT( gl_light_attrib
);
252 MEMCPY( attr
, &ctx
->Light
, sizeof(struct gl_light_attrib
) );
253 newnode
= new_attrib_node( GL_LIGHTING_BIT
);
254 newnode
->data
= attr
;
255 newnode
->next
= head
;
259 if (mask
& GL_LINE_BIT
) {
260 struct gl_line_attrib
*attr
;
261 attr
= MALLOC_STRUCT( gl_line_attrib
);
262 MEMCPY( attr
, &ctx
->Line
, sizeof(struct gl_line_attrib
) );
263 newnode
= new_attrib_node( GL_LINE_BIT
);
264 newnode
->data
= attr
;
265 newnode
->next
= head
;
269 if (mask
& GL_LIST_BIT
) {
270 struct gl_list_attrib
*attr
;
271 attr
= MALLOC_STRUCT( gl_list_attrib
);
272 MEMCPY( attr
, &ctx
->List
, sizeof(struct gl_list_attrib
) );
273 newnode
= new_attrib_node( GL_LIST_BIT
);
274 newnode
->data
= attr
;
275 newnode
->next
= head
;
279 if (mask
& GL_PIXEL_MODE_BIT
) {
280 struct gl_pixel_attrib
*attr
;
281 attr
= MALLOC_STRUCT( gl_pixel_attrib
);
282 MEMCPY( attr
, &ctx
->Pixel
, sizeof(struct gl_pixel_attrib
) );
283 /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */
284 attr
->ReadBuffer
= ctx
->ReadBuffer
->ColorReadBuffer
;
285 newnode
= new_attrib_node( GL_PIXEL_MODE_BIT
);
286 newnode
->data
= attr
;
287 newnode
->next
= head
;
291 if (mask
& GL_POINT_BIT
) {
292 struct gl_point_attrib
*attr
;
293 attr
= MALLOC_STRUCT( gl_point_attrib
);
294 MEMCPY( attr
, &ctx
->Point
, sizeof(struct gl_point_attrib
) );
295 newnode
= new_attrib_node( GL_POINT_BIT
);
296 newnode
->data
= attr
;
297 newnode
->next
= head
;
301 if (mask
& GL_POLYGON_BIT
) {
302 struct gl_polygon_attrib
*attr
;
303 attr
= MALLOC_STRUCT( gl_polygon_attrib
);
304 MEMCPY( attr
, &ctx
->Polygon
, sizeof(struct gl_polygon_attrib
) );
305 newnode
= new_attrib_node( GL_POLYGON_BIT
);
306 newnode
->data
= attr
;
307 newnode
->next
= head
;
311 if (mask
& GL_POLYGON_STIPPLE_BIT
) {
313 stipple
= (GLuint
*) MALLOC( 32*sizeof(GLuint
) );
314 MEMCPY( stipple
, ctx
->PolygonStipple
, 32*sizeof(GLuint
) );
315 newnode
= new_attrib_node( GL_POLYGON_STIPPLE_BIT
);
316 newnode
->data
= stipple
;
317 newnode
->next
= head
;
321 if (mask
& GL_SCISSOR_BIT
) {
322 struct gl_scissor_attrib
*attr
;
323 attr
= MALLOC_STRUCT( gl_scissor_attrib
);
324 MEMCPY( attr
, &ctx
->Scissor
, sizeof(struct gl_scissor_attrib
) );
325 newnode
= new_attrib_node( GL_SCISSOR_BIT
);
326 newnode
->data
= attr
;
327 newnode
->next
= head
;
331 if (mask
& GL_STENCIL_BUFFER_BIT
) {
332 struct gl_stencil_attrib
*attr
;
333 attr
= MALLOC_STRUCT( gl_stencil_attrib
);
334 MEMCPY( attr
, &ctx
->Stencil
, sizeof(struct gl_stencil_attrib
) );
335 newnode
= new_attrib_node( GL_STENCIL_BUFFER_BIT
);
336 newnode
->data
= attr
;
337 newnode
->next
= head
;
341 if (mask
& GL_TEXTURE_BIT
) {
342 struct gl_texture_attrib
*attr
;
345 _mesa_lock_context_textures(ctx
);
346 /* Bump the texture object reference counts so that they don't
347 * inadvertantly get deleted.
349 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
350 ctx
->Texture
.Unit
[u
].Current1D
->RefCount
++;
351 ctx
->Texture
.Unit
[u
].Current2D
->RefCount
++;
352 ctx
->Texture
.Unit
[u
].Current3D
->RefCount
++;
353 ctx
->Texture
.Unit
[u
].CurrentCubeMap
->RefCount
++;
354 ctx
->Texture
.Unit
[u
].CurrentRect
->RefCount
++;
355 ctx
->Texture
.Unit
[u
].Current1DArray
->RefCount
++;
356 ctx
->Texture
.Unit
[u
].Current2DArray
->RefCount
++;
358 attr
= MALLOC_STRUCT( gl_texture_attrib
);
359 MEMCPY( attr
, &ctx
->Texture
, sizeof(struct gl_texture_attrib
) );
360 /* copy state of the currently bound texture objects */
361 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
362 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved1D
,
363 attr
->Unit
[u
].Current1D
);
364 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved2D
,
365 attr
->Unit
[u
].Current2D
);
366 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved3D
,
367 attr
->Unit
[u
].Current3D
);
368 _mesa_copy_texture_object(&attr
->Unit
[u
].SavedCubeMap
,
369 attr
->Unit
[u
].CurrentCubeMap
);
370 _mesa_copy_texture_object(&attr
->Unit
[u
].SavedRect
,
371 attr
->Unit
[u
].CurrentRect
);
372 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved1DArray
,
373 attr
->Unit
[u
].Current1DArray
);
374 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved2DArray
,
375 attr
->Unit
[u
].Current2DArray
);
378 _mesa_unlock_context_textures(ctx
);
380 newnode
= new_attrib_node( GL_TEXTURE_BIT
);
381 newnode
->data
= attr
;
382 newnode
->next
= head
;
386 if (mask
& GL_TRANSFORM_BIT
) {
387 struct gl_transform_attrib
*attr
;
388 attr
= MALLOC_STRUCT( gl_transform_attrib
);
389 MEMCPY( attr
, &ctx
->Transform
, sizeof(struct gl_transform_attrib
) );
390 newnode
= new_attrib_node( GL_TRANSFORM_BIT
);
391 newnode
->data
= attr
;
392 newnode
->next
= head
;
396 if (mask
& GL_VIEWPORT_BIT
) {
397 struct gl_viewport_attrib
*attr
;
398 attr
= MALLOC_STRUCT( gl_viewport_attrib
);
399 MEMCPY( attr
, &ctx
->Viewport
, sizeof(struct gl_viewport_attrib
) );
400 newnode
= new_attrib_node( GL_VIEWPORT_BIT
);
401 newnode
->data
= attr
;
402 newnode
->next
= head
;
406 /* GL_ARB_multisample */
407 if (mask
& GL_MULTISAMPLE_BIT_ARB
) {
408 struct gl_multisample_attrib
*attr
;
409 attr
= MALLOC_STRUCT( gl_multisample_attrib
);
410 MEMCPY( attr
, &ctx
->Multisample
, sizeof(struct gl_multisample_attrib
) );
411 newnode
= new_attrib_node( GL_MULTISAMPLE_BIT_ARB
);
412 newnode
->data
= attr
;
413 newnode
->next
= head
;
417 ctx
->AttribStack
[ctx
->AttribStackDepth
] = head
;
418 ctx
->AttribStackDepth
++;
424 pop_enable_group(GLcontext
*ctx
, const struct gl_enable_attrib
*enable
)
428 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
429 if ((VALUE) != (NEWVALUE)) { \
430 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \
433 TEST_AND_UPDATE(ctx
->Color
.AlphaEnabled
, enable
->AlphaTest
, GL_ALPHA_TEST
);
434 TEST_AND_UPDATE(ctx
->Color
.BlendEnabled
, enable
->Blend
, GL_BLEND
);
436 for (i
=0;i
<MAX_CLIP_PLANES
;i
++) {
437 const GLuint mask
= 1 << i
;
438 if ((ctx
->Transform
.ClipPlanesEnabled
& mask
) != (enable
->ClipPlanes
& mask
))
439 _mesa_set_enable(ctx
, (GLenum
) (GL_CLIP_PLANE0
+ i
),
440 (GLboolean
) ((enable
->ClipPlanes
& mask
) ? GL_TRUE
: GL_FALSE
));
443 TEST_AND_UPDATE(ctx
->Light
.ColorMaterialEnabled
, enable
->ColorMaterial
,
445 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
],
446 enable
->ColorTable
[COLORTABLE_PRECONVOLUTION
],
448 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
],
449 enable
->ColorTable
[COLORTABLE_POSTCONVOLUTION
],
450 GL_POST_CONVOLUTION_COLOR_TABLE
);
451 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
],
452 enable
->ColorTable
[COLORTABLE_POSTCOLORMATRIX
],
453 GL_POST_COLOR_MATRIX_COLOR_TABLE
);
454 TEST_AND_UPDATE(ctx
->Polygon
.CullFlag
, enable
->CullFace
, GL_CULL_FACE
);
455 TEST_AND_UPDATE(ctx
->Depth
.Test
, enable
->DepthTest
, GL_DEPTH_TEST
);
456 TEST_AND_UPDATE(ctx
->Color
.DitherFlag
, enable
->Dither
, GL_DITHER
);
457 TEST_AND_UPDATE(ctx
->Pixel
.Convolution1DEnabled
, enable
->Convolution1D
,
459 TEST_AND_UPDATE(ctx
->Pixel
.Convolution2DEnabled
, enable
->Convolution2D
,
461 TEST_AND_UPDATE(ctx
->Pixel
.Separable2DEnabled
, enable
->Separable2D
,
463 TEST_AND_UPDATE(ctx
->Fog
.Enabled
, enable
->Fog
, GL_FOG
);
464 TEST_AND_UPDATE(ctx
->Light
.Enabled
, enable
->Lighting
, GL_LIGHTING
);
465 TEST_AND_UPDATE(ctx
->Line
.SmoothFlag
, enable
->LineSmooth
, GL_LINE_SMOOTH
);
466 TEST_AND_UPDATE(ctx
->Line
.StippleFlag
, enable
->LineStipple
,
468 TEST_AND_UPDATE(ctx
->Color
.IndexLogicOpEnabled
, enable
->IndexLogicOp
,
470 TEST_AND_UPDATE(ctx
->Color
.ColorLogicOpEnabled
, enable
->ColorLogicOp
,
473 TEST_AND_UPDATE(ctx
->Eval
.Map1Color4
, enable
->Map1Color4
, GL_MAP1_COLOR_4
);
474 TEST_AND_UPDATE(ctx
->Eval
.Map1Index
, enable
->Map1Index
, GL_MAP1_INDEX
);
475 TEST_AND_UPDATE(ctx
->Eval
.Map1Normal
, enable
->Map1Normal
, GL_MAP1_NORMAL
);
476 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord1
, enable
->Map1TextureCoord1
,
477 GL_MAP1_TEXTURE_COORD_1
);
478 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord2
, enable
->Map1TextureCoord2
,
479 GL_MAP1_TEXTURE_COORD_2
);
480 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord3
, enable
->Map1TextureCoord3
,
481 GL_MAP1_TEXTURE_COORD_3
);
482 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord4
, enable
->Map1TextureCoord4
,
483 GL_MAP1_TEXTURE_COORD_4
);
484 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex3
, enable
->Map1Vertex3
,
486 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex4
, enable
->Map1Vertex4
,
488 for (i
= 0; i
< 16; i
++) {
489 TEST_AND_UPDATE(ctx
->Eval
.Map1Attrib
[i
], enable
->Map1Attrib
[i
],
490 GL_MAP1_VERTEX_ATTRIB0_4_NV
+ i
);
493 TEST_AND_UPDATE(ctx
->Eval
.Map2Color4
, enable
->Map2Color4
, GL_MAP2_COLOR_4
);
494 TEST_AND_UPDATE(ctx
->Eval
.Map2Index
, enable
->Map2Index
, GL_MAP2_INDEX
);
495 TEST_AND_UPDATE(ctx
->Eval
.Map2Normal
, enable
->Map2Normal
, GL_MAP2_NORMAL
);
496 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord1
, enable
->Map2TextureCoord1
,
497 GL_MAP2_TEXTURE_COORD_1
);
498 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord2
, enable
->Map2TextureCoord2
,
499 GL_MAP2_TEXTURE_COORD_2
);
500 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord3
, enable
->Map2TextureCoord3
,
501 GL_MAP2_TEXTURE_COORD_3
);
502 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord4
, enable
->Map2TextureCoord4
,
503 GL_MAP2_TEXTURE_COORD_4
);
504 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex3
, enable
->Map2Vertex3
,
506 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex4
, enable
->Map2Vertex4
,
508 for (i
= 0; i
< 16; i
++) {
509 TEST_AND_UPDATE(ctx
->Eval
.Map2Attrib
[i
], enable
->Map2Attrib
[i
],
510 GL_MAP2_VERTEX_ATTRIB0_4_NV
+ i
);
513 TEST_AND_UPDATE(ctx
->Eval
.AutoNormal
, enable
->AutoNormal
, GL_AUTO_NORMAL
);
514 TEST_AND_UPDATE(ctx
->Transform
.Normalize
, enable
->Normalize
, GL_NORMALIZE
);
515 TEST_AND_UPDATE(ctx
->Transform
.RescaleNormals
, enable
->RescaleNormals
,
516 GL_RESCALE_NORMAL_EXT
);
517 TEST_AND_UPDATE(ctx
->Transform
.RasterPositionUnclipped
,
518 enable
->RasterPositionUnclipped
,
519 GL_RASTER_POSITION_UNCLIPPED_IBM
);
520 TEST_AND_UPDATE(ctx
->Point
.SmoothFlag
, enable
->PointSmooth
,
522 if (ctx
->Extensions
.NV_point_sprite
|| ctx
->Extensions
.ARB_point_sprite
) {
523 TEST_AND_UPDATE(ctx
->Point
.PointSprite
, enable
->PointSprite
,
526 TEST_AND_UPDATE(ctx
->Polygon
.OffsetPoint
, enable
->PolygonOffsetPoint
,
527 GL_POLYGON_OFFSET_POINT
);
528 TEST_AND_UPDATE(ctx
->Polygon
.OffsetLine
, enable
->PolygonOffsetLine
,
529 GL_POLYGON_OFFSET_LINE
);
530 TEST_AND_UPDATE(ctx
->Polygon
.OffsetFill
, enable
->PolygonOffsetFill
,
531 GL_POLYGON_OFFSET_FILL
);
532 TEST_AND_UPDATE(ctx
->Polygon
.SmoothFlag
, enable
->PolygonSmooth
,
534 TEST_AND_UPDATE(ctx
->Polygon
.StippleFlag
, enable
->PolygonStipple
,
536 TEST_AND_UPDATE(ctx
->Scissor
.Enabled
, enable
->Scissor
, GL_SCISSOR_TEST
);
537 TEST_AND_UPDATE(ctx
->Stencil
.Enabled
, enable
->Stencil
, GL_STENCIL_TEST
);
538 if (ctx
->Extensions
.EXT_stencil_two_side
) {
539 TEST_AND_UPDATE(ctx
->Stencil
.TestTwoSide
, enable
->StencilTwoSide
, GL_STENCIL_TEST_TWO_SIDE_EXT
);
541 TEST_AND_UPDATE(ctx
->Multisample
.Enabled
, enable
->MultisampleEnabled
,
543 TEST_AND_UPDATE(ctx
->Multisample
.SampleAlphaToCoverage
,
544 enable
->SampleAlphaToCoverage
,
545 GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
);
546 TEST_AND_UPDATE(ctx
->Multisample
.SampleAlphaToOne
,
547 enable
->SampleAlphaToOne
,
548 GL_SAMPLE_ALPHA_TO_ONE_ARB
);
549 TEST_AND_UPDATE(ctx
->Multisample
.SampleCoverage
,
550 enable
->SampleCoverage
,
551 GL_SAMPLE_COVERAGE_ARB
);
552 TEST_AND_UPDATE(ctx
->Multisample
.SampleCoverageInvert
,
553 enable
->SampleCoverageInvert
,
554 GL_SAMPLE_COVERAGE_INVERT_ARB
);
555 /* GL_ARB_vertex_program, GL_NV_vertex_program */
556 TEST_AND_UPDATE(ctx
->VertexProgram
.Enabled
,
557 enable
->VertexProgram
,
558 GL_VERTEX_PROGRAM_ARB
);
559 TEST_AND_UPDATE(ctx
->VertexProgram
.PointSizeEnabled
,
560 enable
->VertexProgramPointSize
,
561 GL_VERTEX_PROGRAM_POINT_SIZE_ARB
);
562 TEST_AND_UPDATE(ctx
->VertexProgram
.TwoSideEnabled
,
563 enable
->VertexProgramTwoSide
,
564 GL_VERTEX_PROGRAM_TWO_SIDE_ARB
);
566 #undef TEST_AND_UPDATE
568 /* texture unit enables */
569 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
570 if (ctx
->Texture
.Unit
[i
].Enabled
!= enable
->Texture
[i
]) {
571 ctx
->Texture
.Unit
[i
].Enabled
= enable
->Texture
[i
];
572 if (ctx
->Driver
.Enable
) {
573 if (ctx
->Driver
.ActiveTexture
) {
574 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
576 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_1D
,
577 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_1D_BIT
) );
578 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_2D
,
579 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_2D_BIT
) );
580 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_3D
,
581 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_3D_BIT
) );
582 if (ctx
->Extensions
.ARB_texture_cube_map
)
583 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_CUBE_MAP_ARB
,
584 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_CUBE_BIT
) );
585 if (ctx
->Extensions
.NV_texture_rectangle
)
586 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_RECTANGLE_NV
,
587 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_RECT_BIT
) );
591 if (ctx
->Texture
.Unit
[i
].TexGenEnabled
!= enable
->TexGen
[i
]) {
592 ctx
->Texture
.Unit
[i
].TexGenEnabled
= enable
->TexGen
[i
];
593 if (ctx
->Driver
.Enable
) {
594 if (ctx
->Driver
.ActiveTexture
) {
595 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
597 if (enable
->TexGen
[i
] & S_BIT
)
598 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_TRUE
);
600 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_FALSE
);
601 if (enable
->TexGen
[i
] & T_BIT
)
602 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_TRUE
);
604 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_FALSE
);
605 if (enable
->TexGen
[i
] & R_BIT
)
606 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_TRUE
);
608 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_FALSE
);
609 if (enable
->TexGen
[i
] & Q_BIT
)
610 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_TRUE
);
612 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_FALSE
);
616 /* GL_SGI_texture_color_table */
617 ctx
->Texture
.Unit
[i
].ColorTableEnabled
= enable
->TextureColorTable
[i
];
620 if (ctx
->Driver
.ActiveTexture
) {
621 (*ctx
->Driver
.ActiveTexture
)(ctx
, ctx
->Texture
.CurrentUnit
);
627 pop_texture_group(GLcontext
*ctx
, const struct gl_texture_attrib
*texAttrib
)
631 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
632 const struct gl_texture_unit
*unit
= &texAttrib
->Unit
[u
];
635 _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
+ u
);
636 _mesa_set_enable(ctx
, GL_TEXTURE_1D
,
637 (unit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
);
638 _mesa_set_enable(ctx
, GL_TEXTURE_2D
,
639 (unit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
);
640 _mesa_set_enable(ctx
, GL_TEXTURE_3D
,
641 (unit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
);
642 if (ctx
->Extensions
.ARB_texture_cube_map
) {
643 _mesa_set_enable(ctx
, GL_TEXTURE_CUBE_MAP_ARB
,
644 (unit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
);
646 if (ctx
->Extensions
.NV_texture_rectangle
) {
647 _mesa_set_enable(ctx
, GL_TEXTURE_RECTANGLE_NV
,
648 (unit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
);
650 if (ctx
->Extensions
.SGI_texture_color_table
) {
651 _mesa_set_enable(ctx
, GL_TEXTURE_COLOR_TABLE_SGI
,
652 unit
->ColorTableEnabled
);
654 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, unit
->EnvMode
);
655 _mesa_TexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, unit
->EnvColor
);
656 _mesa_TexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, unit
->GenModeS
);
657 _mesa_TexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, unit
->GenModeT
);
658 _mesa_TexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, unit
->GenModeR
);
659 _mesa_TexGeni(GL_Q
, GL_TEXTURE_GEN_MODE
, unit
->GenModeQ
);
660 _mesa_TexGenfv(GL_S
, GL_OBJECT_PLANE
, unit
->ObjectPlaneS
);
661 _mesa_TexGenfv(GL_T
, GL_OBJECT_PLANE
, unit
->ObjectPlaneT
);
662 _mesa_TexGenfv(GL_R
, GL_OBJECT_PLANE
, unit
->ObjectPlaneR
);
663 _mesa_TexGenfv(GL_Q
, GL_OBJECT_PLANE
, unit
->ObjectPlaneQ
);
664 /* Eye plane done differently to avoid re-transformation */
666 struct gl_texture_unit
*destUnit
= &ctx
->Texture
.Unit
[u
];
667 COPY_4FV(destUnit
->EyePlaneS
, unit
->EyePlaneS
);
668 COPY_4FV(destUnit
->EyePlaneT
, unit
->EyePlaneT
);
669 COPY_4FV(destUnit
->EyePlaneR
, unit
->EyePlaneR
);
670 COPY_4FV(destUnit
->EyePlaneQ
, unit
->EyePlaneQ
);
671 if (ctx
->Driver
.TexGen
) {
672 ctx
->Driver
.TexGen(ctx
, GL_S
, GL_EYE_PLANE
, unit
->EyePlaneS
);
673 ctx
->Driver
.TexGen(ctx
, GL_T
, GL_EYE_PLANE
, unit
->EyePlaneT
);
674 ctx
->Driver
.TexGen(ctx
, GL_R
, GL_EYE_PLANE
, unit
->EyePlaneR
);
675 ctx
->Driver
.TexGen(ctx
, GL_Q
, GL_EYE_PLANE
, unit
->EyePlaneQ
);
678 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_S
,
679 ((unit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
));
680 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_T
,
681 ((unit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
));
682 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_R
,
683 ((unit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
));
684 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_Q
,
685 ((unit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
));
686 if (ctx
->Extensions
.EXT_texture_lod_bias
) {
687 _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
688 GL_TEXTURE_LOD_BIAS_EXT
, unit
->LodBias
);
690 if (ctx
->Extensions
.EXT_texture_env_combine
||
691 ctx
->Extensions
.ARB_texture_env_combine
) {
692 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_COMBINE_RGB
,
693 unit
->Combine
.ModeRGB
);
694 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_COMBINE_ALPHA
,
695 unit
->Combine
.ModeA
);
696 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE0_RGB
,
697 unit
->Combine
.SourceRGB
[0]);
698 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE1_RGB
,
699 unit
->Combine
.SourceRGB
[1]);
700 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE2_RGB
,
701 unit
->Combine
.SourceRGB
[2]);
702 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE0_ALPHA
,
703 unit
->Combine
.SourceA
[0]);
704 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE1_ALPHA
,
705 unit
->Combine
.SourceA
[1]);
706 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE2_ALPHA
,
707 unit
->Combine
.SourceA
[2]);
708 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND0_RGB
,
709 unit
->Combine
.OperandRGB
[0]);
710 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND1_RGB
,
711 unit
->Combine
.OperandRGB
[1]);
712 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND2_RGB
,
713 unit
->Combine
.OperandRGB
[2]);
714 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND0_ALPHA
,
715 unit
->Combine
.OperandA
[0]);
716 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND1_ALPHA
,
717 unit
->Combine
.OperandA
[1]);
718 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND2_ALPHA
,
719 unit
->Combine
.OperandA
[2]);
720 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_RGB_SCALE
,
721 1 << unit
->Combine
.ScaleShiftRGB
);
722 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_ALPHA_SCALE
,
723 1 << unit
->Combine
.ScaleShiftA
);
726 /* Restore texture object state */
727 for (i
= 0; i
< NUM_TEXTURE_TARGETS
; i
++) {
729 const struct gl_texture_object
*obj
= NULL
;
730 GLfloat bordColor
[4];
734 target
= GL_TEXTURE_1D
;
735 obj
= &unit
->Saved1D
;
738 target
= GL_TEXTURE_2D
;
739 obj
= &unit
->Saved2D
;
742 target
= GL_TEXTURE_3D
;
743 obj
= &unit
->Saved3D
;
746 if (!ctx
->Extensions
.ARB_texture_cube_map
)
748 target
= GL_TEXTURE_CUBE_MAP_ARB
;
749 obj
= &unit
->SavedCubeMap
;
752 if (!ctx
->Extensions
.NV_texture_rectangle
)
754 target
= GL_TEXTURE_RECTANGLE_NV
;
755 obj
= &unit
->SavedRect
;
758 if (!ctx
->Extensions
.MESA_texture_array
)
760 target
= GL_TEXTURE_1D_ARRAY_EXT
;
761 obj
= &unit
->Saved1DArray
;
764 if (!ctx
->Extensions
.MESA_texture_array
)
766 target
= GL_TEXTURE_2D_ARRAY_EXT
;
767 obj
= &unit
->Saved2DArray
;
770 ; /* silence warnings */
773 _mesa_BindTexture(target
, obj
->Name
);
775 bordColor
[0] = CHAN_TO_FLOAT(obj
->BorderColor
[0]);
776 bordColor
[1] = CHAN_TO_FLOAT(obj
->BorderColor
[1]);
777 bordColor
[2] = CHAN_TO_FLOAT(obj
->BorderColor
[2]);
778 bordColor
[3] = CHAN_TO_FLOAT(obj
->BorderColor
[3]);
780 _mesa_TexParameterf(target
, GL_TEXTURE_PRIORITY
, obj
->Priority
);
781 _mesa_TexParameterfv(target
, GL_TEXTURE_BORDER_COLOR
, bordColor
);
782 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_S
, obj
->WrapS
);
783 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_T
, obj
->WrapT
);
784 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_R
, obj
->WrapR
);
785 _mesa_TexParameteri(target
, GL_TEXTURE_MIN_FILTER
, obj
->MinFilter
);
786 _mesa_TexParameteri(target
, GL_TEXTURE_MAG_FILTER
, obj
->MagFilter
);
787 _mesa_TexParameterf(target
, GL_TEXTURE_MIN_LOD
, obj
->MinLod
);
788 _mesa_TexParameterf(target
, GL_TEXTURE_MAX_LOD
, obj
->MaxLod
);
789 _mesa_TexParameterf(target
, GL_TEXTURE_LOD_BIAS
, obj
->LodBias
);
790 _mesa_TexParameteri(target
, GL_TEXTURE_BASE_LEVEL
, obj
->BaseLevel
);
791 if (target
!= GL_TEXTURE_RECTANGLE_ARB
)
792 _mesa_TexParameteri(target
, GL_TEXTURE_MAX_LEVEL
, obj
->MaxLevel
);
793 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
794 _mesa_TexParameterf(target
, GL_TEXTURE_MAX_ANISOTROPY_EXT
,
797 if (ctx
->Extensions
.SGIX_shadow
) {
798 _mesa_TexParameteri(target
, GL_TEXTURE_COMPARE_SGIX
,
800 _mesa_TexParameteri(target
, GL_TEXTURE_COMPARE_OPERATOR_SGIX
,
801 obj
->CompareOperator
);
803 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
804 _mesa_TexParameterf(target
, GL_SHADOW_AMBIENT_SGIX
,
810 _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
811 + texAttrib
->CurrentUnit
);
813 /* "un-bump" the texture object reference counts. We did that so they
814 * wouldn't inadvertantly get deleted while they were still referenced
815 * inside the attribute state stack.
817 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
818 ctx
->Texture
.Unit
[u
].Current1D
->RefCount
--;
819 ctx
->Texture
.Unit
[u
].Current2D
->RefCount
--;
820 ctx
->Texture
.Unit
[u
].Current3D
->RefCount
--;
821 ctx
->Texture
.Unit
[u
].CurrentCubeMap
->RefCount
--;
822 ctx
->Texture
.Unit
[u
].CurrentRect
->RefCount
--;
823 ctx
->Texture
.Unit
[u
].Current1DArray
->RefCount
--;
824 ctx
->Texture
.Unit
[u
].Current2DArray
->RefCount
--;
830 * This function is kind of long just because we have to call a lot
831 * of device driver functions to update device driver state.
833 * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions
834 * in order to restore GL state. This isn't terribly efficient but it
835 * ensures that dirty flags and any derived state gets updated correctly.
836 * We could at least check if the value to restore equals the current value
837 * and then skip the Mesa call.
840 _mesa_PopAttrib(void)
842 struct gl_attrib_node
*attr
, *next
;
843 GET_CURRENT_CONTEXT(ctx
);
844 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
846 if (ctx
->AttribStackDepth
== 0) {
847 _mesa_error( ctx
, GL_STACK_UNDERFLOW
, "glPopAttrib" );
851 ctx
->AttribStackDepth
--;
852 attr
= ctx
->AttribStack
[ctx
->AttribStackDepth
];
856 if (MESA_VERBOSE
& VERBOSE_API
) {
857 _mesa_debug(ctx
, "glPopAttrib %s\n",
858 _mesa_lookup_enum_by_nr(attr
->kind
));
861 switch (attr
->kind
) {
862 case GL_ACCUM_BUFFER_BIT
:
864 const struct gl_accum_attrib
*accum
;
865 accum
= (const struct gl_accum_attrib
*) attr
->data
;
866 _mesa_ClearAccum(accum
->ClearColor
[0],
867 accum
->ClearColor
[1],
868 accum
->ClearColor
[2],
869 accum
->ClearColor
[3]);
872 case GL_COLOR_BUFFER_BIT
:
874 const struct gl_colorbuffer_attrib
*color
;
875 color
= (const struct gl_colorbuffer_attrib
*) attr
->data
;
876 _mesa_ClearIndex((GLfloat
) color
->ClearIndex
);
877 _mesa_ClearColor(color
->ClearColor
[0],
878 color
->ClearColor
[1],
879 color
->ClearColor
[2],
880 color
->ClearColor
[3]);
881 _mesa_IndexMask(color
->IndexMask
);
882 _mesa_ColorMask((GLboolean
) (color
->ColorMask
[0] != 0),
883 (GLboolean
) (color
->ColorMask
[1] != 0),
884 (GLboolean
) (color
->ColorMask
[2] != 0),
885 (GLboolean
) (color
->ColorMask
[3] != 0));
887 /* Need to determine if more than one color output is
888 * specified. If so, call glDrawBuffersARB, else call
889 * glDrawBuffer(). This is a subtle, but essential point
890 * since GL_FRONT (for example) is illegal for the former
891 * function, but legal for the later.
893 GLboolean multipleBuffers
= GL_FALSE
;
894 if (ctx
->Extensions
.ARB_draw_buffers
) {
896 for (i
= 1; i
< ctx
->Const
.MaxDrawBuffers
; i
++) {
897 if (color
->DrawBuffer
[i
] != GL_NONE
) {
898 multipleBuffers
= GL_TRUE
;
903 /* Call the API_level functions, not _mesa_drawbuffers()
904 * since we need to do error checking on the pop'd
906 * Ex: if GL_FRONT were pushed, but we're popping with a
907 * user FBO bound, GL_FRONT will be illegal and we'll need
908 * to record that error. Per OpenGL ARB decision.
911 _mesa_DrawBuffersARB(ctx
->Const
.MaxDrawBuffers
,
914 _mesa_DrawBuffer(color
->DrawBuffer
[0]);
916 _mesa_set_enable(ctx
, GL_ALPHA_TEST
, color
->AlphaEnabled
);
917 _mesa_AlphaFunc(color
->AlphaFunc
, color
->AlphaRef
);
918 _mesa_set_enable(ctx
, GL_BLEND
, color
->BlendEnabled
);
919 _mesa_BlendFuncSeparateEXT(color
->BlendSrcRGB
,
923 /* This special case is because glBlendEquationSeparateEXT
924 * cannot take GL_LOGIC_OP as a parameter.
926 if ( color
->BlendEquationRGB
== color
->BlendEquationA
) {
927 _mesa_BlendEquation(color
->BlendEquationRGB
);
930 _mesa_BlendEquationSeparateEXT(color
->BlendEquationRGB
,
931 color
->BlendEquationA
);
933 _mesa_BlendColor(color
->BlendColor
[0],
934 color
->BlendColor
[1],
935 color
->BlendColor
[2],
936 color
->BlendColor
[3]);
937 _mesa_LogicOp(color
->LogicOp
);
938 _mesa_set_enable(ctx
, GL_COLOR_LOGIC_OP
,
939 color
->ColorLogicOpEnabled
);
940 _mesa_set_enable(ctx
, GL_INDEX_LOGIC_OP
,
941 color
->IndexLogicOpEnabled
);
942 _mesa_set_enable(ctx
, GL_DITHER
, color
->DitherFlag
);
946 FLUSH_CURRENT( ctx
, 0 );
947 MEMCPY( &ctx
->Current
, attr
->data
,
948 sizeof(struct gl_current_attrib
) );
950 case GL_DEPTH_BUFFER_BIT
:
952 const struct gl_depthbuffer_attrib
*depth
;
953 depth
= (const struct gl_depthbuffer_attrib
*) attr
->data
;
954 _mesa_DepthFunc(depth
->Func
);
955 _mesa_ClearDepth(depth
->Clear
);
956 _mesa_set_enable(ctx
, GL_DEPTH_TEST
, depth
->Test
);
957 _mesa_DepthMask(depth
->Mask
);
962 const struct gl_enable_attrib
*enable
;
963 enable
= (const struct gl_enable_attrib
*) attr
->data
;
964 pop_enable_group(ctx
, enable
);
965 ctx
->NewState
|= _NEW_ALL
;
969 MEMCPY( &ctx
->Eval
, attr
->data
, sizeof(struct gl_eval_attrib
) );
970 ctx
->NewState
|= _NEW_EVAL
;
974 const struct gl_fog_attrib
*fog
;
975 fog
= (const struct gl_fog_attrib
*) attr
->data
;
976 _mesa_set_enable(ctx
, GL_FOG
, fog
->Enabled
);
977 _mesa_Fogfv(GL_FOG_COLOR
, fog
->Color
);
978 _mesa_Fogf(GL_FOG_DENSITY
, fog
->Density
);
979 _mesa_Fogf(GL_FOG_START
, fog
->Start
);
980 _mesa_Fogf(GL_FOG_END
, fog
->End
);
981 _mesa_Fogf(GL_FOG_INDEX
, fog
->Index
);
982 _mesa_Fogi(GL_FOG_MODE
, fog
->Mode
);
987 const struct gl_hint_attrib
*hint
;
988 hint
= (const struct gl_hint_attrib
*) attr
->data
;
989 _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT
,
990 hint
->PerspectiveCorrection
);
991 _mesa_Hint(GL_POINT_SMOOTH_HINT
, hint
->PointSmooth
);
992 _mesa_Hint(GL_LINE_SMOOTH_HINT
, hint
->LineSmooth
);
993 _mesa_Hint(GL_POLYGON_SMOOTH_HINT
, hint
->PolygonSmooth
);
994 _mesa_Hint(GL_FOG_HINT
, hint
->Fog
);
995 _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT
,
996 hint
->ClipVolumeClipping
);
997 if (ctx
->Extensions
.ARB_texture_compression
)
998 _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB
,
999 hint
->TextureCompression
);
1002 case GL_LIGHTING_BIT
:
1005 const struct gl_light_attrib
*light
;
1006 light
= (const struct gl_light_attrib
*) attr
->data
;
1007 /* lighting enable */
1008 _mesa_set_enable(ctx
, GL_LIGHTING
, light
->Enabled
);
1009 /* per-light state */
1010 if (_math_matrix_is_dirty(ctx
->ModelviewMatrixStack
.Top
))
1011 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1013 for (i
= 0; i
< ctx
->Const
.MaxLights
; i
++) {
1014 const struct gl_light
*l
= &light
->Light
[i
];
1015 _mesa_set_enable(ctx
, GL_LIGHT0
+ i
, l
->Enabled
);
1016 _mesa_light(ctx
, i
, GL_AMBIENT
, l
->Ambient
);
1017 _mesa_light(ctx
, i
, GL_DIFFUSE
, l
->Diffuse
);
1018 _mesa_light(ctx
, i
, GL_SPECULAR
, l
->Specular
);
1019 _mesa_light(ctx
, i
, GL_POSITION
, l
->EyePosition
);
1020 _mesa_light(ctx
, i
, GL_SPOT_DIRECTION
, l
->EyeDirection
);
1021 _mesa_light(ctx
, i
, GL_SPOT_EXPONENT
, &l
->SpotExponent
);
1022 _mesa_light(ctx
, i
, GL_SPOT_CUTOFF
, &l
->SpotCutoff
);
1023 _mesa_light(ctx
, i
, GL_CONSTANT_ATTENUATION
,
1024 &l
->ConstantAttenuation
);
1025 _mesa_light(ctx
, i
, GL_LINEAR_ATTENUATION
,
1026 &l
->LinearAttenuation
);
1027 _mesa_light(ctx
, i
, GL_QUADRATIC_ATTENUATION
,
1028 &l
->QuadraticAttenuation
);
1031 _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT
,
1032 light
->Model
.Ambient
);
1033 _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER
,
1034 (GLfloat
) light
->Model
.LocalViewer
);
1035 _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE
,
1036 (GLfloat
) light
->Model
.TwoSide
);
1037 _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL
,
1038 (GLfloat
) light
->Model
.ColorControl
);
1040 _mesa_ShadeModel(light
->ShadeModel
);
1041 /* color material */
1042 _mesa_ColorMaterial(light
->ColorMaterialFace
,
1043 light
->ColorMaterialMode
);
1044 _mesa_set_enable(ctx
, GL_COLOR_MATERIAL
,
1045 light
->ColorMaterialEnabled
);
1047 MEMCPY(&ctx
->Light
.Material
, &light
->Material
,
1048 sizeof(struct gl_material
));
1053 const struct gl_line_attrib
*line
;
1054 line
= (const struct gl_line_attrib
*) attr
->data
;
1055 _mesa_set_enable(ctx
, GL_LINE_SMOOTH
, line
->SmoothFlag
);
1056 _mesa_set_enable(ctx
, GL_LINE_STIPPLE
, line
->StippleFlag
);
1057 _mesa_LineStipple(line
->StippleFactor
, line
->StipplePattern
);
1058 _mesa_LineWidth(line
->Width
);
1062 MEMCPY( &ctx
->List
, attr
->data
, sizeof(struct gl_list_attrib
) );
1064 case GL_PIXEL_MODE_BIT
:
1065 MEMCPY( &ctx
->Pixel
, attr
->data
, sizeof(struct gl_pixel_attrib
) );
1066 /* XXX what other pixel state needs to be set by function calls? */
1067 _mesa_ReadBuffer(ctx
->Pixel
.ReadBuffer
);
1068 ctx
->NewState
|= _NEW_PIXEL
;
1072 const struct gl_point_attrib
*point
;
1073 point
= (const struct gl_point_attrib
*) attr
->data
;
1074 _mesa_PointSize(point
->Size
);
1075 _mesa_set_enable(ctx
, GL_POINT_SMOOTH
, point
->SmoothFlag
);
1076 if (ctx
->Extensions
.EXT_point_parameters
) {
1077 _mesa_PointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT
,
1079 _mesa_PointParameterfEXT(GL_POINT_SIZE_MIN_EXT
,
1081 _mesa_PointParameterfEXT(GL_POINT_SIZE_MAX_EXT
,
1083 _mesa_PointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT
,
1086 if (ctx
->Extensions
.NV_point_sprite
1087 || ctx
->Extensions
.ARB_point_sprite
) {
1089 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
1090 _mesa_TexEnvi(GL_POINT_SPRITE_NV
, GL_COORD_REPLACE_NV
,
1091 (GLint
) point
->CoordReplace
[u
]);
1093 _mesa_set_enable(ctx
, GL_POINT_SPRITE_NV
,point
->PointSprite
);
1094 _mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV
,
1095 ctx
->Point
.SpriteRMode
);
1096 _mesa_PointParameterfEXT(GL_POINT_SPRITE_COORD_ORIGIN
,
1097 (GLfloat
)ctx
->Point
.SpriteOrigin
);
1101 case GL_POLYGON_BIT
:
1103 const struct gl_polygon_attrib
*polygon
;
1104 polygon
= (const struct gl_polygon_attrib
*) attr
->data
;
1105 _mesa_CullFace(polygon
->CullFaceMode
);
1106 _mesa_FrontFace(polygon
->FrontFace
);
1107 _mesa_PolygonMode(GL_FRONT
, polygon
->FrontMode
);
1108 _mesa_PolygonMode(GL_BACK
, polygon
->BackMode
);
1109 _mesa_PolygonOffset(polygon
->OffsetFactor
,
1110 polygon
->OffsetUnits
);
1111 _mesa_set_enable(ctx
, GL_POLYGON_SMOOTH
, polygon
->SmoothFlag
);
1112 _mesa_set_enable(ctx
, GL_POLYGON_STIPPLE
, polygon
->StippleFlag
);
1113 _mesa_set_enable(ctx
, GL_CULL_FACE
, polygon
->CullFlag
);
1114 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_POINT
,
1115 polygon
->OffsetPoint
);
1116 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_LINE
,
1117 polygon
->OffsetLine
);
1118 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_FILL
,
1119 polygon
->OffsetFill
);
1122 case GL_POLYGON_STIPPLE_BIT
:
1123 MEMCPY( ctx
->PolygonStipple
, attr
->data
, 32*sizeof(GLuint
) );
1124 ctx
->NewState
|= _NEW_POLYGONSTIPPLE
;
1125 if (ctx
->Driver
.PolygonStipple
)
1126 ctx
->Driver
.PolygonStipple( ctx
, (const GLubyte
*) attr
->data
);
1128 case GL_SCISSOR_BIT
:
1130 const struct gl_scissor_attrib
*scissor
;
1131 scissor
= (const struct gl_scissor_attrib
*) attr
->data
;
1132 _mesa_Scissor(scissor
->X
, scissor
->Y
,
1133 scissor
->Width
, scissor
->Height
);
1134 _mesa_set_enable(ctx
, GL_SCISSOR_TEST
, scissor
->Enabled
);
1137 case GL_STENCIL_BUFFER_BIT
:
1139 const struct gl_stencil_attrib
*stencil
;
1140 stencil
= (const struct gl_stencil_attrib
*) attr
->data
;
1141 _mesa_set_enable(ctx
, GL_STENCIL_TEST
, stencil
->Enabled
);
1142 _mesa_ClearStencil(stencil
->Clear
);
1143 if (ctx
->Extensions
.EXT_stencil_two_side
) {
1144 _mesa_set_enable(ctx
, GL_STENCIL_TEST_TWO_SIDE_EXT
,
1145 stencil
->TestTwoSide
);
1146 _mesa_ActiveStencilFaceEXT(stencil
->ActiveFace
1147 ? GL_BACK
: GL_FRONT
);
1150 _mesa_StencilFuncSeparate(GL_FRONT
,
1151 stencil
->Function
[0],
1153 stencil
->ValueMask
[0]);
1154 _mesa_StencilMaskSeparate(GL_FRONT
, stencil
->WriteMask
[0]);
1155 _mesa_StencilOpSeparate(GL_FRONT
, stencil
->FailFunc
[0],
1156 stencil
->ZFailFunc
[0],
1157 stencil
->ZPassFunc
[0]);
1159 _mesa_StencilFuncSeparate(GL_BACK
,
1160 stencil
->Function
[1],
1162 stencil
->ValueMask
[1]);
1163 _mesa_StencilMaskSeparate(GL_BACK
, stencil
->WriteMask
[1]);
1164 _mesa_StencilOpSeparate(GL_BACK
, stencil
->FailFunc
[1],
1165 stencil
->ZFailFunc
[1],
1166 stencil
->ZPassFunc
[1]);
1169 case GL_TRANSFORM_BIT
:
1172 const struct gl_transform_attrib
*xform
;
1173 xform
= (const struct gl_transform_attrib
*) attr
->data
;
1174 _mesa_MatrixMode(xform
->MatrixMode
);
1175 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
1176 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
1178 /* restore clip planes */
1179 for (i
= 0; i
< MAX_CLIP_PLANES
; i
++) {
1180 const GLuint mask
= 1 << 1;
1181 const GLfloat
*eyePlane
= xform
->EyeUserPlane
[i
];
1182 COPY_4V(ctx
->Transform
.EyeUserPlane
[i
], eyePlane
);
1183 if (xform
->ClipPlanesEnabled
& mask
) {
1184 _mesa_set_enable(ctx
, GL_CLIP_PLANE0
+ i
, GL_TRUE
);
1187 _mesa_set_enable(ctx
, GL_CLIP_PLANE0
+ i
, GL_FALSE
);
1189 if (ctx
->Driver
.ClipPlane
)
1190 ctx
->Driver
.ClipPlane( ctx
, GL_CLIP_PLANE0
+ i
, eyePlane
);
1193 /* normalize/rescale */
1194 if (xform
->Normalize
!= ctx
->Transform
.Normalize
)
1195 _mesa_set_enable(ctx
, GL_NORMALIZE
,ctx
->Transform
.Normalize
);
1196 if (xform
->RescaleNormals
!= ctx
->Transform
.RescaleNormals
)
1197 _mesa_set_enable(ctx
, GL_RESCALE_NORMAL_EXT
,
1198 ctx
->Transform
.RescaleNormals
);
1201 case GL_TEXTURE_BIT
:
1202 /* Take care of texture object reference counters */
1204 const struct gl_texture_attrib
*texture
;
1205 texture
= (const struct gl_texture_attrib
*) attr
->data
;
1206 pop_texture_group(ctx
, texture
);
1207 ctx
->NewState
|= _NEW_TEXTURE
;
1210 case GL_VIEWPORT_BIT
:
1212 const struct gl_viewport_attrib
*vp
;
1213 vp
= (const struct gl_viewport_attrib
*) attr
->data
;
1214 _mesa_Viewport(vp
->X
, vp
->Y
, vp
->Width
, vp
->Height
);
1215 _mesa_DepthRange(vp
->Near
, vp
->Far
);
1218 case GL_MULTISAMPLE_BIT_ARB
:
1220 const struct gl_multisample_attrib
*ms
;
1221 ms
= (const struct gl_multisample_attrib
*) attr
->data
;
1222 _mesa_SampleCoverageARB(ms
->SampleCoverageValue
,
1223 ms
->SampleCoverageInvert
);
1228 _mesa_problem( ctx
, "Bad attrib flag in PopAttrib");
1241 * Helper for incrementing/decrementing vertex buffer object reference
1242 * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group.
1245 adjust_buffer_object_ref_counts(struct gl_array_attrib
*array
, GLint step
)
1248 array
->ArrayObj
->Vertex
.BufferObj
->RefCount
+= step
;
1249 array
->ArrayObj
->Normal
.BufferObj
->RefCount
+= step
;
1250 array
->ArrayObj
->Color
.BufferObj
->RefCount
+= step
;
1251 array
->ArrayObj
->SecondaryColor
.BufferObj
->RefCount
+= step
;
1252 array
->ArrayObj
->FogCoord
.BufferObj
->RefCount
+= step
;
1253 array
->ArrayObj
->Index
.BufferObj
->RefCount
+= step
;
1254 array
->ArrayObj
->EdgeFlag
.BufferObj
->RefCount
+= step
;
1255 for (i
= 0; i
< MAX_TEXTURE_COORD_UNITS
; i
++)
1256 array
->ArrayObj
->TexCoord
[i
].BufferObj
->RefCount
+= step
;
1257 for (i
= 0; i
< VERT_ATTRIB_MAX
; i
++)
1258 array
->ArrayObj
->VertexAttrib
[i
].BufferObj
->RefCount
+= step
;
1260 array
->ArrayBufferObj
->RefCount
+= step
;
1261 array
->ElementArrayBufferObj
->RefCount
+= step
;
1265 #define GL_CLIENT_PACK_BIT (1<<20)
1266 #define GL_CLIENT_UNPACK_BIT (1<<21)
1270 _mesa_PushClientAttrib(GLbitfield mask
)
1272 struct gl_attrib_node
*newnode
;
1273 struct gl_attrib_node
*head
;
1275 GET_CURRENT_CONTEXT(ctx
);
1276 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1278 if (ctx
->ClientAttribStackDepth
>= MAX_CLIENT_ATTRIB_STACK_DEPTH
) {
1279 _mesa_error( ctx
, GL_STACK_OVERFLOW
, "glPushClientAttrib" );
1283 /* Build linked list of attribute nodes which save all attribute */
1284 /* groups specified by the mask. */
1287 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
1288 struct gl_pixelstore_attrib
*attr
;
1289 #if FEATURE_EXT_pixel_buffer_object
1290 ctx
->Pack
.BufferObj
->RefCount
++;
1291 ctx
->Unpack
.BufferObj
->RefCount
++;
1293 /* packing attribs */
1294 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
1295 MEMCPY( attr
, &ctx
->Pack
, sizeof(struct gl_pixelstore_attrib
) );
1296 newnode
= new_attrib_node( GL_CLIENT_PACK_BIT
);
1297 newnode
->data
= attr
;
1298 newnode
->next
= head
;
1300 /* unpacking attribs */
1301 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
1302 MEMCPY( attr
, &ctx
->Unpack
, sizeof(struct gl_pixelstore_attrib
) );
1303 newnode
= new_attrib_node( GL_CLIENT_UNPACK_BIT
);
1304 newnode
->data
= attr
;
1305 newnode
->next
= head
;
1308 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
1309 struct gl_array_attrib
*attr
;
1310 struct gl_array_object
*obj
;
1312 attr
= MALLOC_STRUCT( gl_array_attrib
);
1313 obj
= MALLOC_STRUCT( gl_array_object
);
1315 #if FEATURE_ARB_vertex_buffer_object
1316 /* increment ref counts since we're copying pointers to these objects */
1317 ctx
->Array
.ArrayBufferObj
->RefCount
++;
1318 ctx
->Array
.ElementArrayBufferObj
->RefCount
++;
1321 MEMCPY( attr
, &ctx
->Array
, sizeof(struct gl_array_attrib
) );
1322 MEMCPY( obj
, ctx
->Array
.ArrayObj
, sizeof(struct gl_array_object
) );
1324 attr
->ArrayObj
= obj
;
1326 newnode
= new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT
);
1327 newnode
->data
= attr
;
1328 newnode
->next
= head
;
1330 /* bump reference counts on buffer objects */
1331 adjust_buffer_object_ref_counts(&ctx
->Array
, 1);
1334 ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
] = head
;
1335 ctx
->ClientAttribStackDepth
++;
1342 _mesa_PopClientAttrib(void)
1344 struct gl_attrib_node
*attr
, *next
;
1346 GET_CURRENT_CONTEXT(ctx
);
1347 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
1349 if (ctx
->ClientAttribStackDepth
== 0) {
1350 _mesa_error( ctx
, GL_STACK_UNDERFLOW
, "glPopClientAttrib" );
1354 ctx
->ClientAttribStackDepth
--;
1355 attr
= ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
];
1358 switch (attr
->kind
) {
1359 case GL_CLIENT_PACK_BIT
:
1360 #if FEATURE_EXT_pixel_buffer_object
1361 ctx
->Pack
.BufferObj
->RefCount
--;
1362 if (ctx
->Pack
.BufferObj
->RefCount
<= 0) {
1363 _mesa_remove_buffer_object( ctx
, ctx
->Pack
.BufferObj
);
1364 (*ctx
->Driver
.DeleteBuffer
)( ctx
, ctx
->Pack
.BufferObj
);
1367 MEMCPY( &ctx
->Pack
, attr
->data
,
1368 sizeof(struct gl_pixelstore_attrib
) );
1369 ctx
->NewState
|= _NEW_PACKUNPACK
;
1371 case GL_CLIENT_UNPACK_BIT
:
1372 #if FEATURE_EXT_pixel_buffer_object
1373 ctx
->Unpack
.BufferObj
->RefCount
--;
1374 if (ctx
->Unpack
.BufferObj
->RefCount
<= 0) {
1375 _mesa_remove_buffer_object( ctx
, ctx
->Unpack
.BufferObj
);
1376 (*ctx
->Driver
.DeleteBuffer
)( ctx
, ctx
->Unpack
.BufferObj
);
1379 MEMCPY( &ctx
->Unpack
, attr
->data
,
1380 sizeof(struct gl_pixelstore_attrib
) );
1381 ctx
->NewState
|= _NEW_PACKUNPACK
;
1383 case GL_CLIENT_VERTEX_ARRAY_BIT
: {
1384 struct gl_array_attrib
* data
=
1385 (struct gl_array_attrib
*) attr
->data
;
1387 adjust_buffer_object_ref_counts(&ctx
->Array
, -1);
1389 ctx
->Array
.ActiveTexture
= data
->ActiveTexture
;
1390 ctx
->Array
.LockFirst
= data
->LockFirst
;
1391 ctx
->Array
.LockCount
= data
->LockCount
;
1393 _mesa_BindVertexArrayAPPLE( data
->ArrayObj
->Name
);
1395 #if FEATURE_ARB_vertex_buffer_object
1396 _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB
,
1397 data
->ArrayBufferObj
->Name
);
1398 _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
,
1399 data
->ElementArrayBufferObj
->Name
);
1402 MEMCPY( ctx
->Array
.ArrayObj
, data
->ArrayObj
,
1403 sizeof( struct gl_array_object
) );
1405 FREE( data
->ArrayObj
);
1407 /* FIXME: Should some bits in ctx->Array->NewState also be set
1408 * FIXME: here? It seems like it should be set to inclusive-or
1409 * FIXME: of the old ArrayObj->_Enabled and the new _Enabled.
1412 ctx
->NewState
|= _NEW_ARRAY
;
1416 _mesa_problem( ctx
, "Bad attrib flag in PopClientAttrib");
1428 void _mesa_init_attrib( GLcontext
*ctx
)
1430 /* Renderer and client attribute stacks */
1431 ctx
->AttribStackDepth
= 0;
1432 ctx
->ClientAttribStackDepth
= 0;