Add missing includes of indirect.h.
[mesa.git] / src / glx / x11 / pixelstore.c
1 /* $XFree86: xc/lib/GL/glx/pixelstore.c,v 1.4 2004/01/28 18:11:43 alanh 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 "glxclient.h"
38 #include "indirect.h"
39
40 /*
41 ** Specify parameters that control the storage format of pixel arrays.
42 */
43 void __indirect_glPixelStoref(GLenum pname, GLfloat param)
44 {
45 __GLXcontext *gc = __glXGetCurrentContext();
46 __GLXattribute * state = gc->client_state_private;
47 Display *dpy = gc->currentDpy;
48 GLuint a;
49
50 if (!dpy) return;
51
52 switch (pname) {
53 case GL_PACK_ROW_LENGTH:
54 a = (GLuint) (param + 0.5);
55 if (((GLint) a) < 0) {
56 __glXSetError(gc, GL_INVALID_VALUE);
57 return;
58 }
59 state->storePack.rowLength = a;
60 break;
61 case GL_PACK_IMAGE_HEIGHT:
62 a = (GLuint) (param + 0.5);
63 if (((GLint) a) < 0) {
64 __glXSetError(gc, GL_INVALID_VALUE);
65 return;
66 }
67 state->storePack.imageHeight = a;
68 break;
69 case GL_PACK_SKIP_ROWS:
70 a = (GLuint) (param + 0.5);
71 if (((GLint) a) < 0) {
72 __glXSetError(gc, GL_INVALID_VALUE);
73 return;
74 }
75 state->storePack.skipRows = a;
76 break;
77 case GL_PACK_SKIP_PIXELS:
78 a = (GLuint) (param + 0.5);
79 if (((GLint) a) < 0) {
80 __glXSetError(gc, GL_INVALID_VALUE);
81 return;
82 }
83 state->storePack.skipPixels = a;
84 break;
85 case GL_PACK_SKIP_IMAGES:
86 a = (GLuint) (param + 0.5);
87 if (((GLint) a) < 0) {
88 __glXSetError(gc, GL_INVALID_VALUE);
89 return;
90 }
91 state->storePack.skipImages = a;
92 break;
93 case GL_PACK_ALIGNMENT:
94 a = (GLint) (param + 0.5);
95 switch (a) {
96 case 1: case 2: case 4: case 8:
97 state->storePack.alignment = a;
98 break;
99 default:
100 __glXSetError(gc, GL_INVALID_VALUE);
101 return;
102 }
103 break;
104 case GL_PACK_SWAP_BYTES:
105 state->storePack.swapEndian = (param != 0);
106 break;
107 case GL_PACK_LSB_FIRST:
108 state->storePack.lsbFirst = (param != 0);
109 break;
110
111 case GL_UNPACK_ROW_LENGTH:
112 a = (GLuint) (param + 0.5);
113 if (((GLint) a) < 0) {
114 __glXSetError(gc, GL_INVALID_VALUE);
115 return;
116 }
117 state->storeUnpack.rowLength = a;
118 break;
119 case GL_UNPACK_IMAGE_HEIGHT:
120 a = (GLuint) (param + 0.5);
121 if (((GLint) a) < 0) {
122 __glXSetError(gc, GL_INVALID_VALUE);
123 return;
124 }
125 state->storeUnpack.imageHeight = a;
126 break;
127 case GL_UNPACK_SKIP_ROWS:
128 a = (GLuint) (param + 0.5);
129 if (((GLint) a) < 0) {
130 __glXSetError(gc, GL_INVALID_VALUE);
131 return;
132 }
133 state->storeUnpack.skipRows = a;
134 break;
135 case GL_UNPACK_SKIP_PIXELS:
136 a = (GLuint) (param + 0.5);
137 if (((GLint) a) < 0) {
138 __glXSetError(gc, GL_INVALID_VALUE);
139 return;
140 }
141 state->storeUnpack.skipPixels = a;
142 break;
143 case GL_UNPACK_SKIP_IMAGES:
144 a = (GLuint) (param + 0.5);
145 if (((GLint) a) < 0) {
146 __glXSetError(gc, GL_INVALID_VALUE);
147 return;
148 }
149 state->storeUnpack.skipImages = a;
150 break;
151 case GL_UNPACK_ALIGNMENT:
152 a = (GLint) (param + 0.5);
153 switch (a) {
154 case 1: case 2: case 4: case 8:
155 state->storeUnpack.alignment = a;
156 break;
157 default:
158 __glXSetError(gc, GL_INVALID_VALUE);
159 return;
160 }
161 break;
162 case GL_UNPACK_SWAP_BYTES:
163 state->storeUnpack.swapEndian = (param != 0);
164 break;
165 case GL_UNPACK_LSB_FIRST:
166 state->storeUnpack.lsbFirst = (param != 0);
167 break;
168 default:
169 /*
170 ** NOTE: there are currently no pixel storage commands that need to
171 ** be sent to the server. This may change in future versions
172 ** of the API, however.
173 */
174 __glXSetError(gc, GL_INVALID_ENUM);
175 break;
176 }
177 }
178
179 void __indirect_glPixelStorei(GLenum pname, GLint param)
180 {
181 __GLXcontext *gc = __glXGetCurrentContext();
182 __GLXattribute * state = gc->client_state_private;
183 Display *dpy = gc->currentDpy;
184
185 if (!dpy) return;
186
187 switch (pname) {
188 case GL_PACK_ROW_LENGTH:
189 if (param < 0) {
190 __glXSetError(gc, GL_INVALID_VALUE);
191 return;
192 }
193 state->storePack.rowLength = param;
194 break;
195 case GL_PACK_IMAGE_HEIGHT:
196 if (param < 0) {
197 __glXSetError(gc, GL_INVALID_VALUE);
198 return;
199 }
200 state->storePack.imageHeight = param;
201 break;
202 case GL_PACK_SKIP_ROWS:
203 if (param < 0) {
204 __glXSetError(gc, GL_INVALID_VALUE);
205 return;
206 }
207 state->storePack.skipRows = param;
208 break;
209 case GL_PACK_SKIP_PIXELS:
210 if (param < 0) {
211 __glXSetError(gc, GL_INVALID_VALUE);
212 return;
213 }
214 state->storePack.skipPixels = param;
215 break;
216 case GL_PACK_SKIP_IMAGES:
217 if (param < 0) {
218 __glXSetError(gc, GL_INVALID_VALUE);
219 return;
220 }
221 state->storePack.skipImages = param;
222 break;
223 case GL_PACK_ALIGNMENT:
224 switch (param) {
225 case 1: case 2: case 4: case 8:
226 state->storePack.alignment = param;
227 break;
228 default:
229 __glXSetError(gc, GL_INVALID_VALUE);
230 return;
231 }
232 break;
233 case GL_PACK_SWAP_BYTES:
234 state->storePack.swapEndian = (param != 0);
235 break;
236 case GL_PACK_LSB_FIRST:
237 state->storePack.lsbFirst = (param != 0);
238 break;
239
240 case GL_UNPACK_ROW_LENGTH:
241 if (param < 0) {
242 __glXSetError(gc, GL_INVALID_VALUE);
243 return;
244 }
245 state->storeUnpack.rowLength = param;
246 break;
247 case GL_UNPACK_IMAGE_HEIGHT:
248 if (param < 0) {
249 __glXSetError(gc, GL_INVALID_VALUE);
250 return;
251 }
252 state->storeUnpack.imageHeight = param;
253 break;
254 case GL_UNPACK_SKIP_ROWS:
255 if (param < 0) {
256 __glXSetError(gc, GL_INVALID_VALUE);
257 return;
258 }
259 state->storeUnpack.skipRows = param;
260 break;
261 case GL_UNPACK_SKIP_PIXELS:
262 if (param < 0) {
263 __glXSetError(gc, GL_INVALID_VALUE);
264 return;
265 }
266 state->storeUnpack.skipPixels = param;
267 break;
268 case GL_UNPACK_SKIP_IMAGES:
269 if (param < 0) {
270 __glXSetError(gc, GL_INVALID_VALUE);
271 return;
272 }
273 state->storeUnpack.skipImages = param;
274 break;
275 case GL_UNPACK_ALIGNMENT:
276 switch (param) {
277 case 1: case 2: case 4: case 8:
278 state->storeUnpack.alignment = param;
279 break;
280 default:
281 __glXSetError(gc, GL_INVALID_VALUE);
282 return;
283 }
284 break;
285 case GL_UNPACK_SWAP_BYTES:
286 state->storeUnpack.swapEndian = (param != 0);
287 break;
288 case GL_UNPACK_LSB_FIRST:
289 state->storeUnpack.lsbFirst = (param != 0);
290 break;
291 default:
292 /*
293 ** NOTE: there are currently no pixel storage commands that need to
294 ** be sent to the server. This may change in future versions
295 ** of the API, however.
296 */
297 __glXSetError(gc, GL_INVALID_ENUM);
298 break;
299 }
300 }