1 #ifndef __GLX_packsingle_h__
2 #define __GLX_packsingle_h__
5 ** License Applicability. Except to the extent portions of this file are
6 ** made subject to an alternative license as permitted in the SGI Free
7 ** Software License B, Version 1.1 (the "License"), the contents of this
8 ** file are subject only to the provisions of the License. You may not use
9 ** this file except in compliance with the License. You may obtain a copy
10 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
11 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
13 ** http://oss.sgi.com/projects/FreeB
15 ** Note that, as provided in the License, the Software is distributed on an
16 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
17 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
18 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
21 ** Original Code. The Original Code is: OpenGL Sample Implementation,
22 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
23 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
24 ** Copyright in any portions created by third parties is as indicated
25 ** elsewhere herein. All Rights Reserved.
27 ** Additional Notice Provisions: The application programming interfaces
28 ** established by SGI in conjunction with the Original Code are The
29 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
30 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
31 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
32 ** Window System(R) (Version 1.3), released October 19, 1998. This software
33 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
34 ** published by SGI, but has not been independently verified as being
35 ** compliant with the OpenGL(R) version 1.2.1 Specification.
39 #include "packrender.h"
42 ** The macros in this header convert wire protocol data types to the client
43 ** machine's native data types. The header is part of the porting layer of
44 ** the client library, and it is intended that hardware vendors will rewrite
45 ** this header to suit their own machines.
49 ** Dummy define to make the GetReqExtra macro happy. The value is not
50 ** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store
51 ** to req->reqType with the proper code (our extension code).
55 /* Declare common variables used during a single command */
56 #define __GLX_SINGLE_DECLARE_VARIABLES() \
57 __GLXcontext *gc = __glXGetCurrentContext(); \
58 GLubyte *pc, *pixelHeaderPC; \
59 GLuint compsize, cmdlen; \
60 Display *dpy = gc->currentDpy; \
63 #define __GLX_SINGLE_LOAD_VARIABLES() \
65 /* Muffle compilers */ \
66 pixelHeaderPC = 0; (void)pixelHeaderPC; \
67 compsize = 0; (void)compsize; \
68 cmdlen = 0; (void)cmdlen
70 /* Start a single command */
71 #define __GLX_SINGLE_BEGIN(opcode,bytes) \
73 (void) __glXFlushRenderBuffer(gc, pc); \
75 GetReqExtra(GLXSingle,bytes,req); \
76 req->reqType = gc->majorOpcode; \
77 req->glxCode = opcode; \
78 req->contextTag = gc->currentContextTag; \
79 pc = ((GLubyte *)(req) + sz_xGLXSingleReq)
81 /* End a single command */
82 #define __GLX_SINGLE_END() \
87 /* Store data to sending for a single command */
88 #define __GLX_SINGLE_PUT_CHAR(offset,a) \
89 *((INT8 *) (pc + offset)) = a
92 #define __GLX_SINGLE_PUT_SHORT(offset,a) \
93 *((INT16 *) (pc + offset)) = a
95 #define __GLX_SINGLE_PUT_LONG(offset,a) \
96 *((INT32 *) (pc + offset)) = a
98 #define __GLX_SINGLE_PUT_FLOAT(offset,a) \
99 *((FLOAT32 *) (pc + offset)) = a
102 #define __GLX_SINGLE_PUT_SHORT(offset,a) \
103 { GLubyte *cp = (pc+offset); \
104 int shift = (64-16) - ((int)(cp) >> (64-6)); \
105 *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
107 #define __GLX_SINGLE_PUT_LONG(offset,a) \
108 { GLubyte *cp = (pc+offset); \
109 int shift = (64-32) - ((int)(cp) >> (64-6)); \
110 *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
112 #define __GLX_SINGLE_PUT_FLOAT(offset,a) \
113 gl_put_float(pc + offset, a)
116 /* Read support macros */
117 #define __GLX_SINGLE_READ_XREPLY() \
118 (void) _XReply(dpy, (xReply*) &reply, 0, False)
120 #define __GLX_SINGLE_GET_RETVAL(a,cast) \
121 a = (cast) reply.retval
123 #define __GLX_SINGLE_GET_SIZE(a) \
124 a = (GLint) reply.size
127 #define __GLX_SINGLE_GET_CHAR(p) \
128 *p = *(GLbyte *)&reply.pad3;
130 #define __GLX_SINGLE_GET_SHORT(p) \
131 *p = *(GLshort *)&reply.pad3;
133 #define __GLX_SINGLE_GET_LONG(p) \
134 *p = *(GLint *)&reply.pad3;
136 #define __GLX_SINGLE_GET_FLOAT(p) \
137 *p = *(GLfloat *)&reply.pad3;
140 #define __GLX_SINGLE_GET_CHAR(p) \
141 *p = reply.pad3 >> 24;
143 #define __GLX_SINGLE_GET_SHORT(p) \
144 {int t = reply.pad3 >> 16; \
145 *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
147 #define __GLX_SINGLE_GET_LONG(p) \
148 {int t = reply.pad3; \
149 *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
151 #define PAD3OFFSET 16
152 #define __GLX_SINGLE_GET_FLOAT(p) \
153 *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
155 #define __GLX_SINGLE_GET_DOUBLE(p) \
156 *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
158 extern float gl_ntoh_float(GLubyte
*);
159 extern float gl_ntoh_double(GLubyte
*);
165 #define __GLX_SINGLE_GET_DOUBLE(p) \
166 __GLX_MEM_COPY(p, &reply.pad3, 8)
168 #define __GLX_SINGLE_GET_DOUBLE(p) \
169 *p = *(GLdouble *)&reply.pad3
174 /* Get an array of typed data */
175 #define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \
177 GLint slop = alen*__GLX_SIZE_INT8 & 3; \
178 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
179 if (slop) _XEatData(dpy,4-slop); \
182 #define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \
184 GLint slop = alen*__GLX_SIZE_INT8 & 3; \
185 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
186 if (slop) _XEatData(dpy,4-slop); \
190 #define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \
192 GLint slop = (alen*__GLX_SIZE_INT16) & 3; \
193 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16);\
194 if (slop) _XEatData(dpy,4-slop); \
197 #define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
198 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
201 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
202 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
204 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
205 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
208 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
209 gl_get_float_array(dpy,a,alen);
211 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
212 gl_get_double_array(dpy, a, alen);
214 extern void gl_get_float_array(Display
*dpy
, float *a
, int alen
);
215 extern void gl_get_double_array(Display
*dpy
, double *a
, int alen
);
218 #endif /* !__GLX_packsingle_h__ */