1 /* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
3 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
4 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
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, sublicense,
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 including the dates of first publication and
14 * either this permission notice or a reference to
15 * http://oss.sgi.com/projects/FreeB/
16 * shall be included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * SILICON GRAPHICS, INC. 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
26 * Except as contained in this notice, the name of Silicon Graphics, Inc.
27 * shall not be used in advertising or otherwise to promote the sale, use or
28 * other dealings in this Software without prior written authorization from
29 * Silicon Graphics, Inc.
32 #include "packrender.h"
34 #include "indirect_size.h"
37 ** This file contains routines that might need to be transported as
38 ** GLXRender or GLXRenderLarge commands, and these commands don't
39 ** use the pixel header. See renderpix.c for those routines.
42 void __indirect_glMap1d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint stride
,
43 GLint order
, const GLdouble
*pnts
)
45 __GLX_DECLARE_VARIABLES();
48 __GLX_LOAD_VARIABLES();
49 k
= __glMap1d_size(target
);
51 __glXSetError(gc
, GL_INVALID_ENUM
);
53 } else if (stride
< k
|| order
<= 0) {
54 __glXSetError(gc
, GL_INVALID_VALUE
);
57 compsize
= k
* order
* __GLX_SIZE_FLOAT64
;
59 if (!gc
->currentDpy
) return;
61 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
62 /* Use GLXRender protocol to send small command */
63 __GLX_BEGIN_VARIABLE(X_GLrop_Map1d
,cmdlen
);
64 __GLX_PUT_DOUBLE(4,u1
);
65 __GLX_PUT_DOUBLE(12,u2
);
66 __GLX_PUT_LONG(20,target
);
67 __GLX_PUT_LONG(24,order
);
69 ** NOTE: the doubles that follow are not aligned because of 3
72 __glFillMap1d(k
, order
, stride
, pnts
, (pc
+28));
75 /* Use GLXRenderLarge protocol to send command */
76 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d
,cmdlen
+4);
77 __GLX_PUT_DOUBLE(8,u1
);
78 __GLX_PUT_DOUBLE(16,u2
);
79 __GLX_PUT_LONG(24,target
);
80 __GLX_PUT_LONG(28,order
);
83 ** NOTE: the doubles that follow are not aligned because of 3
89 buf
= (GLubyte
*) Xmalloc(compsize
);
91 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
94 __glFillMap1d(k
, order
, stride
, pnts
, buf
);
95 __glXSendLargeCommand(gc
, pc
, 32, buf
, compsize
);
98 /* Data is already packed. Just send it out */
99 __glXSendLargeCommand(gc
, pc
, 32, pnts
, compsize
);
104 void __indirect_glMap1f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
105 GLint order
, const GLfloat
*pnts
)
107 __GLX_DECLARE_VARIABLES();
110 __GLX_LOAD_VARIABLES();
111 k
= __glMap1f_size(target
);
113 __glXSetError(gc
, GL_INVALID_ENUM
);
115 } else if (stride
< k
|| order
<= 0) {
116 __glXSetError(gc
, GL_INVALID_VALUE
);
119 compsize
= k
* order
* __GLX_SIZE_FLOAT32
;
120 cmdlen
= 20+compsize
;
121 if (!gc
->currentDpy
) return;
124 ** The order that arguments are packed is different from the order
127 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
128 /* Use GLXRender protocol to send small command */
129 __GLX_BEGIN_VARIABLE(X_GLrop_Map1f
,cmdlen
);
130 __GLX_PUT_LONG(4,target
);
131 __GLX_PUT_FLOAT(8,u1
);
132 __GLX_PUT_FLOAT(12,u2
);
133 __GLX_PUT_LONG(16,order
);
134 __glFillMap1f(k
, order
, stride
, pnts
, (GLubyte
*) (pc
+20));
137 /* Use GLXRenderLarge protocol to send command */
138 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f
,cmdlen
+4);
139 __GLX_PUT_LONG(8,target
);
140 __GLX_PUT_FLOAT(12,u1
);
141 __GLX_PUT_FLOAT(16,u2
);
142 __GLX_PUT_LONG(20,order
);
147 buf
= (GLubyte
*) Xmalloc(compsize
);
149 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
152 __glFillMap1f(k
, order
, stride
, pnts
, buf
);
153 __glXSendLargeCommand(gc
, pc
, 24, buf
, compsize
);
156 /* Data is already packed. Just send it out */
157 __glXSendLargeCommand(gc
, pc
, 24, pnts
, compsize
);
162 void __indirect_glMap2d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint ustr
, GLint uord
,
163 GLdouble v1
, GLdouble v2
, GLint vstr
, GLint vord
,
164 const GLdouble
*pnts
)
166 __GLX_DECLARE_VARIABLES();
169 __GLX_LOAD_VARIABLES();
170 k
= __glMap2d_size(target
);
172 __glXSetError(gc
, GL_INVALID_ENUM
);
174 } else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
175 __glXSetError(gc
, GL_INVALID_VALUE
);
178 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT64
;
179 cmdlen
= 48+compsize
;
180 if (!gc
->currentDpy
) return;
182 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
183 /* Use GLXRender protocol to send small command */
184 __GLX_BEGIN_VARIABLE(X_GLrop_Map2d
,cmdlen
);
185 __GLX_PUT_DOUBLE(4,u1
);
186 __GLX_PUT_DOUBLE(12,u2
);
187 __GLX_PUT_DOUBLE(20,v1
);
188 __GLX_PUT_DOUBLE(28,v2
);
189 __GLX_PUT_LONG(36,target
);
190 __GLX_PUT_LONG(40,uord
);
191 __GLX_PUT_LONG(44,vord
);
193 ** Pack into a u-major ordering.
194 ** NOTE: the doubles that follow are not aligned because of 5
197 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLdouble
*) (pc
+48));
200 /* Use GLXRenderLarge protocol to send command */
201 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d
,cmdlen
+4);
202 __GLX_PUT_DOUBLE(8,u1
);
203 __GLX_PUT_DOUBLE(16,u2
);
204 __GLX_PUT_DOUBLE(24,v1
);
205 __GLX_PUT_DOUBLE(32,v2
);
206 __GLX_PUT_LONG(40,target
);
207 __GLX_PUT_LONG(44,uord
);
208 __GLX_PUT_LONG(48,vord
);
211 ** NOTE: the doubles that follow are not aligned because of 5
214 if ((vstr
!= k
) || (ustr
!= k
*vord
)) {
217 buf
= (GLdouble
*) Xmalloc(compsize
);
219 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
223 ** Pack into a u-major ordering.
225 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
226 __glXSendLargeCommand(gc
, pc
, 52, buf
, compsize
);
229 /* Data is already packed. Just send it out */
230 __glXSendLargeCommand(gc
, pc
, 52, pnts
, compsize
);
235 void __indirect_glMap2f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustr
, GLint uord
,
236 GLfloat v1
, GLfloat v2
, GLint vstr
, GLint vord
,
239 __GLX_DECLARE_VARIABLES();
242 __GLX_LOAD_VARIABLES();
243 k
= __glMap2f_size(target
);
245 __glXSetError(gc
, GL_INVALID_ENUM
);
247 } else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
248 __glXSetError(gc
, GL_INVALID_VALUE
);
251 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT32
;
252 cmdlen
= 32+compsize
;
253 if (!gc
->currentDpy
) return;
256 ** The order that arguments are packed is different from the order
259 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
260 /* Use GLXRender protocol to send small command */
261 __GLX_BEGIN_VARIABLE(X_GLrop_Map2f
,cmdlen
);
262 __GLX_PUT_LONG(4,target
);
263 __GLX_PUT_FLOAT(8,u1
);
264 __GLX_PUT_FLOAT(12,u2
);
265 __GLX_PUT_LONG(16,uord
);
266 __GLX_PUT_FLOAT(20,v1
);
267 __GLX_PUT_FLOAT(24,v2
);
268 __GLX_PUT_LONG(28,vord
);
270 ** Pack into a u-major ordering.
272 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLfloat
*) (pc
+32));
275 /* Use GLXRenderLarge protocol to send command */
276 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f
,cmdlen
+4);
277 __GLX_PUT_LONG(8,target
);
278 __GLX_PUT_FLOAT(12,u1
);
279 __GLX_PUT_FLOAT(16,u2
);
280 __GLX_PUT_LONG(20,uord
);
281 __GLX_PUT_FLOAT(24,v1
);
282 __GLX_PUT_FLOAT(28,v2
);
283 __GLX_PUT_LONG(32,vord
);
285 if ((vstr
!= k
) || (ustr
!= k
*vord
)) {
288 buf
= (GLfloat
*) Xmalloc(compsize
);
290 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
294 ** Pack into a u-major ordering.
296 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
297 __glXSendLargeCommand(gc
, pc
, 36, buf
, compsize
);
300 /* Data is already packed. Just send it out */
301 __glXSendLargeCommand(gc
, pc
, 36, pnts
, compsize
);
306 void __indirect_glEnable(GLenum cap
)
308 __GLX_DECLARE_VARIABLES();
310 __GLX_LOAD_VARIABLES();
311 if (!gc
->currentDpy
) return;
315 case GL_EDGE_FLAG_ARRAY
:
317 case GL_NORMAL_ARRAY
:
318 case GL_TEXTURE_COORD_ARRAY
:
319 case GL_VERTEX_ARRAY
:
320 case GL_SECONDARY_COLOR_ARRAY
:
321 case GL_FOG_COORD_ARRAY
:
322 __indirect_glEnableClientState(cap
);
328 __GLX_BEGIN(X_GLrop_Enable
,8);
329 __GLX_PUT_LONG(4,cap
);
333 void __indirect_glDisable(GLenum cap
)
335 __GLX_DECLARE_VARIABLES();
337 __GLX_LOAD_VARIABLES();
338 if (!gc
->currentDpy
) return;
342 case GL_EDGE_FLAG_ARRAY
:
344 case GL_NORMAL_ARRAY
:
345 case GL_TEXTURE_COORD_ARRAY
:
346 case GL_VERTEX_ARRAY
:
347 case GL_SECONDARY_COLOR_ARRAY
:
348 case GL_FOG_COORD_ARRAY
:
349 __indirect_glDisableClientState(cap
);
355 __GLX_BEGIN(X_GLrop_Disable
,8);
356 __GLX_PUT_LONG(4,cap
);