2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
31 #ifndef GLX_USE_APPLEGL
33 #include "packrender.h"
35 #include "indirect_size.h"
38 ** This file contains routines that might need to be transported as
39 ** GLXRender or GLXRenderLarge commands, and these commands don't
40 ** use the pixel header. See renderpix.c for those routines.
44 __indirect_glMap1d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint stride
,
45 GLint order
, const GLdouble
* pnts
)
47 __GLX_DECLARE_VARIABLES();
50 __GLX_LOAD_VARIABLES();
51 k
= __glMap1d_size(target
);
53 __glXSetError(gc
, GL_INVALID_ENUM
);
56 else if (stride
< k
|| order
<= 0) {
57 __glXSetError(gc
, GL_INVALID_VALUE
);
60 compsize
= k
* order
* __GLX_SIZE_FLOAT64
;
61 cmdlen
= 28 + compsize
;
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));
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
= malloc(compsize
);
96 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
99 __glFillMap1d(k
, order
, stride
, pnts
, buf
);
100 __glXSendLargeCommand(gc
, pc
, 32, buf
, compsize
);
104 /* Data is already packed. Just send it out */
105 __glXSendLargeCommand(gc
, pc
, 32, pnts
, compsize
);
111 __indirect_glMap1f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
112 GLint order
, const GLfloat
* pnts
)
114 __GLX_DECLARE_VARIABLES();
117 __GLX_LOAD_VARIABLES();
118 k
= __glMap1f_size(target
);
120 __glXSetError(gc
, GL_INVALID_ENUM
);
123 else if (stride
< k
|| order
<= 0) {
124 __glXSetError(gc
, GL_INVALID_VALUE
);
127 compsize
= k
* order
* __GLX_SIZE_FLOAT32
;
128 cmdlen
= 20 + compsize
;
133 ** The order that arguments are packed is different from the order
136 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
137 /* Use GLXRender protocol to send small command */
138 __GLX_BEGIN_VARIABLE(X_GLrop_Map1f
, cmdlen
);
139 __GLX_PUT_LONG(4, target
);
140 __GLX_PUT_FLOAT(8, u1
);
141 __GLX_PUT_FLOAT(12, u2
);
142 __GLX_PUT_LONG(16, order
);
143 __glFillMap1f(k
, order
, stride
, pnts
, (GLubyte
*) (pc
+ 20));
147 /* Use GLXRenderLarge protocol to send command */
148 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f
, cmdlen
+ 4);
149 __GLX_PUT_LONG(8, target
);
150 __GLX_PUT_FLOAT(12, u1
);
151 __GLX_PUT_FLOAT(16, u2
);
152 __GLX_PUT_LONG(20, order
);
157 buf
= malloc(compsize
);
159 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
162 __glFillMap1f(k
, order
, stride
, pnts
, buf
);
163 __glXSendLargeCommand(gc
, pc
, 24, buf
, compsize
);
167 /* Data is already packed. Just send it out */
168 __glXSendLargeCommand(gc
, pc
, 24, pnts
, compsize
);
174 __indirect_glMap2d(GLenum target
, GLdouble u1
, GLdouble u2
, GLint ustr
,
175 GLint uord
, GLdouble v1
, GLdouble v2
, GLint vstr
,
176 GLint vord
, const GLdouble
* pnts
)
178 __GLX_DECLARE_VARIABLES();
181 __GLX_LOAD_VARIABLES();
182 k
= __glMap2d_size(target
);
184 __glXSetError(gc
, GL_INVALID_ENUM
);
187 else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
188 __glXSetError(gc
, GL_INVALID_VALUE
);
191 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT64
;
192 cmdlen
= 48 + compsize
;
196 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
197 /* Use GLXRender protocol to send small command */
198 __GLX_BEGIN_VARIABLE(X_GLrop_Map2d
, cmdlen
);
199 __GLX_PUT_DOUBLE(4, u1
);
200 __GLX_PUT_DOUBLE(12, u2
);
201 __GLX_PUT_DOUBLE(20, v1
);
202 __GLX_PUT_DOUBLE(28, v2
);
203 __GLX_PUT_LONG(36, target
);
204 __GLX_PUT_LONG(40, uord
);
205 __GLX_PUT_LONG(44, vord
);
207 ** Pack into a u-major ordering.
208 ** NOTE: the doubles that follow are not aligned because of 5
211 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLdouble
*) (pc
+ 48));
215 /* Use GLXRenderLarge protocol to send command */
216 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d
, cmdlen
+ 4);
217 __GLX_PUT_DOUBLE(8, u1
);
218 __GLX_PUT_DOUBLE(16, u2
);
219 __GLX_PUT_DOUBLE(24, v1
);
220 __GLX_PUT_DOUBLE(32, v2
);
221 __GLX_PUT_LONG(40, target
);
222 __GLX_PUT_LONG(44, uord
);
223 __GLX_PUT_LONG(48, vord
);
226 ** NOTE: the doubles that follow are not aligned because of 5
229 if ((vstr
!= k
) || (ustr
!= k
* vord
)) {
232 buf
= malloc(compsize
);
234 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
238 ** Pack into a u-major ordering.
240 __glFillMap2d(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
241 __glXSendLargeCommand(gc
, pc
, 52, buf
, compsize
);
245 /* Data is already packed. Just send it out */
246 __glXSendLargeCommand(gc
, pc
, 52, pnts
, compsize
);
252 __indirect_glMap2f(GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustr
,
253 GLint uord
, GLfloat v1
, GLfloat v2
, GLint vstr
, GLint vord
,
254 const GLfloat
* pnts
)
256 __GLX_DECLARE_VARIABLES();
259 __GLX_LOAD_VARIABLES();
260 k
= __glMap2f_size(target
);
262 __glXSetError(gc
, GL_INVALID_ENUM
);
265 else if (vstr
< k
|| ustr
< k
|| vord
<= 0 || uord
<= 0) {
266 __glXSetError(gc
, GL_INVALID_VALUE
);
269 compsize
= k
* uord
* vord
* __GLX_SIZE_FLOAT32
;
270 cmdlen
= 32 + compsize
;
275 ** The order that arguments are packed is different from the order
278 if (cmdlen
<= gc
->maxSmallRenderCommandSize
) {
279 /* Use GLXRender protocol to send small command */
280 __GLX_BEGIN_VARIABLE(X_GLrop_Map2f
, cmdlen
);
281 __GLX_PUT_LONG(4, target
);
282 __GLX_PUT_FLOAT(8, u1
);
283 __GLX_PUT_FLOAT(12, u2
);
284 __GLX_PUT_LONG(16, uord
);
285 __GLX_PUT_FLOAT(20, v1
);
286 __GLX_PUT_FLOAT(24, v2
);
287 __GLX_PUT_LONG(28, vord
);
289 ** Pack into a u-major ordering.
291 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, (GLfloat
*) (pc
+ 32));
295 /* Use GLXRenderLarge protocol to send command */
296 __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f
, cmdlen
+ 4);
297 __GLX_PUT_LONG(8, target
);
298 __GLX_PUT_FLOAT(12, u1
);
299 __GLX_PUT_FLOAT(16, u2
);
300 __GLX_PUT_LONG(20, uord
);
301 __GLX_PUT_FLOAT(24, v1
);
302 __GLX_PUT_FLOAT(28, v2
);
303 __GLX_PUT_LONG(32, vord
);
305 if ((vstr
!= k
) || (ustr
!= k
* vord
)) {
308 buf
= malloc(compsize
);
310 __glXSetError(gc
, GL_OUT_OF_MEMORY
);
314 ** Pack into a u-major ordering.
316 __glFillMap2f(k
, uord
, vord
, ustr
, vstr
, pnts
, buf
);
317 __glXSendLargeCommand(gc
, pc
, 36, buf
, compsize
);
321 /* Data is already packed. Just send it out */
322 __glXSendLargeCommand(gc
, pc
, 36, pnts
, compsize
);
328 __indirect_glEnable(GLenum cap
)
330 __GLX_DECLARE_VARIABLES();
332 __GLX_LOAD_VARIABLES();
338 case GL_EDGE_FLAG_ARRAY
:
340 case GL_NORMAL_ARRAY
:
341 case GL_TEXTURE_COORD_ARRAY
:
342 case GL_VERTEX_ARRAY
:
343 case GL_SECONDARY_COLOR_ARRAY
:
344 case GL_FOG_COORD_ARRAY
:
345 __indirect_glEnableClientState(cap
);
351 __GLX_BEGIN(X_GLrop_Enable
, 8);
352 __GLX_PUT_LONG(4, cap
);
357 __indirect_glDisable(GLenum cap
)
359 __GLX_DECLARE_VARIABLES();
361 __GLX_LOAD_VARIABLES();
367 case GL_EDGE_FLAG_ARRAY
:
369 case GL_NORMAL_ARRAY
:
370 case GL_TEXTURE_COORD_ARRAY
:
371 case GL_VERTEX_ARRAY
:
372 case GL_SECONDARY_COLOR_ARRAY
:
373 case GL_FOG_COORD_ARRAY
:
374 __indirect_glDisableClientState(cap
);
380 __GLX_BEGIN(X_GLrop_Disable
, 8);
381 __GLX_PUT_LONG(4, cap
);