1 /* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
3 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
4 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice including the dates of first publication and
14 * either this permission notice or a reference to
15 * http://oss.sgi.com/projects/FreeB/
16 * shall be included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Except as contained in this notice, the name of Silicon Graphics, Inc.
27 * shall not be used in advertising or otherwise to promote the sale, use or
28 * other dealings in this Software without prior written authorization from
29 * Silicon Graphics, Inc.
32 #include "glxclient.h"
36 * Send glPixelStore command to the server
38 * \param gc Current GLX context
39 * \param sop Either \c X_GLsop_PixelStoref or \c X_GLsop_PixelStorei
40 * \param pname Selector of which pixel parameter is to be set.
41 * \param param Value that \c pname is set to.
43 * \sa __indirect_glPixelStorei, __indirect_glPixelStoref
46 send_PixelStore(__GLXcontext
* gc
, unsigned sop
, GLenum pname
,
49 Display
*const dpy
= gc
->currentDpy
;
50 const GLuint cmdlen
= 8;
51 if (__builtin_expect(dpy
!= NULL
, 1)) {
52 GLubyte
const *pc
= __glXSetupSingleRequest(gc
, sop
, cmdlen
);
53 (void) memcpy((void *) (pc
+ 0), (void *) (&pname
), 4);
54 (void) memcpy((void *) (pc
+ 4), param
, 4);
62 ** Specify parameters that control the storage format of pixel arrays.
65 __indirect_glPixelStoref(GLenum pname
, GLfloat param
)
67 __GLXcontext
*gc
= __glXGetCurrentContext();
68 __GLXattribute
*state
= gc
->client_state_private
;
69 Display
*dpy
= gc
->currentDpy
;
76 case GL_PACK_ROW_LENGTH
:
77 a
= (GLuint
) (param
+ 0.5);
78 if (((GLint
) a
) < 0) {
79 __glXSetError(gc
, GL_INVALID_VALUE
);
82 state
->storePack
.rowLength
= a
;
84 case GL_PACK_IMAGE_HEIGHT
:
85 a
= (GLuint
) (param
+ 0.5);
86 if (((GLint
) a
) < 0) {
87 __glXSetError(gc
, GL_INVALID_VALUE
);
90 state
->storePack
.imageHeight
= a
;
92 case GL_PACK_SKIP_ROWS
:
93 a
= (GLuint
) (param
+ 0.5);
94 if (((GLint
) a
) < 0) {
95 __glXSetError(gc
, GL_INVALID_VALUE
);
98 state
->storePack
.skipRows
= a
;
100 case GL_PACK_SKIP_PIXELS
:
101 a
= (GLuint
) (param
+ 0.5);
102 if (((GLint
) a
) < 0) {
103 __glXSetError(gc
, GL_INVALID_VALUE
);
106 state
->storePack
.skipPixels
= a
;
108 case GL_PACK_SKIP_IMAGES
:
109 a
= (GLuint
) (param
+ 0.5);
110 if (((GLint
) a
) < 0) {
111 __glXSetError(gc
, GL_INVALID_VALUE
);
114 state
->storePack
.skipImages
= a
;
116 case GL_PACK_ALIGNMENT
:
117 a
= (GLint
) (param
+ 0.5);
123 state
->storePack
.alignment
= a
;
126 __glXSetError(gc
, GL_INVALID_VALUE
);
130 case GL_PACK_SWAP_BYTES
:
131 state
->storePack
.swapEndian
= (param
!= 0);
133 case GL_PACK_LSB_FIRST
:
134 state
->storePack
.lsbFirst
= (param
!= 0);
137 case GL_UNPACK_ROW_LENGTH
:
138 a
= (GLuint
) (param
+ 0.5);
139 if (((GLint
) a
) < 0) {
140 __glXSetError(gc
, GL_INVALID_VALUE
);
143 state
->storeUnpack
.rowLength
= a
;
145 case GL_UNPACK_IMAGE_HEIGHT
:
146 a
= (GLuint
) (param
+ 0.5);
147 if (((GLint
) a
) < 0) {
148 __glXSetError(gc
, GL_INVALID_VALUE
);
151 state
->storeUnpack
.imageHeight
= a
;
153 case GL_UNPACK_SKIP_ROWS
:
154 a
= (GLuint
) (param
+ 0.5);
155 if (((GLint
) a
) < 0) {
156 __glXSetError(gc
, GL_INVALID_VALUE
);
159 state
->storeUnpack
.skipRows
= a
;
161 case GL_UNPACK_SKIP_PIXELS
:
162 a
= (GLuint
) (param
+ 0.5);
163 if (((GLint
) a
) < 0) {
164 __glXSetError(gc
, GL_INVALID_VALUE
);
167 state
->storeUnpack
.skipPixels
= a
;
169 case GL_UNPACK_SKIP_IMAGES
:
170 a
= (GLuint
) (param
+ 0.5);
171 if (((GLint
) a
) < 0) {
172 __glXSetError(gc
, GL_INVALID_VALUE
);
175 state
->storeUnpack
.skipImages
= a
;
177 case GL_UNPACK_ALIGNMENT
:
178 a
= (GLint
) (param
+ 0.5);
184 state
->storeUnpack
.alignment
= a
;
187 __glXSetError(gc
, GL_INVALID_VALUE
);
191 case GL_UNPACK_SWAP_BYTES
:
192 state
->storeUnpack
.swapEndian
= (param
!= 0);
194 case GL_UNPACK_LSB_FIRST
:
195 state
->storeUnpack
.lsbFirst
= (param
!= 0);
198 /* Group all of the pixel store modes that need to be sent to the
199 * server here. Care must be used to only send modes to the server that
200 * won't affect the size of the data sent to or received from the
201 * server. GL_PACK_INVERT_MESA is safe in this respect, but other,
202 * future modes may not be.
204 case GL_PACK_INVERT_MESA
:
205 send_PixelStore(gc
, X_GLsop_PixelStoref
, pname
, ¶m
);
209 __glXSetError(gc
, GL_INVALID_ENUM
);
215 __indirect_glPixelStorei(GLenum pname
, GLint param
)
217 __GLXcontext
*gc
= __glXGetCurrentContext();
218 __GLXattribute
*state
= gc
->client_state_private
;
219 Display
*dpy
= gc
->currentDpy
;
225 case GL_PACK_ROW_LENGTH
:
227 __glXSetError(gc
, GL_INVALID_VALUE
);
230 state
->storePack
.rowLength
= param
;
232 case GL_PACK_IMAGE_HEIGHT
:
234 __glXSetError(gc
, GL_INVALID_VALUE
);
237 state
->storePack
.imageHeight
= param
;
239 case GL_PACK_SKIP_ROWS
:
241 __glXSetError(gc
, GL_INVALID_VALUE
);
244 state
->storePack
.skipRows
= param
;
246 case GL_PACK_SKIP_PIXELS
:
248 __glXSetError(gc
, GL_INVALID_VALUE
);
251 state
->storePack
.skipPixels
= param
;
253 case GL_PACK_SKIP_IMAGES
:
255 __glXSetError(gc
, GL_INVALID_VALUE
);
258 state
->storePack
.skipImages
= param
;
260 case GL_PACK_ALIGNMENT
:
266 state
->storePack
.alignment
= param
;
269 __glXSetError(gc
, GL_INVALID_VALUE
);
273 case GL_PACK_SWAP_BYTES
:
274 state
->storePack
.swapEndian
= (param
!= 0);
276 case GL_PACK_LSB_FIRST
:
277 state
->storePack
.lsbFirst
= (param
!= 0);
280 case GL_UNPACK_ROW_LENGTH
:
282 __glXSetError(gc
, GL_INVALID_VALUE
);
285 state
->storeUnpack
.rowLength
= param
;
287 case GL_UNPACK_IMAGE_HEIGHT
:
289 __glXSetError(gc
, GL_INVALID_VALUE
);
292 state
->storeUnpack
.imageHeight
= param
;
294 case GL_UNPACK_SKIP_ROWS
:
296 __glXSetError(gc
, GL_INVALID_VALUE
);
299 state
->storeUnpack
.skipRows
= param
;
301 case GL_UNPACK_SKIP_PIXELS
:
303 __glXSetError(gc
, GL_INVALID_VALUE
);
306 state
->storeUnpack
.skipPixels
= param
;
308 case GL_UNPACK_SKIP_IMAGES
:
310 __glXSetError(gc
, GL_INVALID_VALUE
);
313 state
->storeUnpack
.skipImages
= param
;
315 case GL_UNPACK_ALIGNMENT
:
321 state
->storeUnpack
.alignment
= param
;
324 __glXSetError(gc
, GL_INVALID_VALUE
);
328 case GL_UNPACK_SWAP_BYTES
:
329 state
->storeUnpack
.swapEndian
= (param
!= 0);
331 case GL_UNPACK_LSB_FIRST
:
332 state
->storeUnpack
.lsbFirst
= (param
!= 0);
335 /* Group all of the pixel store modes that need to be sent to the
336 * server here. Care must be used to only send modes to the server that
337 * won't affect the size of the data sent to or received from the
338 * server. GL_PACK_INVERT_MESA is safe in this respect, but other,
339 * future modes may not be.
341 case GL_PACK_INVERT_MESA
:
342 send_PixelStore(gc
, X_GLsop_PixelStorei
, pname
, ¶m
);
346 __glXSetError(gc
, GL_INVALID_ENUM
);