1GLPUSHATTRIB(3G)                 OpenGL Manual                GLPUSHATTRIB(3G)
2
3
4

NAME

6       glPushAttrib - push and pop the server attribute stack
7

C SPECIFICATION

9       void glPushAttrib(GLbitfield mask);
10

PARAMETERS

12       mask
13           Specifies a mask that indicates which attributes to save. Values
14           for mask are listed below.
15

C SPECIFICATION

17       void glPopAttrib(void);
18

DESCRIPTION

20       glPushAttrib takes one argument, a mask that indicates which groups of
21       state variables to save on the attribute stack. Symbolic constants are
22       used to set bits in the mask.  mask is typically constructed by
23       specifying the bitwise-or of several of these constants together. The
24       special mask GL_ALL_ATTRIB_BITS can be used to save all stackable
25       states.
26
27       The symbolic mask constants and their associated GL state are as
28       follows (the second column lists which attributes are saved):
29
30       ┌───────────────────────┬──────────────────────────────────┐
31GL_ACCUM_BUFFER_BIT    │ Accumulation buffer clear        │
32       │                       │ value                            │
33       ├───────────────────────┼──────────────────────────────────┤
34GL_COLOR_BUFFER_BIT    GL_ALPHA_TEST enable bit         │
35       ├───────────────────────┼──────────────────────────────────┤
36       │                       │ Alpha test function and          │
37       │                       │ reference value                  │
38       ├───────────────────────┼──────────────────────────────────┤
39       │                       │ GL_BLEND enable bit              │
40       ├───────────────────────┼──────────────────────────────────┤
41       │                       │ Blending source and              │
42       │                       │ destination functions            │
43       ├───────────────────────┼──────────────────────────────────┤
44       │                       │ Constant blend color             │
45       ├───────────────────────┼──────────────────────────────────┤
46       │                       │ Blending equation                │
47       ├───────────────────────┼──────────────────────────────────┤
48       │                       │ GL_DITHER enable bit             │
49       ├───────────────────────┼──────────────────────────────────┤
50       │                       │ GL_DRAW_BUFFER setting           │
51       ├───────────────────────┼──────────────────────────────────┤
52       │                       │ GL_COLOR_LOGIC_OP enable         │
53       │                       │ bit                              │
54       ├───────────────────────┼──────────────────────────────────┤
55       │                       │ GL_INDEX_LOGIC_OP enable         │
56       │                       │ bit                              │
57       ├───────────────────────┼──────────────────────────────────┤
58       │                       │ Logic op function                │
59       ├───────────────────────┼──────────────────────────────────┤
60       │                       │ Color mode and index mode        │
61       │                       │ clear values                     │
62       ├───────────────────────┼──────────────────────────────────┤
63       │                       │ Color mode and index mode        │
64       │                       │ writemasks                       │
65       ├───────────────────────┼──────────────────────────────────┤
66GL_CURRENT_BIT         │ Current RGBA color               │
67       ├───────────────────────┼──────────────────────────────────┤
68       │                       │ Current color index              │
69       ├───────────────────────┼──────────────────────────────────┤
70       │                       │ Current normal vector            │
71       ├───────────────────────┼──────────────────────────────────┤
72       │                       │ Current texture                  │
73       │                       │ coordinates                      │
74       ├───────────────────────┼──────────────────────────────────┤
75       │                       │ Current raster position          │
76       ├───────────────────────┼──────────────────────────────────┤
77       │                       │ GL_CURRENT_RASTER_POSITION_VALID 
78       │                       │ flag                             │
79       ├───────────────────────┼──────────────────────────────────┤
80       │                       │ RGBA color associated with       │
81       │                       │ current raster position          │
82       ├───────────────────────┼──────────────────────────────────┤
83       │                       │ Color index associated with      │
84       │                       │ current raster position          │
85       ├───────────────────────┼──────────────────────────────────┤
86       │                       │ Texture coordinates associated   │
87       │                       │ with current raster position     │
88       ├───────────────────────┼──────────────────────────────────┤
89       │                       │ GL_EDGE_FLAG flag                │
90       ├───────────────────────┼──────────────────────────────────┤
91GL_DEPTH_BUFFER_BIT    GL_DEPTH_TEST enable bit         │
92       ├───────────────────────┼──────────────────────────────────┤
93       │                       │ Depth buffer test function       │
94       ├───────────────────────┼──────────────────────────────────┤
95       │                       │ Depth buffer clear value         │
96       ├───────────────────────┼──────────────────────────────────┤
97       │                       │ GL_DEPTH_WRITEMASK enable bit    │
98       ├───────────────────────┼──────────────────────────────────┤
99GL_ENABLE_BIT          GL_ALPHA_TEST flag               │
100       ├───────────────────────┼──────────────────────────────────┤
101       │                       │ GL_AUTO_NORMAL flag              │
102       ├───────────────────────┼──────────────────────────────────┤
103       │                       │ GL_BLEND flag                    │
104       ├───────────────────────┼──────────────────────────────────┤
105       │                       │ Enable bits for the              │
106       │                       │ user-definable clipping planes   │
107       ├───────────────────────┼──────────────────────────────────┤
108       │                       │ GL_COLOR_MATERIAL                
109       ├───────────────────────┼──────────────────────────────────┤
110       │                       │ GL_CULL_FACE flag                │
111       ├───────────────────────┼──────────────────────────────────┤
112       │                       │ GL_DEPTH_TEST flag               │
113       ├───────────────────────┼──────────────────────────────────┤
114       │                       │ GL_DITHER flag                   │
115       ├───────────────────────┼──────────────────────────────────┤
116       │                       │ GL_FOG flag                      │
117       ├───────────────────────┼──────────────────────────────────┤
118       │                       │ GL_LIGHTi                where   │
119       │                       │                         0 <=     │
120       │                       │                                  │
121       │                       │ i <                              │
122       │                       │ GL_MAX_LIGHTS                    
123       ├───────────────────────┼──────────────────────────────────┤
124       │                       │ GL_LIGHTING flag                 │
125       ├───────────────────────┼──────────────────────────────────┤
126       │                       │ GL_LINE_SMOOTH flag              │
127       ├───────────────────────┼──────────────────────────────────┤
128       │                       │ GL_LINE_STIPPLE flag             │
129       ├───────────────────────┼──────────────────────────────────┤
130       │                       │ GL_COLOR_LOGIC_OP flag           │
131       ├───────────────────────┼──────────────────────────────────┤
132       │                       │ GL_INDEX_LOGIC_OP flag           │
133       ├───────────────────────┼──────────────────────────────────┤
134       │                       │ GL_MAP1_x where x is a map type  │
135       ├───────────────────────┼──────────────────────────────────┤
136       │                       │ GL_MAP2_x where x is a map type  │
137       ├───────────────────────┼──────────────────────────────────┤
138       │                       │ GL_MULTISAMPLE flag              │
139       ├───────────────────────┼──────────────────────────────────┤
140       │                       │ GL_NORMALIZE flag                │
141       ├───────────────────────┼──────────────────────────────────┤
142       │                       │ GL_POINT_SMOOTH flag             │
143       ├───────────────────────┼──────────────────────────────────┤
144       │                       │ GL_POLYGON_OFFSET_LINE flag      │
145       ├───────────────────────┼──────────────────────────────────┤
146       │                       │ GL_POLYGON_OFFSET_FILL flag      │
147       ├───────────────────────┼──────────────────────────────────┤
148       │                       │ GL_POLYGON_OFFSET_POINT flag     │
149       ├───────────────────────┼──────────────────────────────────┤
150       │                       │ GL_POLYGON_SMOOTH flag           │
151       ├───────────────────────┼──────────────────────────────────┤
152       │                       │ GL_POLYGON_STIPPLE flag          │
153       ├───────────────────────┼──────────────────────────────────┤
154       │                       │ GL_SAMPLE_ALPHA_TO_COVERAGE flag │
155       ├───────────────────────┼──────────────────────────────────┤
156       │                       │ GL_SAMPLE_ALPHA_TO_ONE flag      │
157       ├───────────────────────┼──────────────────────────────────┤
158       │                       │ GL_SAMPLE_COVERAGE flag          │
159       ├───────────────────────┼──────────────────────────────────┤
160       │                       │ GL_SCISSOR_TEST flag             │
161       ├───────────────────────┼──────────────────────────────────┤
162       │                       │ GL_STENCIL_TEST flag             │
163       ├───────────────────────┼──────────────────────────────────┤
164       │                       │ GL_TEXTURE_1D flag               │
165       ├───────────────────────┼──────────────────────────────────┤
166       │                       │ GL_TEXTURE_2D flag               │
167       ├───────────────────────┼──────────────────────────────────┤
168       │                       │ GL_TEXTURE_3D flag               │
169       ├───────────────────────┼──────────────────────────────────┤
170       │                       │ Flags GL_TEXTURE_GEN_x where x
171       │                       │ is S, T, R, or Q                 │
172       ├───────────────────────┼──────────────────────────────────┤
173GL_EVAL_BIT            GL_MAP1_x enable bits, where x
174       │                       │ is a map type                    │
175       ├───────────────────────┼──────────────────────────────────┤
176       │                       │ GL_MAP2_x enable bits, where x
177       │                       │ is a map type                    │
178       ├───────────────────────┼──────────────────────────────────┤
179       │                       │ 1D grid endpoints and divisions  │
180       ├───────────────────────┼──────────────────────────────────┤
181       │                       │ 2D grid endpoints and divisions  │
182       ├───────────────────────┼──────────────────────────────────┤
183       │                       │ GL_AUTO_NORMAL enable bit        │
184       ├───────────────────────┼──────────────────────────────────┤
185GL_FOG_BIT             GL_FOG enable bit                │
186       ├───────────────────────┼──────────────────────────────────┤
187       │                       │ Fog color                        │
188       ├───────────────────────┼──────────────────────────────────┤
189       │                       │ Fog density                      │
190       ├───────────────────────┼──────────────────────────────────┤
191       │                       │ Linear fog start                 │
192       ├───────────────────────┼──────────────────────────────────┤
193       │                       │ Linear fog end                   │
194       ├───────────────────────┼──────────────────────────────────┤
195       │                       │ Fog index                        │
196       ├───────────────────────┼──────────────────────────────────┤
197       │                       │ GL_FOG_MODE value                │
198       ├───────────────────────┼──────────────────────────────────┤
199GL_HINT_BIT            GL_PERSPECTIVE_CORRECTION_HINT   
200       │                       │ setting                          │
201       ├───────────────────────┼──────────────────────────────────┤
202       │                       │ GL_POINT_SMOOTH_HINT setting     │
203       ├───────────────────────┼──────────────────────────────────┤
204       │                       │ GL_LINE_SMOOTH_HINT setting      │
205       ├───────────────────────┼──────────────────────────────────┤
206       │                       │ GL_POLYGON_SMOOTH_HINT setting   │
207       ├───────────────────────┼──────────────────────────────────┤
208       │                       │ GL_FOG_HINT setting              │
209       ├───────────────────────┼──────────────────────────────────┤
210       │                       │ GL_GENERATE_MIPMAP_HINT setting  │
211       ├───────────────────────┼──────────────────────────────────┤
212       │                       │ GL_TEXTURE_COMPRESSION_HINT      
213       │                       │ setting                          │
214       ├───────────────────────┼──────────────────────────────────┤
215GL_LIGHTING_BIT        GL_COLOR_MATERIAL enable bit     │
216       ├───────────────────────┼──────────────────────────────────┤
217       │                       │ GL_COLOR_MATERIAL_FACE value     │
218       ├───────────────────────┼──────────────────────────────────┤
219       │                       │ Color material parameters that   │
220       │                       │ are tracking the current color   │
221       ├───────────────────────┼──────────────────────────────────┤
222       │                       │ Ambient scene color              │
223       ├───────────────────────┼──────────────────────────────────┤
224       │                       │ GL_LIGHT_MODEL_LOCAL_VIEWER      
225       │                       │ value                            │
226       ├───────────────────────┼──────────────────────────────────┤
227       │                       │ GL_LIGHT_MODEL_TWO_SIDE setting  │
228       ├───────────────────────┼──────────────────────────────────┤
229       │                       │ GL_LIGHTING enable bit           │
230       ├───────────────────────┼──────────────────────────────────┤
231       │                       │ Enable bit for each light        │
232       ├───────────────────────┼──────────────────────────────────┤
233       │                       │ Ambient, diffuse, and specular   │
234       │                       │ intensity for each light         │
235       ├───────────────────────┼──────────────────────────────────┤
236       │                       │ Direction, position, exponent,   │
237       │                       │ and cutoff angle for each light  │
238       ├───────────────────────┼──────────────────────────────────┤
239       │                       │ Constant, linear, and quadratic  │
240       │                       │ attenuation factors for each     │
241       │                       │ light                            │
242       ├───────────────────────┼──────────────────────────────────┤
243       │                       │ Ambient, diffuse, specular, and  │
244       │                       │ emissive color for each material │
245       ├───────────────────────┼──────────────────────────────────┤
246       │                       │ Ambient, diffuse, and specular   │
247       │                       │ color indices for each material  │
248       ├───────────────────────┼──────────────────────────────────┤
249       │                       │ Specular exponent for each       │
250       │                       │ material                         │
251       ├───────────────────────┼──────────────────────────────────┤
252       │                       │ GL_SHADE_MODEL setting           │
253       ├───────────────────────┼──────────────────────────────────┤
254GL_LINE_BIT            GL_LINE_SMOOTH flag              │
255       ├───────────────────────┼──────────────────────────────────┤
256       │                       │ GL_LINE_STIPPLE enable bit       │
257       ├───────────────────────┼──────────────────────────────────┤
258       │                       │ Line stipple pattern and repeat  │
259       │                       │ counter                          │
260       ├───────────────────────┼──────────────────────────────────┤
261       │                       │ Line width                       │
262       ├───────────────────────┼──────────────────────────────────┤
263GL_LIST_BIT            GL_LIST_BASE setting             │
264       ├───────────────────────┼──────────────────────────────────┤
265GL_MULTISAMPLE_BIT     GL_MULTISAMPLE flag              │
266       ├───────────────────────┼──────────────────────────────────┤
267       │                       │ GL_SAMPLE_ALPHA_TO_COVERAGE flag │
268       ├───────────────────────┼──────────────────────────────────┤
269       │                       │ GL_SAMPLE_ALPHA_TO_ONE flag      │
270       ├───────────────────────┼──────────────────────────────────┤
271       │                       │ GL_SAMPLE_COVERAGE flag          │
272       ├───────────────────────┼──────────────────────────────────┤
273       │                       │ GL_SAMPLE_COVERAGE_VALUE value   │
274       ├───────────────────────┼──────────────────────────────────┤
275       │                       │ GL_SAMPLE_COVERAGE_INVERT value  │
276       ├───────────────────────┼──────────────────────────────────┤
277GL_PIXEL_MODE_BIT      GL_RED_BIAS and GL_RED_SCALE     
278       │                       │ settings                         │
279       ├───────────────────────┼──────────────────────────────────┤
280       │                       │ GL_GREEN_BIAS and GL_GREEN_SCALE 
281       │                       │ values                           │
282       ├───────────────────────┼──────────────────────────────────┤
283       │                       │ GL_BLUE_BIAS and GL_BLUE_SCALE   
284       ├───────────────────────┼──────────────────────────────────┤
285       │                       │ GL_ALPHA_BIAS and GL_ALPHA_SCALE 
286       ├───────────────────────┼──────────────────────────────────┤
287       │                       │ GL_DEPTH_BIAS and GL_DEPTH_SCALE 
288       ├───────────────────────┼──────────────────────────────────┤
289       │                       │ GL_INDEX_OFFSET and              │
290       │                       │ GL_INDEX_SHIFT values            │
291       ├───────────────────────┼──────────────────────────────────┤
292       │                       │ GL_MAP_COLOR and GL_MAP_STENCIL  
293       │                       │ flags                            │
294       ├───────────────────────┼──────────────────────────────────┤
295       │                       │ GL_ZOOM_X and GL_ZOOM_Y factors  │
296       ├───────────────────────┼──────────────────────────────────┤
297       │                       │ GL_READ_BUFFER setting           │
298       ├───────────────────────┼──────────────────────────────────┤
299GL_POINT_BIT           GL_POINT_SMOOTH flag             │
300       ├───────────────────────┼──────────────────────────────────┤
301       │                       │ Point size                       │
302       ├───────────────────────┼──────────────────────────────────┤
303GL_POLYGON_BIT         GL_CULL_FACE enable bit          │
304       ├───────────────────────┼──────────────────────────────────┤
305       │                       │ GL_CULL_FACE_MODE value          │
306       ├───────────────────────┼──────────────────────────────────┤
307       │                       │ GL_FRONT_FACE indicator          │
308       ├───────────────────────┼──────────────────────────────────┤
309       │                       │ GL_POLYGON_MODE setting          │
310       ├───────────────────────┼──────────────────────────────────┤
311       │                       │ GL_POLYGON_SMOOTH flag           │
312       ├───────────────────────┼──────────────────────────────────┤
313       │                       │ GL_POLYGON_STIPPLE enable bit    │
314       ├───────────────────────┼──────────────────────────────────┤
315       │                       │ GL_POLYGON_OFFSET_FILL flag      │
316       ├───────────────────────┼──────────────────────────────────┤
317       │                       │ GL_POLYGON_OFFSET_LINE flag      │
318       ├───────────────────────┼──────────────────────────────────┤
319       │                       │ GL_POLYGON_OFFSET_POINT flag     │
320       ├───────────────────────┼──────────────────────────────────┤
321       │                       │ GL_POLYGON_OFFSET_FACTOR         
322       ├───────────────────────┼──────────────────────────────────┤
323       │                       │ GL_POLYGON_OFFSET_UNITS          
324       ├───────────────────────┼──────────────────────────────────┤
325GL_POLYGON_STIPPLE_BIT │ Polygon stipple image            │
326       ├───────────────────────┼──────────────────────────────────┤
327GL_SCISSOR_BIT         GL_SCISSOR_TEST flag             │
328       ├───────────────────────┼──────────────────────────────────┤
329       │                       │ Scissor box                      │
330       ├───────────────────────┼──────────────────────────────────┤
331GL_STENCIL_BUFFER_BIT  GL_STENCIL_TEST enable bit       │
332       ├───────────────────────┼──────────────────────────────────┤
333       │                       │ Stencil function and reference   │
334       │                       │ value                            │
335       ├───────────────────────┼──────────────────────────────────┤
336       │                       │ Stencil value mask               │
337       ├───────────────────────┼──────────────────────────────────┤
338       │                       │ Stencil fail, pass, and depth    │
339       │                       │ buffer pass actions              │
340       ├───────────────────────┼──────────────────────────────────┤
341       │                       │ Stencil buffer clear value       │
342       ├───────────────────────┼──────────────────────────────────┤
343       │                       │ Stencil buffer writemask         │
344       ├───────────────────────┼──────────────────────────────────┤
345GL_TEXTURE_BIT         │ Enable bits for the four texture │
346       │                       │ coordinates                      │
347       ├───────────────────────┼──────────────────────────────────┤
348       │                       │ Border color for each texture    │
349       │                       │ image                            │
350       ├───────────────────────┼──────────────────────────────────┤
351       │                       │ Minification function for each   │
352       │                       │ texture image                    │
353       ├───────────────────────┼──────────────────────────────────┤
354       │                       │ Magnification function for each  │
355       │                       │ texture image                    │
356       ├───────────────────────┼──────────────────────────────────┤
357       │                       │ Texture coordinates and wrap     │
358       │                       │ mode for each texture image      │
359       ├───────────────────────┼──────────────────────────────────┤
360       │                       │ Color and mode for each texture  │
361       │                       │ environment                      │
362       ├───────────────────────┼──────────────────────────────────┤
363       │                       │ Enable bits GL_TEXTURE_GEN_x, x
364       │                       │ is S, T, R, and Q                │
365       ├───────────────────────┼──────────────────────────────────┤
366       │                       │ GL_TEXTURE_GEN_MODE setting for  │
367       │                       │ S, T, R, and Q                   │
368       ├───────────────────────┼──────────────────────────────────┤
369       │                       │ glTexGen() plane equations for   │
370       │                       │ S, T, R, and Q                   │
371       ├───────────────────────┼──────────────────────────────────┤
372       │                       │ Current texture bindings (for    │
373       │                       │ example, GL_TEXTURE_BINDING_2D)  │
374       ├───────────────────────┼──────────────────────────────────┤
375GL_TRANSFORM_BIT       │ Coefficients of the six clipping │
376       │                       │ planes                           │
377       ├───────────────────────┼──────────────────────────────────┤
378       │                       │ Enable bits for the              │
379       │                       │ user-definable clipping planes   │
380       ├───────────────────────┼──────────────────────────────────┤
381       │                       │ GL_MATRIX_MODE value             │
382       ├───────────────────────┼──────────────────────────────────┤
383       │                       │ GL_NORMALIZE flag                │
384       ├───────────────────────┼──────────────────────────────────┤
385       │                       │ GL_RESCALE_NORMAL flag           │
386       ├───────────────────────┼──────────────────────────────────┤
387GL_VIEWPORT_BIT        │ Depth range (near and far)       │
388       ├───────────────────────┼──────────────────────────────────┤
389       │                       │ Viewport origin and extent       │
390       └───────────────────────┴──────────────────────────────────┘
391
392       glPopAttrib() restores the values of the state variables saved with the
393       last glPushAttrib command. Those not saved are left unchanged.
394
395       It is an error to push attributes onto a full stack or to pop
396       attributes off an empty stack. In either case, the error flag is set
397       and no other change is made to GL state.
398
399       Initially, the attribute stack is empty.
400

