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_CMDBLOCK_CHECK_FLUSH(pc);
|
---|
688 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
689 | }
|
---|
690 |
|
---|
691 |
|
---|
692 | /**********************************************************************
|
---|
693 | * Texture compression
|
---|
694 | */
|
---|
695 |
|
---|
696 | void PACK_APIENTRY crPackCompressedTexImage1DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data )
|
---|
697 | {
|
---|
698 | unsigned char *data_ptr;
|
---|
699 | int packet_length;
|
---|
700 | int isnull = (data == NULL);
|
---|
701 |
|
---|
702 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
703 | * the first four indicate the packet size, and the next four
|
---|
704 | * indicate the actual extended opcode.
|
---|
705 | */
|
---|
706 | packet_length =
|
---|
707 | sizeof( GLenum) + /* extended opcode */
|
---|
708 | sizeof( target ) +
|
---|
709 | sizeof( level ) +
|
---|
710 | sizeof( internalformat ) +
|
---|
711 | sizeof( width ) +
|
---|
712 | sizeof( border ) +
|
---|
713 | sizeof( imagesize ) +
|
---|
714 | sizeof( int );
|
---|
715 |
|
---|
716 | if (data)
|
---|
717 | {
|
---|
718 | packet_length += imagesize;
|
---|
719 | }
|
---|
720 |
|
---|
721 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
722 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE) );
|
---|
723 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
724 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
725 | WRITE_DATA( 12, GLint, SWAP32(internalformat) );
|
---|
726 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
727 | WRITE_DATA( 20, GLint, SWAP32(border) );
|
---|
728 | WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
|
---|
729 | WRITE_DATA( 28, int, SWAP32(isnull) );
|
---|
730 |
|
---|
731 | if (data) {
|
---|
732 | crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
|
---|
733 | }
|
---|
734 |
|
---|
735 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
736 | crPackFree( data_ptr );
|
---|
737 | }
|
---|
738 |
|
---|
739 | void PACK_APIENTRY crPackCompressedTexImage2DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data )
|
---|
740 | {
|
---|
741 | unsigned char *data_ptr;
|
---|
742 | int packet_length;
|
---|
743 | int isnull = (data == NULL);
|
---|
744 |
|
---|
745 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
746 | * the first four indicate the packet size, and the next four
|
---|
747 | * indicate the actual extended opcode.
|
---|
748 | */
|
---|
749 | packet_length =
|
---|
750 | sizeof( GLenum) + /* extended opcode */
|
---|
751 | sizeof( target ) +
|
---|
752 | sizeof( level ) +
|
---|
753 | sizeof( internalformat ) +
|
---|
754 | sizeof( width ) +
|
---|
755 | sizeof( height ) +
|
---|
756 | sizeof( border ) +
|
---|
757 | sizeof( imagesize ) +
|
---|
758 | sizeof( int ); /* isnull */
|
---|
759 |
|
---|
760 | if (data)
|
---|
761 | {
|
---|
762 | packet_length += imagesize;
|
---|
763 | }
|
---|
764 |
|
---|
765 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
766 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE2DARB_EXTEND_OPCODE) );
|
---|
767 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
768 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
769 | WRITE_DATA( 12, GLint, SWAP32(internalformat) );
|
---|
770 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
771 | WRITE_DATA( 20, GLsizei, SWAP32(height) );
|
---|
772 | WRITE_DATA( 24, GLint, SWAP32(border) );
|
---|
773 | WRITE_DATA( 28, GLsizei, SWAP32(imagesize) );
|
---|
774 | WRITE_DATA( 32, int, SWAP32(isnull) );
|
---|
775 |
|
---|
776 | if (data) {
|
---|
777 | crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize);
|
---|
778 | }
|
---|
779 |
|
---|
780 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
781 | crPackFree( data_ptr );
|
---|
782 | }
|
---|
783 |
|
---|
784 | void PACK_APIENTRY crPackCompressedTexImage3DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data )
|
---|
785 | {
|
---|
786 | unsigned char *data_ptr;
|
---|
787 | int packet_length;
|
---|
788 | int isnull = (data == NULL);
|
---|
789 |
|
---|
790 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
791 | * the first four indicate the packet size, and the next four
|
---|
792 | * indicate the actual extended opcode.
|
---|
793 | */
|
---|
794 | packet_length =
|
---|
795 | sizeof( GLenum) + /* extended opcode */
|
---|
796 | sizeof( target ) +
|
---|
797 | sizeof( level ) +
|
---|
798 | sizeof( internalformat ) +
|
---|
799 | sizeof( width ) +
|
---|
800 | sizeof( height ) +
|
---|
801 | sizeof( depth ) +
|
---|
802 | sizeof( border ) +
|
---|
803 | sizeof( imagesize ) +
|
---|
804 | sizeof( int ); /* isnull */
|
---|
805 |
|
---|
806 | if (data)
|
---|
807 | {
|
---|
808 | packet_length += imagesize;
|
---|
809 | }
|
---|
810 |
|
---|
811 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
812 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE3DARB_EXTEND_OPCODE) );
|
---|
813 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
814 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
815 | WRITE_DATA( 12, GLint, SWAP32(internalformat) );
|
---|
816 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
817 | WRITE_DATA( 20, GLsizei, SWAP32(height) );
|
---|
818 | WRITE_DATA( 24, GLsizei, SWAP32(depth) );
|
---|
819 | WRITE_DATA( 28, GLint, SWAP32(border) );
|
---|
820 | WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
|
---|
821 | WRITE_DATA( 36, int, SWAP32(isnull) );
|
---|
822 |
|
---|
823 | if (data) {
|
---|
824 | crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
|
---|
825 | }
|
---|
826 |
|
---|
827 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
828 | crPackFree( data_ptr );
|
---|
829 | }
|
---|
830 |
|
---|
831 | void PACK_APIENTRY crPackCompressedTexSubImage1DARBSWAP( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data )
|
---|
832 | {
|
---|
833 | unsigned char *data_ptr;
|
---|
834 | int packet_length;
|
---|
835 | int isnull = (data == NULL);
|
---|
836 |
|
---|
837 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
838 | * the first four indicate the packet size, and the next four
|
---|
839 | * indicate the actual extended opcode.
|
---|
840 | */
|
---|
841 | packet_length =
|
---|
842 | sizeof( GLenum) + /* extended opcode */
|
---|
843 | sizeof( target ) +
|
---|
844 | sizeof( level ) +
|
---|
845 | sizeof( xoffset ) +
|
---|
846 | sizeof( width ) +
|
---|
847 | sizeof( format ) +
|
---|
848 | sizeof( imagesize ) +
|
---|
849 | sizeof( int ); /* isnull */
|
---|
850 |
|
---|
851 | if (data)
|
---|
852 | {
|
---|
853 | packet_length += imagesize;
|
---|
854 | }
|
---|
855 |
|
---|
856 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
857 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE1DARB_EXTEND_OPCODE) );
|
---|
858 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
859 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
860 | WRITE_DATA( 12, GLint, SWAP32(xoffset) );
|
---|
861 | WRITE_DATA( 16, GLsizei, SWAP32(width) );
|
---|
862 | WRITE_DATA( 20, GLenum, SWAP32(format) );
|
---|
863 | WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
|
---|
864 | WRITE_DATA( 28, int, SWAP32(isnull) );
|
---|
865 |
|
---|
866 | if (data) {
|
---|
867 | crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
|
---|
868 | }
|
---|
869 |
|
---|
870 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
871 | crPackFree( data_ptr );
|
---|
872 | }
|
---|
873 |
|
---|
874 | void PACK_APIENTRY crPackCompressedTexSubImage2DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data )
|
---|
875 | {
|
---|
876 | unsigned char *data_ptr;
|
---|
877 | int packet_length;
|
---|
878 | int isnull = (data == NULL);
|
---|
879 |
|
---|
880 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
881 | * the first four indicate the packet size, and the next four
|
---|
882 | * indicate the actual extended opcode.
|
---|
883 | */
|
---|
884 | packet_length =
|
---|
885 | sizeof( GLenum) + /* extended opcode */
|
---|
886 | sizeof( target ) +
|
---|
887 | sizeof( level ) +
|
---|
888 | sizeof( xoffset ) +
|
---|
889 | sizeof( yoffset ) +
|
---|
890 | sizeof( width ) +
|
---|
891 | sizeof( height ) +
|
---|
892 | sizeof( format ) +
|
---|
893 | sizeof( imagesize ) +
|
---|
894 | sizeof( int ); /* isnull */
|
---|
895 |
|
---|
896 | if (data)
|
---|
897 | {
|
---|
898 | packet_length += imagesize;
|
---|
899 | }
|
---|
900 |
|
---|
901 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
902 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE2DARB_EXTEND_OPCODE) );
|
---|
903 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
904 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
905 | WRITE_DATA( 12, GLint, SWAP32(xoffset) );
|
---|
906 | WRITE_DATA( 16, GLint, SWAP32(yoffset) );
|
---|
907 | WRITE_DATA( 20, GLsizei, SWAP32(width) );
|
---|
908 | WRITE_DATA( 24, GLsizei, SWAP32(height) );
|
---|
909 | WRITE_DATA( 28, GLenum, SWAP32(format) );
|
---|
910 | WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
|
---|
911 | WRITE_DATA( 36, int, SWAP32(isnull) );
|
---|
912 |
|
---|
913 | if (data) {
|
---|
914 | crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
|
---|
915 | }
|
---|
916 |
|
---|
917 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
918 | crPackFree( data_ptr );
|
---|
919 | }
|
---|
920 |
|
---|
921 | 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 )
|
---|
922 | {
|
---|
923 | unsigned char *data_ptr;
|
---|
924 | int packet_length;
|
---|
925 | int isnull = (data == NULL);
|
---|
926 |
|
---|
927 | /* All extended opcodes have their first 8 bytes predefined:
|
---|
928 | * the first four indicate the packet size, and the next four
|
---|
929 | * indicate the actual extended opcode.
|
---|
930 | */
|
---|
931 | packet_length =
|
---|
932 | sizeof( GLenum) + /* extended opcode */
|
---|
933 | sizeof( target ) +
|
---|
934 | sizeof( level ) +
|
---|
935 | sizeof( xoffset ) +
|
---|
936 | sizeof( yoffset ) +
|
---|
937 | sizeof( zoffset ) +
|
---|
938 | sizeof( width ) +
|
---|
939 | sizeof( height ) +
|
---|
940 | sizeof( depth ) +
|
---|
941 | sizeof( format ) +
|
---|
942 | sizeof( imagesize ) +
|
---|
943 | sizeof( int ); /* isnull */
|
---|
944 |
|
---|
945 | if (data)
|
---|
946 | {
|
---|
947 | packet_length += imagesize;
|
---|
948 | }
|
---|
949 |
|
---|
950 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
951 | WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE) );
|
---|
952 | WRITE_DATA( 4, GLenum, SWAP32(target) );
|
---|
953 | WRITE_DATA( 8, GLint, SWAP32(level) );
|
---|
954 | WRITE_DATA( 12, GLint, SWAP32(xoffset) );
|
---|
955 | WRITE_DATA( 16, GLint, SWAP32(yoffset) );
|
---|
956 | WRITE_DATA( 20, GLint, SWAP32(zoffset) );
|
---|
957 | WRITE_DATA( 24, GLsizei, SWAP32(width) );
|
---|
958 | WRITE_DATA( 28, GLsizei, SWAP32(height) );
|
---|
959 | WRITE_DATA( 32, GLsizei, SWAP32(depth) );
|
---|
960 | WRITE_DATA( 36, GLenum, SWAP32(format) );
|
---|
961 | WRITE_DATA( 40, GLsizei, SWAP32(imagesize) );
|
---|
962 | WRITE_DATA( 44, int, SWAP32(isnull) );
|
---|
963 |
|
---|
964 | if (data) {
|
---|
965 | crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize);
|
---|
966 | }
|
---|
967 |
|
---|
968 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
969 | crPackFree( data_ptr );
|
---|
970 | }
|
---|
971 |
|
---|
972 | void PACK_APIENTRY crPackGetCompressedTexImageARBSWAP( GLenum target, GLint level, GLvoid *img, int *writeback )
|
---|
973 | {
|
---|
974 | CR_GET_PACKER_CONTEXT(pc);
|
---|
975 | crError ( "GetCompressedTexImageARB needs to be special cased!");
|
---|
976 | (void) pc;
|
---|
977 | (void) target;
|
---|
978 | (void) level;
|
---|
979 | (void) img;
|
---|
980 | (void) writeback;
|
---|
981 | }
|
---|