1 /* $XFree86: xc/lib/GL/glx/singlepix.c,v 1.3 2001/03/21 16:04:39 dawes 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 "packsingle.h"
39 void __indirect_glReadPixels(GLint x
, GLint y
, GLsizei width
, GLsizei height
,
40 GLenum format
, GLenum type
, GLvoid
*pixels
)
42 __GLX_SINGLE_DECLARE_VARIABLES();
43 const __GLXattribute
* state
;
44 xGLXReadPixelsReply reply
;
48 __GLX_SINGLE_LOAD_VARIABLES();
49 state
= gc
->client_state_private
;
52 __GLX_SINGLE_BEGIN(X_GLsop_ReadPixels
,__GLX_PAD(26));
53 __GLX_SINGLE_PUT_LONG(0,x
);
54 __GLX_SINGLE_PUT_LONG(4,y
);
55 __GLX_SINGLE_PUT_LONG(8,width
);
56 __GLX_SINGLE_PUT_LONG(12,height
);
57 __GLX_SINGLE_PUT_LONG(16,format
);
58 __GLX_SINGLE_PUT_LONG(20,type
);
59 __GLX_SINGLE_PUT_CHAR(24,state
->storePack
.swapEndian
);
60 __GLX_SINGLE_PUT_CHAR(25,GL_FALSE
);
61 __GLX_SINGLE_READ_XREPLY();
62 compsize
= reply
.length
<< 2;
65 /* Allocate a holding buffer to transform the data from */
66 buf
= (GLubyte
*) Xmalloc(compsize
);
69 _XEatData(dpy
, compsize
);
70 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
73 ** Fetch data into holding buffer. Apply pixel store pack modes
74 ** to put data back into client memory
76 __GLX_SINGLE_GET_CHAR_ARRAY(buf
,compsize
);
77 __glEmptyImage(gc
, 2, width
, height
, 1, format
, type
, buf
, pixels
);
82 ** GL error occurred; don't modify user's buffer.
88 void __indirect_glGetTexImage(GLenum target
, GLint level
, GLenum format
, GLenum type
,
91 __GLX_SINGLE_DECLARE_VARIABLES();
92 const __GLXattribute
* state
;
93 xGLXGetTexImageReply reply
;
97 __GLX_SINGLE_LOAD_VARIABLES();
98 state
= gc
->client_state_private
;
101 __GLX_SINGLE_BEGIN(X_GLsop_GetTexImage
,__GLX_PAD(17));
102 __GLX_SINGLE_PUT_LONG(0,target
);
103 __GLX_SINGLE_PUT_LONG(4,level
);
104 __GLX_SINGLE_PUT_LONG(8,format
);
105 __GLX_SINGLE_PUT_LONG(12,type
);
106 __GLX_SINGLE_PUT_CHAR(16,state
->storePack
.swapEndian
);
107 __GLX_SINGLE_READ_XREPLY();
108 compsize
= reply
.length
<< 2;
111 /* Allocate a holding buffer to transform the data from */
112 buf
= (GLubyte
*) Xmalloc(compsize
);
114 /* Throw data away */
115 _XEatData(dpy
, compsize
);
116 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
118 GLint width
, height
, depth
;
121 ** Fetch data into holding buffer. Apply pixel store pack modes
122 ** to put data back into client memory
125 height
= reply
.height
;
127 __GLX_SINGLE_GET_CHAR_ARRAY(buf
,compsize
);
128 __glEmptyImage(gc
, 2, width
, height
, depth
, format
, type
, buf
,
134 ** GL error occured, don't modify user's buffer.
140 void __indirect_glGetPolygonStipple(GLubyte
*mask
)
142 __GLX_SINGLE_DECLARE_VARIABLES();
143 xGLXSingleReply reply
;
148 __GLX_SINGLE_LOAD_VARIABLES();
149 __GLX_SINGLE_BEGIN(X_GLsop_GetPolygonStipple
,__GLX_PAD(1));
150 __GLX_SINGLE_PUT_CHAR(0,GL_FALSE
);
151 __GLX_SINGLE_READ_XREPLY();
152 if (reply
.length
== 32) {
153 __GLX_SINGLE_GET_CHAR_ARRAY(buf
,128);
154 __glEmptyImage(gc
, 2, 32, 32, 1, GL_COLOR_INDEX
, GL_BITMAP
, buf
, mask
);
159 void __indirect_glGetColorTable(GLenum target
, GLenum format
, GLenum type
, GLvoid
*table
)
161 __GLX_SINGLE_DECLARE_VARIABLES();
162 const __GLXattribute
* state
;
163 xGLXGetColorTableReply reply
;
167 __GLX_SINGLE_LOAD_VARIABLES();
168 state
= gc
->client_state_private
;
171 __GLX_SINGLE_BEGIN(X_GLsop_GetColorTable
,__GLX_PAD(13));
172 __GLX_SINGLE_PUT_LONG(0,(long)target
);
173 __GLX_SINGLE_PUT_LONG(4,(long)format
);
174 __GLX_SINGLE_PUT_LONG(8,(long)type
);
175 __GLX_SINGLE_PUT_CHAR(12,state
->storePack
.swapEndian
);
176 __GLX_SINGLE_READ_XREPLY();
177 compsize
= (long)reply
.length
<< 2;
180 /* Allocate a holding buffer to transform the data from */
181 buf
= (GLubyte
*)Xmalloc(compsize
);
183 /* Throw data away */
184 _XEatData(dpy
, compsize
);
185 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
190 ** Fetch data into holding buffer. Apply pixel store pack modes
191 ** to put data back into client memory
193 width
= (int)reply
.width
;
194 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf
),(long)compsize
);
195 __glEmptyImage(gc
, 1, width
, 1, 1, format
, type
, buf
, table
);
200 ** GL error occured, don't modify user's buffer.
206 void __indirect_glGetConvolutionFilter(GLenum target
, GLenum format
, GLenum type
,
209 __GLX_SINGLE_DECLARE_VARIABLES();
210 const __GLXattribute
* state
;
211 xGLXGetConvolutionFilterReply reply
;
215 __GLX_SINGLE_LOAD_VARIABLES();
216 state
= gc
->client_state_private
;
219 __GLX_SINGLE_BEGIN(X_GLsop_GetConvolutionFilter
, __GLX_PAD(13));
220 __GLX_SINGLE_PUT_LONG(0,target
);
221 __GLX_SINGLE_PUT_LONG(4,format
);
222 __GLX_SINGLE_PUT_LONG(8,type
);
223 __GLX_SINGLE_PUT_CHAR(12,state
->storePack
.swapEndian
);
224 __GLX_SINGLE_READ_XREPLY();
225 compsize
= reply
.length
<< 2;
228 /* Allocate a holding buffer to transform the data from */
229 buf
= (GLubyte
*) Xmalloc(compsize
);
231 /* Throw data away */
232 _XEatData(dpy
, compsize
);
233 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
238 ** Fetch data into holding buffer. Apply pixel store pack modes
239 ** to put data back into client memory
242 height
= reply
.height
;
243 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf
),compsize
);
244 __glEmptyImage(gc
, 2, width
, height
, 1, format
, type
, buf
, image
);
249 ** GL error occured, don't modify user's buffer.
255 void __indirect_glGetSeparableFilter(GLenum target
, GLenum format
, GLenum type
,
256 GLvoid
*row
, GLvoid
*column
, GLvoid
*span
)
258 __GLX_SINGLE_DECLARE_VARIABLES();
259 const __GLXattribute
* state
;
260 xGLXGetSeparableFilterReply reply
;
261 GLubyte
*rowBuf
, *colBuf
;
264 __GLX_SINGLE_LOAD_VARIABLES();
265 state
= gc
->client_state_private
;
268 __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter
, __GLX_PAD(13));
269 __GLX_SINGLE_PUT_LONG(0,target
);
270 __GLX_SINGLE_PUT_LONG(4,format
);
271 __GLX_SINGLE_PUT_LONG(8,type
);
272 __GLX_SINGLE_PUT_CHAR(12,state
->storePack
.swapEndian
);
273 __GLX_SINGLE_READ_XREPLY();
274 compsize
= reply
.length
<< 2;
278 GLint widthsize
, heightsize
;
281 height
= reply
.height
;
283 widthsize
= __glImageSize(width
,1,1,format
, type
, 0);
284 heightsize
= __glImageSize(height
,1,1,format
, type
, 0);
286 /* Allocate a holding buffer to transform the data from */
287 rowBuf
= (GLubyte
*) Xmalloc(widthsize
);
289 /* Throw data away */
290 _XEatData(dpy
, compsize
);
291 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
296 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)rowBuf
),widthsize
);
297 __glEmptyImage(gc
, 1, width
, 1, 1, format
, type
, rowBuf
, row
);
298 Xfree((char*) rowBuf
);
300 colBuf
= (GLubyte
*) Xmalloc(heightsize
);
302 /* Throw data away */
303 _XEatData(dpy
, compsize
- __GLX_PAD(widthsize
));
304 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
309 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)colBuf
),heightsize
);
310 __glEmptyImage(gc
, 1, height
, 1, 1, format
, type
, colBuf
, column
);
311 Xfree((char*) colBuf
);
315 ** don't modify user's buffer.
322 void __indirect_glGetHistogram(GLenum target
, GLboolean reset
, GLenum format
,
323 GLenum type
, GLvoid
*values
)
325 __GLX_SINGLE_DECLARE_VARIABLES();
326 const __GLXattribute
* state
;
327 xGLXGetHistogramReply reply
;
331 __GLX_SINGLE_LOAD_VARIABLES();
332 state
= gc
->client_state_private
;
335 __GLX_SINGLE_BEGIN(X_GLsop_GetHistogram
,__GLX_PAD(14));
336 __GLX_SINGLE_PUT_LONG(0,(long)target
);
337 __GLX_SINGLE_PUT_LONG(4,(long)format
);
338 __GLX_SINGLE_PUT_LONG(8,(long)type
);
339 __GLX_SINGLE_PUT_CHAR(12,state
->storePack
.swapEndian
);
340 __GLX_SINGLE_PUT_CHAR(13,reset
);
341 __GLX_SINGLE_READ_XREPLY();
342 compsize
= (long)reply
.length
<< 2;
345 /* Allocate a holding buffer to transform the data from */
346 buf
= (GLubyte
*)Xmalloc(compsize
);
348 /* Throw data away */
349 _XEatData(dpy
, compsize
);
350 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
355 ** Fetch data into holding buffer. Apply pixel store pack modes
356 ** to put data back into client memory
358 width
= (int)reply
.width
;
359 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf
),(long)compsize
);
360 __glEmptyImage(gc
, 1, width
, 1, 1, format
, type
, buf
, values
);
365 ** GL error occured, don't modify user's buffer.
371 void __indirect_glGetMinmax(GLenum target
, GLboolean reset
, GLenum format
, GLenum type
,
374 __GLX_SINGLE_DECLARE_VARIABLES();
375 const __GLXattribute
* state
;
376 xGLXGetMinmaxReply reply
;
380 __GLX_SINGLE_LOAD_VARIABLES();
381 state
= gc
->client_state_private
;
384 __GLX_SINGLE_BEGIN(X_GLsop_GetMinmax
,__GLX_PAD(14));
385 __GLX_SINGLE_PUT_LONG(0,(long)target
);
386 __GLX_SINGLE_PUT_LONG(4,(long)format
);
387 __GLX_SINGLE_PUT_LONG(8,(long)type
);
388 __GLX_SINGLE_PUT_CHAR(12,state
->storePack
.swapEndian
);
389 __GLX_SINGLE_PUT_CHAR(13,reset
);
390 __GLX_SINGLE_READ_XREPLY();
391 compsize
= (long)reply
.length
<< 2;
394 /* Allocate a holding buffer to transform the data from */
395 buf
= (GLubyte
*)Xmalloc(compsize
);
397 /* Throw data away */
398 _XEatData(dpy
, compsize
);
399 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
402 ** Fetch data into holding buffer. Apply pixel store pack modes
403 ** to put data back into client memory
405 __GLX_SINGLE_GET_CHAR_ARRAY(((char*)buf
),(long)compsize
);
406 __glEmptyImage(gc
, 1, 2, 1, 1, format
, type
, buf
, values
);
411 ** GL error occured, don't modify user's buffer.