1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "packspu.h"
|
---|
8 | #include "cr_packfunctions.h"
|
---|
9 | #include "cr_glstate.h"
|
---|
10 | #include "packspu_proto.h"
|
---|
11 |
|
---|
12 | void PACKSPU_APIENTRY packspu_FogCoordPointerEXT( GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
13 | {
|
---|
14 | #if CR_ARB_vertex_buffer_object
|
---|
15 | GET_CONTEXT(ctx);
|
---|
16 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
17 | if (pack_spu.swap)
|
---|
18 | crPackFogCoordPointerEXTSWAP( type, stride, pointer );
|
---|
19 | else
|
---|
20 | crPackFogCoordPointerEXT( type, stride, pointer );
|
---|
21 | }
|
---|
22 | #endif
|
---|
23 | crStateFogCoordPointerEXT( type, stride, pointer );
|
---|
24 | }
|
---|
25 |
|
---|
26 | void PACKSPU_APIENTRY packspu_ColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
27 | {
|
---|
28 | #if CR_ARB_vertex_buffer_object
|
---|
29 | GET_CONTEXT(ctx);
|
---|
30 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
31 | if (pack_spu.swap)
|
---|
32 | crPackColorPointerSWAP( size, type, stride, pointer );
|
---|
33 | else
|
---|
34 | crPackColorPointer( size, type, stride, pointer );
|
---|
35 | }
|
---|
36 | #endif
|
---|
37 | crStateColorPointer( size, type, stride, pointer );
|
---|
38 | }
|
---|
39 |
|
---|
40 | void PACKSPU_APIENTRY packspu_SecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
41 | {
|
---|
42 | #if CR_ARB_vertex_buffer_object
|
---|
43 | GET_CONTEXT(ctx);
|
---|
44 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
45 | if (pack_spu.swap)
|
---|
46 | crPackSecondaryColorPointerEXTSWAP( size, type, stride, pointer );
|
---|
47 | else
|
---|
48 | crPackSecondaryColorPointerEXT( size, type, stride, pointer );
|
---|
49 | }
|
---|
50 | #endif
|
---|
51 | crStateSecondaryColorPointerEXT( size, type, stride, pointer );
|
---|
52 | }
|
---|
53 |
|
---|
54 | void PACKSPU_APIENTRY packspu_VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
55 | {
|
---|
56 | #if CR_ARB_vertex_buffer_object
|
---|
57 | GET_CONTEXT(ctx);
|
---|
58 | CRASSERT(ctx->clientState->extensions.ARB_vertex_buffer_object);
|
---|
59 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
60 | if (pack_spu.swap)
|
---|
61 | crPackVertexPointerSWAP( size, type, stride, pointer );
|
---|
62 | else
|
---|
63 | crPackVertexPointer( size, type, stride, pointer );
|
---|
64 | }
|
---|
65 | #endif
|
---|
66 | crStateVertexPointer( size, type, stride, pointer );
|
---|
67 | }
|
---|
68 |
|
---|
69 | void PACKSPU_APIENTRY packspu_TexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
70 | {
|
---|
71 | #if CR_ARB_vertex_buffer_object
|
---|
72 | GET_CONTEXT(ctx);
|
---|
73 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
74 | if (pack_spu.swap)
|
---|
75 | crPackTexCoordPointerSWAP( size, type, stride, pointer );
|
---|
76 | else
|
---|
77 | crPackTexCoordPointer( size, type, stride, pointer );
|
---|
78 | }
|
---|
79 | #endif
|
---|
80 | crStateTexCoordPointer( size, type, stride, pointer );
|
---|
81 | }
|
---|
82 |
|
---|
83 | void PACKSPU_APIENTRY packspu_NormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
84 | {
|
---|
85 | #if CR_ARB_vertex_buffer_object
|
---|
86 | GET_CONTEXT(ctx);
|
---|
87 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
88 | if (pack_spu.swap)
|
---|
89 | crPackNormalPointerSWAP( type, stride, pointer );
|
---|
90 | else
|
---|
91 | crPackNormalPointer( type, stride, pointer );
|
---|
92 | }
|
---|
93 | #endif
|
---|
94 | crStateNormalPointer( type, stride, pointer );
|
---|
95 | }
|
---|
96 |
|
---|
97 | void PACKSPU_APIENTRY packspu_EdgeFlagPointer( GLsizei stride, const GLvoid *pointer )
|
---|
98 | {
|
---|
99 | #if CR_ARB_vertex_buffer_object
|
---|
100 | GET_CONTEXT(ctx);
|
---|
101 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
102 | if (pack_spu.swap)
|
---|
103 | crPackEdgeFlagPointerSWAP( stride, pointer );
|
---|
104 | else
|
---|
105 | crPackEdgeFlagPointer( stride, pointer );
|
---|
106 | }
|
---|
107 | #endif
|
---|
108 | crStateEdgeFlagPointer( stride, pointer );
|
---|
109 | }
|
---|
110 |
|
---|
111 | void PACKSPU_APIENTRY packspu_VertexAttribPointerARB( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer )
|
---|
112 | {
|
---|
113 | #if CR_ARB_vertex_buffer_object
|
---|
114 | GET_CONTEXT(ctx);
|
---|
115 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
116 | if (pack_spu.swap)
|
---|
117 | crPackVertexAttribPointerARBSWAP( index, size, type, normalized, stride, pointer );
|
---|
118 | else
|
---|
119 | crPackVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
|
---|
120 | }
|
---|
121 | #endif
|
---|
122 | crStateVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
|
---|
123 | }
|
---|
124 |
|
---|
125 | void PACKSPU_APIENTRY packspu_VertexAttribPointerNV( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
126 | {
|
---|
127 | #if CR_ARB_vertex_buffer_object
|
---|
128 | GET_CONTEXT(ctx);
|
---|
129 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
130 | if (pack_spu.swap)
|
---|
131 | crPackVertexAttribPointerNVSWAP( index, size, type, stride, pointer );
|
---|
132 | else
|
---|
133 | crPackVertexAttribPointerNV( index, size, type, stride, pointer );
|
---|
134 | }
|
---|
135 | #endif
|
---|
136 | crStateVertexAttribPointerNV( index, size, type, stride, pointer );
|
---|
137 | }
|
---|
138 |
|
---|
139 | void PACKSPU_APIENTRY packspu_GetPointerv( GLenum pname, GLvoid **params )
|
---|
140 | {
|
---|
141 | crStateGetPointerv( pname, params );
|
---|
142 | }
|
---|
143 |
|
---|
144 | void PACKSPU_APIENTRY packspu_InterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer )
|
---|
145 | {
|
---|
146 | #if CR_ARB_vertex_buffer_object
|
---|
147 | GET_CONTEXT(ctx);
|
---|
148 | if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
|
---|
149 | if (pack_spu.swap)
|
---|
150 | crPackInterleavedArraysSWAP( format, stride, pointer );
|
---|
151 | else
|
---|
152 | crPackInterleavedArrays( format, stride, pointer );
|
---|
153 | }
|
---|
154 | #endif
|
---|
155 | crStateInterleavedArrays( format, stride, pointer );
|
---|
156 | }
|
---|
157 |
|
---|
158 |
|
---|
159 | void PACKSPU_APIENTRY
|
---|
160 | packspu_ArrayElement( GLint index )
|
---|
161 | {
|
---|
162 | GLboolean serverArrays = GL_FALSE;
|
---|
163 |
|
---|
164 | #if CR_ARB_vertex_buffer_object
|
---|
165 | GET_CONTEXT(ctx);
|
---|
166 | if (ctx->clientState->extensions.ARB_vertex_buffer_object)
|
---|
167 | serverArrays = crStateUseServerArrays();
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | if (serverArrays) {
|
---|
171 | /* Send the DrawArrays command over the wire */
|
---|
172 | if (pack_spu.swap)
|
---|
173 | crPackArrayElementSWAP( index );
|
---|
174 | else
|
---|
175 | crPackArrayElement( index );
|
---|
176 | }
|
---|
177 | else {
|
---|
178 | /* evaluate locally */
|
---|
179 | GET_CONTEXT(ctx);
|
---|
180 | CRClientState *clientState = &(ctx->clientState->client);
|
---|
181 | if (pack_spu.swap)
|
---|
182 | crPackExpandArrayElementSWAP( index, clientState );
|
---|
183 | else
|
---|
184 | crPackExpandArrayElement( index, clientState );
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 |
|
---|
189 | void PACKSPU_APIENTRY
|
---|
190 | packspu_DrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
|
---|
191 | {
|
---|
192 | GLboolean serverArrays = GL_FALSE;
|
---|
193 |
|
---|
194 | #if CR_ARB_vertex_buffer_object
|
---|
195 | GET_CONTEXT(ctx);
|
---|
196 | if (ctx->clientState->extensions.ARB_vertex_buffer_object)
|
---|
197 | serverArrays = crStateUseServerArrays();
|
---|
198 | #endif
|
---|
199 |
|
---|
200 | if (serverArrays) {
|
---|
201 | /* Send the DrawArrays command over the wire */
|
---|
202 | if (pack_spu.swap)
|
---|
203 | crPackDrawElementsSWAP( mode, count, type, indices );
|
---|
204 | else
|
---|
205 | crPackDrawElements( mode, count, type, indices );
|
---|
206 | }
|
---|
207 | else {
|
---|
208 | /* evaluate locally */
|
---|
209 | GET_CONTEXT(ctx);
|
---|
210 | CRClientState *clientState = &(ctx->clientState->client);
|
---|
211 | if (pack_spu.swap)
|
---|
212 | crPackExpandDrawElementsSWAP( mode, count, type, indices, clientState );
|
---|
213 | else
|
---|
214 | crPackExpandDrawElements( mode, count, type, indices, clientState );
|
---|
215 | }
|
---|
216 | }
|
---|
217 |
|
---|
218 |
|
---|
219 | void PACKSPU_APIENTRY
|
---|
220 | packspu_DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices )
|
---|
221 | {
|
---|
222 | GLboolean serverArrays = GL_FALSE;
|
---|
223 |
|
---|
224 | #if CR_ARB_vertex_buffer_object
|
---|
225 | GET_CONTEXT(ctx);
|
---|
226 | if (ctx->clientState->extensions.ARB_vertex_buffer_object)
|
---|
227 | serverArrays = crStateUseServerArrays();
|
---|
228 | #endif
|
---|
229 |
|
---|
230 | if (serverArrays) {
|
---|
231 | /* Send the DrawRangeElements command over the wire */
|
---|
232 | if (pack_spu.swap)
|
---|
233 | crPackDrawRangeElementsSWAP( mode, start, end, count, type, indices );
|
---|
234 | else
|
---|
235 | crPackDrawRangeElements( mode, start, end, count, type, indices );
|
---|
236 | }
|
---|
237 | else {
|
---|
238 | /* evaluate locally */
|
---|
239 | GET_CONTEXT(ctx);
|
---|
240 | CRClientState *clientState = &(ctx->clientState->client);
|
---|
241 | if (pack_spu.swap)
|
---|
242 | crPackExpandDrawRangeElementsSWAP( mode, start, end, count, type, indices, clientState );
|
---|
243 | else
|
---|
244 | crPackExpandDrawRangeElements( mode, start, end, count, type, indices, clientState );
|
---|
245 | }
|
---|
246 | }
|
---|
247 |
|
---|
248 |
|
---|
249 | void PACKSPU_APIENTRY
|
---|
250 | packspu_DrawArrays( GLenum mode, GLint first, GLsizei count )
|
---|
251 | {
|
---|
252 | GLboolean serverArrays = GL_FALSE;
|
---|
253 |
|
---|
254 | #if CR_ARB_vertex_buffer_object
|
---|
255 | GET_CONTEXT(ctx);
|
---|
256 | if (ctx->clientState->extensions.ARB_vertex_buffer_object)
|
---|
257 | serverArrays = crStateUseServerArrays();
|
---|
258 | #endif
|
---|
259 |
|
---|
260 | if (serverArrays) {
|
---|
261 | /* Send the DrawArrays command over the wire */
|
---|
262 | if (pack_spu.swap)
|
---|
263 | crPackDrawArraysSWAP( mode, first, count );
|
---|
264 | else
|
---|
265 | crPackDrawArrays( mode, first, count );
|
---|
266 | }
|
---|
267 | else {
|
---|
268 | /* evaluate locally */
|
---|
269 | GET_CONTEXT(ctx);
|
---|
270 | CRClientState *clientState = &(ctx->clientState->client);
|
---|
271 | if (pack_spu.swap)
|
---|
272 | crPackExpandDrawArraysSWAP( mode, first, count, clientState );
|
---|
273 | else
|
---|
274 | crPackExpandDrawArrays( mode, first, count, clientState );
|
---|
275 | }
|
---|
276 | }
|
---|
277 |
|
---|
278 |
|
---|
279 | #ifdef CR_EXT_multi_draw_arrays
|
---|
280 | void PACKSPU_APIENTRY packspu_MultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count, GLsizei primcount )
|
---|
281 | {
|
---|
282 | GLint i;
|
---|
283 | for (i = 0; i < primcount; i++) {
|
---|
284 | if (count[i] > 0) {
|
---|
285 | packspu_DrawArrays(mode, first[i], count[i]);
|
---|
286 | }
|
---|
287 | }
|
---|
288 | }
|
---|
289 |
|
---|
290 | void PACKSPU_APIENTRY packspu_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount )
|
---|
291 | {
|
---|
292 | GLint i;
|
---|
293 | for (i = 0; i < primcount; i++) {
|
---|
294 | if (count[i] > 0) {
|
---|
295 | packspu_DrawElements(mode, count[i], type, indices[i]);
|
---|
296 | }
|
---|
297 | }
|
---|
298 | }
|
---|
299 | #endif
|
---|
300 |
|
---|
301 |
|
---|
302 | void PACKSPU_APIENTRY packspu_EnableClientState( GLenum array )
|
---|
303 | {
|
---|
304 | crStateEnableClientState( array );
|
---|
305 | }
|
---|
306 |
|
---|
307 | void PACKSPU_APIENTRY packspu_DisableClientState( GLenum array )
|
---|
308 | {
|
---|
309 | crStateDisableClientState( array );
|
---|
310 | }
|
---|
311 |
|
---|
312 | void PACKSPU_APIENTRY packspu_ClientActiveTextureARB( GLenum texUnit )
|
---|
313 | {
|
---|
314 | crStateClientActiveTextureARB( texUnit );
|
---|
315 | /* XXX also send to server for texcoord arrays? */
|
---|
316 | }
|
---|
317 |
|
---|
318 |
|
---|
319 | void PACKSPU_APIENTRY packspu_Enable( GLenum cap )
|
---|
320 | {
|
---|
321 | switch (cap) {
|
---|
322 | case GL_VERTEX_ARRAY:
|
---|
323 | case GL_NORMAL_ARRAY:
|
---|
324 | case GL_COLOR_ARRAY:
|
---|
325 | case GL_INDEX_ARRAY:
|
---|
326 | case GL_TEXTURE_COORD_ARRAY:
|
---|
327 | case GL_EDGE_FLAG_ARRAY:
|
---|
328 | case GL_FOG_COORDINATE_ARRAY_EXT:
|
---|
329 | case GL_SECONDARY_COLOR_ARRAY_EXT:
|
---|
330 | #if CR_NV_vertex_program
|
---|
331 | case GL_VERTEX_ATTRIB_ARRAY0_NV:
|
---|
332 | case GL_VERTEX_ATTRIB_ARRAY1_NV:
|
---|
333 | case GL_VERTEX_ATTRIB_ARRAY2_NV:
|
---|
334 | case GL_VERTEX_ATTRIB_ARRAY3_NV:
|
---|
335 | case GL_VERTEX_ATTRIB_ARRAY4_NV:
|
---|
336 | case GL_VERTEX_ATTRIB_ARRAY5_NV:
|
---|
337 | case GL_VERTEX_ATTRIB_ARRAY6_NV:
|
---|
338 | case GL_VERTEX_ATTRIB_ARRAY7_NV:
|
---|
339 | case GL_VERTEX_ATTRIB_ARRAY8_NV:
|
---|
340 | case GL_VERTEX_ATTRIB_ARRAY9_NV:
|
---|
341 | case GL_VERTEX_ATTRIB_ARRAY10_NV:
|
---|
342 | case GL_VERTEX_ATTRIB_ARRAY11_NV:
|
---|
343 | case GL_VERTEX_ATTRIB_ARRAY12_NV:
|
---|
344 | case GL_VERTEX_ATTRIB_ARRAY13_NV:
|
---|
345 | case GL_VERTEX_ATTRIB_ARRAY14_NV:
|
---|
346 | case GL_VERTEX_ATTRIB_ARRAY15_NV:
|
---|
347 | #endif /* CR_NV_vertex_program */
|
---|
348 | crStateEnableClientState(cap);
|
---|
349 | break;
|
---|
350 | default:
|
---|
351 | ;
|
---|
352 | }
|
---|
353 |
|
---|
354 | if (pack_spu.swap)
|
---|
355 | crPackEnableSWAP(cap);
|
---|
356 | else
|
---|
357 | crPackEnable(cap);
|
---|
358 | }
|
---|
359 |
|
---|
360 |
|
---|
361 | void PACKSPU_APIENTRY packspu_Disable( GLenum cap )
|
---|
362 | {
|
---|
363 | switch (cap) {
|
---|
364 | case GL_VERTEX_ARRAY:
|
---|
365 | case GL_NORMAL_ARRAY:
|
---|
366 | case GL_COLOR_ARRAY:
|
---|
367 | case GL_INDEX_ARRAY:
|
---|
368 | case GL_TEXTURE_COORD_ARRAY:
|
---|
369 | case GL_EDGE_FLAG_ARRAY:
|
---|
370 | case GL_FOG_COORDINATE_ARRAY_EXT:
|
---|
371 | case GL_SECONDARY_COLOR_ARRAY_EXT:
|
---|
372 | #if CR_NV_vertex_program
|
---|
373 | case GL_VERTEX_ATTRIB_ARRAY0_NV:
|
---|
374 | case GL_VERTEX_ATTRIB_ARRAY1_NV:
|
---|
375 | case GL_VERTEX_ATTRIB_ARRAY2_NV:
|
---|
376 | case GL_VERTEX_ATTRIB_ARRAY3_NV:
|
---|
377 | case GL_VERTEX_ATTRIB_ARRAY4_NV:
|
---|
378 | case GL_VERTEX_ATTRIB_ARRAY5_NV:
|
---|
379 | case GL_VERTEX_ATTRIB_ARRAY6_NV:
|
---|
380 | case GL_VERTEX_ATTRIB_ARRAY7_NV:
|
---|
381 | case GL_VERTEX_ATTRIB_ARRAY8_NV:
|
---|
382 | case GL_VERTEX_ATTRIB_ARRAY9_NV:
|
---|
383 | case GL_VERTEX_ATTRIB_ARRAY10_NV:
|
---|
384 | case GL_VERTEX_ATTRIB_ARRAY11_NV:
|
---|
385 | case GL_VERTEX_ATTRIB_ARRAY12_NV:
|
---|
386 | case GL_VERTEX_ATTRIB_ARRAY13_NV:
|
---|
387 | case GL_VERTEX_ATTRIB_ARRAY14_NV:
|
---|
388 | case GL_VERTEX_ATTRIB_ARRAY15_NV:
|
---|
389 | #endif /* CR_NV_vertex_program */
|
---|
390 | crStateDisableClientState(cap);
|
---|
391 | break;
|
---|
392 | default:
|
---|
393 | ;
|
---|
394 | }
|
---|
395 |
|
---|
396 | if (pack_spu.swap)
|
---|
397 | crPackDisableSWAP(cap);
|
---|
398 | else
|
---|
399 | crPackDisable(cap);
|
---|
400 | }
|
---|
401 |
|
---|
402 |
|
---|
403 | void PACKSPU_APIENTRY packspu_PushClientAttrib( GLbitfield mask )
|
---|
404 | {
|
---|
405 | crStatePushClientAttrib(mask);
|
---|
406 | }
|
---|
407 |
|
---|
408 | void PACKSPU_APIENTRY packspu_PopClientAttrib( void )
|
---|
409 | {
|
---|
410 | crStatePopClientAttrib();
|
---|
411 | }
|
---|