NOTES

402       Not all values for GL state can be saved on the attribute stack. For
403       example, render mode state, and select and feedback state cannot be
404       saved. Client state must be saved with glPushClientAttrib().
405
406       The depth of the attribute stack depends on the implementation, but it
407       must be at least 16.
408
409       For OpenGL versions 1.3 and greater, or when the ARB_multitexture
410       extension is supported, pushing and popping texture state applies to
411       all supported texture units.
412

ERRORS

414       GL_STACK_OVERFLOW is generated if glPushAttrib is called while the
415       attribute stack is full.
416
417       GL_STACK_UNDERFLOW is generated if glPopAttrib() is called while the
418       attribute stack is empty.
419
420       GL_INVALID_OPERATION is generated if glPushAttrib or glPopAttrib() is
421       executed between the execution of glBegin() and the corresponding
422       execution of glEnd().
423

ASSOCIATED GETS

425       glGet() with argument GL_ATTRIB_STACK_DEPTH
426
427       glGet() with argument GL_MAX_ATTRIB_STACK_DEPTH
428

SEE ALSO

430       glGet(), glGetClipPlane(), glGetError(), glGetLight(), glGetMap(),
431       glGetMaterial(), glGetPixelMap(), glGetPolygonStipple(), glGetString(),
432       glGetTexEnv(), glGetTexGen(), glGetTexImage(),
433       glGetTexLevelParameter(), glGetTexParameter(), glIsEnabled(),
434       glPushClientAttrib()
435
437       Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed
438       under the SGI Free Software B License. For details, see
439       http://oss.sgi.com/projects/FreeB/.
440

AUTHORS

442       opengl.org
443
444
445
446opengl.org                        07/13/2018                  GLPUSHATTRIB(3G)
Impressum