1 /* $XFree86: xc/lib/GL/glx/render2.c,v 1.6 2004/01/31 09:29:33 alanh 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 "packrender.h"
39 #include "indirect_size.h"
42 ** This file contains routines that might need to be transported as
43 ** GLXRender or GLXRenderLarge commands, and these commands don't
44 ** use the pixel header. See renderpix.c for those routines.
47 void __indirect_glMap1d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint stride
,
48 GLint order
, const GLdouble
*pnts
)
50 __GLX_DECLARE_VARIABLES();
53 __GLX_LOAD_VARIABLES();
54 k
= __glMap1d_size(target
);
56 __glXSetError(gc
, GL_INVALID_ENUM
);
58 } else if (stride
< k
|| order
<= 0) {
59 __glXSetError(gc
, GL_INVALID_VALUE
);
62 compsize
= k
* order
* __GLX_SIZE_FLOAT64
;
64 if (!gc
->currentDpy
) return;
66 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
67 /* Use GLXRender protocol to send small command */
68 __GLX_BEGIN_VARIABLE(X_GLrop_Map1d
,cmdlen
);
69 __GLX_PUT_DOUBLE(4,u1
);
70 __GLX_PUT_DOUBLE(12,u2
);
71 __GLX_PUT_LONG(20,target
);
72 __GLX_PUT_LONG(24,order
);
74 ** NOTE: the doubles that follow are not aligned because of 3
77 __glFillMap1d(k
, order
, stride
, pnts
, (pc
+28));
80 /* Use GLXRenderLarge protocol to send command */
81 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d
,cmdlen
+4);
82 __GLX_PUT_DOUBLE(8,u1
);
83 __GLX_PUT_DOUBLE(16,u2
);
84 __GLX_PUT_LONG(24,target
);
85 __GLX_PUT_LONG(28,order
);
88 ** NOTE: the doubles that follow are not aligned because of 3
94 buf
= (GLubyte
*) Xmalloc(compsize
);
96 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
99 __glFillMap1d(k
, order
, stride
, pnts
, buf
);
100 __glXSendLargeCommand(gc
, pc
, 32, buf
, compsize
);
103 /* Data is already packed. Just send it out */
104 __glXSendLargeCommand(gc
, pc
, 32, pnts
, compsize
);
109 void __indirect_glMap1f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
110 GLint order
, const GLfloat
*pnts
)
112 __GLX_DECLARE_VARIABLES();
115 __GLX_LOAD_VARIABLES();
116 k
= __glMap1f_size(target
);
118 __glXSetError(gc
, GL_INVALID_ENUM
);
120 } else if (stride
< k
|| order
<= 0) {
121 __glXSetError(gc
, GL_INVALID_VALUE
);
124 compsize
= k
* order
* __GLX_SIZE_FLOAT32
;
125 cmdlen
= 20+compsize
;
126 if (!gc
->currentDpy
) return;
129 ** The order that arguments are packed is different from the order
132 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
133 /* Use GLXRender protocol to send small command */
134 __GLX_BEGIN_VARIABLE(X_GLrop_Map1f
,cmdlen
);
135 __GLX_PUT_LONG(4,target
);
136 __GLX_PUT_FLOAT(8,u1
);
137 __GLX_PUT_FLOAT(12,u2
);
138 __GLX_PUT_LONG(16,order
);
139 __glFillMap1f(k
, order
, stride
, pnts
, (GLubyte
*) (pc
+20));
142 /* Use GLXRenderLarge protocol to send command */
143 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f
,cmdlen
+4);
144 __GLX_PUT_LONG(8,target
);
145 __GLX_PUT_FLOAT(12,u1
);
146 __GLX_PUT_FLOAT(16,u2
);
147 __GLX_PUT_LONG(20,order
);
152 buf
= (GLubyte
*) Xmalloc(compsize
);
154 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
157 __glFillMap1f(k
, order
, stride
, pnts
, buf
);
158 __glXSendLargeCommand(gc
, pc
, 24, buf
, compsize
);
161 /* Data is already packed. Just send it out */
162 __glXSendLargeCommand(gc
, pc
, 24, pnts
, compsize
);
167 void __indirect_glMap2d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint ustr
, GLint uord
,
168 GLdouble v1
, GLdouble v2
, GLint vstr
, GLint vord
,
169 const GLdouble
*pnts
)
171 __GLX_DECLARE_VARIABLES();
174 __GLX_LOAD_VARIABLES();
175 k
= __glMap2d_size(target
);
177 __glXSetError(gc
, GL_INVALID_ENUM
);
179 } else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
180 __glXSetError(gc
, GL_INVALID_VALUE
);
183 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT64
;
184 cmdlen
= 48+compsize
;
185 if (!gc
->currentDpy
) return;
187 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
188 /* Use GLXRender protocol to send small command */
189 __GLX_BEGIN_VARIABLE(X_GLrop_Map2d
,cmdlen
);
190 __GLX_PUT_DOUBLE(4,u1
);
191 __GLX_PUT_DOUBLE(12,u2
);
192 __GLX_PUT_DOUBLE(20,v1
);
193 __GLX_PUT_DOUBLE(28,v2
);
194 __GLX_PUT_LONG(36,target
);
195 __GLX_PUT_LONG(40,uord
);
196 __GLX_PUT_LONG(44,vord
);
198 ** Pack into a u-major ordering.
199 ** NOTE: the doubles that follow are not aligned because of 5
202 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLdouble
*) (pc
+48));
205 /* Use GLXRenderLarge protocol to send command */
206 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d
,cmdlen
+4);
207 __GLX_PUT_DOUBLE(8,u1
);
208 __GLX_PUT_DOUBLE(16,u2
);
209 __GLX_PUT_DOUBLE(24,v1
);
210 __GLX_PUT_DOUBLE(32,v2
);
211 __GLX_PUT_LONG(40,target
);
212 __GLX_PUT_LONG(44,uord
);
213 __GLX_PUT_LONG(48,vord
);
216 ** NOTE: the doubles that follow are not aligned because of 5
219 if ((vstr
!= k
) || (ustr
!= k
*vord
)) {
222 buf
= (GLdouble
*) Xmalloc(compsize
);
224 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
228 ** Pack into a u-major ordering.
230 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
231 __glXSendLargeCommand(gc
, pc
, 52, buf
, compsize
);
234 /* Data is already packed. Just send it out */
235 __glXSendLargeCommand(gc
, pc
, 52, pnts
, compsize
);
240 void __indirect_glMap2f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustr
, GLint uord
,
241 GLfloat v1
, GLfloat v2
, GLint vstr
, GLint vord
,
244 __GLX_DECLARE_VARIABLES();
247 __GLX_LOAD_VARIABLES();
248 k
= __glMap2f_size(target
);
250 __glXSetError(gc
, GL_INVALID_ENUM
);
252 } else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
253 __glXSetError(gc
, GL_INVALID_VALUE
);
256 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT32
;
257 cmdlen
= 32+compsize
;
258 if (!gc
->currentDpy
) return;
261 ** The order that arguments are packed is different from the order
264 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
265 /* Use GLXRender protocol to send small command */
266 __GLX_BEGIN_VARIABLE(X_GLrop_Map2f
,cmdlen
);
267 __GLX_PUT_LONG(4,target
);
268 __GLX_PUT_FLOAT(8,u1
);
269 __GLX_PUT_FLOAT(12,u2
);
270 __GLX_PUT_LONG(16,uord
);
271 __GLX_PUT_FLOAT(20,v1
);
272 __GLX_PUT_FLOAT(24,v2
);
273 __GLX_PUT_LONG(28,vord
);
275 ** Pack into a u-major ordering.
277 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLfloat
*) (pc
+32));
280 /* Use GLXRenderLarge protocol to send command */
281 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f
,cmdlen
+4);
282 __GLX_PUT_LONG(8,target
);
283 __GLX_PUT_FLOAT(12,u1
);
284 __GLX_PUT_FLOAT(16,u2
);
285 __GLX_PUT_LONG(20,uord
);
286 __GLX_PUT_FLOAT(24,v1
);
287 __GLX_PUT_FLOAT(28,v2
);
288 __GLX_PUT_LONG(32,vord
);
290 if ((vstr
!= k
) || (ustr
!= k
*vord
)) {
293 buf
= (GLfloat
*) Xmalloc(compsize
);
295 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
299 ** Pack into a u-major ordering.
301 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
302 __glXSendLargeCommand(gc
, pc
, 36, buf
, compsize
);
305 /* Data is already packed. Just send it out */
306 __glXSendLargeCommand(gc
, pc
, 36, pnts
, compsize
);
311 void __indirect_glEnable(GLenum cap
)
313 __GLX_DECLARE_VARIABLES();
315 __GLX_LOAD_VARIABLES();
316 if (!gc
->currentDpy
) return;
320 case GL_EDGE_FLAG_ARRAY
:
322 case GL_NORMAL_ARRAY
:
323 case GL_TEXTURE_COORD_ARRAY
:
324 case GL_VERTEX_ARRAY
:
325 case GL_SECONDARY_COLOR_ARRAY
:
326 case GL_FOG_COORD_ARRAY
:
327 __indirect_glEnableClientState(cap
);
333 __GLX_BEGIN(X_GLrop_Enable
,8);
334 __GLX_PUT_LONG(4,cap
);
338 void __indirect_glDisable(GLenum cap
)
340 __GLX_DECLARE_VARIABLES();
342 __GLX_LOAD_VARIABLES();
343 if (!gc
->currentDpy
) return;
347 case GL_EDGE_FLAG_ARRAY
:
349 case GL_NORMAL_ARRAY
:
350 case GL_TEXTURE_COORD_ARRAY
:
351 case GL_VERTEX_ARRAY
:
352 case GL_SECONDARY_COLOR_ARRAY
:
353 case GL_FOG_COORD_ARRAY
:
354 __indirect_glDisableClientState(cap
);
360 __GLX_BEGIN(X_GLrop_Disable
,8);
361 __GLX_PUT_LONG(4,cap
);