2 * (C) Copyright Apple Inc. 2008
3 * (C) Copyright IBM Corporation 2004, 2005
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, sub license,
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 and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * AND/OR THEIR SUPPLIERS 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
28 #include "glxclient.h"
29 #include <GL/glxproto.h>
32 __glXReadReply(Display
* dpy
, size_t size
, void *dest
,
33 GLboolean reply_is_always_array
)
35 xGLXSingleReply reply
;
37 (void) _XReply(dpy
, (xReply
*) & reply
, 0, False
);
39 if ((reply
.length
> 0) || reply_is_always_array
) {
40 const GLint bytes
= (reply_is_always_array
)
41 ? (4 * reply
.length
) : (reply
.size
* size
);
42 const GLint extra
= 4 - (bytes
& 3);
44 _XRead(dpy
, dest
, bytes
);
46 _XEatData(dpy
, extra
);
50 (void) memcpy(dest
, &(reply
.pad3
), size
);
58 __glXReadPixelReply(Display
* dpy
, struct glx_context
* gc
, unsigned max_dim
,
59 GLint width
, GLint height
, GLint depth
, GLenum format
,
60 GLenum type
, void *dest
, GLboolean dimensions_in_reply
)
62 xGLXSingleReply reply
;
65 (void) _XReply(dpy
, (xReply
*) & reply
, 0, False
);
67 if (dimensions_in_reply
) {
72 if ((height
== 0) || (max_dim
< 2)) {
75 if ((depth
== 0) || (max_dim
< 3)) {
80 size
= reply
.length
* 4;
82 void *buf
= Xmalloc(size
);
86 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
89 const GLint extra
= 4 - (size
& 3);
91 _XRead(dpy
, buf
, size
);
93 _XEatData(dpy
, extra
);
96 __glEmptyImage(gc
, 3, width
, height
, depth
, format
, type
, buf
, dest
);
104 __glXSetupSingleRequest(struct glx_context
* gc
, GLint sop
, GLint cmdlen
)
107 Display
*const dpy
= gc
->currentDpy
;
109 (void) __glXFlushRenderBuffer(gc
, gc
->pc
);
111 GetReqExtra(GLXSingle
, cmdlen
, req
);
112 req
->reqType
= gc
->majorOpcode
;
113 req
->contextTag
= gc
->currentContextTag
;
115 return (GLubyte
*) (req
) + sz_xGLXSingleReq
;
120 __glXSetupVendorRequest(struct glx_context
* gc
, GLint code
, GLint vop
,
123 xGLXVendorPrivateReq
*req
;
124 Display
*const dpy
= gc
->currentDpy
;
126 (void) __glXFlushRenderBuffer(gc
, gc
->pc
);
128 GetReqExtra(GLXVendorPrivate
, cmdlen
, req
);
129 req
->reqType
= gc
->majorOpcode
;
131 req
->vendorCode
= vop
;
132 req
->contextTag
= gc
->currentContextTag
;
133 return (GLubyte
*) (req
) + sz_xGLXVendorPrivateReq
;