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
) {
101 struct gl_colorbuffer_attrib
*attr
;
102 attr
= MALLOC_STRUCT( gl_colorbuffer_attrib
);
103 MEMCPY( attr
, &ctx
->Color
, sizeof(struct gl_colorbuffer_attrib
) );
104 newnode
= new_attrib_node( GL_COLOR_BUFFER_BIT
);
105 newnode
->data
= attr
;
106 newnode
->next
= head
;
110 if (mask
& GL_CURRENT_BIT
) {
111 struct gl_current_attrib
*attr
;
112 FLUSH_CURRENT( ctx
, 0 );
113 attr
= MALLOC_STRUCT( gl_current_attrib
);
114 MEMCPY( attr
, &ctx
->Current
, sizeof(struct gl_current_attrib
) );
115 newnode
= new_attrib_node( GL_CURRENT_BIT
);
116 newnode
->data
= attr
;
117 newnode
->next
= head
;
121 if (mask
& GL_DEPTH_BUFFER_BIT
) {
122 struct gl_depthbuffer_attrib
*attr
;
123 attr
= MALLOC_STRUCT( gl_depthbuffer_attrib
);
124 MEMCPY( attr
, &ctx
->Depth
, sizeof(struct gl_depthbuffer_attrib
) );
125 newnode
= new_attrib_node( GL_DEPTH_BUFFER_BIT
);
126 newnode
->data
= attr
;
127 newnode
->next
= head
;
131 if (mask
& GL_ENABLE_BIT
) {
132 struct gl_enable_attrib
*attr
;
134 attr
= MALLOC_STRUCT( gl_enable_attrib
);
135 /* Copy enable flags from all other attributes into the enable struct. */
136 attr
->AlphaTest
= ctx
->Color
.AlphaEnabled
;
137 attr
->AutoNormal
= ctx
->Eval
.AutoNormal
;
138 attr
->Blend
= ctx
->Color
.BlendEnabled
;
139 attr
->ClipPlanes
= ctx
->Transform
.ClipPlanesEnabled
;
140 attr
->ColorMaterial
= ctx
->Light
.ColorMaterialEnabled
;
141 for (i
= 0; i
< COLORTABLE_MAX
; i
++) {
142 attr
->ColorTable
[i
] = ctx
->Pixel
.ColorTableEnabled
[i
];
144 attr
->Convolution1D
= ctx
->Pixel
.Convolution1DEnabled
;
145 attr
->Convolution2D
= ctx
->Pixel
.Convolution2DEnabled
;
146 attr
->Separable2D
= ctx
->Pixel
.Separable2DEnabled
;
147 attr
->CullFace
= ctx
->Polygon
.CullFlag
;
148 attr
->DepthTest
= ctx
->Depth
.Test
;
149 attr
->Dither
= ctx
->Color
.DitherFlag
;
150 attr
->Fog
= ctx
->Fog
.Enabled
;
151 for (i
= 0; i
< ctx
->Const
.MaxLights
; i
++) {
152 attr
->Light
[i
] = ctx
->Light
.Light
[i
].Enabled
;
154 attr
->Lighting
= ctx
->Light
.Enabled
;
155 attr
->LineSmooth
= ctx
->Line
.SmoothFlag
;
156 attr
->LineStipple
= ctx
->Line
.StippleFlag
;
157 attr
->Histogram
= ctx
->Pixel
.HistogramEnabled
;
158 attr
->MinMax
= ctx
->Pixel
.MinMaxEnabled
;
159 attr
->IndexLogicOp
= ctx
->Color
.IndexLogicOpEnabled
;
160 attr
->ColorLogicOp
= ctx
->Color
.ColorLogicOpEnabled
;
161 attr
->Map1Color4
= ctx
->Eval
.Map1Color4
;
162 attr
->Map1Index
= ctx
->Eval
.Map1Index
;
163 attr
->Map1Normal
= ctx
->Eval
.Map1Normal
;
164 attr
->Map1TextureCoord1
= ctx
->Eval
.Map1TextureCoord1
;
165 attr
->Map1TextureCoord2
= ctx
->Eval
.Map1TextureCoord2
;
166 attr
->Map1TextureCoord3
= ctx
->Eval
.Map1TextureCoord3
;
167 attr
->Map1TextureCoord4
= ctx
->Eval
.Map1TextureCoord4
;
168 attr
->Map1Vertex3
= ctx
->Eval
.Map1Vertex3
;
169 attr
->Map1Vertex4
= ctx
->Eval
.Map1Vertex4
;
170 MEMCPY(attr
->Map1Attrib
, ctx
->Eval
.Map1Attrib
, sizeof(ctx
->Eval
.Map1Attrib
));
171 attr
->Map2Color4
= ctx
->Eval
.Map2Color4
;
172 attr
->Map2Index
= ctx
->Eval
.Map2Index
;
173 attr
->Map2Normal
= ctx
->Eval
.Map2Normal
;
174 attr
->Map2TextureCoord1
= ctx
->Eval
.Map2TextureCoord1
;
175 attr
->Map2TextureCoord2
= ctx
->Eval
.Map2TextureCoord2
;
176 attr
->Map2TextureCoord3
= ctx
->Eval
.Map2TextureCoord3
;
177 attr
->Map2TextureCoord4
= ctx
->Eval
.Map2TextureCoord4
;
178 attr
->Map2Vertex3
= ctx
->Eval
.Map2Vertex3
;
179 attr
->Map2Vertex4
= ctx
->Eval
.Map2Vertex4
;
180 MEMCPY(attr
->Map2Attrib
, ctx
->Eval
.Map2Attrib
, sizeof(ctx
->Eval
.Map2Attrib
));
181 attr
->Normalize
= ctx
->Transform
.Normalize
;
182 attr
->RasterPositionUnclipped
= ctx
->Transform
.RasterPositionUnclipped
;
183 attr
->PointSmooth
= ctx
->Point
.SmoothFlag
;
184 attr
->PointSprite
= ctx
->Point
.PointSprite
;
185 attr
->PolygonOffsetPoint
= ctx
->Polygon
.OffsetPoint
;
186 attr
->PolygonOffsetLine
= ctx
->Polygon
.OffsetLine
;
187 attr
->PolygonOffsetFill
= ctx
->Polygon
.OffsetFill
;
188 attr
->PolygonSmooth
= ctx
->Polygon
.SmoothFlag
;
189 attr
->PolygonStipple
= ctx
->Polygon
.StippleFlag
;
190 attr
->RescaleNormals
= ctx
->Transform
.RescaleNormals
;
191 attr
->Scissor
= ctx
->Scissor
.Enabled
;
192 attr
->Stencil
= ctx
->Stencil
.Enabled
;
193 attr
->StencilTwoSide
= ctx
->Stencil
.TestTwoSide
;
194 attr
->MultisampleEnabled
= ctx
->Multisample
.Enabled
;
195 attr
->SampleAlphaToCoverage
= ctx
->Multisample
.SampleAlphaToCoverage
;
196 attr
->SampleAlphaToOne
= ctx
->Multisample
.SampleAlphaToOne
;
197 attr
->SampleCoverage
= ctx
->Multisample
.SampleCoverage
;
198 attr
->SampleCoverageInvert
= ctx
->Multisample
.SampleCoverageInvert
;
199 for (i
=0; i
<MAX_TEXTURE_UNITS
; i
++) {
200 attr
->Texture
[i
] = ctx
->Texture
.Unit
[i
].Enabled
;
201 attr
->TexGen
[i
] = ctx
->Texture
.Unit
[i
].TexGenEnabled
;
202 attr
->TextureColorTable
[i
] = ctx
->Texture
.Unit
[i
].ColorTableEnabled
;
204 /* GL_NV_vertex_program */
205 attr
->VertexProgram
= ctx
->VertexProgram
.Enabled
;
206 attr
->VertexProgramPointSize
= ctx
->VertexProgram
.PointSizeEnabled
;
207 attr
->VertexProgramTwoSide
= ctx
->VertexProgram
.TwoSideEnabled
;
208 newnode
= new_attrib_node( GL_ENABLE_BIT
);
209 newnode
->data
= attr
;
210 newnode
->next
= head
;
214 if (mask
& GL_EVAL_BIT
) {
215 struct gl_eval_attrib
*attr
;
216 attr
= MALLOC_STRUCT( gl_eval_attrib
);
217 MEMCPY( attr
, &ctx
->Eval
, sizeof(struct gl_eval_attrib
) );
218 newnode
= new_attrib_node( GL_EVAL_BIT
);
219 newnode
->data
= attr
;
220 newnode
->next
= head
;
224 if (mask
& GL_FOG_BIT
) {
225 struct gl_fog_attrib
*attr
;
226 attr
= MALLOC_STRUCT( gl_fog_attrib
);
227 MEMCPY( attr
, &ctx
->Fog
, sizeof(struct gl_fog_attrib
) );
228 newnode
= new_attrib_node( GL_FOG_BIT
);
229 newnode
->data
= attr
;
230 newnode
->next
= head
;
234 if (mask
& GL_HINT_BIT
) {
235 struct gl_hint_attrib
*attr
;
236 attr
= MALLOC_STRUCT( gl_hint_attrib
);
237 MEMCPY( attr
, &ctx
->Hint
, sizeof(struct gl_hint_attrib
) );
238 newnode
= new_attrib_node( GL_HINT_BIT
);
239 newnode
->data
= attr
;
240 newnode
->next
= head
;
244 if (mask
& GL_LIGHTING_BIT
) {
245 struct gl_light_attrib
*attr
;
246 FLUSH_CURRENT(ctx
, 0); /* flush material changes */
247 attr
= MALLOC_STRUCT( gl_light_attrib
);
248 MEMCPY( attr
, &ctx
->Light
, sizeof(struct gl_light_attrib
) );
249 newnode
= new_attrib_node( GL_LIGHTING_BIT
);
250 newnode
->data
= attr
;
251 newnode
->next
= head
;
255 if (mask
& GL_LINE_BIT
) {
256 struct gl_line_attrib
*attr
;
257 attr
= MALLOC_STRUCT( gl_line_attrib
);
258 MEMCPY( attr
, &ctx
->Line
, sizeof(struct gl_line_attrib
) );
259 newnode
= new_attrib_node( GL_LINE_BIT
);
260 newnode
->data
= attr
;
261 newnode
->next
= head
;
265 if (mask
& GL_LIST_BIT
) {
266 struct gl_list_attrib
*attr
;
267 attr
= MALLOC_STRUCT( gl_list_attrib
);
268 MEMCPY( attr
, &ctx
->List
, sizeof(struct gl_list_attrib
) );
269 newnode
= new_attrib_node( GL_LIST_BIT
);
270 newnode
->data
= attr
;
271 newnode
->next
= head
;
275 if (mask
& GL_PIXEL_MODE_BIT
) {
276 struct gl_pixel_attrib
*attr
;
277 attr
= MALLOC_STRUCT( gl_pixel_attrib
);
278 MEMCPY( attr
, &ctx
->Pixel
, sizeof(struct gl_pixel_attrib
) );
279 /* push the Read FBO's ReadBuffer state, not ctx->Pixel.ReadBuffer */
280 attr
->ReadBuffer
= ctx
->ReadBuffer
->ColorReadBuffer
;
281 newnode
= new_attrib_node( GL_PIXEL_MODE_BIT
);
282 newnode
->data
= attr
;
283 newnode
->next
= head
;
287 if (mask
& GL_POINT_BIT
) {
288 struct gl_point_attrib
*attr
;
289 attr
= MALLOC_STRUCT( gl_point_attrib
);
290 MEMCPY( attr
, &ctx
->Point
, sizeof(struct gl_point_attrib
) );
291 newnode
= new_attrib_node( GL_POINT_BIT
);
292 newnode
->data
= attr
;
293 newnode
->next
= head
;
297 if (mask
& GL_POLYGON_BIT
) {
298 struct gl_polygon_attrib
*attr
;
299 attr
= MALLOC_STRUCT( gl_polygon_attrib
);
300 MEMCPY( attr
, &ctx
->Polygon
, sizeof(struct gl_polygon_attrib
) );
301 newnode
= new_attrib_node( GL_POLYGON_BIT
);
302 newnode
->data
= attr
;
303 newnode
->next
= head
;
307 if (mask
& GL_POLYGON_STIPPLE_BIT
) {
309 stipple
= (GLuint
*) MALLOC( 32*sizeof(GLuint
) );
310 MEMCPY( stipple
, ctx
->PolygonStipple
, 32*sizeof(GLuint
) );
311 newnode
= new_attrib_node( GL_POLYGON_STIPPLE_BIT
);
312 newnode
->data
= stipple
;
313 newnode
->next
= head
;
317 if (mask
& GL_SCISSOR_BIT
) {
318 struct gl_scissor_attrib
*attr
;
319 attr
= MALLOC_STRUCT( gl_scissor_attrib
);
320 MEMCPY( attr
, &ctx
->Scissor
, sizeof(struct gl_scissor_attrib
) );
321 newnode
= new_attrib_node( GL_SCISSOR_BIT
);
322 newnode
->data
= attr
;
323 newnode
->next
= head
;
327 if (mask
& GL_STENCIL_BUFFER_BIT
) {
328 struct gl_stencil_attrib
*attr
;
329 attr
= MALLOC_STRUCT( gl_stencil_attrib
);
330 MEMCPY( attr
, &ctx
->Stencil
, sizeof(struct gl_stencil_attrib
) );
331 newnode
= new_attrib_node( GL_STENCIL_BUFFER_BIT
);
332 newnode
->data
= attr
;
333 newnode
->next
= head
;
337 if (mask
& GL_TEXTURE_BIT
) {
338 struct gl_texture_attrib
*attr
;
341 _mesa_lock_context_textures(ctx
);
342 /* Bump the texture object reference counts so that they don't
343 * inadvertantly get deleted.
345 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
346 ctx
->Texture
.Unit
[u
].Current1D
->RefCount
++;
347 ctx
->Texture
.Unit
[u
].Current2D
->RefCount
++;
348 ctx
->Texture
.Unit
[u
].Current3D
->RefCount
++;
349 ctx
->Texture
.Unit
[u
].CurrentCubeMap
->RefCount
++;
350 ctx
->Texture
.Unit
[u
].CurrentRect
->RefCount
++;
351 ctx
->Texture
.Unit
[u
].Current1DArray
->RefCount
++;
352 ctx
->Texture
.Unit
[u
].Current2DArray
->RefCount
++;
354 attr
= MALLOC_STRUCT( gl_texture_attrib
);
355 MEMCPY( attr
, &ctx
->Texture
, sizeof(struct gl_texture_attrib
) );
356 /* copy state of the currently bound texture objects */
357 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
358 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved1D
,
359 attr
->Unit
[u
].Current1D
);
360 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved2D
,
361 attr
->Unit
[u
].Current2D
);
362 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved3D
,
363 attr
->Unit
[u
].Current3D
);
364 _mesa_copy_texture_object(&attr
->Unit
[u
].SavedCubeMap
,
365 attr
->Unit
[u
].CurrentCubeMap
);
366 _mesa_copy_texture_object(&attr
->Unit
[u
].SavedRect
,
367 attr
->Unit
[u
].CurrentRect
);
368 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved1DArray
,
369 attr
->Unit
[u
].Current1DArray
);
370 _mesa_copy_texture_object(&attr
->Unit
[u
].Saved2DArray
,
371 attr
->Unit
[u
].Current2DArray
);
374 _mesa_unlock_context_textures(ctx
);
376 newnode
= new_attrib_node( GL_TEXTURE_BIT
);
377 newnode
->data
= attr
;
378 newnode
->next
= head
;
382 if (mask
& GL_TRANSFORM_BIT
) {
383 struct gl_transform_attrib
*attr
;
384 attr
= MALLOC_STRUCT( gl_transform_attrib
);
385 MEMCPY( attr
, &ctx
->Transform
, sizeof(struct gl_transform_attrib
) );
386 newnode
= new_attrib_node( GL_TRANSFORM_BIT
);
387 newnode
->data
= attr
;
388 newnode
->next
= head
;
392 if (mask
& GL_VIEWPORT_BIT
) {
393 struct gl_viewport_attrib
*attr
;
394 attr
= MALLOC_STRUCT( gl_viewport_attrib
);
395 MEMCPY( attr
, &ctx
->Viewport
, sizeof(struct gl_viewport_attrib
) );
396 newnode
= new_attrib_node( GL_VIEWPORT_BIT
);
397 newnode
->data
= attr
;
398 newnode
->next
= head
;
402 /* GL_ARB_multisample */
403 if (mask
& GL_MULTISAMPLE_BIT_ARB
) {
404 struct gl_multisample_attrib
*attr
;
405 attr
= MALLOC_STRUCT( gl_multisample_attrib
);
406 MEMCPY( attr
, &ctx
->Multisample
, sizeof(struct gl_multisample_attrib
) );
407 newnode
= new_attrib_node( GL_MULTISAMPLE_BIT_ARB
);
408 newnode
->data
= attr
;
409 newnode
->next
= head
;
413 ctx
->AttribStack
[ctx
->AttribStackDepth
] = head
;
414 ctx
->AttribStackDepth
++;
420 pop_enable_group(GLcontext
*ctx
, const struct gl_enable_attrib
*enable
)
424 #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
425 if ((VALUE) != (NEWVALUE)) { \
426 _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \
429 TEST_AND_UPDATE(ctx
->Color
.AlphaEnabled
, enable
->AlphaTest
, GL_ALPHA_TEST
);
430 TEST_AND_UPDATE(ctx
->Color
.BlendEnabled
, enable
->Blend
, GL_BLEND
);
432 for (i
=0;i
<MAX_CLIP_PLANES
;i
++) {
433 const GLuint mask
= 1 << i
;
434 if ((ctx
->Transform
.ClipPlanesEnabled
& mask
) != (enable
->ClipPlanes
& mask
))
435 _mesa_set_enable(ctx
, (GLenum
) (GL_CLIP_PLANE0
+ i
),
436 (GLboolean
) ((enable
->ClipPlanes
& mask
) ? GL_TRUE
: GL_FALSE
));
439 TEST_AND_UPDATE(ctx
->Light
.ColorMaterialEnabled
, enable
->ColorMaterial
,
441 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_PRECONVOLUTION
],
442 enable
->ColorTable
[COLORTABLE_PRECONVOLUTION
],
444 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCONVOLUTION
],
445 enable
->ColorTable
[COLORTABLE_POSTCONVOLUTION
],
446 GL_POST_CONVOLUTION_COLOR_TABLE
);
447 TEST_AND_UPDATE(ctx
->Pixel
.ColorTableEnabled
[COLORTABLE_POSTCOLORMATRIX
],
448 enable
->ColorTable
[COLORTABLE_POSTCOLORMATRIX
],
449 GL_POST_COLOR_MATRIX_COLOR_TABLE
);
450 TEST_AND_UPDATE(ctx
->Polygon
.CullFlag
, enable
->CullFace
, GL_CULL_FACE
);
451 TEST_AND_UPDATE(ctx
->Depth
.Test
, enable
->DepthTest
, GL_DEPTH_TEST
);
452 TEST_AND_UPDATE(ctx
->Color
.DitherFlag
, enable
->Dither
, GL_DITHER
);
453 TEST_AND_UPDATE(ctx
->Pixel
.Convolution1DEnabled
, enable
->Convolution1D
,
455 TEST_AND_UPDATE(ctx
->Pixel
.Convolution2DEnabled
, enable
->Convolution2D
,
457 TEST_AND_UPDATE(ctx
->Pixel
.Separable2DEnabled
, enable
->Separable2D
,
459 TEST_AND_UPDATE(ctx
->Fog
.Enabled
, enable
->Fog
, GL_FOG
);
460 TEST_AND_UPDATE(ctx
->Light
.Enabled
, enable
->Lighting
, GL_LIGHTING
);
461 TEST_AND_UPDATE(ctx
->Line
.SmoothFlag
, enable
->LineSmooth
, GL_LINE_SMOOTH
);
462 TEST_AND_UPDATE(ctx
->Line
.StippleFlag
, enable
->LineStipple
,
464 TEST_AND_UPDATE(ctx
->Color
.IndexLogicOpEnabled
, enable
->IndexLogicOp
,
466 TEST_AND_UPDATE(ctx
->Color
.ColorLogicOpEnabled
, enable
->ColorLogicOp
,
469 TEST_AND_UPDATE(ctx
->Eval
.Map1Color4
, enable
->Map1Color4
, GL_MAP1_COLOR_4
);
470 TEST_AND_UPDATE(ctx
->Eval
.Map1Index
, enable
->Map1Index
, GL_MAP1_INDEX
);
471 TEST_AND_UPDATE(ctx
->Eval
.Map1Normal
, enable
->Map1Normal
, GL_MAP1_NORMAL
);
472 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord1
, enable
->Map1TextureCoord1
,
473 GL_MAP1_TEXTURE_COORD_1
);
474 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord2
, enable
->Map1TextureCoord2
,
475 GL_MAP1_TEXTURE_COORD_2
);
476 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord3
, enable
->Map1TextureCoord3
,
477 GL_MAP1_TEXTURE_COORD_3
);
478 TEST_AND_UPDATE(ctx
->Eval
.Map1TextureCoord4
, enable
->Map1TextureCoord4
,
479 GL_MAP1_TEXTURE_COORD_4
);
480 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex3
, enable
->Map1Vertex3
,
482 TEST_AND_UPDATE(ctx
->Eval
.Map1Vertex4
, enable
->Map1Vertex4
,
484 for (i
= 0; i
< 16; i
++) {
485 TEST_AND_UPDATE(ctx
->Eval
.Map1Attrib
[i
], enable
->Map1Attrib
[i
],
486 GL_MAP1_VERTEX_ATTRIB0_4_NV
+ i
);
489 TEST_AND_UPDATE(ctx
->Eval
.Map2Color4
, enable
->Map2Color4
, GL_MAP2_COLOR_4
);
490 TEST_AND_UPDATE(ctx
->Eval
.Map2Index
, enable
->Map2Index
, GL_MAP2_INDEX
);
491 TEST_AND_UPDATE(ctx
->Eval
.Map2Normal
, enable
->Map2Normal
, GL_MAP2_NORMAL
);
492 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord1
, enable
->Map2TextureCoord1
,
493 GL_MAP2_TEXTURE_COORD_1
);
494 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord2
, enable
->Map2TextureCoord2
,
495 GL_MAP2_TEXTURE_COORD_2
);
496 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord3
, enable
->Map2TextureCoord3
,
497 GL_MAP2_TEXTURE_COORD_3
);
498 TEST_AND_UPDATE(ctx
->Eval
.Map2TextureCoord4
, enable
->Map2TextureCoord4
,
499 GL_MAP2_TEXTURE_COORD_4
);
500 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex3
, enable
->Map2Vertex3
,
502 TEST_AND_UPDATE(ctx
->Eval
.Map2Vertex4
, enable
->Map2Vertex4
,
504 for (i
= 0; i
< 16; i
++) {
505 TEST_AND_UPDATE(ctx
->Eval
.Map2Attrib
[i
], enable
->Map2Attrib
[i
],
506 GL_MAP2_VERTEX_ATTRIB0_4_NV
+ i
);
509 TEST_AND_UPDATE(ctx
->Eval
.AutoNormal
, enable
->AutoNormal
, GL_AUTO_NORMAL
);
510 TEST_AND_UPDATE(ctx
->Transform
.Normalize
, enable
->Normalize
, GL_NORMALIZE
);
511 TEST_AND_UPDATE(ctx
->Transform
.RescaleNormals
, enable
->RescaleNormals
,
512 GL_RESCALE_NORMAL_EXT
);
513 TEST_AND_UPDATE(ctx
->Transform
.RasterPositionUnclipped
,
514 enable
->RasterPositionUnclipped
,
515 GL_RASTER_POSITION_UNCLIPPED_IBM
);
516 TEST_AND_UPDATE(ctx
->Point
.SmoothFlag
, enable
->PointSmooth
,
518 if (ctx
->Extensions
.NV_point_sprite
|| ctx
->Extensions
.ARB_point_sprite
) {
519 TEST_AND_UPDATE(ctx
->Point
.PointSprite
, enable
->PointSprite
,
522 TEST_AND_UPDATE(ctx
->Polygon
.OffsetPoint
, enable
->PolygonOffsetPoint
,
523 GL_POLYGON_OFFSET_POINT
);
524 TEST_AND_UPDATE(ctx
->Polygon
.OffsetLine
, enable
->PolygonOffsetLine
,
525 GL_POLYGON_OFFSET_LINE
);
526 TEST_AND_UPDATE(ctx
->Polygon
.OffsetFill
, enable
->PolygonOffsetFill
,
527 GL_POLYGON_OFFSET_FILL
);
528 TEST_AND_UPDATE(ctx
->Polygon
.SmoothFlag
, enable
->PolygonSmooth
,
530 TEST_AND_UPDATE(ctx
->Polygon
.StippleFlag
, enable
->PolygonStipple
,
532 TEST_AND_UPDATE(ctx
->Scissor
.Enabled
, enable
->Scissor
, GL_SCISSOR_TEST
);
533 TEST_AND_UPDATE(ctx
->Stencil
.Enabled
, enable
->Stencil
, GL_STENCIL_TEST
);
534 if (ctx
->Extensions
.EXT_stencil_two_side
) {
535 TEST_AND_UPDATE(ctx
->Stencil
.TestTwoSide
, enable
->StencilTwoSide
, GL_STENCIL_TEST_TWO_SIDE_EXT
);
537 TEST_AND_UPDATE(ctx
->Multisample
.Enabled
, enable
->MultisampleEnabled
,
539 TEST_AND_UPDATE(ctx
->Multisample
.SampleAlphaToCoverage
,
540 enable
->SampleAlphaToCoverage
,
541 GL_SAMPLE_ALPHA_TO_COVERAGE_ARB
);
542 TEST_AND_UPDATE(ctx
->Multisample
.SampleAlphaToOne
,
543 enable
->SampleAlphaToOne
,
544 GL_SAMPLE_ALPHA_TO_ONE_ARB
);
545 TEST_AND_UPDATE(ctx
->Multisample
.SampleCoverage
,
546 enable
->SampleCoverage
,
547 GL_SAMPLE_COVERAGE_ARB
);
548 TEST_AND_UPDATE(ctx
->Multisample
.SampleCoverageInvert
,
549 enable
->SampleCoverageInvert
,
550 GL_SAMPLE_COVERAGE_INVERT_ARB
);
551 /* GL_ARB_vertex_program, GL_NV_vertex_program */
552 TEST_AND_UPDATE(ctx
->VertexProgram
.Enabled
,
553 enable
->VertexProgram
,
554 GL_VERTEX_PROGRAM_ARB
);
555 TEST_AND_UPDATE(ctx
->VertexProgram
.PointSizeEnabled
,
556 enable
->VertexProgramPointSize
,
557 GL_VERTEX_PROGRAM_POINT_SIZE_ARB
);
558 TEST_AND_UPDATE(ctx
->VertexProgram
.TwoSideEnabled
,
559 enable
->VertexProgramTwoSide
,
560 GL_VERTEX_PROGRAM_TWO_SIDE_ARB
);
562 #undef TEST_AND_UPDATE
564 /* texture unit enables */
565 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
566 if (ctx
->Texture
.Unit
[i
].Enabled
!= enable
->Texture
[i
]) {
567 ctx
->Texture
.Unit
[i
].Enabled
= enable
->Texture
[i
];
568 if (ctx
->Driver
.Enable
) {
569 if (ctx
->Driver
.ActiveTexture
) {
570 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
572 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_1D
,
573 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_1D_BIT
) );
574 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_2D
,
575 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_2D_BIT
) );
576 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_3D
,
577 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_3D_BIT
) );
578 if (ctx
->Extensions
.ARB_texture_cube_map
)
579 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_CUBE_MAP_ARB
,
580 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_CUBE_BIT
) );
581 if (ctx
->Extensions
.NV_texture_rectangle
)
582 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_RECTANGLE_NV
,
583 (GLboolean
) (enable
->Texture
[i
] & TEXTURE_RECT_BIT
) );
587 if (ctx
->Texture
.Unit
[i
].TexGenEnabled
!= enable
->TexGen
[i
]) {
588 ctx
->Texture
.Unit
[i
].TexGenEnabled
= enable
->TexGen
[i
];
589 if (ctx
->Driver
.Enable
) {
590 if (ctx
->Driver
.ActiveTexture
) {
591 (*ctx
->Driver
.ActiveTexture
)(ctx
, i
);
593 if (enable
->TexGen
[i
] & S_BIT
)
594 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_TRUE
);
596 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_S
, GL_FALSE
);
597 if (enable
->TexGen
[i
] & T_BIT
)
598 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_TRUE
);
600 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_T
, GL_FALSE
);
601 if (enable
->TexGen
[i
] & R_BIT
)
602 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_TRUE
);
604 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_R
, GL_FALSE
);
605 if (enable
->TexGen
[i
] & Q_BIT
)
606 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_TRUE
);
608 (*ctx
->Driver
.Enable
)( ctx
, GL_TEXTURE_GEN_Q
, GL_FALSE
);
612 /* GL_SGI_texture_color_table */
613 ctx
->Texture
.Unit
[i
].ColorTableEnabled
= enable
->TextureColorTable
[i
];
616 if (ctx
->Driver
.ActiveTexture
) {
617 (*ctx
->Driver
.ActiveTexture
)(ctx
, ctx
->Texture
.CurrentUnit
);
623 pop_texture_group(GLcontext
*ctx
, const struct gl_texture_attrib
*texAttrib
)
627 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
628 const struct gl_texture_unit
*unit
= &texAttrib
->Unit
[u
];
631 _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
+ u
);
632 _mesa_set_enable(ctx
, GL_TEXTURE_1D
,
633 (unit
->Enabled
& TEXTURE_1D_BIT
) ? GL_TRUE
: GL_FALSE
);
634 _mesa_set_enable(ctx
, GL_TEXTURE_2D
,
635 (unit
->Enabled
& TEXTURE_2D_BIT
) ? GL_TRUE
: GL_FALSE
);
636 _mesa_set_enable(ctx
, GL_TEXTURE_3D
,
637 (unit
->Enabled
& TEXTURE_3D_BIT
) ? GL_TRUE
: GL_FALSE
);
638 if (ctx
->Extensions
.ARB_texture_cube_map
) {
639 _mesa_set_enable(ctx
, GL_TEXTURE_CUBE_MAP_ARB
,
640 (unit
->Enabled
& TEXTURE_CUBE_BIT
) ? GL_TRUE
: GL_FALSE
);
642 if (ctx
->Extensions
.NV_texture_rectangle
) {
643 _mesa_set_enable(ctx
, GL_TEXTURE_RECTANGLE_NV
,
644 (unit
->Enabled
& TEXTURE_RECT_BIT
) ? GL_TRUE
: GL_FALSE
);
646 if (ctx
->Extensions
.SGI_texture_color_table
) {
647 _mesa_set_enable(ctx
, GL_TEXTURE_COLOR_TABLE_SGI
,
648 unit
->ColorTableEnabled
);
650 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, unit
->EnvMode
);
651 _mesa_TexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, unit
->EnvColor
);
652 _mesa_TexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, unit
->GenModeS
);
653 _mesa_TexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, unit
->GenModeT
);
654 _mesa_TexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, unit
->GenModeR
);
655 _mesa_TexGeni(GL_Q
, GL_TEXTURE_GEN_MODE
, unit
->GenModeQ
);
656 _mesa_TexGenfv(GL_S
, GL_OBJECT_PLANE
, unit
->ObjectPlaneS
);
657 _mesa_TexGenfv(GL_T
, GL_OBJECT_PLANE
, unit
->ObjectPlaneT
);
658 _mesa_TexGenfv(GL_R
, GL_OBJECT_PLANE
, unit
->ObjectPlaneR
);
659 _mesa_TexGenfv(GL_Q
, GL_OBJECT_PLANE
, unit
->ObjectPlaneQ
);
660 /* Eye plane done differently to avoid re-transformation */
662 struct gl_texture_unit
*destUnit
= &ctx
->Texture
.Unit
[u
];
663 COPY_4FV(destUnit
->EyePlaneS
, unit
->EyePlaneS
);
664 COPY_4FV(destUnit
->EyePlaneT
, unit
->EyePlaneT
);
665 COPY_4FV(destUnit
->EyePlaneR
, unit
->EyePlaneR
);
666 COPY_4FV(destUnit
->EyePlaneQ
, unit
->EyePlaneQ
);
667 if (ctx
->Driver
.TexGen
) {
668 ctx
->Driver
.TexGen(ctx
, GL_S
, GL_EYE_PLANE
, unit
->EyePlaneS
);
669 ctx
->Driver
.TexGen(ctx
, GL_T
, GL_EYE_PLANE
, unit
->EyePlaneT
);
670 ctx
->Driver
.TexGen(ctx
, GL_R
, GL_EYE_PLANE
, unit
->EyePlaneR
);
671 ctx
->Driver
.TexGen(ctx
, GL_Q
, GL_EYE_PLANE
, unit
->EyePlaneQ
);
674 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_S
,
675 ((unit
->TexGenEnabled
& S_BIT
) ? GL_TRUE
: GL_FALSE
));
676 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_T
,
677 ((unit
->TexGenEnabled
& T_BIT
) ? GL_TRUE
: GL_FALSE
));
678 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_R
,
679 ((unit
->TexGenEnabled
& R_BIT
) ? GL_TRUE
: GL_FALSE
));
680 _mesa_set_enable(ctx
, GL_TEXTURE_GEN_Q
,
681 ((unit
->TexGenEnabled
& Q_BIT
) ? GL_TRUE
: GL_FALSE
));
682 if (ctx
->Extensions
.EXT_texture_lod_bias
) {
683 _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
684 GL_TEXTURE_LOD_BIAS_EXT
, unit
->LodBias
);
686 if (ctx
->Extensions
.EXT_texture_env_combine
||
687 ctx
->Extensions
.ARB_texture_env_combine
) {
688 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_COMBINE_RGB
,
689 unit
->Combine
.ModeRGB
);
690 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_COMBINE_ALPHA
,
691 unit
->Combine
.ModeA
);
692 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE0_RGB
,
693 unit
->Combine
.SourceRGB
[0]);
694 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE1_RGB
,
695 unit
->Combine
.SourceRGB
[1]);
696 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE2_RGB
,
697 unit
->Combine
.SourceRGB
[2]);
698 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE0_ALPHA
,
699 unit
->Combine
.SourceA
[0]);
700 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE1_ALPHA
,
701 unit
->Combine
.SourceA
[1]);
702 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_SOURCE2_ALPHA
,
703 unit
->Combine
.SourceA
[2]);
704 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND0_RGB
,
705 unit
->Combine
.OperandRGB
[0]);
706 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND1_RGB
,
707 unit
->Combine
.OperandRGB
[1]);
708 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND2_RGB
,
709 unit
->Combine
.OperandRGB
[2]);
710 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND0_ALPHA
,
711 unit
->Combine
.OperandA
[0]);
712 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND1_ALPHA
,
713 unit
->Combine
.OperandA
[1]);
714 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_OPERAND2_ALPHA
,
715 unit
->Combine
.OperandA
[2]);
716 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_RGB_SCALE
,
717 1 << unit
->Combine
.ScaleShiftRGB
);
718 _mesa_TexEnvi(GL_TEXTURE_ENV
, GL_ALPHA_SCALE
,
719 1 << unit
->Combine
.ScaleShiftA
);
722 /* Restore texture object state */
723 for (i
= 0; i
< NUM_TEXTURE_TARGETS
; i
++) {
725 const struct gl_texture_object
*obj
= NULL
;
726 GLfloat bordColor
[4];
730 target
= GL_TEXTURE_1D
;
731 obj
= &unit
->Saved1D
;
734 target
= GL_TEXTURE_2D
;
735 obj
= &unit
->Saved2D
;
738 target
= GL_TEXTURE_3D
;
739 obj
= &unit
->Saved3D
;
742 if (!ctx
->Extensions
.ARB_texture_cube_map
)
744 target
= GL_TEXTURE_CUBE_MAP_ARB
;
745 obj
= &unit
->SavedCubeMap
;
748 if (!ctx
->Extensions
.NV_texture_rectangle
)
750 target
= GL_TEXTURE_RECTANGLE_NV
;
751 obj
= &unit
->SavedRect
;
754 if (!ctx
->Extensions
.MESA_texture_array
)
756 target
= GL_TEXTURE_1D_ARRAY_EXT
;
757 obj
= &unit
->Saved1DArray
;
760 if (!ctx
->Extensions
.MESA_texture_array
)
762 target
= GL_TEXTURE_2D_ARRAY_EXT
;
763 obj
= &unit
->Saved2DArray
;
766 ; /* silence warnings */
769 _mesa_BindTexture(target
, obj
->Name
);
771 bordColor
[0] = CHAN_TO_FLOAT(obj
->BorderColor
[0]);
772 bordColor
[1] = CHAN_TO_FLOAT(obj
->BorderColor
[1]);
773 bordColor
[2] = CHAN_TO_FLOAT(obj
->BorderColor
[2]);
774 bordColor
[3] = CHAN_TO_FLOAT(obj
->BorderColor
[3]);
776 _mesa_TexParameterf(target
, GL_TEXTURE_PRIORITY
, obj
->Priority
);
777 _mesa_TexParameterfv(target
, GL_TEXTURE_BORDER_COLOR
, bordColor
);
778 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_S
, obj
->WrapS
);
779 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_T
, obj
->WrapT
);
780 _mesa_TexParameteri(target
, GL_TEXTURE_WRAP_R
, obj
->WrapR
);
781 _mesa_TexParameteri(target
, GL_TEXTURE_MIN_FILTER
, obj
->MinFilter
);
782 _mesa_TexParameteri(target
, GL_TEXTURE_MAG_FILTER
, obj
->MagFilter
);
783 _mesa_TexParameterf(target
, GL_TEXTURE_MIN_LOD
, obj
->MinLod
);
784 _mesa_TexParameterf(target
, GL_TEXTURE_MAX_LOD
, obj
->MaxLod
);
785 _mesa_TexParameterf(target
, GL_TEXTURE_LOD_BIAS
, obj
->LodBias
);
786 _mesa_TexParameteri(target
, GL_TEXTURE_BASE_LEVEL
, obj
->BaseLevel
);
787 if (target
!= GL_TEXTURE_RECTANGLE_ARB
)
788 _mesa_TexParameteri(target
, GL_TEXTURE_MAX_LEVEL
, obj
->MaxLevel
);
789 if (ctx
->Extensions
.EXT_texture_filter_anisotropic
) {
790 _mesa_TexParameterf(target
, GL_TEXTURE_MAX_ANISOTROPY_EXT
,
793 if (ctx
->Extensions
.SGIX_shadow
) {
794 _mesa_TexParameteri(target
, GL_TEXTURE_COMPARE_SGIX
,
796 _mesa_TexParameteri(target
, GL_TEXTURE_COMPARE_OPERATOR_SGIX
,
797 obj
->CompareOperator
);
799 if (ctx
->Extensions
.SGIX_shadow_ambient
) {
800 _mesa_TexParameterf(target
, GL_SHADOW_AMBIENT_SGIX
,
806 _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
807 + texAttrib
->CurrentUnit
);
809 /* "un-bump" the texture object reference counts. We did that so they
810 * wouldn't inadvertantly get deleted while they were still referenced
811 * inside the attribute state stack.
813 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
814 ctx
->Texture
.Unit
[u
].Current1D
->RefCount
--;
815 ctx
->Texture
.Unit
[u
].Current2D
->RefCount
--;
816 ctx
->Texture
.Unit
[u
].Current3D
->RefCount
--;
817 ctx
->Texture
.Unit
[u
].CurrentCubeMap
->RefCount
--;
818 ctx
->Texture
.Unit
[u
].CurrentRect
->RefCount
--;
819 ctx
->Texture
.Unit
[u
].Current1DArray
->RefCount
--;
820 ctx
->Texture
.Unit
[u
].Current2DArray
->RefCount
--;
826 * This function is kind of long just because we have to call a lot
827 * of device driver functions to update device driver state.
829 * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions
830 * in order to restore GL state. This isn't terribly efficient but it
831 * ensures that dirty flags and any derived state gets updated correctly.
832 * We could at least check if the value to restore equals the current value
833 * and then skip the Mesa call.
836 _mesa_PopAttrib(void)
838 struct gl_attrib_node
*attr
, *next
;
839 GET_CURRENT_CONTEXT(ctx
);
840 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
842 if (ctx
->AttribStackDepth
== 0) {
843 _mesa_error( ctx
, GL_STACK_UNDERFLOW
, "glPopAttrib" );
847 ctx
->AttribStackDepth
--;
848 attr
= ctx
->AttribStack
[ctx
->AttribStackDepth
];
852 if (MESA_VERBOSE
& VERBOSE_API
) {
853 _mesa_debug(ctx
, "glPopAttrib %s\n",
854 _mesa_lookup_enum_by_nr(attr
->kind
));
857 switch (attr
->kind
) {
858 case GL_ACCUM_BUFFER_BIT
:
860 const struct gl_accum_attrib
*accum
;
861 accum
= (const struct gl_accum_attrib
*) attr
->data
;
862 _mesa_ClearAccum(accum
->ClearColor
[0],
863 accum
->ClearColor
[1],
864 accum
->ClearColor
[2],
865 accum
->ClearColor
[3]);
868 case GL_COLOR_BUFFER_BIT
:
870 const struct gl_colorbuffer_attrib
*color
;
871 color
= (const struct gl_colorbuffer_attrib
*) attr
->data
;
872 _mesa_ClearIndex((GLfloat
) color
->ClearIndex
);
873 _mesa_ClearColor(color
->ClearColor
[0],
874 color
->ClearColor
[1],
875 color
->ClearColor
[2],
876 color
->ClearColor
[3]);
877 _mesa_IndexMask(color
->IndexMask
);
878 _mesa_ColorMask((GLboolean
) (color
->ColorMask
[0] != 0),
879 (GLboolean
) (color
->ColorMask
[1] != 0),
880 (GLboolean
) (color
->ColorMask
[2] != 0),
881 (GLboolean
) (color
->ColorMask
[3] != 0));
883 /* Need to determine if more than one color output is
884 * specified. If so, call glDrawBuffersARB, else call
885 * glDrawBuffer(). This is a subtle, but essential point
886 * since GL_FRONT (for example) is illegal for the former
887 * function, but legal for the later.
889 GLboolean multipleBuffers
= GL_FALSE
;
890 if (ctx
->Extensions
.ARB_draw_buffers
) {
892 for (i
= 1; i
< ctx
->Const
.MaxDrawBuffers
; i
++) {
893 if (color
->DrawBuffer
[i
] != GL_NONE
) {
894 multipleBuffers
= GL_TRUE
;
899 /* Call the API_level functions, not _mesa_drawbuffers()
900 * since we need to do error checking on the pop'd
902 * Ex: if GL_FRONT were pushed, but we're popping with a
903 * user FBO bound, GL_FRONT will be illegal and we'll need
904 * to record that error. Per OpenGL ARB decision.
907 _mesa_DrawBuffersARB(ctx
->Const
.MaxDrawBuffers
,
910 _mesa_DrawBuffer(color
->DrawBuffer
[0]);
912 _mesa_set_enable(ctx
, GL_ALPHA_TEST
, color
->AlphaEnabled
);
913 _mesa_AlphaFunc(color
->AlphaFunc
, color
->AlphaRef
);
914 _mesa_set_enable(ctx
, GL_BLEND
, color
->BlendEnabled
);
915 _mesa_BlendFuncSeparateEXT(color
->BlendSrcRGB
,
919 /* This special case is because glBlendEquationSeparateEXT
920 * cannot take GL_LOGIC_OP as a parameter.
922 if ( color
->BlendEquationRGB
== color
->BlendEquationA
) {
923 _mesa_BlendEquation(color
->BlendEquationRGB
);
926 _mesa_BlendEquationSeparateEXT(color
->BlendEquationRGB
,
927 color
->BlendEquationA
);
929 _mesa_BlendColor(color
->BlendColor
[0],
930 color
->BlendColor
[1],
931 color
->BlendColor
[2],
932 color
->BlendColor
[3]);
933 _mesa_LogicOp(color
->LogicOp
);
934 _mesa_set_enable(ctx
, GL_COLOR_LOGIC_OP
,
935 color
->ColorLogicOpEnabled
);
936 _mesa_set_enable(ctx
, GL_INDEX_LOGIC_OP
,
937 color
->IndexLogicOpEnabled
);
938 _mesa_set_enable(ctx
, GL_DITHER
, color
->DitherFlag
);
942 FLUSH_CURRENT( ctx
, 0 );
943 MEMCPY( &ctx
->Current
, attr
->data
,
944 sizeof(struct gl_current_attrib
) );
946 case GL_DEPTH_BUFFER_BIT
:
948 const struct gl_depthbuffer_attrib
*depth
;
949 depth
= (const struct gl_depthbuffer_attrib
*) attr
->data
;
950 _mesa_DepthFunc(depth
->Func
);
951 _mesa_ClearDepth(depth
->Clear
);
952 _mesa_set_enable(ctx
, GL_DEPTH_TEST
, depth
->Test
);
953 _mesa_DepthMask(depth
->Mask
);
958 const struct gl_enable_attrib
*enable
;
959 enable
= (const struct gl_enable_attrib
*) attr
->data
;
960 pop_enable_group(ctx
, enable
);
961 ctx
->NewState
|= _NEW_ALL
;
965 MEMCPY( &ctx
->Eval
, attr
->data
, sizeof(struct gl_eval_attrib
) );
966 ctx
->NewState
|= _NEW_EVAL
;
970 const struct gl_fog_attrib
*fog
;
971 fog
= (const struct gl_fog_attrib
*) attr
->data
;
972 _mesa_set_enable(ctx
, GL_FOG
, fog
->Enabled
);
973 _mesa_Fogfv(GL_FOG_COLOR
, fog
->Color
);
974 _mesa_Fogf(GL_FOG_DENSITY
, fog
->Density
);
975 _mesa_Fogf(GL_FOG_START
, fog
->Start
);
976 _mesa_Fogf(GL_FOG_END
, fog
->End
);
977 _mesa_Fogf(GL_FOG_INDEX
, fog
->Index
);
978 _mesa_Fogi(GL_FOG_MODE
, fog
->Mode
);
983 const struct gl_hint_attrib
*hint
;
984 hint
= (const struct gl_hint_attrib
*) attr
->data
;
985 _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT
,
986 hint
->PerspectiveCorrection
);
987 _mesa_Hint(GL_POINT_SMOOTH_HINT
, hint
->PointSmooth
);
988 _mesa_Hint(GL_LINE_SMOOTH_HINT
, hint
->LineSmooth
);
989 _mesa_Hint(GL_POLYGON_SMOOTH_HINT
, hint
->PolygonSmooth
);
990 _mesa_Hint(GL_FOG_HINT
, hint
->Fog
);
991 _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT
,
992 hint
->ClipVolumeClipping
);
993 if (ctx
->Extensions
.ARB_texture_compression
)
994 _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB
,
995 hint
->TextureCompression
);
998 case GL_LIGHTING_BIT
:
1001 const struct gl_light_attrib
*light
;
1002 light
= (const struct gl_light_attrib
*) attr
->data
;
1003 /* lighting enable */
1004 _mesa_set_enable(ctx
, GL_LIGHTING
, light
->Enabled
);
1005 /* per-light state */
1006 if (_math_matrix_is_dirty(ctx
->ModelviewMatrixStack
.Top
))
1007 _math_matrix_analyse( ctx
->ModelviewMatrixStack
.Top
);
1009 for (i
= 0; i
< ctx
->Const
.MaxLights
; i
++) {
1010 const struct gl_light
*l
= &light
->Light
[i
];
1011 _mesa_set_enable(ctx
, GL_LIGHT0
+ i
, l
->Enabled
);
1012 _mesa_light(ctx
, i
, GL_AMBIENT
, l
->Ambient
);
1013 _mesa_light(ctx
, i
, GL_DIFFUSE
, l
->Diffuse
);
1014 _mesa_light(ctx
, i
, GL_SPECULAR
, l
->Specular
);
1015 _mesa_light(ctx
, i
, GL_POSITION
, l
->EyePosition
);
1016 _mesa_light(ctx
, i
, GL_SPOT_DIRECTION
, l
->EyeDirection
);
1017 _mesa_light(ctx
, i
, GL_SPOT_EXPONENT
, &l
->SpotExponent
);
1018 _mesa_light(ctx
, i
, GL_SPOT_CUTOFF
, &l
->SpotCutoff
);
1019 _mesa_light(ctx
, i
, GL_CONSTANT_ATTENUATION
,
1020 &l
->ConstantAttenuation
);
1021 _mesa_light(ctx
, i
, GL_LINEAR_ATTENUATION
,
1022 &l
->LinearAttenuation
);
1023 _mesa_light(ctx
, i
, GL_QUADRATIC_ATTENUATION
,
1024 &l
->QuadraticAttenuation
);
1027 _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT
,
1028 light
->Model
.Ambient
);
1029 _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER
,
1030 (GLfloat
) light
->Model
.LocalViewer
);
1031 _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE
,
1032 (GLfloat
) light
->Model
.TwoSide
);
1033 _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL
,
1034 (GLfloat
) light
->Model
.ColorControl
);
1036 _mesa_ShadeModel(light
->ShadeModel
);
1037 /* color material */
1038 _mesa_ColorMaterial(light
->ColorMaterialFace
,
1039 light
->ColorMaterialMode
);
1040 _mesa_set_enable(ctx
, GL_COLOR_MATERIAL
,
1041 light
->ColorMaterialEnabled
);
1043 MEMCPY(&ctx
->Light
.Material
, &light
->Material
,
1044 sizeof(struct gl_material
));
1049 const struct gl_line_attrib
*line
;
1050 line
= (const struct gl_line_attrib
*) attr
->data
;
1051 _mesa_set_enable(ctx
, GL_LINE_SMOOTH
, line
->SmoothFlag
);
1052 _mesa_set_enable(ctx
, GL_LINE_STIPPLE
, line
->StippleFlag
);
1053 _mesa_LineStipple(line
->StippleFactor
, line
->StipplePattern
);
1054 _mesa_LineWidth(line
->Width
);
1058 MEMCPY( &ctx
->List
, attr
->data
, sizeof(struct gl_list_attrib
) );
1060 case GL_PIXEL_MODE_BIT
:
1061 MEMCPY( &ctx
->Pixel
, attr
->data
, sizeof(struct gl_pixel_attrib
) );
1062 /* XXX what other pixel state needs to be set by function calls? */
1063 _mesa_ReadBuffer(ctx
->Pixel
.ReadBuffer
);
1064 ctx
->NewState
|= _NEW_PIXEL
;
1068 const struct gl_point_attrib
*point
;
1069 point
= (const struct gl_point_attrib
*) attr
->data
;
1070 _mesa_PointSize(point
->Size
);
1071 _mesa_set_enable(ctx
, GL_POINT_SMOOTH
, point
->SmoothFlag
);
1072 if (ctx
->Extensions
.EXT_point_parameters
) {
1073 _mesa_PointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT
,
1075 _mesa_PointParameterfEXT(GL_POINT_SIZE_MIN_EXT
,
1077 _mesa_PointParameterfEXT(GL_POINT_SIZE_MAX_EXT
,
1079 _mesa_PointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT
,
1082 if (ctx
->Extensions
.NV_point_sprite
1083 || ctx
->Extensions
.ARB_point_sprite
) {
1085 for (u
= 0; u
< ctx
->Const
.MaxTextureUnits
; u
++) {
1086 _mesa_TexEnvi(GL_POINT_SPRITE_NV
, GL_COORD_REPLACE_NV
,
1087 (GLint
) point
->CoordReplace
[u
]);
1089 _mesa_set_enable(ctx
, GL_POINT_SPRITE_NV
,point
->PointSprite
);
1090 _mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV
,
1091 ctx
->Point
.SpriteRMode
);
1092 _mesa_PointParameterfEXT(GL_POINT_SPRITE_COORD_ORIGIN
,
1093 (GLfloat
)ctx
->Point
.SpriteOrigin
);
1097 case GL_POLYGON_BIT
:
1099 const struct gl_polygon_attrib
*polygon
;
1100 polygon
= (const struct gl_polygon_attrib
*) attr
->data
;
1101 _mesa_CullFace(polygon
->CullFaceMode
);
1102 _mesa_FrontFace(polygon
->FrontFace
);
1103 _mesa_PolygonMode(GL_FRONT
, polygon
->FrontMode
);
1104 _mesa_PolygonMode(GL_BACK
, polygon
->BackMode
);
1105 _mesa_PolygonOffset(polygon
->OffsetFactor
,
1106 polygon
->OffsetUnits
);
1107 _mesa_set_enable(ctx
, GL_POLYGON_SMOOTH
, polygon
->SmoothFlag
);
1108 _mesa_set_enable(ctx
, GL_POLYGON_STIPPLE
, polygon
->StippleFlag
);
1109 _mesa_set_enable(ctx
, GL_CULL_FACE
, polygon
->CullFlag
);
1110 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_POINT
,
1111 polygon
->OffsetPoint
);
1112 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_LINE
,
1113 polygon
->OffsetLine
);
1114 _mesa_set_enable(ctx
, GL_POLYGON_OFFSET_FILL
,
1115 polygon
->OffsetFill
);
1118 case GL_POLYGON_STIPPLE_BIT
:
1119 MEMCPY( ctx
->PolygonStipple
, attr
->data
, 32*sizeof(GLuint
) );
1120 ctx
->NewState
|= _NEW_POLYGONSTIPPLE
;
1121 if (ctx
->Driver
.PolygonStipple
)
1122 ctx
->Driver
.PolygonStipple( ctx
, (const GLubyte
*) attr
->data
);
1124 case GL_SCISSOR_BIT
:
1126 const struct gl_scissor_attrib
*scissor
;
1127 scissor
= (const struct gl_scissor_attrib
*) attr
->data
;
1128 _mesa_Scissor(scissor
->X
, scissor
->Y
,
1129 scissor
->Width
, scissor
->Height
);
1130 _mesa_set_enable(ctx
, GL_SCISSOR_TEST
, scissor
->Enabled
);
1133 case GL_STENCIL_BUFFER_BIT
:
1135 const struct gl_stencil_attrib
*stencil
;
1136 stencil
= (const struct gl_stencil_attrib
*) attr
->data
;
1137 _mesa_set_enable(ctx
, GL_STENCIL_TEST
, stencil
->Enabled
);
1138 _mesa_ClearStencil(stencil
->Clear
);
1139 if (ctx
->Extensions
.EXT_stencil_two_side
) {
1140 _mesa_set_enable(ctx
, GL_STENCIL_TEST_TWO_SIDE_EXT
,
1141 stencil
->TestTwoSide
);
1142 _mesa_ActiveStencilFaceEXT(stencil
->ActiveFace
1143 ? GL_BACK
: GL_FRONT
);
1146 _mesa_StencilFuncSeparate(GL_FRONT
,
1147 stencil
->Function
[0],
1149 stencil
->ValueMask
[0]);
1150 _mesa_StencilMaskSeparate(GL_FRONT
, stencil
->WriteMask
[0]);
1151 _mesa_StencilOpSeparate(GL_FRONT
, stencil
->FailFunc
[0],
1152 stencil
->ZFailFunc
[0],
1153 stencil
->ZPassFunc
[0]);
1155 _mesa_StencilFuncSeparate(GL_BACK
,
1156 stencil
->Function
[1],
1158 stencil
->ValueMask
[1]);
1159 _mesa_StencilMaskSeparate(GL_BACK
, stencil
->WriteMask
[1]);
1160 _mesa_StencilOpSeparate(GL_BACK
, stencil
->FailFunc
[1],
1161 stencil
->ZFailFunc
[1],
1162 stencil
->ZPassFunc
[1]);
1165 case GL_TRANSFORM_BIT
:
1168 const struct gl_transform_attrib
*xform
;
1169 xform
= (const struct gl_transform_attrib
*) attr
->data
;
1170 _mesa_MatrixMode(xform
->MatrixMode
);
1171 if (_math_matrix_is_dirty(ctx
->ProjectionMatrixStack
.Top
))
1172 _math_matrix_analyse( ctx
->ProjectionMatrixStack
.Top
);
1174 /* restore clip planes */
1175 for (i
= 0; i
< MAX_CLIP_PLANES
; i
++) {
1176 const GLuint mask
= 1 << 1;
1177 const GLfloat
*eyePlane
= xform
->EyeUserPlane
[i
];
1178 COPY_4V(ctx
->Transform
.EyeUserPlane
[i
], eyePlane
);
1179 if (xform
->ClipPlanesEnabled
& mask
) {
1180 _mesa_set_enable(ctx
, GL_CLIP_PLANE0
+ i
, GL_TRUE
);
1183 _mesa_set_enable(ctx
, GL_CLIP_PLANE0
+ i
, GL_FALSE
);
1185 if (ctx
->Driver
.ClipPlane
)
1186 ctx
->Driver
.ClipPlane( ctx
, GL_CLIP_PLANE0
+ i
, eyePlane
);
1189 /* normalize/rescale */
1190 if (xform
->Normalize
!= ctx
->Transform
.Normalize
)
1191 _mesa_set_enable(ctx
, GL_NORMALIZE
,ctx
->Transform
.Normalize
);
1192 if (xform
->RescaleNormals
!= ctx
->Transform
.RescaleNormals
)
1193 _mesa_set_enable(ctx
, GL_RESCALE_NORMAL_EXT
,
1194 ctx
->Transform
.RescaleNormals
);
1197 case GL_TEXTURE_BIT
:
1198 /* Take care of texture object reference counters */
1200 const struct gl_texture_attrib
*texture
;
1201 texture
= (const struct gl_texture_attrib
*) attr
->data
;
1202 pop_texture_group(ctx
, texture
);
1203 ctx
->NewState
|= _NEW_TEXTURE
;
1206 case GL_VIEWPORT_BIT
:
1208 const struct gl_viewport_attrib
*vp
;
1209 vp
= (const struct gl_viewport_attrib
*) attr
->data
;
1210 _mesa_Viewport(vp
->X
, vp
->Y
, vp
->Width
, vp
->Height
);
1211 _mesa_DepthRange(vp
->Near
, vp
->Far
);
1214 case GL_MULTISAMPLE_BIT_ARB
:
1216 const struct gl_multisample_attrib
*ms
;
1217 ms
= (const struct gl_multisample_attrib
*) attr
->data
;
1218 _mesa_SampleCoverageARB(ms
->SampleCoverageValue
,
1219 ms
->SampleCoverageInvert
);
1224 _mesa_problem( ctx
, "Bad attrib flag in PopAttrib");
1237 * Helper for incrementing/decrementing vertex buffer object reference
1238 * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group.
1241 adjust_buffer_object_ref_counts(struct gl_array_attrib
*array
, GLint step
)
1244 array
->ArrayObj
->Vertex
.BufferObj
->RefCount
+= step
;
1245 array
->ArrayObj
->Normal
.BufferObj
->RefCount
+= step
;
1246 array
->ArrayObj
->Color
.BufferObj
->RefCount
+= step
;
1247 array
->ArrayObj
->SecondaryColor
.BufferObj
->RefCount
+= step
;
1248 array
->ArrayObj
->FogCoord
.BufferObj
->RefCount
+= step
;
1249 array
->ArrayObj
->Index
.BufferObj
->RefCount
+= step
;
1250 array
->ArrayObj
->EdgeFlag
.BufferObj
->RefCount
+= step
;
1251 for (i
= 0; i
< MAX_TEXTURE_COORD_UNITS
; i
++)
1252 array
->ArrayObj
->TexCoord
[i
].BufferObj
->RefCount
+= step
;
1253 for (i
= 0; i
< VERT_ATTRIB_MAX
; i
++)
1254 array
->ArrayObj
->VertexAttrib
[i
].BufferObj
->RefCount
+= step
;
1256 array
->ArrayBufferObj
->RefCount
+= step
;
1257 array
->ElementArrayBufferObj
->RefCount
+= step
;
1261 #define GL_CLIENT_PACK_BIT (1<<20)
1262 #define GL_CLIENT_UNPACK_BIT (1<<21)
1266 _mesa_PushClientAttrib(GLbitfield mask
)
1268 struct gl_attrib_node
*newnode
;
1269 struct gl_attrib_node
*head
;
1271 GET_CURRENT_CONTEXT(ctx
);
1272 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1274 if (ctx
->ClientAttribStackDepth
>= MAX_CLIENT_ATTRIB_STACK_DEPTH
) {
1275 _mesa_error( ctx
, GL_STACK_OVERFLOW
, "glPushClientAttrib" );
1279 /* Build linked list of attribute nodes which save all attribute */
1280 /* groups specified by the mask. */
1283 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
1284 struct gl_pixelstore_attrib
*attr
;
1285 #if FEATURE_EXT_pixel_buffer_object
1286 ctx
->Pack
.BufferObj
->RefCount
++;
1287 ctx
->Unpack
.BufferObj
->RefCount
++;
1289 /* packing attribs */
1290 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
1291 MEMCPY( attr
, &ctx
->Pack
, sizeof(struct gl_pixelstore_attrib
) );
1292 newnode
= new_attrib_node( GL_CLIENT_PACK_BIT
);
1293 newnode
->data
= attr
;
1294 newnode
->next
= head
;
1296 /* unpacking attribs */
1297 attr
= MALLOC_STRUCT( gl_pixelstore_attrib
);
1298 MEMCPY( attr
, &ctx
->Unpack
, sizeof(struct gl_pixelstore_attrib
) );
1299 newnode
= new_attrib_node( GL_CLIENT_UNPACK_BIT
);
1300 newnode
->data
= attr
;
1301 newnode
->next
= head
;
1304 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
1305 struct gl_array_attrib
*attr
;
1306 struct gl_array_object
*obj
;
1308 attr
= MALLOC_STRUCT( gl_array_attrib
);
1309 obj
= MALLOC_STRUCT( gl_array_object
);
1311 #if FEATURE_ARB_vertex_buffer_object
1312 /* increment ref counts since we're copying pointers to these objects */
1313 ctx
->Array
.ArrayBufferObj
->RefCount
++;
1314 ctx
->Array
.ElementArrayBufferObj
->RefCount
++;
1317 MEMCPY( attr
, &ctx
->Array
, sizeof(struct gl_array_attrib
) );
1318 MEMCPY( obj
, ctx
->Array
.ArrayObj
, sizeof(struct gl_array_object
) );
1320 attr
->ArrayObj
= obj
;
1322 newnode
= new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT
);
1323 newnode
->data
= attr
;
1324 newnode
->next
= head
;
1326 /* bump reference counts on buffer objects */
1327 adjust_buffer_object_ref_counts(&ctx
->Array
, 1);
1330 ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
] = head
;
1331 ctx
->ClientAttribStackDepth
++;
1338 _mesa_PopClientAttrib(void)
1340 struct gl_attrib_node
*attr
, *next
;
1342 GET_CURRENT_CONTEXT(ctx
);
1343 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
1345 if (ctx
->ClientAttribStackDepth
== 0) {
1346 _mesa_error( ctx
, GL_STACK_UNDERFLOW
, "glPopClientAttrib" );
1350 ctx
->ClientAttribStackDepth
--;
1351 attr
= ctx
->ClientAttribStack
[ctx
->ClientAttribStackDepth
];
1354 switch (attr
->kind
) {
1355 case GL_CLIENT_PACK_BIT
:
1356 #if FEATURE_EXT_pixel_buffer_object
1357 ctx
->Pack
.BufferObj
->RefCount
--;
1358 if (ctx
->Pack
.BufferObj
->RefCount
<= 0) {
1359 _mesa_remove_buffer_object( ctx
, ctx
->Pack
.BufferObj
);
1360 (*ctx
->Driver
.DeleteBuffer
)( ctx
, ctx
->Pack
.BufferObj
);
1363 MEMCPY( &ctx
->Pack
, attr
->data
,
1364 sizeof(struct gl_pixelstore_attrib
) );
1365 ctx
->NewState
|= _NEW_PACKUNPACK
;
1367 case GL_CLIENT_UNPACK_BIT
:
1368 #if FEATURE_EXT_pixel_buffer_object
1369 ctx
->Unpack
.BufferObj
->RefCount
--;
1370 if (ctx
->Unpack
.BufferObj
->RefCount
<= 0) {
1371 _mesa_remove_buffer_object( ctx
, ctx
->Unpack
.BufferObj
);
1372 (*ctx
->Driver
.DeleteBuffer
)( ctx
, ctx
->Unpack
.BufferObj
);
1375 MEMCPY( &ctx
->Unpack
, attr
->data
,
1376 sizeof(struct gl_pixelstore_attrib
) );
1377 ctx
->NewState
|= _NEW_PACKUNPACK
;
1379 case GL_CLIENT_VERTEX_ARRAY_BIT
: {
1380 struct gl_array_attrib
* data
=
1381 (struct gl_array_attrib
*) attr
->data
;
1383 adjust_buffer_object_ref_counts(&ctx
->Array
, -1);
1385 ctx
->Array
.ActiveTexture
= data
->ActiveTexture
;
1386 ctx
->Array
.LockFirst
= data
->LockFirst
;
1387 ctx
->Array
.LockCount
= data
->LockCount
;
1389 _mesa_BindVertexArrayAPPLE( data
->ArrayObj
->Name
);
1391 #if FEATURE_ARB_vertex_buffer_object
1392 _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB
,
1393 data
->ArrayBufferObj
->Name
);
1394 _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
,
1395 data
->ElementArrayBufferObj
->Name
);
1398 MEMCPY( ctx
->Array
.ArrayObj
, data
->ArrayObj
,
1399 sizeof( struct gl_array_object
) );
1401 FREE( data
->ArrayObj
);
1403 /* FIXME: Should some bits in ctx->Array->NewState also be set
1404 * FIXME: here? It seems like it should be set to inclusive-or
1405 * FIXME: of the old ArrayObj->_Enabled and the new _Enabled.
1408 ctx
->NewState
|= _NEW_ARRAY
;
1412 _mesa_problem( ctx
, "Bad attrib flag in PopClientAttrib");
1424 void _mesa_init_attrib( GLcontext
*ctx
)
1426 /* Renderer and client attribute stacks */
1427 ctx
->AttribStackDepth
= 0;
1428 ctx
->ClientAttribStackDepth
= 0;