Enable client-side GLX support for texture compression extensions.
[mesa.git] / src / glx / x11 / clientattrib.c
1 /* $XFree86: xc/lib/GL/glx/clientattrib.c,v 1.5 2001/03/21 16:04:39 dawes Exp $ */
2 /*
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:
10 **
11 ** http://oss.sgi.com/projects/FreeB
12 **
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.
18 **
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.
24 **
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.
34 **
35 */
36
37 #include <assert.h>
38 #include "glxclient.h"
39
40 /*****************************************************************************/
41
42 void __indirect_glEnableClientState(GLenum array)
43 {
44 __GLXcontext *gc = __glXGetCurrentContext();
45 __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
46
47 switch (array) {
48 case GL_COLOR_ARRAY:
49 ENABLE_ARRAY(state, color);
50 break;
51 case GL_EDGE_FLAG_ARRAY:
52 ENABLE_ARRAY(state, edgeFlag);
53 break;
54 case GL_INDEX_ARRAY:
55 ENABLE_ARRAY(state, index);
56 break;
57 case GL_NORMAL_ARRAY:
58 ENABLE_ARRAY(state, normal);
59 break;
60 case GL_TEXTURE_COORD_ARRAY:
61 ENABLE_TEXARRAY(state, state->vertArray.activeTexture);
62 break;
63 case GL_VERTEX_ARRAY:
64 ENABLE_ARRAY(state, vertex);
65 break;
66 case GL_SECONDARY_COLOR_ARRAY:
67 ENABLE_ARRAY(state, secondaryColor);
68 break;
69 case GL_FOG_COORD_ARRAY:
70 ENABLE_ARRAY(state, fogCoord);
71 break;
72 default:
73 __glXSetError(gc, GL_INVALID_ENUM);
74 }
75 }
76
77 void __indirect_glDisableClientState(GLenum array)
78 {
79 __GLXcontext *gc = __glXGetCurrentContext();
80 __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
81
82 switch (array) {
83 case GL_COLOR_ARRAY:
84 DISABLE_ARRAY(state, color);
85 break;
86 case GL_EDGE_FLAG_ARRAY:
87 DISABLE_ARRAY(state, edgeFlag);
88 break;
89 case GL_INDEX_ARRAY:
90 DISABLE_ARRAY(state, index);
91 break;
92 case GL_NORMAL_ARRAY:
93 DISABLE_ARRAY(state, normal);
94 break;
95 case GL_TEXTURE_COORD_ARRAY:
96 DISABLE_TEXARRAY(state, state->vertArray.activeTexture);
97 break;
98 case GL_VERTEX_ARRAY:
99 DISABLE_ARRAY(state, vertex);
100 break;
101 case GL_SECONDARY_COLOR_ARRAY:
102 DISABLE_ARRAY(state, secondaryColor);
103 break;
104 case GL_FOG_COORD_ARRAY:
105 DISABLE_ARRAY(state, fogCoord);
106 break;
107 default:
108 __glXSetError(gc, GL_INVALID_ENUM);
109 }
110 }
111
112 /************************************************************************/
113
114 void __indirect_glPushClientAttrib(GLuint mask)
115 {
116 __GLXcontext *gc = __glXGetCurrentContext();
117 __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
118 __GLXattribute **spp = gc->attributes.stackPointer, *sp;
119
120 if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
121 if (!(sp = *spp)) {
122 sp = (__GLXattribute *)Xmalloc(sizeof(__GLXattribute));
123 *spp = sp;
124 }
125 sp->mask = mask;
126 gc->attributes.stackPointer = spp + 1;
127 if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
128 sp->storePack = state->storePack;
129 sp->storeUnpack = state->storeUnpack;
130 }
131 if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
132 sp->vertArray = state->vertArray;
133 }
134 } else {
135 __glXSetError(gc, GL_STACK_OVERFLOW);
136 return;
137 }
138 }
139
140 void __indirect_glPopClientAttrib(void)
141 {
142 __GLXcontext *gc = __glXGetCurrentContext();
143 __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
144 __GLXattribute **spp = gc->attributes.stackPointer, *sp;
145 GLuint mask;
146
147 if (spp > &gc->attributes.stack[0]) {
148 --spp;
149 sp = *spp;
150 assert(sp != 0);
151 mask = sp->mask;
152 gc->attributes.stackPointer = spp;
153
154 if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
155 state->storePack = sp->storePack;
156 state->storeUnpack = sp->storeUnpack;
157 }
158 if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
159 state->vertArray = sp->vertArray;
160 }
161
162 sp->mask = 0;
163 } else {
164 __glXSetError(gc, GL_STACK_UNDERFLOW);
165 return;
166 }
167 }
168
169 void __glFreeAttributeState(__GLXcontext *gc)
170 {
171 __GLXattribute *sp, **spp;
172
173 for (spp = &gc->attributes.stack[0];
174 spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
175 spp++) {
176 sp = *spp;
177 if (sp) {
178 XFree((char *)sp);
179 } else {
180 break;
181 }
182 }
183 }
184
185