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 #include "glxclient.h"
40 /*****************************************************************************/
42 void __indirect_glEnableClientState(GLenum array
)
44 __GLXcontext
*gc
= __glXGetCurrentContext();
45 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
49 ENABLE_ARRAY(state
, color
);
51 case GL_EDGE_FLAG_ARRAY
:
52 ENABLE_ARRAY(state
, edgeFlag
);
55 ENABLE_ARRAY(state
, index
);
58 ENABLE_ARRAY(state
, normal
);
60 case GL_TEXTURE_COORD_ARRAY
:
61 ENABLE_TEXARRAY(state
, state
->vertArray
.activeTexture
);
64 ENABLE_ARRAY(state
, vertex
);
66 case GL_SECONDARY_COLOR_ARRAY
:
67 ENABLE_ARRAY(state
, secondaryColor
);
69 case GL_FOG_COORD_ARRAY
:
70 ENABLE_ARRAY(state
, fogCoord
);
73 __glXSetError(gc
, GL_INVALID_ENUM
);
77 void __indirect_glDisableClientState(GLenum array
)
79 __GLXcontext
*gc
= __glXGetCurrentContext();
80 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
84 DISABLE_ARRAY(state
, color
);
86 case GL_EDGE_FLAG_ARRAY
:
87 DISABLE_ARRAY(state
, edgeFlag
);
90 DISABLE_ARRAY(state
, index
);
93 DISABLE_ARRAY(state
, normal
);
95 case GL_TEXTURE_COORD_ARRAY
:
96 DISABLE_TEXARRAY(state
, state
->vertArray
.activeTexture
);
99 DISABLE_ARRAY(state
, vertex
);
101 case GL_SECONDARY_COLOR_ARRAY
:
102 DISABLE_ARRAY(state
, secondaryColor
);
104 case GL_FOG_COORD_ARRAY
:
105 DISABLE_ARRAY(state
, fogCoord
);
108 __glXSetError(gc
, GL_INVALID_ENUM
);
112 /************************************************************************/
114 void __indirect_glPushClientAttrib(GLuint mask
)
116 __GLXcontext
*gc
= __glXGetCurrentContext();
117 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
118 __GLXattribute
**spp
= gc
->attributes
.stackPointer
, *sp
;
120 if (spp
< &gc
->attributes
.stack
[__GL_CLIENT_ATTRIB_STACK_DEPTH
]) {
122 sp
= (__GLXattribute
*)Xmalloc(sizeof(__GLXattribute
));
126 gc
->attributes
.stackPointer
= spp
+ 1;
127 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
128 sp
->storePack
= state
->storePack
;
129 sp
->storeUnpack
= state
->storeUnpack
;
131 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
132 sp
->vertArray
= state
->vertArray
;
135 __glXSetError(gc
, GL_STACK_OVERFLOW
);
140 void __indirect_glPopClientAttrib(void)
142 __GLXcontext
*gc
= __glXGetCurrentContext();
143 __GLXattribute
* state
= (__GLXattribute
*)(gc
->client_state_private
);
144 __GLXattribute
**spp
= gc
->attributes
.stackPointer
, *sp
;
147 if (spp
> &gc
->attributes
.stack
[0]) {
152 gc
->attributes
.stackPointer
= spp
;
154 if (mask
& GL_CLIENT_PIXEL_STORE_BIT
) {
155 state
->storePack
= sp
->storePack
;
156 state
->storeUnpack
= sp
->storeUnpack
;
158 if (mask
& GL_CLIENT_VERTEX_ARRAY_BIT
) {
159 state
->vertArray
= sp
->vertArray
;
164 __glXSetError(gc
, GL_STACK_UNDERFLOW
);
169 void __glFreeAttributeState(__GLXcontext
*gc
)
171 __GLXattribute
*sp
, **spp
;
173 for (spp
= &gc
->attributes
.stack
[0];
174 spp
< &gc
->attributes
.stack
[__GL_CLIENT_ATTRIB_STACK_DEPTH
];