2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
31 #include "glxclient.h"
35 * Send glPixelStore command to the server
37 * \param gc Current GLX context
38 * \param sop Either \c X_GLsop_PixelStoref or \c X_GLsop_PixelStorei
39 * \param pname Selector of which pixel parameter is to be set.
40 * \param param Value that \c pname is set to.
42 * \sa __indirect_glPixelStorei, __indirect_glPixelStoref
45 send_PixelStore(__GLXcontext
* gc
, unsigned sop
, GLenum pname
,
48 Display
*const dpy
= gc
->currentDpy
;
49 const GLuint cmdlen
= 8;
50 if (__builtin_expect(dpy
!= NULL
, 1)) {
51 GLubyte
const *pc
= __glXSetupSingleRequest(gc
, sop
, cmdlen
);
52 (void) memcpy((void *) (pc
+ 0), (void *) (&pname
), 4);
53 (void) memcpy((void *) (pc
+ 4), param
, 4);
61 ** Specify parameters that control the storage format of pixel arrays.
64 __indirect_glPixelStoref(GLenum pname
, GLfloat param
)
66 __GLXcontext
*gc
= __glXGetCurrentContext();
67 __GLXattribute
*state
= gc
->client_state_private
;
68 Display
*dpy
= gc
->currentDpy
;
75 case GL_PACK_ROW_LENGTH
:
76 a
= (GLuint
) (param
+ 0.5);
77 if (((GLint
) a
) < 0) {
78 __glXSetError(gc
, GL_INVALID_VALUE
);
81 state
->storePack
.rowLength
= a
;
83 case GL_PACK_IMAGE_HEIGHT
:
84 a
= (GLuint
) (param
+ 0.5);
85 if (((GLint
) a
) < 0) {
86 __glXSetError(gc
, GL_INVALID_VALUE
);
89 state
->storePack
.imageHeight
= a
;
91 case GL_PACK_SKIP_ROWS
:
92 a
= (GLuint
) (param
+ 0.5);
93 if (((GLint
) a
) < 0) {
94 __glXSetError(gc
, GL_INVALID_VALUE
);
97 state
->storePack
.skipRows
= a
;
99 case GL_PACK_SKIP_PIXELS
:
100 a
= (GLuint
) (param
+ 0.5);
101 if (((GLint
) a
) < 0) {
102 __glXSetError(gc
, GL_INVALID_VALUE
);
105 state
->storePack
.skipPixels
= a
;
107 case GL_PACK_SKIP_IMAGES
:
108 a
= (GLuint
) (param
+ 0.5);
109 if (((GLint
) a
) < 0) {
110 __glXSetError(gc
, GL_INVALID_VALUE
);
113 state
->storePack
.skipImages
= a
;
115 case GL_PACK_ALIGNMENT
:
116 a
= (GLint
) (param
+ 0.5);
122 state
->storePack
.alignment
= a
;
125 __glXSetError(gc
, GL_INVALID_VALUE
);
129 case GL_PACK_SWAP_BYTES
:
130 state
->storePack
.swapEndian
= (param
!= 0);
132 case GL_PACK_LSB_FIRST
:
133 state
->storePack
.lsbFirst
= (param
!= 0);
136 case GL_UNPACK_ROW_LENGTH
:
137 a
= (GLuint
) (param
+ 0.5);
138 if (((GLint
) a
) < 0) {
139 __glXSetError(gc
, GL_INVALID_VALUE
);
142 state
->storeUnpack
.rowLength
= a
;
144 case GL_UNPACK_IMAGE_HEIGHT
:
145 a
= (GLuint
) (param
+ 0.5);
146 if (((GLint
) a
) < 0) {
147 __glXSetError(gc
, GL_INVALID_VALUE
);
150 state
->storeUnpack
.imageHeight
= a
;
152 case GL_UNPACK_SKIP_ROWS
:
153 a
= (GLuint
) (param
+ 0.5);
154 if (((GLint
) a
) < 0) {
155 __glXSetError(gc
, GL_INVALID_VALUE
);
158 state
->storeUnpack
.skipRows
= a
;
160 case GL_UNPACK_SKIP_PIXELS
:
161 a
= (GLuint
) (param
+ 0.5);
162 if (((GLint
) a
) < 0) {
163 __glXSetError(gc
, GL_INVALID_VALUE
);
166 state
->storeUnpack
.skipPixels
= a
;
168 case GL_UNPACK_SKIP_IMAGES
:
169 a
= (GLuint
) (param
+ 0.5);
170 if (((GLint
) a
) < 0) {
171 __glXSetError(gc
, GL_INVALID_VALUE
);
174 state
->storeUnpack
.skipImages
= a
;
176 case GL_UNPACK_ALIGNMENT
:
177 a
= (GLint
) (param
+ 0.5);
183 state
->storeUnpack
.alignment
= a
;
186 __glXSetError(gc
, GL_INVALID_VALUE
);
190 case GL_UNPACK_SWAP_BYTES
:
191 state
->storeUnpack
.swapEndian
= (param
!= 0);
193 case GL_UNPACK_LSB_FIRST
:
194 state
->storeUnpack
.lsbFirst
= (param
!= 0);
197 /* Group all of the pixel store modes that need to be sent to the
198 * server here. Care must be used to only send modes to the server that
199 * won't affect the size of the data sent to or received from the
200 * server. GL_PACK_INVERT_MESA is safe in this respect, but other,
201 * future modes may not be.
203 case GL_PACK_INVERT_MESA
:
204 send_PixelStore(gc
, X_GLsop_PixelStoref
, pname
, ¶m
);
208 __glXSetError(gc
, GL_INVALID_ENUM
);
214 __indirect_glPixelStorei(GLenum pname
, GLint param
)
216 __GLXcontext
*gc
= __glXGetCurrentContext();
217 __GLXattribute
*state
= gc
->client_state_private
;
218 Display
*dpy
= gc
->currentDpy
;
224 case GL_PACK_ROW_LENGTH
:
226 __glXSetError(gc
, GL_INVALID_VALUE
);
229 state
->storePack
.rowLength
= param
;
231 case GL_PACK_IMAGE_HEIGHT
:
233 __glXSetError(gc
, GL_INVALID_VALUE
);
236 state
->storePack
.imageHeight
= param
;
238 case GL_PACK_SKIP_ROWS
:
240 __glXSetError(gc
, GL_INVALID_VALUE
);
243 state
->storePack
.skipRows
= param
;
245 case GL_PACK_SKIP_PIXELS
:
247 __glXSetError(gc
, GL_INVALID_VALUE
);
250 state
->storePack
.skipPixels
= param
;
252 case GL_PACK_SKIP_IMAGES
:
254 __glXSetError(gc
, GL_INVALID_VALUE
);
257 state
->storePack
.skipImages
= param
;
259 case GL_PACK_ALIGNMENT
:
265 state
->storePack
.alignment
= param
;
268 __glXSetError(gc
, GL_INVALID_VALUE
);
272 case GL_PACK_SWAP_BYTES
:
273 state
->storePack
.swapEndian
= (param
!= 0);
275 case GL_PACK_LSB_FIRST
:
276 state
->storePack
.lsbFirst
= (param
!= 0);
279 case GL_UNPACK_ROW_LENGTH
:
281 __glXSetError(gc
, GL_INVALID_VALUE
);
284 state
->storeUnpack
.rowLength
= param
;
286 case GL_UNPACK_IMAGE_HEIGHT
:
288 __glXSetError(gc
, GL_INVALID_VALUE
);
291 state
->storeUnpack
.imageHeight
= param
;
293 case GL_UNPACK_SKIP_ROWS
:
295 __glXSetError(gc
, GL_INVALID_VALUE
);
298 state
->storeUnpack
.skipRows
= param
;
300 case GL_UNPACK_SKIP_PIXELS
:
302 __glXSetError(gc
, GL_INVALID_VALUE
);
305 state
->storeUnpack
.skipPixels
= param
;
307 case GL_UNPACK_SKIP_IMAGES
:
309 __glXSetError(gc
, GL_INVALID_VALUE
);
312 state
->storeUnpack
.skipImages
= param
;
314 case GL_UNPACK_ALIGNMENT
:
320 state
->storeUnpack
.alignment
= param
;
323 __glXSetError(gc
, GL_INVALID_VALUE
);
327 case GL_UNPACK_SWAP_BYTES
:
328 state
->storeUnpack
.swapEndian
= (param
!= 0);
330 case GL_UNPACK_LSB_FIRST
:
331 state
->storeUnpack
.lsbFirst
= (param
!= 0);
334 /* Group all of the pixel store modes that need to be sent to the
335 * server here. Care must be used to only send modes to the server that
336 * won't affect the size of the data sent to or received from the
337 * server. GL_PACK_INVERT_MESA is safe in this respect, but other,
338 * future modes may not be.
340 case GL_PACK_INVERT_MESA
:
341 send_PixelStore(gc
, X_GLsop_PixelStorei
, pname
, ¶m
);
345 __glXSetError(gc
, GL_INVALID_ENUM
);