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 "packer.h"
|
---|
8 | #include "cr_pixeldata.h"
|
---|
9 | #include "cr_error.h"
|
---|
10 | #include "cr_string.h"
|
---|
11 | #include "cr_version.h"
|
---|
12 |
|
---|
13 | void PACK_APIENTRY crPackTexImage1DSWAP(GLenum target, GLint level,
|
---|
14 | GLint internalformat, GLsizei width, GLint border, GLenum format,
|
---|
15 | GLenum type, const GLvoid *pixels, const CRPixelPackState *unpackstate )
|
---|
16 | {
|
---|
17 | unsigned char *data_ptr;
|
---|
18 | int packet_length;
|
---|
19 | int isnull = (pixels == NULL);
|
---|
20 |
|
---|
21 | packet_length =
|
---|
22 | sizeof( target ) +
|
---|
23 | sizeof( level ) +
|
---|
24 | sizeof( internalformat ) +
|
---|
25 | sizeof( width ) +
|
---|
26 | sizeof( border ) +
|
---|
27 | sizeof( format ) +
|
---|
28 | sizeof( type ) +
|
---|
29 | sizeof( int );
|
---|
30 |
|
---|
31 | if (pixels)
|
---|
32 | {
|
---|
33 | packet_length += crImageSize( format, type, width, 1 );
|
---|
34 | }
|
---|
35 |
|
---|
36 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
37 | WRITE_DATA( 0, GLenum, SWAP32(target) );
|
---|
38 | WRITE_DATA( 4, GLint, SWAP32(level) );
|
---|
39 | WRITE_DATA( 8, GLint, SWAP32(internalformat) );
|
---|
40 | WRITE_DATA( 12, GLsizei, SWAP32(width) );
|
---|
41 | WRITE_DATA( 16, GLint, SWAP32(border) );
|
---|
42 | WRITE_DATA( 20, GLenum, SWAP32(format) );
|
---|
43 | WRITE_DATA( 24, GLenum, SWAP32(type) );
|
---|
44 | WRITE_DATA( 28, int, SWAP32(isnull) );
|
---|
45 |
|
---|
46 | if (pixels) {
|
---|
47 | CRPixelPackState tmpUnpackState = *unpackstate;
|
---|
48 | /* flip application-requested swapBytes state */
|
---|
49 | tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
|
---|
50 |
|
---|
51 | crPixelCopy1D( (void *)(data_ptr + 32), format, type,
|
---|
52 | pixels, format, type, width, &tmpUnpackState );
|
---|
53 | }
|
---|
54 |
|
---|
55 | crHugePacket( CR_TEXIMAGE1D_OPCODE, data_ptr );
|
---|
56 | crPackFree( data_ptr );
|
---|
57 | }
|
---|
58 |
|
---|
59 | void PACK_APIENTRY crPackTexImage2DSWAP(GLenum target, GLint level,
|
---|
60 | GLint internalformat, GLsizei width, GLsizei height, GLint border,
|
---|
61 | GLenum format, GLenum type, const GLvoid *pixels,
|
---|
62 | const CRPixelPackState *unpackstate )
|
---|
63 | {
|
---|
64 | unsigned char *data_ptr;
|
---|
65 | int packet_length;
|
---|
66 | int isnull = (pixels == NULL);
|
---|
67 |
|
---|
68 | packet_length =
|
---|
69 | sizeof( target ) +
|
---|
70 | sizeof( level ) +
|
---|
71 | sizeof( internalformat ) +
|
---|
72 | sizeof( width ) +
|
---|
73 | sizeof( height ) +
|
---|
74 | sizeof( border ) +
|
---|
75 | sizeof( format ) +
|
---|
76 | sizeof( type ) +
|
---|
77 | sizeof( int );
|
---|
78 |
|
---|
79 | if (pixels)
|
---|
80 | {
|
---|
81 | packet_length += crImageSize( format, type, width, height );
|
---|
82 | }
|
---|
83 |
|
---|
84 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
85 | WRITE_DATA( 0, GLenum, SWAP32(target) );
|
---|
86 | WRITE_DATA( 4, GLint, SWAP32(level) );
|
---|
87 | WRITE_DATA( 8, GLint, SWAP32(internalformat) );
|
---|
88 | WRITE_DATA( 12, GLsizei, SWAP32(width) );
|
---|
89 | WRITE_DATA( 16, GLsizei, SWAP32(height) );
|
---|
90 | WRITE_DATA( 20, GLint, SWAP32(border) );
|
---|
91 | WRITE_DATA( 24, GLenum, SWAP32(format) );
|
---|
92 | WRITE_DATA( 28, GLenum, SWAP32(type) );
|
---|
93 | WRITE_DATA( 32, int, SWAP32(isnull) );
|
---|
94 |
|
---|
95 | if (pixels)
|
---|
96 | {
|
---|
97 | CRPixelPackState tmpUnpackState = *unpackstate;
|
---|
98 | /* flip application-requested swapBytes state */
|
---|
99 | tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
|
---|
100 |
|
---|
101 | crPixelCopy2D( width, height,
|
---|
102 | (void *)(data_ptr + 36), format, type, NULL, /* dst */
|
---|
103 | pixels, format, type, &tmpUnpackState ); /* src */
|
---|
104 | }
|
---|
105 |
|
---|
106 | crHugePacket( CR_TEXIMAGE2D_OPCODE, data_ptr );
|
---|
107 | crPackFree( data_ptr );
|
---|
108 | }
|
---|
109 |
|
---|
110 | #if defined( GL_EXT_texture3D )
|
---|
111 | void PACK_APIENTRY crPackTexImage3DEXTSWAP(GLenum target, GLint level,
|
---|
112 | GLenum internalformat,
|
---|
113 | GLsizei width, GLsizei height, GLsizei depth, GLint border,
|
---|
114 | GLenum format, GLenum type, const GLvoid *pixels,
|
---|
115 | const CRPixelPackState *unpackstate )
|
---|
116 | {
|
---|
117 | unsigned char *data_ptr;
|
---|
118 | int packet_length;
|
---|
119 | int isnull = (pixels == NULL);
|
---|
120 | int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ;
|
---|
121 | int distrib_buf_len = 0;
|
---|
122 | int tex_size = 0;
|
---|
123 |
|
---|
124 | packet_length =
|
---|
125 | sizeof( target ) +
|
---|
126 | sizeof( level ) +
|
---|
127 | sizeof( internalformat ) +
|
---|
128 | sizeof( width ) +
|
---|
129 | sizeof( height ) +
|
---|
130 | sizeof( depth ) +
|
---|
131 | sizeof( border ) +
|
---|
132 | sizeof( format ) +
|
---|
133 | sizeof( type ) +
|
---|
134 | sizeof( int );
|
---|
135 |
|
---|
136 | if (pixels)
|
---|
137 | {
|
---|
138 | if ( is_distrib )
|
---|
139 | {
|
---|
140 | distrib_buf_len = crStrlen( pixels ) + 1 +
|
---|
141 | ( (type == GL_TRUE) ? width*height*3 : 0 ) ;
|
---|
142 | packet_length += distrib_buf_len ;
|
---|
143 | }
|
---|
144 | else
|
---|
145 | {
|
---|
146 | tex_size = crTextureSize( format, type, width, height, depth );
|
---|
147 | packet_length += tex_size;
|
---|
148 | }
|
---|
149 | }
|
---|
150 |
|
---|
151 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
152 | WRITE_DATA( 0, GLenum, SWAP32( target ) );
|
---|
153 | WRITE_DATA( 4, GLint, SWAP32( level ) );
|
---|
154 | WRITE_DATA( 8, GLint, SWAP32( internalformat ) );
|
---|
155 | WRITE_DATA( 12, GLsizei, SWAP32( width ) );
|
---|
156 | WRITE_DATA( 16, GLsizei, SWAP32( height ) );
|
---|
157 | WRITE_DATA( 20, GLsizei, SWAP32( depth ) );
|
---|
158 | WRITE_DATA( 24, GLint, SWAP32( border ) );
|
---|
159 | WRITE_DATA( 28, GLenum, SWAP32( format ) );
|
---|
160 | WRITE_DATA( 32, GLenum, SWAP32( type ) );
|
---|
161 | WRITE_DATA( 36, int, SWAP32( isnull ) );
|
---|
162 |
|
---|
163 | if (pixels)
|
---|
164 | {
|
---|
165 | if ( is_distrib )
|
---|
166 | {
|
---|
167 | crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ;
|
---|
168 | }
|
---|
169 | else
|
---|
170 | {
|
---|
171 | CRPixelPackState tmpUnpackState = *unpackstate;
|
---|
172 | /* flip application-requested swapBytes state */
|
---|
173 | tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
|
---|
174 |
|
---|
175 | crPixelCopy3D( width, height, depth,
|
---|
176 | (void *)(data_ptr + 40), format, type, NULL,
|
---|
177 | pixels, format, type, &tmpUnpackState );
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | crHugePacket( CR_TEXIMAGE3DEXT_OPCODE, data_ptr );
|
---|
182 | crPackFree( data_ptr );
|
---|
183 | }
|
---|
184 | #endif /* GL_EXT_texture3D */
|
---|
185 |
|
---|
186 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
187 | void PACK_APIENTRY crPackTexImage3DSWAP(GLenum target, GLint level,
|
---|
188 | GLint internalformat,
|
---|
189 | GLsizei width, GLsizei height,
|
---|
190 | GLsizei depth, GLint border,
|
---|
191 | GLenum format, GLenum type,
|
---|
192 | const GLvoid *pixels,
|
---|
193 | const CRPixelPackState *unpackstate )
|
---|
194 | {
|
---|
195 | unsigned char *data_ptr;
|
---|
196 | int packet_length;
|
---|
197 | int isnull = (pixels == NULL);
|
---|
198 | int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ;
|
---|
199 | int distrib_buf_len = 0;
|
---|
200 | int tex_size = 0;
|
---|
201 |
|
---|
202 | packet_length =
|
---|
203 | sizeof( target ) +
|
---|
204 | sizeof( level ) +
|
---|
205 | sizeof( internalformat ) +
|
---|
206 | sizeof( width ) +
|
---|
207 | sizeof( height ) +
|
---|
208 | sizeof( depth ) +
|
---|
209 | sizeof( border ) +
|
---|
210 | sizeof( format ) +
|
---|
211 | sizeof( type ) +
|
---|
212 | sizeof( int );
|
---|
213 |
|
---|
214 | if (pixels)
|
---|
215 | {
|
---|
216 | if ( is_distrib )
|
---|
217 | {
|
---|
218 | distrib_buf_len = crStrlen( pixels ) + 1 +
|
---|
219 | ( (type == GL_TRUE) ? width*height*3 : 0 ) ;
|
---|
220 | packet_length += distrib_buf_len ;
|
---|
221 | }
|
---|
222 | else
|
---|
223 | {
|
---|
224 | tex_size = crTextureSize( format, type, width, height, depth );
|
---|
225 | packet_length += tex_size;
|
---|
226 | }
|
---|
227 | }
|
---|
228 |
|
---|
229 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
230 | WRITE_DATA( 0, GLenum, SWAP32( target ) );
|
---|
231 | WRITE_DATA( 4, GLint, SWAP32( level ) );
|
---|
232 | WRITE_DATA( 8, GLint, SWAP32( internalformat ) );
|
---|
233 | WRITE_DATA( 12, GLsizei, SWAP32( width ) );
|
---|
234 | WRITE_DATA( 16, GLsizei, SWAP32( height ) );
|
---|
235 | WRITE_DATA( 20, GLsizei, SWAP32( depth ) );
|
---|
236 | WRITE_DATA( 24, GLint, SWAP32( border ) );
|
---|
237 | WRITE_DATA( 28, GLenum, SWAP32( format ) );
|
---|
238 | WRITE_DATA( 32, GLenum, SWAP32( type ) );
|
---|
239 | WRITE_DATA( 36, int, SWAP32( isnull ) );
|
---|
240 |
|
---|
241 | if (pixels)
|
---|
242 | {
|
---|
243 | if ( is_distrib )
|
---|
244 | {
|
---|
245 | crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ;
|
---|
246 | }
|
---|
247 | else
|
---|
248 | {
|
---|
249 | CRPixelPackState tmpUnpackState = *unpackstate;
|
---|
250 | /* flip application-requested swapBytes state */
|
---|
251 | tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
|
---|
252 |
|
---|
253 | crPixelCopy3D( width, height, depth,
|
---|
254 | (void *)(data_ptr + 40), format, type, NULL,
|
---|
255 | pixels, format, type, &tmpUnpackState );
|
---|
256 | }
|
---|
257 | }
|
---|
258 |
|
---|
259 | crHugePacket( CR_TEXIMAGE3D_OPCODE, data_ptr );
|
---|
260 | crPackFree( data_ptr );
|
---|
261 | }
|
---|
262 | #endif /* CR_OPENGL_VERSION_1_2 */
|
---|
263 |
|
---|
264 |
|
---|
265 | void PACK_APIENTRY crPackDeleteTexturesSWAP( GLsizei n, const GLuint *textures )
|
---|
266 | {
|
---|
267 | unsigned char *data_ptr;
|
---|
268 | int i;
|
---|
269 |
|
---|
270 | int packet_length =
|
---|
271 | sizeof( n ) +
|
---|
272 | n*sizeof( *textures );
|
---|
273 |
|
---|
274 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
275 | WRITE_DATA( 0, GLsizei, SWAP32(n) );
|
---|
276 |
|
---|
277 | for ( i = 0 ; i < n ; i++)
|
---|
278 | {
|
---|
279 | WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]) );
|
---|
280 | }
|
---|
281 | crHugePacket( CR_DELETETEXTURES_OPCODE, data_ptr );
|
---|
282 | crPackFree( data_ptr );
|
---|
283 | }
|
---|
284 |
|
---|
285 | static void __handleTexEnvData( GLenum target, GLenum pname, const GLfloat *params )
|
---|
286 | {
|
---|
287 | CR_GET_PACKER_CONTEXT(pc);
|
---|
288 | unsigned char *data_ptr;
|
---|
289 | int num_params;
|
---|
290 | int i;
|
---|
291 |
|
---|
292 | int packet_length =
|
---|
293 | sizeof( int ) +
|
---|
294 | sizeof( target ) +
|
---|
295 | sizeof( pname );
|
---|
296 |
|
---|
297 | num_params = 1;
|
---|
298 | if ( pname == GL_TEXTURE_ENV_COLOR )
|
---|
299 | {
|
---|
300 | num_params = 4;
|
---|
301 | }
|
---|
302 |
|
---|
303 | packet_length += num_params*sizeof(*params);
|
---|
304 |
|
---|
305 | CR_GET_BUFFERED_POINTER(pc, packet_length );
|
---|
306 | WRITE_DATA( 0, int, SWAP32(packet_length) );
|
---|
307 | WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) );
|
---|
308 | WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
|
---|
309 | for ( i = 0 ; i < num_params ; i++)
|
---|
310 | {
|
---|
311 | WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT( params[i] ) );
|
---|
312 | }
|
---|
313 | }
|
---|
314 |
|
---|
315 |
|
---|
316 | void PACK_APIENTRY crPackTexEnvfvSWAP( GLenum target, GLenum pname,
|
---|
317 | const GLfloat *params )
|
---|
318 | {
|
---|
319 | CR_GET_PACKER_CONTEXT(pc);
|
---|
320 | __handleTexEnvData( target, pname, params );
|
---|
321 | WRITE_OPCODE( pc, CR_TEXENVFV_OPCODE );
|
---|
322 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
323 | }
|
---|
324 |
|
---|
325 | void PACK_APIENTRY crPackTexEnvivSWAP( GLenum target, GLenum pname,
|
---|
326 | const GLint *params )
|
---|
327 | {
|
---|
328 | /* floats and ints are the same size, so the packing should be the same */
|
---|
329 | CR_GET_PACKER_CONTEXT(pc);
|
---|
330 | __handleTexEnvData( target, pname, (const GLfloat *) params );
|
---|
331 | WRITE_OPCODE( pc, CR_TEXENVIV_OPCODE );
|
---|
332 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
333 | }
|
---|
334 |
|
---|
335 | void PACK_APIENTRY crPackTexEnviSWAP( GLenum target, GLenum pname, GLint param )
|
---|
336 | {
|
---|
337 | crPackTexEnvivSWAP( target, pname, ¶m );
|
---|
338 | }
|
---|
339 |
|
---|
340 | void PACK_APIENTRY crPackTexEnvfSWAP( GLenum target, GLenum pname, GLfloat param )
|
---|
341 | {
|
---|
342 | crPackTexEnvfvSWAP( target, pname, ¶m );
|
---|
343 | }
|
---|
344 |
|
---|
345 | void PACK_APIENTRY crPackPrioritizeTexturesSWAP( GLsizei n,
|
---|
346 | const GLuint *textures, const GLclampf *priorities )
|
---|
347 | {
|
---|
348 | unsigned char *data_ptr;
|
---|
349 | int packet_length =
|
---|
350 | sizeof( n ) +
|
---|
351 | n*sizeof( *textures ) +
|
---|
352 | n*sizeof( *priorities );
|
---|
353 | int i;
|
---|
354 |
|
---|
355 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
356 | WRITE_DATA( 0, GLsizei, SWAP32(n) );
|
---|
357 | for ( i = 0 ; i < n ; i++)
|
---|
358 | {
|
---|
359 | WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]));
|
---|
360 | }
|
---|
361 | for ( i = 0 ; i < n ; i++)
|
---|
362 | {
|
---|
363 | WRITE_DATA( i*sizeof(int) + 4 + n*sizeof( *textures ),
|
---|
364 | GLuint, SWAPFLOAT(priorities[i]));
|
---|
365 | }
|
---|
366 |
|
---|
367 | crHugePacket( CR_PRIORITIZETEXTURES_OPCODE, data_ptr );
|
---|
368 | crPackFree( data_ptr );
|
---|
369 | }
|
---|
370 |
|
---|
371 | static void __handleTexGenData( GLenum coord, GLenum pname,
|
---|
372 | int sizeof_param, const GLvoid *params )
|
---|
373 | {
|
---|
374 | CR_GET_PACKER_CONTEXT(pc);
|
---|
375 | unsigned char *data_ptr;
|
---|
376 | int packet_length = sizeof( int ) + sizeof( coord ) + sizeof( pname );
|
---|
377 | int num_params = 1;
|
---|
378 | int i;
|
---|
379 | if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
|
---|
380 | {
|
---|
381 | num_params = 4;
|
---|
382 | }
|
---|
383 | packet_length += num_params * sizeof_param;
|
---|
384 |
|
---|
385 | CR_GET_BUFFERED_POINTER(pc, packet_length );
|
---|
386 | WRITE_DATA( 0, int, SWAP32(packet_length) );
|
---|
387 | WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(coord) );
|
---|
388 | WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
|
---|
389 | for ( i = 0 ; i < num_params ; i++)
|
---|
390 | {
|
---|
391 | WRITE_DATA( (i+1)*sizeof( int ) + 8, GLint, SWAP32(((GLint *)params)[i]) );
|
---|
392 | }
|
---|
393 | }
|
---|
394 |
|
---|
395 | void PACK_APIENTRY crPackTexGendvSWAP( GLenum coord, GLenum pname,
|
---|
396 | const GLdouble *params )
|
---|
397 | {
|
---|
398 | CR_GET_PACKER_CONTEXT(pc);
|
---|
399 | __handleTexGenData( coord, pname, sizeof( *params ), params );
|
---|
400 | WRITE_OPCODE( pc, CR_TEXGENDV_OPCODE );
|
---|
401 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
402 | }
|
---|
403 |
|
---|
404 | void PACK_APIENTRY crPackTexGenfvSWAP( GLenum coord, GLenum pname,
|
---|
405 | const GLfloat *params )
|
---|
406 | {
|
---|
407 | CR_GET_PACKER_CONTEXT(pc);
|
---|
408 | __handleTexGenData( coord, pname, sizeof( *params ), params );
|
---|
409 | WRITE_OPCODE( pc, CR_TEXGENFV_OPCODE );
|
---|
410 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
411 | }
|
---|
412 |
|
---|
413 | void PACK_APIENTRY crPackTexGenivSWAP( GLenum coord, GLenum pname,
|
---|
414 | const GLint *params )
|
---|
415 | {
|
---|
416 | CR_GET_PACKER_CONTEXT(pc);
|
---|
417 | __handleTexGenData( coord, pname, sizeof( *params ), params );
|
---|
418 | WRITE_OPCODE( pc, CR_TEXGENIV_OPCODE );
|
---|
419 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
420 | }
|
---|
421 |
|
---|
422 | void PACK_APIENTRY crPackTexGendSWAP( GLenum coord, GLenum pname, GLdouble param )
|
---|
423 | {
|
---|
424 | crPackTexGendvSWAP( coord, pname, ¶m );
|
---|
425 | }
|
---|
426 |
|
---|
427 | void PACK_APIENTRY crPackTexGenfSWAP( GLenum coord, GLenum pname, GLfloat param )
|
---|
428 | {
|
---|
429 | crPackTexGenfvSWAP( coord, pname, ¶m );
|
---|
430 | }
|
---|
431 |
|
---|
432 | void PACK_APIENTRY crPackTexGeniSWAP( GLenum coord, GLenum pname, GLint param )
|
---|
433 | {
|
---|
434 | crPackTexGenivSWAP( coord, pname, ¶m );
|
---|
435 | }
|
---|
436 |
|
---|
437 | static GLboolean __handleTexParameterData( GLenum target, GLenum pname, const GLfloat *params )
|
---|
438 | {
|
---|
439 | CR_GET_PACKER_CONTEXT(pc);
|
---|
440 | unsigned char *data_ptr;
|
---|
441 | int packet_length = sizeof( int ) + sizeof( target ) + sizeof( pname );
|
---|
442 | int num_params = 0;
|
---|
443 | int i;
|
---|
444 |
|
---|
445 | switch( pname )
|
---|
446 | {
|
---|
447 |
|
---|
448 | case GL_TEXTURE_MIN_FILTER:
|
---|
449 | case GL_TEXTURE_MAG_FILTER:
|
---|
450 | case GL_TEXTURE_WRAP_R:
|
---|
451 | case GL_TEXTURE_WRAP_S:
|
---|
452 | case GL_TEXTURE_WRAP_T:
|
---|
453 | #ifdef GL_TEXTURE_PRIORITY
|
---|
454 | case GL_TEXTURE_PRIORITY:
|
---|
455 | #endif
|
---|
456 | num_params = 1;
|
---|
457 | break;
|
---|
458 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
---|
459 | num_params = 1;
|
---|
460 | break;
|
---|
461 | case GL_TEXTURE_MIN_LOD:
|
---|
462 | case GL_TEXTURE_MAX_LOD:
|
---|
463 | case GL_TEXTURE_BASE_LEVEL:
|
---|
464 | case GL_TEXTURE_MAX_LEVEL:
|
---|
465 | num_params = 1;
|
---|
466 | break;
|
---|
467 | case GL_TEXTURE_BORDER_COLOR:
|
---|
468 | num_params = 4;
|
---|
469 | break;
|
---|
470 | #ifdef CR_ARB_shadow
|
---|
471 | case GL_TEXTURE_COMPARE_MODE_ARB:
|
---|
472 | case GL_TEXTURE_COMPARE_FUNC_ARB:
|
---|
473 | num_params = 1;
|
---|
474 | break;
|
---|
475 | #endif
|
---|
476 | #ifdef CR_ARB_shadow_ambient
|
---|
477 | case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
|
---|
478 | num_params = 1;
|
---|
479 | break;
|
---|
480 | #endif
|
---|
481 | #ifdef CR_ARB_depth_texture
|
---|
482 | case GL_DEPTH_TEXTURE_MODE_ARB:
|
---|
483 | num_params = 1;
|
---|
484 | break;
|
---|
485 | #endif
|
---|
486 | #ifdef CR_SGIS_generate_mipmap
|
---|
487 | case GL_GENERATE_MIPMAP_SGIS:
|
---|
488 | num_params = 1;
|
---|
489 | break;
|
---|
490 | #endif
|
---|
491 | default:
|
---|
492 | num_params = __packTexParameterNumParams( pname );
|
---|
493 | if (!num_params)
|
---|
494 | {
|
---|
495 | __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
496 | "crPackTexParameter(bad pname)" );
|
---|
497 | return GL_FALSE;
|
---|
498 | }
|
---|
499 | }
|
---|
500 | packet_length += num_params * sizeof(*params);
|
---|
501 |
|
---|
502 | CR_GET_BUFFERED_POINTER(pc, packet_length );
|
---|
503 | WRITE_DATA( 0, int, SWAP32(packet_length) );
|
---|
504 | WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) );
|
---|
505 | WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
|
---|
506 | for ( i = 0 ; i < num_params ; i++)
|
---|
507 | {
|
---|
508 | WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT(params[i]) );
|
---|
509 | }
|
---|
510 | return GL_TRUE;
|
---|
511 | }
|
---|
512 |
|
---|
513 | void PACK_APIENTRY crPackTexParameterfvSWAP( GLenum target, GLenum pname,
|
---|
514 | const GLfloat *params )
|
---|
515 | {
|
---|
516 | CR_GET_PACKER_CONTEXT(pc);
|
---|
517 | if (__handleTexParameterData( target, pname, params ))
|
---|
518 | WRITE_OPCODE( pc, CR_TEXPARAMETERFV_OPCODE );
|
---|
519 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
520 | }
|
---|
521 |
|
---|
522 | void PACK_APIENTRY crPackTexParameterivSWAP( GLenum target, GLenum pname,
|
---|
523 | const GLint *params )
|
---|
524 | {
|
---|
525 | CR_GET_PACKER_CONTEXT(pc);
|
---|
526 | if (__handleTexParameterData( target, pname, (GLfloat *) params ))
|
---|
527 | WRITE_OPCODE( pc, CR_TEXPARAMETERIV_OPCODE );
|
---|
528 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
529 | }
|
---|
530 |
|
---|
531 | void PACK_APIENTRY crPackTexParameterfSWAP( GLenum target, GLenum pname, GLfloat param )
|
---|
532 | {
|
---|
533 | crPackTexParameterfvSWAP( target, pname, ¶m );
|
---|
534 | }
|
---|
535 |
|
---|
536 | void PACK_APIENTRY crPackTexParameteriSWAP( GLenum target, GLenum pname, GLint param )
|
---|
537 | {
|
---|
538 | crPackTexParameterivSWAP( target, pname, ¶m );
|
---|
539 | }
|
---|
540 |
|
---|
541 | #ifdef CR_OPENGL_VERSION_1_2
|
---|
542 | void PACK_APIENTRY crPackTexSubImage3DSWAP (GLenum target, GLint level,
|
---|
543 | GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
|
---|
544 | GLenum format, GLenum type, const GLvoid *pixels,
|
---|
545 | const CRPixelPackState *unpackstate )
|
---|
546 | {
|
---|
547 | unsigned char *data_ptr;
|
---|
548 | int packet_length;
|
---|
549 |
|
---|
550 | packet_length =
|
---|
551 | sizeof( target ) +
|
---|
552 | sizeof( level ) +
|
---|
553 | sizeof( xoffset ) +
|
---|
554 | sizeof( yoffset ) +
|
---|
555 | sizeof( zoffset ) +
|
---|
556 | sizeof( width ) +
|
---|
557 | sizeof( height ) +
|
---|
558 | sizeof( depth ) +
|
---|
559 | sizeof( format ) +
|
---|
560 | sizeof( type ) +
|
---|
561 | crTextureSize( format, type, width, height, depth );
|
---|
562 |
|
---|
563 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
564 | WRITE_DATA( 0, GLenum, SWAP32(target) );
|
---|
565 | WRITE_DATA( 4, GLint, SWAP32(level) );
|
---|
566 | WRITE_DATA( 8, GLint, SWAP32(xoffset) );
|
---|
567 | WRITE_DATA( 12, GLint, SWAP32(yoffset) );
|
---|
568 | WRITE_DATA( 16, GLint, SWAP32(zoffset) );
|
---|
569 | WRITE_DATA( 20, GLsizei, SWAP32(width) );
|
---|
570 | WRITE_DATA( 24, GLsizei, SWAP32(height) );
|
---|
571 | WRITE_DATA( 28, GLsizei, SWAP32(depth) );
|
---|
572 | WRITE_DATA( 32, GLenum, SWAP32(format) );
|
---|
573 | WRITE_DATA( 36, GLenum, SWAP32(type) );
|
---|
574 |
|
---|
575 | crPixelCopy3D( width, height, depth,
|
---|
576 | (GLvoid *) (data_ptr + 36), format, type, NULL, /* dst */
|
---|
577 | pixels, format, type, unpackstate ); /* src */
|
---|
578 |
|
---|
579 | crHugePacket( CR_TEXSUBIMAGE3D_OPCODE, data_ptr );
|
---|
580 | crPackFree( data_ptr );
|
---|
581 | }
|
---|
582 | #endif /* CR_OPENGL_VERSION_1_2 */
|
---|
583 |
|
---|
584 | void PACK_APIENTRY crPackTexSubImage2DSWAP (GLenum target, GLint level,
|
---|
585 | GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
---|
586 | GLenum format, GLenum type, const GLvoid *pixels,
|
---|
587 | const CRPixelPackState *unpackstate )
|
---|
588 | {
|
---|
589 | unsigned char *data_ptr;
|
---|
590 | int packet_length;
|
---|
591 |
|
---|
592 | CRPixelPackState tmpUnpackState = *unpackstate;
|
---|
593 |
|
---|
594 | packet_length =
|
---|
595 | sizeof( target ) +
|
---|
596 | sizeof( level ) +
|
---|
597 | sizeof( xoffset ) +
|
---|
598 | sizeof( yoffset ) +
|
---|
599 | sizeof( width ) +
|
---|
600 | sizeof( height ) +
|
---|
601 | sizeof( format ) +
|
---|
602 | sizeof( type ) +
|
---|
603 | crImageSize( format, type, width, height );
|
---|
604 |
|
---|
605 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
606 | WRITE_DATA( 0, GLenum, SWAP32(target) );
|
---|
607 | WRITE_DATA( 4, GLint, SWAP32(level) );
|
---|
608 | WRITE_DATA( 8, GLint, SWAP32(xoffset) );
|
---|
609 | WRITE_DATA( 12, GLint, SWAP32(yoffset) );
|
---|
610 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
611 | WRITE_DATA( 20, GLsizei, SWAP32(height) );
|
---|
612 | WRITE_DATA( 24, GLenum, SWAP32(format) );
|
---|
613 | WRITE_DATA( 28, GLenum, SWAP32(type) );
|
---|
614 |
|
---|
615 | /* flip application-requested swapBytes state */
|
---|
616 | tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
|
---|
617 |
|
---|
618 | crPixelCopy2D( width, height,
|
---|
619 | (GLvoid *) (data_ptr + 32), format, type, NULL, /* dst */
|
---|
620 | pixels, format, type, &tmpUnpackState ); /* src */
|
---|
621 |
|
---|
622 | crHugePacket( CR_TEXSUBIMAGE2D_OPCODE, data_ptr );
|
---|
623 | crPackFree( data_ptr );
|
---|
624 | }
|
---|
625 |
|
---|
626 | void PACK_APIENTRY crPackTexSubImage1DSWAP (GLenum target, GLint level,
|
---|
627 | GLint xoffset, GLsizei width, GLenum format, GLenum type,
|
---|
628 | const GLvoid *pixels, const CRPixelPackState *unpackstate )
|
---|
629 | {
|
---|
630 | unsigned char *data_ptr;
|
---|
631 | int packet_length;
|
---|
632 | CRPixelPackState tmpUnpackState = *unpackstate;
|
---|
633 |
|
---|
634 | packet_length =
|
---|
635 | sizeof( target ) +
|
---|
636 | sizeof( level ) +
|
---|
637 | sizeof( xoffset ) +
|
---|
638 | sizeof( width ) +
|
---|
639 | sizeof( format ) +
|
---|
640 | sizeof( type ) +
|
---|
641 | crImageSize( format, type, width, 1 );
|
---|
642 |
|
---|
643 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
644 | WRITE_DATA( 0, GLenum, SWAP32(target) );
|
---|
645 | WRITE_DATA( 4, GLint, SWAP32(level) );
|
---|
646 | WRITE_DATA( 8, GLint, SWAP32(xoffset) );
|
---|
647 | WRITE_DATA( 12, GLsizei, SWAP32(width) );
|
---|
648 | WRITE_DATA( 16, GLenum, SWAP32(format) );
|
---|
649 | WRITE_DATA( 20, GLenum, SWAP32(type) );
|
---|
650 |
|
---|
651 | /* flip application-requested swapBytes state */
|
---|
652 | tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
|
---|
653 |
|
---|
654 | crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type,
|
---|
655 | pixels, format, type, width, &tmpUnpackState );
|
---|
656 |
|
---|
657 | crHugePacket( CR_TEXSUBIMAGE1D_OPCODE, data_ptr );
|
---|
658 | crPackFree( data_ptr );
|
---|
659 | }
|
---|
660 |
|
---|
661 | void PACK_APIENTRY crPackAreTexturesResidentSWAP( GLsizei n, const GLuint *textures, GLboolean *residences, GLboolean *return_val, int *writeback )
|
---|
662 | {
|
---|
663 | CR_GET_PACKER_CONTEXT(pc);
|
---|
664 | unsigned char *data_ptr;
|
---|
665 | int packet_length;
|
---|
666 | int i;
|
---|
667 |
|
---|
668 | packet_length =
|
---|
669 | sizeof( int ) + /* packet length */
|
---|
670 | sizeof( GLenum ) + /* extend-o opcode */
|
---|
671 | sizeof( n ) + /* num_textures */
|
---|
672 | n*sizeof( *textures ) + /* textures */
|
---|
673 | 8 + 8 + 8; /* return pointers */
|
---|
674 |
|
---|
675 | CR_GET_BUFFERED_POINTER(pc, packet_length);
|
---|
676 | WRITE_DATA( 0, int, SWAP32(packet_length) );
|
---|
677 | WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(CR_ARETEXTURESRESIDENT_EXTEND_OPCODE) );
|
---|
678 | WRITE_DATA( sizeof( int ) + 4, GLsizei, SWAP32(n) );
|
---|
679 | for (i = 0 ; i < n ; i++)
|
---|
680 | {
|
---|
681 | WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAP32(textures[i]) );
|
---|
682 | }
|
---|
683 | WRITE_NETWORK_POINTER( sizeof( int ) + 8 + n*sizeof( *textures ), (void *) residences );
|
---|
684 | WRITE_NETWORK_POINTER( sizeof( int ) + 16 + n*sizeof( *textures ), (void *) return_val );
|
---|
685 | WRITE_NETWORK_POINTER( sizeof( int ) + 24 + n*sizeof( *textures ), (void *) writeback );
|
---|
686 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
687 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
688 | }
|
---|
689 |
|
---|
690 |
|
---|
691 | /**********************************************************************
|
---|
692 | * Texture compression
|
---|
693 | */
|
---|
694 |
|
---|
695 | void PACK_APIENTRY crPackCompressedTexImage1DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data )
|
---|
696 | {
|
---|
697 | unsigned char *data_ptr;
|
---|
698 | int packet_length;
|
---|
699 | int isnull = (data == NULL);
|
---|
700 |
|
---|
701 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
702 | * the first four indicate the packet size, and the next four
|
---|
703 | * indicate the actual extended opcode.
|
---|
704 | */
|
---|
705 | packet_length =
|
---|
706 | sizeof( GLenum) + /* extended opcode */
|
---|
707 | sizeof( target ) +
|
---|
708 | sizeof( level ) +
|
---|
709 | sizeof( internalformat ) +
|
---|
710 | sizeof( width ) +
|
---|
711 | sizeof( border ) +
|
---|
712 | sizeof( imagesize ) +
|
---|
713 | sizeof( int );
|
---|
714 |
|
---|
715 | if (data)
|
---|
716 | {
|
---|
717 | packet_length += imagesize;
|
---|
718 | }
|
---|
719 |
|
---|
720 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
721 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE) );
|
---|
722 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
723 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
724 | WRITE_DATA( 12, GLint, SWAP32(internalformat) );
|
---|
725 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
726 | WRITE_DATA( 20, GLint, SWAP32(border) );
|
---|
727 | WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
|
---|
728 | WRITE_DATA( 28, int, SWAP32(isnull) );
|
---|
729 |
|
---|
730 | if (data) {
|
---|
731 | crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
|
---|
732 | }
|
---|
733 |
|
---|
734 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
735 | crPackFree( data_ptr );
|
---|
736 | }
|
---|
737 |
|
---|
738 | void PACK_APIENTRY crPackCompressedTexImage2DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data )
|
---|
739 | {
|
---|
740 | unsigned char *data_ptr;
|
---|
741 | int packet_length;
|
---|
742 | int isnull = (data == NULL);
|
---|
743 |
|
---|
744 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
745 | * the first four indicate the packet size, and the next four
|
---|
746 | * indicate the actual extended opcode.
|
---|
747 | */
|
---|
748 | packet_length =
|
---|
749 | sizeof( GLenum) + /* extended opcode */
|
---|
750 | sizeof( target ) +
|
---|
751 | sizeof( level ) +
|
---|
752 | sizeof( internalformat ) +
|
---|
753 | sizeof( width ) +
|
---|
754 | sizeof( height ) +
|
---|
755 | sizeof( border ) +
|
---|
756 | sizeof( imagesize ) +
|
---|
757 | sizeof( int ); /* isnull */
|
---|
758 |
|
---|
759 | if (data)
|
---|
760 | {
|
---|
761 | packet_length += imagesize;
|
---|
762 | }
|
---|
763 |
|
---|
764 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
765 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE2DARB_EXTEND_OPCODE) );
|
---|
766 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
767 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
768 | WRITE_DATA( 12, GLint, SWAP32(internalformat) );
|
---|
769 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
770 | WRITE_DATA( 20, GLsizei, SWAP32(height) );
|
---|
771 | WRITE_DATA( 24, GLint, SWAP32(border) );
|
---|
772 | WRITE_DATA( 28, GLsizei, SWAP32(imagesize) );
|
---|
773 | WRITE_DATA( 32, int, SWAP32(isnull) );
|
---|
774 |
|
---|
775 | if (data) {
|
---|
776 | crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize);
|
---|
777 | }
|
---|
778 |
|
---|
779 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
780 | crPackFree( data_ptr );
|
---|
781 | }
|
---|
782 |
|
---|
783 | void PACK_APIENTRY crPackCompressedTexImage3DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data )
|
---|
784 | {
|
---|
785 | unsigned char *data_ptr;
|
---|
786 | int packet_length;
|
---|
787 | int isnull = (data == NULL);
|
---|
788 |
|
---|
789 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
790 | * the first four indicate the packet size, and the next four
|
---|
791 | * indicate the actual extended opcode.
|
---|
792 | */
|
---|
793 | packet_length =
|
---|
794 | sizeof( GLenum) + /* extended opcode */
|
---|
795 | sizeof( target ) +
|
---|
796 | sizeof( level ) +
|
---|
797 | sizeof( internalformat ) +
|
---|
798 | sizeof( width ) +
|
---|
799 | sizeof( height ) +
|
---|
800 | sizeof( depth ) +
|
---|
801 | sizeof( border ) +
|
---|
802 | sizeof( imagesize ) +
|
---|
803 | sizeof( int ); /* isnull */
|
---|
804 |
|
---|
805 | if (data)
|
---|
806 | {
|
---|
807 | packet_length += imagesize;
|
---|
808 | }
|
---|
809 |
|
---|
810 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
811 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE3DARB_EXTEND_OPCODE) );
|
---|
812 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
813 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
814 | WRITE_DATA( 12, GLint, SWAP32(internalformat) );
|
---|
815 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
816 | WRITE_DATA( 20, GLsizei, SWAP32(height) );
|
---|
817 | WRITE_DATA( 24, GLsizei, SWAP32(depth) );
|
---|
818 | WRITE_DATA( 28, GLint, SWAP32(border) );
|
---|
819 | WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
|
---|
820 | WRITE_DATA( 36, int, SWAP32(isnull) );
|
---|
821 |
|
---|
822 | if (data) {
|
---|
823 | crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
|
---|
824 | }
|
---|
825 |
|
---|
826 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
827 | crPackFree( data_ptr );
|
---|
828 | }
|
---|
829 |
|
---|
830 | void PACK_APIENTRY crPackCompressedTexSubImage1DARBSWAP( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data )
|
---|
831 | {
|
---|
832 | unsigned char *data_ptr;
|
---|
833 | int packet_length;
|
---|
834 | int isnull = (data == NULL);
|
---|
835 |
|
---|
836 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
837 | * the first four indicate the packet size, and the next four
|
---|
838 | * indicate the actual extended opcode.
|
---|
839 | */
|
---|
840 | packet_length =
|
---|
841 | sizeof( GLenum) + /* extended opcode */
|
---|
842 | sizeof( target ) +
|
---|
843 | sizeof( level ) +
|
---|
844 | sizeof( xoffset ) +
|
---|
845 | sizeof( width ) +
|
---|
846 | sizeof( format ) +
|
---|
847 | sizeof( imagesize ) +
|
---|
848 | sizeof( int ); /* isnull */
|
---|
849 |
|
---|
850 | if (data)
|
---|
851 | {
|
---|
852 | packet_length += imagesize;
|
---|
853 | }
|
---|
854 |
|
---|
855 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
856 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE1DARB_EXTEND_OPCODE) );
|
---|
857 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
858 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
859 | WRITE_DATA( 12, GLint, SWAP32(xoffset) );
|
---|
860 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
861 | WRITE_DATA( 20, GLenum, SWAP32(format) );
|
---|
862 | WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
|
---|
863 | WRITE_DATA( 28, int, SWAP32(isnull) );
|
---|
864 |
|
---|
865 | if (data) {
|
---|
866 | crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
|
---|
867 | }
|
---|
868 |
|
---|
869 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
870 | crPackFree( data_ptr );
|
---|
871 | }
|
---|
872 |
|
---|
873 | void PACK_APIENTRY crPackCompressedTexSubImage2DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data )
|
---|
874 | {
|
---|
875 | unsigned char *data_ptr;
|
---|
876 | int packet_length;
|
---|
877 | int isnull = (data == NULL);
|
---|
878 |
|
---|
879 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
880 | * the first four indicate the packet size, and the next four
|
---|
881 | * indicate the actual extended opcode.
|
---|
882 | */
|
---|
883 | packet_length =
|
---|
884 | sizeof( GLenum) + /* extended opcode */
|
---|
885 | sizeof( target ) +
|
---|
886 | sizeof( level ) +
|
---|
887 | sizeof( xoffset ) +
|
---|
888 | sizeof( yoffset ) +
|
---|
889 | sizeof( width ) +
|
---|
890 | sizeof( height ) +
|
---|
891 | sizeof( format ) +
|
---|
892 | sizeof( imagesize ) +
|
---|
893 | sizeof( int ); /* isnull */
|
---|
894 |
|
---|
895 | if (data)
|
---|
896 | {
|
---|
897 | packet_length += imagesize;
|
---|
898 | }
|
---|
899 |
|
---|
900 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
901 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE2DARB_EXTEND_OPCODE) );
|
---|
902 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
903 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
904 | WRITE_DATA( 12, GLint, SWAP32(xoffset) );
|
---|
905 | WRITE_DATA( 16, GLint, SWAP32(yoffset) );
|
---|
906 | WRITE_DATA( 20, GLsizei, SWAP32(width) );
|
---|
907 | WRITE_DATA( 24, GLsizei, SWAP32(height) );
|
---|
908 | WRITE_DATA( 28, GLenum, SWAP32(format) );
|
---|
909 | WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
|
---|
910 | WRITE_DATA( 36, int, SWAP32(isnull) );
|
---|
911 |
|
---|
912 | if (data) {
|
---|
913 | crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
|
---|
914 | }
|
---|
915 |
|
---|
916 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
917 | crPackFree( data_ptr );
|
---|
918 | }
|
---|
919 |
|
---|
920 | void PACK_APIENTRY crPackCompressedTexSubImage3DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data )
|
---|
921 | {
|
---|
922 | unsigned char *data_ptr;
|
---|
923 | int packet_length;
|
---|
924 | int isnull = (data == NULL);
|
---|
925 |
|
---|
926 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
927 | * the first four indicate the packet size, and the next four
|
---|
928 | * indicate the actual extended opcode.
|
---|
929 | */
|
---|
930 | packet_length =
|
---|
931 | sizeof( GLenum) + /* extended opcode */
|
---|
932 | sizeof( target ) +
|
---|
933 | sizeof( level ) +
|
---|
934 | sizeof( xoffset ) +
|
---|
935 | sizeof( yoffset ) +
|
---|
936 | sizeof( zoffset ) +
|
---|
937 | sizeof( width ) +
|
---|
938 | sizeof( height ) +
|
---|
939 | sizeof( depth ) +
|
---|
940 | sizeof( format ) +
|
---|
941 | sizeof( imagesize ) +
|
---|
942 | sizeof( int ); /* isnull */
|
---|
943 |
|
---|
944 | if (data)
|
---|
945 | {
|
---|
946 | packet_length += imagesize;
|
---|
947 | }
|
---|
948 |
|
---|
949 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
950 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE) );
|
---|
951 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
952 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
953 | WRITE_DATA( 12, GLint, SWAP32(xoffset) );
|
---|
954 | WRITE_DATA( 16, GLint, SWAP32(yoffset) );
|
---|
955 | WRITE_DATA( 20, GLint, SWAP32(zoffset) );
|
---|
956 | WRITE_DATA( 24, GLsizei, SWAP32(width) );
|
---|
957 | WRITE_DATA( 28, GLsizei, SWAP32(height) );
|
---|
958 | WRITE_DATA( 32, GLsizei, SWAP32(depth) );
|
---|
959 | WRITE_DATA( 36, GLenum, SWAP32(format) );
|
---|
960 | WRITE_DATA( 40, GLsizei, SWAP32(imagesize) );
|
---|
961 | WRITE_DATA( 44, int, SWAP32(isnull) );
|
---|
962 |
|
---|
963 | if (data) {
|
---|
964 | crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize);
|
---|
965 | }
|
---|
966 |
|
---|
967 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
968 | crPackFree( data_ptr );
|
---|
969 | }
|
---|
970 |
|
---|
971 | void PACK_APIENTRY crPackGetCompressedTexImageARBSWAP( GLenum target, GLint level, GLvoid *img, int *writeback )
|
---|
972 | {
|
---|
973 | CR_GET_PACKER_CONTEXT(pc);
|
---|
974 | crError ( "GetCompressedTexImageARB needs to be special cased!");
|
---|
975 | (void) pc;
|
---|
976 | (void) target;
|
---|
977 | (void) level;
|
---|
978 | (void) img;
|
---|
979 | (void) writeback;
|
---|
980 | }
|
---|