1 /* $XFree86: xc/lib/GL/glx/clientattrib.c,v 1.5 2001/03/21 16:04:39 dawes Exp $ */
3 ** License Applicability. Except to the extent portions of this file are
4 ** made subject to an alternative license as permitted in the SGI Free
5 ** Software License B, Version 1.1 (the "License"), the contents of this
6 ** file are subject only to the provisions of the License. You may not use
7 ** this file except in compliance with the License. You may obtain a copy
8 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
9 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
11 ** http://oss.sgi.com/projects/FreeB
13 ** Note that, as provided in the License, the Software is distributed on an
14 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
15 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
16 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
17 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
19 ** Original Code. The Original Code is: OpenGL Sample Implementation,
20 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
21 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
22 ** Copyright in any portions created by third parties is as indicated
23 ** elsewhere herein. All Rights Reserved.
25 ** Additional Notice Provisions: The application programming interfaces
26 ** established by SGI in conjunction with the Original Code are The
27 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
28 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
29 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
30 ** Window System(R) (Version 1.3), released October 19, 1998. This software
31 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
32 ** published by SGI, but has not been independently verified as being
33 ** compliant with the OpenGL(R) version 1.2.1 Specification.
38 #define NEED_GL_FUNCS_WRAPPED
39 #include "glxclient.h"
41 /*****************************************************************************/
43 void glEnableClientState(GLenum array
)
45 __GLXcontext
*gc
= __glXGetCurrentContext();
46 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
50 ENABLE_ARRAY(state
, color
);
52 case GL_EDGE_FLAG_ARRAY
:
53 ENABLE_ARRAY(state
, edgeFlag
);
56 ENABLE_ARRAY(state
, index
);
59 ENABLE_ARRAY(state
, normal
);
61 case GL_TEXTURE_COORD_ARRAY
:
62 ENABLE_TEXARRAY(state
, state
->vertArray
.activeTexture
);
65 ENABLE_ARRAY(state
, vertex
);
67 case GL_SECONDARY_COLOR_ARRAY
:
68 ENABLE_ARRAY(state
, secondaryColor
);
70 case GL_FOG_COORD_ARRAY
:
71 ENABLE_ARRAY(state
, fogCoord
);
74 __glXSetError(gc
, GL_INVALID_ENUM
);
78 void glDisableClientState(GLenum array
)
80 __GLXcontext
*gc
= __glXGetCurrentContext();
81 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
85 DISABLE_ARRAY(state
, color
);
87 case GL_EDGE_FLAG_ARRAY
:
88 DISABLE_ARRAY(state
, edgeFlag
);
91 DISABLE_ARRAY(state
, index
);
94 DISABLE_ARRAY(state
, normal
);
96 case GL_TEXTURE_COORD_ARRAY
:
97 DISABLE_TEXARRAY(state
, state
->vertArray
.activeTexture
);
100 DISABLE_ARRAY(state
, vertex
);
102 case GL_SECONDARY_COLOR_ARRAY
:
103 DISABLE_ARRAY(state
, secondaryColor
);
105 case GL_FOG_COORD_ARRAY
:
106 DISABLE_ARRAY(state
, fogCoord
);
109 __glXSetError(gc
, GL_INVALID_ENUM
);
113 /************************************************************************/
115 void glPushClientAttrib(GLuint mask
)
117 __GLXcontext
*gc
= __glXGetCurrentContext();
118 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
119 __GLXattribute
**spp
= gc
->attributes
.stackPointer
, *sp
;
121 if (spp
< &gc
->attributes
.stack
[__GL_CLIENT_ATTRIB_STACK_DEPTH
]) {
123 sp
= (__GLXattribute
*)Xmalloc(sizeof(__GLXattribute
));
127 gc
->attributes
.stackPointer
= spp
+ 1;
128 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
129 sp
->storePack
= state
->storePack
;
130 sp
->storeUnpack
= state
->storeUnpack
;
132 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
133 sp
->vertArray
= state
->vertArray
;
136 __glXSetError(gc
, GL_STACK_OVERFLOW
);
141 void glPopClientAttrib(void)
143 __GLXcontext
*gc
= __glXGetCurrentContext();
144 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
145 __GLXattribute
**spp
= gc
->attributes
.stackPointer
, *sp
;
148 if (spp
> &gc
->attributes
.stack
[0]) {
153 gc
->attributes
.stackPointer
= spp
;
155 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
156 state
->storePack
= sp
->storePack
;
157 state
->storeUnpack
= sp
->storeUnpack
;
159 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
160 state
->vertArray
= sp
->vertArray
;
165 __glXSetError(gc
, GL_STACK_UNDERFLOW
);
170 void __glFreeAttributeState(__GLXcontext
*gc
)
172 __GLXattribute
*sp
, **spp
;
174 for (spp
= &gc
->attributes
.stack
[0];
175 spp
< &gc
->attributes
.stack
[__GL_CLIENT_ATTRIB_STACK_DEPTH
];