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"
41 ** Specify parameters that control the storage format of pixel arrays.
43 void __indirect_glPixelStoref(GLenum pname
, GLfloat param
)
45 __GLXcontext
*gc
= __glXGetCurrentContext();
46 __GLXattribute
* state
= gc
->client_state_private
;
47 Display
*dpy
= gc
->currentDpy
;
53 case GL_PACK_ROW_LENGTH
:
54 a
= (GLuint
) (param
+ 0.5);
55 if (((GLint
) a
) < 0) {
56 __glXSetError(gc
, GL_INVALID_VALUE
);
59 state
->storePack
.rowLength
= a
;
61 case GL_PACK_IMAGE_HEIGHT
:
62 a
= (GLuint
) (param
+ 0.5);
63 if (((GLint
) a
) < 0) {
64 __glXSetError(gc
, GL_INVALID_VALUE
);
67 state
->storePack
.imageHeight
= a
;
69 case GL_PACK_SKIP_ROWS
:
70 a
= (GLuint
) (param
+ 0.5);
71 if (((GLint
) a
) < 0) {
72 __glXSetError(gc
, GL_INVALID_VALUE
);
75 state
->storePack
.skipRows
= a
;
77 case GL_PACK_SKIP_PIXELS
:
78 a
= (GLuint
) (param
+ 0.5);
79 if (((GLint
) a
) < 0) {
80 __glXSetError(gc
, GL_INVALID_VALUE
);
83 state
->storePack
.skipPixels
= a
;
85 case GL_PACK_SKIP_IMAGES
:
86 a
= (GLuint
) (param
+ 0.5);
87 if (((GLint
) a
) < 0) {
88 __glXSetError(gc
, GL_INVALID_VALUE
);
91 state
->storePack
.skipImages
= a
;
93 case GL_PACK_ALIGNMENT
:
94 a
= (GLint
) (param
+ 0.5);
96 case 1: case 2: case 4: case 8:
97 state
->storePack
.alignment
= a
;
100 __glXSetError(gc
, GL_INVALID_VALUE
);
104 case GL_PACK_SWAP_BYTES
:
105 state
->storePack
.swapEndian
= (param
!= 0);
107 case GL_PACK_LSB_FIRST
:
108 state
->storePack
.lsbFirst
= (param
!= 0);
111 case GL_UNPACK_ROW_LENGTH
:
112 a
= (GLuint
) (param
+ 0.5);
113 if (((GLint
) a
) < 0) {
114 __glXSetError(gc
, GL_INVALID_VALUE
);
117 state
->storeUnpack
.rowLength
= a
;
119 case GL_UNPACK_IMAGE_HEIGHT
:
120 a
= (GLuint
) (param
+ 0.5);
121 if (((GLint
) a
) < 0) {
122 __glXSetError(gc
, GL_INVALID_VALUE
);
125 state
->storeUnpack
.imageHeight
= a
;
127 case GL_UNPACK_SKIP_ROWS
:
128 a
= (GLuint
) (param
+ 0.5);
129 if (((GLint
) a
) < 0) {
130 __glXSetError(gc
, GL_INVALID_VALUE
);
133 state
->storeUnpack
.skipRows
= a
;
135 case GL_UNPACK_SKIP_PIXELS
:
136 a
= (GLuint
) (param
+ 0.5);
137 if (((GLint
) a
) < 0) {
138 __glXSetError(gc
, GL_INVALID_VALUE
);
141 state
->storeUnpack
.skipPixels
= a
;
143 case GL_UNPACK_SKIP_IMAGES
:
144 a
= (GLuint
) (param
+ 0.5);
145 if (((GLint
) a
) < 0) {
146 __glXSetError(gc
, GL_INVALID_VALUE
);
149 state
->storeUnpack
.skipImages
= a
;
151 case GL_UNPACK_ALIGNMENT
:
152 a
= (GLint
) (param
+ 0.5);
154 case 1: case 2: case 4: case 8:
155 state
->storeUnpack
.alignment
= a
;
158 __glXSetError(gc
, GL_INVALID_VALUE
);
162 case GL_UNPACK_SWAP_BYTES
:
163 state
->storeUnpack
.swapEndian
= (param
!= 0);
165 case GL_UNPACK_LSB_FIRST
:
166 state
->storeUnpack
.lsbFirst
= (param
!= 0);
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.
174 __glXSetError(gc
, GL_INVALID_ENUM
);
179 void __indirect_glPixelStorei(GLenum pname
, GLint param
)
181 __GLXcontext
*gc
= __glXGetCurrentContext();
182 __GLXattribute
* state
= gc
->client_state_private
;
183 Display
*dpy
= gc
->currentDpy
;
188 case GL_PACK_ROW_LENGTH
:
190 __glXSetError(gc
, GL_INVALID_VALUE
);
193 state
->storePack
.rowLength
= param
;
195 case GL_PACK_IMAGE_HEIGHT
:
197 __glXSetError(gc
, GL_INVALID_VALUE
);
200 state
->storePack
.imageHeight
= param
;
202 case GL_PACK_SKIP_ROWS
:
204 __glXSetError(gc
, GL_INVALID_VALUE
);
207 state
->storePack
.skipRows
= param
;
209 case GL_PACK_SKIP_PIXELS
:
211 __glXSetError(gc
, GL_INVALID_VALUE
);
214 state
->storePack
.skipPixels
= param
;
216 case GL_PACK_SKIP_IMAGES
:
218 __glXSetError(gc
, GL_INVALID_VALUE
);
221 state
->storePack
.skipImages
= param
;
223 case GL_PACK_ALIGNMENT
:
225 case 1: case 2: case 4: case 8:
226 state
->storePack
.alignment
= param
;
229 __glXSetError(gc
, GL_INVALID_VALUE
);
233 case GL_PACK_SWAP_BYTES
:
234 state
->storePack
.swapEndian
= (param
!= 0);
236 case GL_PACK_LSB_FIRST
:
237 state
->storePack
.lsbFirst
= (param
!= 0);
240 case GL_UNPACK_ROW_LENGTH
:
242 __glXSetError(gc
, GL_INVALID_VALUE
);
245 state
->storeUnpack
.rowLength
= param
;
247 case GL_UNPACK_IMAGE_HEIGHT
:
249 __glXSetError(gc
, GL_INVALID_VALUE
);
252 state
->storeUnpack
.imageHeight
= param
;
254 case GL_UNPACK_SKIP_ROWS
:
256 __glXSetError(gc
, GL_INVALID_VALUE
);
259 state
->storeUnpack
.skipRows
= param
;
261 case GL_UNPACK_SKIP_PIXELS
:
263 __glXSetError(gc
, GL_INVALID_VALUE
);
266 state
->storeUnpack
.skipPixels
= param
;
268 case GL_UNPACK_SKIP_IMAGES
:
270 __glXSetError(gc
, GL_INVALID_VALUE
);
273 state
->storeUnpack
.skipImages
= param
;
275 case GL_UNPACK_ALIGNMENT
:
277 case 1: case 2: case 4: case 8:
278 state
->storeUnpack
.alignment
= param
;
281 __glXSetError(gc
, GL_INVALID_VALUE
);
285 case GL_UNPACK_SWAP_BYTES
:
286 state
->storeUnpack
.swapEndian
= (param
!= 0);
288 case GL_UNPACK_LSB_FIRST
:
289 state
->storeUnpack
.lsbFirst
= (param
!= 0);
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.
297 __glXSetError(gc
, GL_INVALID_ENUM
);