1 /* $XFree86: xc/lib/GL/glx/pixelstore.c,v 1.4 2004/01/28 18:11:43 alanh 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.
37 #include "glxclient.h"
40 ** Specify parameters that control the storage format of pixel arrays.
42 void __indirect_glPixelStoref(GLenum pname
, GLfloat param
)
44 __GLXcontext
*gc
= __glXGetCurrentContext();
45 __GLXattribute
* state
= gc
->client_state_private
;
46 Display
*dpy
= gc
->currentDpy
;
52 case GL_PACK_ROW_LENGTH
:
53 a
= (GLuint
) (param
+ 0.5);
54 if (((GLint
) a
) < 0) {
55 __glXSetError(gc
, GL_INVALID_VALUE
);
58 state
->storePack
.rowLength
= a
;
60 case GL_PACK_IMAGE_HEIGHT
:
61 a
= (GLuint
) (param
+ 0.5);
62 if (((GLint
) a
) < 0) {
63 __glXSetError(gc
, GL_INVALID_VALUE
);
66 state
->storePack
.imageHeight
= a
;
68 case GL_PACK_SKIP_ROWS
:
69 a
= (GLuint
) (param
+ 0.5);
70 if (((GLint
) a
) < 0) {
71 __glXSetError(gc
, GL_INVALID_VALUE
);
74 state
->storePack
.skipRows
= a
;
76 case GL_PACK_SKIP_PIXELS
:
77 a
= (GLuint
) (param
+ 0.5);
78 if (((GLint
) a
) < 0) {
79 __glXSetError(gc
, GL_INVALID_VALUE
);
82 state
->storePack
.skipPixels
= a
;
84 case GL_PACK_SKIP_IMAGES
:
85 a
= (GLuint
) (param
+ 0.5);
86 if (((GLint
) a
) < 0) {
87 __glXSetError(gc
, GL_INVALID_VALUE
);
90 state
->storePack
.skipImages
= a
;
92 case GL_PACK_ALIGNMENT
:
93 a
= (GLint
) (param
+ 0.5);
95 case 1: case 2: case 4: case 8:
96 state
->storePack
.alignment
= a
;
99 __glXSetError(gc
, GL_INVALID_VALUE
);
103 case GL_PACK_SWAP_BYTES
:
104 state
->storePack
.swapEndian
= (param
!= 0);
106 case GL_PACK_LSB_FIRST
:
107 state
->storePack
.lsbFirst
= (param
!= 0);
110 case GL_UNPACK_ROW_LENGTH
:
111 a
= (GLuint
) (param
+ 0.5);
112 if (((GLint
) a
) < 0) {
113 __glXSetError(gc
, GL_INVALID_VALUE
);
116 state
->storeUnpack
.rowLength
= a
;
118 case GL_UNPACK_IMAGE_HEIGHT
:
119 a
= (GLuint
) (param
+ 0.5);
120 if (((GLint
) a
) < 0) {
121 __glXSetError(gc
, GL_INVALID_VALUE
);
124 state
->storeUnpack
.imageHeight
= a
;
126 case GL_UNPACK_SKIP_ROWS
:
127 a
= (GLuint
) (param
+ 0.5);
128 if (((GLint
) a
) < 0) {
129 __glXSetError(gc
, GL_INVALID_VALUE
);
132 state
->storeUnpack
.skipRows
= a
;
134 case GL_UNPACK_SKIP_PIXELS
:
135 a
= (GLuint
) (param
+ 0.5);
136 if (((GLint
) a
) < 0) {
137 __glXSetError(gc
, GL_INVALID_VALUE
);
140 state
->storeUnpack
.skipPixels
= a
;
142 case GL_UNPACK_SKIP_IMAGES
:
143 a
= (GLuint
) (param
+ 0.5);
144 if (((GLint
) a
) < 0) {
145 __glXSetError(gc
, GL_INVALID_VALUE
);
148 state
->storeUnpack
.skipImages
= a
;
150 case GL_UNPACK_ALIGNMENT
:
151 a
= (GLint
) (param
+ 0.5);
153 case 1: case 2: case 4: case 8:
154 state
->storeUnpack
.alignment
= a
;
157 __glXSetError(gc
, GL_INVALID_VALUE
);
161 case GL_UNPACK_SWAP_BYTES
:
162 state
->storeUnpack
.swapEndian
= (param
!= 0);
164 case GL_UNPACK_LSB_FIRST
:
165 state
->storeUnpack
.lsbFirst
= (param
!= 0);
169 ** NOTE: there are currently no pixel storage commands that need to
170 ** be sent to the server. This may change in future versions
171 ** of the API, however.
173 __glXSetError(gc
, GL_INVALID_ENUM
);
178 void __indirect_glPixelStorei(GLenum pname
, GLint param
)
180 __GLXcontext
*gc
= __glXGetCurrentContext();
181 __GLXattribute
* state
= gc
->client_state_private
;
182 Display
*dpy
= gc
->currentDpy
;
187 case GL_PACK_ROW_LENGTH
:
189 __glXSetError(gc
, GL_INVALID_VALUE
);
192 state
->storePack
.rowLength
= param
;
194 case GL_PACK_IMAGE_HEIGHT
:
196 __glXSetError(gc
, GL_INVALID_VALUE
);
199 state
->storePack
.imageHeight
= param
;
201 case GL_PACK_SKIP_ROWS
:
203 __glXSetError(gc
, GL_INVALID_VALUE
);
206 state
->storePack
.skipRows
= param
;
208 case GL_PACK_SKIP_PIXELS
:
210 __glXSetError(gc
, GL_INVALID_VALUE
);
213 state
->storePack
.skipPixels
= param
;
215 case GL_PACK_SKIP_IMAGES
:
217 __glXSetError(gc
, GL_INVALID_VALUE
);
220 state
->storePack
.skipImages
= param
;
222 case GL_PACK_ALIGNMENT
:
224 case 1: case 2: case 4: case 8:
225 state
->storePack
.alignment
= param
;
228 __glXSetError(gc
, GL_INVALID_VALUE
);
232 case GL_PACK_SWAP_BYTES
:
233 state
->storePack
.swapEndian
= (param
!= 0);
235 case GL_PACK_LSB_FIRST
:
236 state
->storePack
.lsbFirst
= (param
!= 0);
239 case GL_UNPACK_ROW_LENGTH
:
241 __glXSetError(gc
, GL_INVALID_VALUE
);
244 state
->storeUnpack
.rowLength
= param
;
246 case GL_UNPACK_IMAGE_HEIGHT
:
248 __glXSetError(gc
, GL_INVALID_VALUE
);
251 state
->storeUnpack
.imageHeight
= param
;
253 case GL_UNPACK_SKIP_ROWS
:
255 __glXSetError(gc
, GL_INVALID_VALUE
);
258 state
->storeUnpack
.skipRows
= param
;
260 case GL_UNPACK_SKIP_PIXELS
:
262 __glXSetError(gc
, GL_INVALID_VALUE
);
265 state
->storeUnpack
.skipPixels
= param
;
267 case GL_UNPACK_SKIP_IMAGES
:
269 __glXSetError(gc
, GL_INVALID_VALUE
);
272 state
->storeUnpack
.skipImages
= param
;
274 case GL_UNPACK_ALIGNMENT
:
276 case 1: case 2: case 4: case 8:
277 state
->storeUnpack
.alignment
= param
;
280 __glXSetError(gc
, GL_INVALID_VALUE
);
284 case GL_UNPACK_SWAP_BYTES
:
285 state
->storeUnpack
.swapEndian
= (param
!= 0);
287 case GL_UNPACK_LSB_FIRST
:
288 state
->storeUnpack
.lsbFirst
= (param
!= 0);
292 ** NOTE: there are currently no pixel storage commands that need to
293 ** be sent to the server. This may change in future versions
294 ** of the API, however.
296 __glXSetError(gc
, GL_INVALID_ENUM
);