2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
10 ** http://oss.sgi.com/projects/FreeB
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
36 /* #define NEED_REPLIES */
37 #include "glxserver.h"
39 #include "g_disptab.h"
41 GLint
__glEvalComputeK(GLenum target
)
44 case GL_MAP1_VERTEX_4
:
46 case GL_MAP1_TEXTURE_COORD_4
:
47 case GL_MAP2_VERTEX_4
:
49 case GL_MAP2_TEXTURE_COORD_4
:
51 case GL_MAP1_VERTEX_3
:
52 case GL_MAP1_TEXTURE_COORD_3
:
54 case GL_MAP2_VERTEX_3
:
55 case GL_MAP2_TEXTURE_COORD_3
:
58 case GL_MAP1_TEXTURE_COORD_2
:
59 case GL_MAP2_TEXTURE_COORD_2
:
61 case GL_MAP1_TEXTURE_COORD_1
:
62 case GL_MAP2_TEXTURE_COORD_1
:
71 void __glXDispSwap_Map1f(GLbyte
*pc
)
74 GLfloat u1
, u2
, *points
;
77 __GLX_DECLARE_SWAP_VARIABLES
;
79 __GLX_SWAP_INT(pc
+ 0);
80 __GLX_SWAP_INT(pc
+ 12);
81 __GLX_SWAP_FLOAT(pc
+ 4);
82 __GLX_SWAP_FLOAT(pc
+ 8);
84 target
= *(GLenum
*)(pc
+ 0);
85 order
= *(GLint
*)(pc
+ 12);
86 u1
= *(GLfloat
*)(pc
+ 4);
87 u2
= *(GLfloat
*)(pc
+ 8);
88 points
= (GLfloat
*)(pc
+ 16);
89 k
= __glEvalComputeK(target
);
91 if (order
<= 0 || k
< 0) {
92 /* Erroneous command. */
97 __GLX_SWAP_FLOAT_ARRAY(points
, compsize
);
101 void __glXDispSwap_Map2f(GLbyte
*pc
)
103 GLint uorder
, vorder
, ustride
, vstride
, k
;
104 GLfloat u1
, u2
, v1
, v2
, *points
;
107 __GLX_DECLARE_SWAP_VARIABLES
;
109 __GLX_SWAP_INT(pc
+ 0);
110 __GLX_SWAP_INT(pc
+ 12);
111 __GLX_SWAP_INT(pc
+ 24);
112 __GLX_SWAP_FLOAT(pc
+ 4);
113 __GLX_SWAP_FLOAT(pc
+ 8);
114 __GLX_SWAP_FLOAT(pc
+ 16);
115 __GLX_SWAP_FLOAT(pc
+ 20);
117 target
= *(GLenum
*)(pc
+ 0);
118 uorder
= *(GLint
*)(pc
+ 12);
119 vorder
= *(GLint
*)(pc
+ 24);
120 u1
= *(GLfloat
*)(pc
+ 4);
121 u2
= *(GLfloat
*)(pc
+ 8);
122 v1
= *(GLfloat
*)(pc
+ 16);
123 v2
= *(GLfloat
*)(pc
+ 20);
124 points
= (GLfloat
*)(pc
+ 28);
126 k
= __glEvalComputeK(target
);
127 ustride
= vorder
* k
;
130 if (vorder
<= 0 || uorder
<= 0 || k
< 0) {
131 /* Erroneous command. */
134 compsize
= uorder
* vorder
* k
;
136 __GLX_SWAP_FLOAT_ARRAY(points
, compsize
);
140 void __glXDispSwap_Map1d(GLbyte
*pc
)
142 GLint order
, k
, compsize
;
144 GLdouble u1
, u2
, *points
;
145 __GLX_DECLARE_SWAP_VARIABLES
;
147 __GLX_SWAP_DOUBLE(pc
+ 0);
148 __GLX_SWAP_DOUBLE(pc
+ 8);
149 __GLX_SWAP_INT(pc
+ 16);
150 __GLX_SWAP_INT(pc
+ 20);
152 target
= *(GLenum
*) (pc
+ 16);
153 order
= *(GLint
*) (pc
+ 20);
154 k
= __glEvalComputeK(target
);
155 if (order
<= 0 || k
< 0) {
156 /* Erroneous command. */
159 compsize
= order
* k
;
161 __GLX_GET_DOUBLE(u1
,pc
);
162 __GLX_GET_DOUBLE(u2
,pc
+8);
163 __GLX_SWAP_DOUBLE_ARRAY(pc
+24, compsize
);
167 if (((unsigned long)pc
) & 7) {
169 ** Copy the doubles up 4 bytes, trashing the command but aligning
170 ** the data in the process
172 __GLX_MEM_COPY(pc
-4, pc
, compsize
*8);
173 points
= (GLdouble
*) (pc
- 4);
175 points
= (GLdouble
*) pc
;
178 points
= (GLdouble
*) pc
;
182 void __glXDispSwap_Map2d(GLbyte
*pc
)
184 GLdouble u1
, u2
, v1
, v2
, *points
;
185 GLint uorder
, vorder
, ustride
, vstride
, k
, compsize
;
187 __GLX_DECLARE_SWAP_VARIABLES
;
189 __GLX_SWAP_DOUBLE(pc
+ 0);
190 __GLX_SWAP_DOUBLE(pc
+ 8);
191 __GLX_SWAP_DOUBLE(pc
+ 16);
192 __GLX_SWAP_DOUBLE(pc
+ 24);
193 __GLX_SWAP_INT(pc
+ 32);
194 __GLX_SWAP_INT(pc
+ 36);
195 __GLX_SWAP_INT(pc
+ 40);
197 target
= *(GLenum
*)(pc
+ 32);
198 uorder
= *(GLint
*)(pc
+ 36);
199 vorder
= *(GLint
*)(pc
+ 40);
200 k
= __glEvalComputeK(target
);
201 if (vorder
<= 0 || uorder
<= 0 || k
< 0) {
202 /* Erroneous command. */
205 compsize
= uorder
* vorder
* k
;
207 __GLX_GET_DOUBLE(u1
,pc
);
208 __GLX_GET_DOUBLE(u2
,pc
+8);
209 __GLX_GET_DOUBLE(v1
,pc
+16);
210 __GLX_GET_DOUBLE(v2
,pc
+24);
211 __GLX_SWAP_DOUBLE_ARRAY(pc
+44, compsize
);
213 ustride
= vorder
* k
;
217 if (((unsigned long)pc
) & 7) {
219 ** Copy the doubles up 4 bytes, trashing the command but aligning
220 ** the data in the process
222 __GLX_MEM_COPY(pc
-4, pc
, compsize
*8);
223 points
= (GLdouble
*) (pc
- 4);
225 points
= (GLdouble
*) pc
;
228 points
= (GLdouble
*) pc
;
232 void __glXDispSwap_CallLists(GLbyte
*pc
)
236 __GLX_DECLARE_SWAP_VARIABLES
;
238 __GLX_SWAP_INT(pc
+ 4);
239 __GLX_SWAP_INT(pc
+ 0);
240 type
= *(GLenum
*)(pc
+ 4);
241 n
= *(GLsizei
*)(pc
+ 0);
245 case GL_UNSIGNED_BYTE
:
251 case GL_UNSIGNED_SHORT
:
252 __GLX_SWAP_SHORT_ARRAY(pc
+8, n
);
255 case GL_UNSIGNED_INT
:
256 __GLX_SWAP_INT_ARRAY(pc
+8, n
);
259 __GLX_SWAP_FLOAT_ARRAY(pc
+8, n
);
265 static void swapArray(GLint numVals
, GLenum datatype
,
266 GLint stride
, GLint numVertexes
, GLbyte
*pc
)
269 __GLX_DECLARE_SWAP_VARIABLES
;
273 case GL_UNSIGNED_BYTE
:
274 /* don't need to swap */
277 case GL_UNSIGNED_SHORT
:
278 for (i
=0; i
<numVertexes
; i
++) {
279 GLshort
*pVal
= (GLshort
*) pc
;
280 for (j
=0; j
<numVals
; j
++) {
281 __GLX_SWAP_SHORT(&pVal
[j
]);
287 case GL_UNSIGNED_INT
:
288 for (i
=0; i
<numVertexes
; i
++) {
289 GLint
*pVal
= (GLint
*) pc
;
290 for (j
=0; j
<numVals
; j
++) {
291 __GLX_SWAP_INT(&pVal
[j
]);
297 for (i
=0; i
<numVertexes
; i
++) {
298 GLfloat
*pVal
= (GLfloat
*) pc
;
299 for (j
=0; j
<numVals
; j
++) {
300 __GLX_SWAP_FLOAT(&pVal
[j
]);
306 for (i
=0; i
<numVertexes
; i
++) {
307 GLdouble
*pVal
= (GLdouble
*) pc
;
308 for (j
=0; j
<numVals
; j
++) {
309 __GLX_SWAP_DOUBLE(&pVal
[j
]);
319 void __glXDispSwap_DrawArrays(GLbyte
*pc
)
321 __GLXdispatchDrawArraysHeader
*hdr
= (__GLXdispatchDrawArraysHeader
*)pc
;
322 __GLXdispatchDrawArraysComponentHeader
*compHeader
;
324 __GLX_DECLARE_SWAP_VARIABLES
;
326 __GLX_SWAP_INT(&hdr
->numVertexes
);
327 __GLX_SWAP_INT(&hdr
->numComponents
);
328 __GLX_SWAP_INT(&hdr
->primType
);
330 pc
+= sizeof(__GLXdispatchDrawArraysHeader
);
331 compHeader
= (__GLXdispatchDrawArraysComponentHeader
*) pc
;
333 /* compute stride (same for all component arrays) */
334 for (i
=0; i
<hdr
->numComponents
; i
++) {
335 __GLX_SWAP_INT(&compHeader
[i
].datatype
);
336 __GLX_SWAP_INT(&compHeader
[i
].numVals
);
337 __GLX_SWAP_INT(&compHeader
[i
].component
);
343 void __glXDispSwap_DrawArraysEXT(GLbyte
*pc
)