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 #include "packrender.h"
38 #include "indirect_size.h"
41 ** This file contains routines that might need to be transported as
42 ** GLXRender or GLXRenderLarge commands, and these commands don't
43 ** use the pixel header. See renderpix.c for those routines.
46 void __indirect_glMap1d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint stride
,
47 GLint order
, const GLdouble
*pnts
)
49 __GLX_DECLARE_VARIABLES();
52 __GLX_LOAD_VARIABLES();
53 k
= __glMap1d_size(target
);
55 __glXSetError(gc
, GL_INVALID_ENUM
);
57 } else if (stride
< k
|| order
<= 0) {
58 __glXSetError(gc
, GL_INVALID_VALUE
);
61 compsize
= k
* order
* __GLX_SIZE_FLOAT64
;
63 if (!gc
->currentDpy
) return;
65 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
66 /* Use GLXRender protocol to send small command */
67 __GLX_BEGIN_VARIABLE(X_GLrop_Map1d
,cmdlen
);
68 __GLX_PUT_DOUBLE(4,u1
);
69 __GLX_PUT_DOUBLE(12,u2
);
70 __GLX_PUT_LONG(20,target
);
71 __GLX_PUT_LONG(24,order
);
73 ** NOTE: the doubles that follow are not aligned because of 3
76 __glFillMap1d(k
, order
, stride
, pnts
, (pc
+28));
79 /* Use GLXRenderLarge protocol to send command */
80 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d
,cmdlen
+4);
81 __GLX_PUT_DOUBLE(8,u1
);
82 __GLX_PUT_DOUBLE(16,u2
);
83 __GLX_PUT_LONG(24,target
);
84 __GLX_PUT_LONG(28,order
);
87 ** NOTE: the doubles that follow are not aligned because of 3
93 buf
= (GLubyte
*) Xmalloc(compsize
);
95 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
98 __glFillMap1d(k
, order
, stride
, pnts
, buf
);
99 __glXSendLargeCommand(gc
, pc
, 32, buf
, compsize
);
102 /* Data is already packed. Just send it out */
103 __glXSendLargeCommand(gc
, pc
, 32, pnts
, compsize
);
108 void __indirect_glMap1f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
109 GLint order
, const GLfloat
*pnts
)
111 __GLX_DECLARE_VARIABLES();
114 __GLX_LOAD_VARIABLES();
115 k
= __glMap1f_size(target
);
117 __glXSetError(gc
, GL_INVALID_ENUM
);
119 } else if (stride
< k
|| order
<= 0) {
120 __glXSetError(gc
, GL_INVALID_VALUE
);
123 compsize
= k
* order
* __GLX_SIZE_FLOAT32
;
124 cmdlen
= 20+compsize
;
125 if (!gc
->currentDpy
) return;
128 ** The order that arguments are packed is different from the order
131 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
132 /* Use GLXRender protocol to send small command */
133 __GLX_BEGIN_VARIABLE(X_GLrop_Map1f
,cmdlen
);
134 __GLX_PUT_LONG(4,target
);
135 __GLX_PUT_FLOAT(8,u1
);
136 __GLX_PUT_FLOAT(12,u2
);
137 __GLX_PUT_LONG(16,order
);
138 __glFillMap1f(k
, order
, stride
, pnts
, (GLubyte
*) (pc
+20));
141 /* Use GLXRenderLarge protocol to send command */
142 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f
,cmdlen
+4);
143 __GLX_PUT_LONG(8,target
);
144 __GLX_PUT_FLOAT(12,u1
);
145 __GLX_PUT_FLOAT(16,u2
);
146 __GLX_PUT_LONG(20,order
);
151 buf
= (GLubyte
*) Xmalloc(compsize
);
153 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
156 __glFillMap1f(k
, order
, stride
, pnts
, buf
);
157 __glXSendLargeCommand(gc
, pc
, 24, buf
, compsize
);
160 /* Data is already packed. Just send it out */
161 __glXSendLargeCommand(gc
, pc
, 24, pnts
, compsize
);
166 void __indirect_glMap2d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint ustr
, GLint uord
,
167 GLdouble v1
, GLdouble v2
, GLint vstr
, GLint vord
,
168 const GLdouble
*pnts
)
170 __GLX_DECLARE_VARIABLES();
173 __GLX_LOAD_VARIABLES();
174 k
= __glMap2d_size(target
);
176 __glXSetError(gc
, GL_INVALID_ENUM
);
178 } else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
179 __glXSetError(gc
, GL_INVALID_VALUE
);
182 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT64
;
183 cmdlen
= 48+compsize
;
184 if (!gc
->currentDpy
) return;
186 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
187 /* Use GLXRender protocol to send small command */
188 __GLX_BEGIN_VARIABLE(X_GLrop_Map2d
,cmdlen
);
189 __GLX_PUT_DOUBLE(4,u1
);
190 __GLX_PUT_DOUBLE(12,u2
);
191 __GLX_PUT_DOUBLE(20,v1
);
192 __GLX_PUT_DOUBLE(28,v2
);
193 __GLX_PUT_LONG(36,target
);
194 __GLX_PUT_LONG(40,uord
);
195 __GLX_PUT_LONG(44,vord
);
197 ** Pack into a u-major ordering.
198 ** NOTE: the doubles that follow are not aligned because of 5
201 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLdouble
*) (pc
+48));
204 /* Use GLXRenderLarge protocol to send command */
205 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d
,cmdlen
+4);
206 __GLX_PUT_DOUBLE(8,u1
);
207 __GLX_PUT_DOUBLE(16,u2
);
208 __GLX_PUT_DOUBLE(24,v1
);
209 __GLX_PUT_DOUBLE(32,v2
);
210 __GLX_PUT_LONG(40,target
);
211 __GLX_PUT_LONG(44,uord
);
212 __GLX_PUT_LONG(48,vord
);
215 ** NOTE: the doubles that follow are not aligned because of 5
218 if ((vstr
!= k
) || (ustr
!= k
*vord
)) {
221 buf
= (GLdouble
*) Xmalloc(compsize
);
223 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
227 ** Pack into a u-major ordering.
229 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
230 __glXSendLargeCommand(gc
, pc
, 52, buf
, compsize
);
233 /* Data is already packed. Just send it out */
234 __glXSendLargeCommand(gc
, pc
, 52, pnts
, compsize
);
239 void __indirect_glMap2f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustr
, GLint uord
,
240 GLfloat v1
, GLfloat v2
, GLint vstr
, GLint vord
,
243 __GLX_DECLARE_VARIABLES();
246 __GLX_LOAD_VARIABLES();
247 k
= __glMap2f_size(target
);
249 __glXSetError(gc
, GL_INVALID_ENUM
);
251 } else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
252 __glXSetError(gc
, GL_INVALID_VALUE
);
255 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT32
;
256 cmdlen
= 32+compsize
;
257 if (!gc
->currentDpy
) return;
260 ** The order that arguments are packed is different from the order
263 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
264 /* Use GLXRender protocol to send small command */
265 __GLX_BEGIN_VARIABLE(X_GLrop_Map2f
,cmdlen
);
266 __GLX_PUT_LONG(4,target
);
267 __GLX_PUT_FLOAT(8,u1
);
268 __GLX_PUT_FLOAT(12,u2
);
269 __GLX_PUT_LONG(16,uord
);
270 __GLX_PUT_FLOAT(20,v1
);
271 __GLX_PUT_FLOAT(24,v2
);
272 __GLX_PUT_LONG(28,vord
);
274 ** Pack into a u-major ordering.
276 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLfloat
*) (pc
+32));
279 /* Use GLXRenderLarge protocol to send command */
280 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f
,cmdlen
+4);
281 __GLX_PUT_LONG(8,target
);
282 __GLX_PUT_FLOAT(12,u1
);
283 __GLX_PUT_FLOAT(16,u2
);
284 __GLX_PUT_LONG(20,uord
);
285 __GLX_PUT_FLOAT(24,v1
);
286 __GLX_PUT_FLOAT(28,v2
);
287 __GLX_PUT_LONG(32,vord
);
289 if ((vstr
!= k
) || (ustr
!= k
*vord
)) {
292 buf
= (GLfloat
*) Xmalloc(compsize
);
294 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
298 ** Pack into a u-major ordering.
300 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
301 __glXSendLargeCommand(gc
, pc
, 36, buf
, compsize
);
304 /* Data is already packed. Just send it out */
305 __glXSendLargeCommand(gc
, pc
, 36, pnts
, compsize
);
310 void __indirect_glEnable(GLenum cap
)
312 __GLX_DECLARE_VARIABLES();
314 __GLX_LOAD_VARIABLES();
315 if (!gc
->currentDpy
) return;
319 case GL_EDGE_FLAG_ARRAY
:
321 case GL_NORMAL_ARRAY
:
322 case GL_TEXTURE_COORD_ARRAY
:
323 case GL_VERTEX_ARRAY
:
324 case GL_SECONDARY_COLOR_ARRAY
:
325 case GL_FOG_COORD_ARRAY
:
326 __indirect_glEnableClientState(cap
);
332 __GLX_BEGIN(X_GLrop_Enable
,8);
333 __GLX_PUT_LONG(4,cap
);
337 void __indirect_glDisable(GLenum cap
)
339 __GLX_DECLARE_VARIABLES();
341 __GLX_LOAD_VARIABLES();
342 if (!gc
->currentDpy
) return;
346 case GL_EDGE_FLAG_ARRAY
:
348 case GL_NORMAL_ARRAY
:
349 case GL_TEXTURE_COORD_ARRAY
:
350 case GL_VERTEX_ARRAY
:
351 case GL_SECONDARY_COLOR_ARRAY
:
352 case GL_FOG_COORD_ARRAY
:
353 __indirect_glDisableClientState(cap
);
359 __GLX_BEGIN(X_GLrop_Disable
,8);
360 __GLX_PUT_LONG(4,cap
);