VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.c@ 23495

Last change on this file since 23495 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.7 KB
Line 
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 "unpacker.h"
8#include "cr_error.h"
9#include "cr_protocol.h"
10#include "cr_mem.h"
11#include "cr_version.h"
12
13#if defined( GL_EXT_texture3D )
14void crUnpackTexImage3DEXT( void )
15{
16 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
17 GLint level = READ_DATA( sizeof( int ) + 4, GLint );
18 GLenum internalformat = READ_DATA( sizeof( int ) + 8, GLint );
19 GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
20 GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei );
21 GLsizei depth = READ_DATA( sizeof( int ) + 20, GLsizei );
22 GLint border = READ_DATA( sizeof( int ) + 24, GLint );
23 GLenum format = READ_DATA( sizeof( int ) + 28, GLenum );
24 GLenum type = READ_DATA( sizeof( int ) + 32, GLenum );
25 int is_null = READ_DATA( sizeof( int ) + 36, int );
26 GLvoid *pixels;
27
28 if ( is_null )
29 pixels = NULL;
30 else
31 pixels = DATA_POINTER( sizeof( int ) + 40, GLvoid );
32
33 cr_unpackDispatch.TexImage3DEXT(target, level, internalformat, width,
34 height, depth, border, format, type,
35 pixels);
36 INCR_VAR_PTR();
37}
38#endif /* GL_EXT_texture3D */
39
40#if defined( CR_OPENGL_VERSION_1_2 )
41void crUnpackTexImage3D( void )
42{
43 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
44 GLint level = READ_DATA( sizeof( int ) + 4, GLint );
45 GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint );
46 GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
47 GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei );
48 GLsizei depth = READ_DATA( sizeof( int ) + 20, GLsizei );
49 GLint border = READ_DATA( sizeof( int ) + 24, GLint );
50 GLenum format = READ_DATA( sizeof( int ) + 28, GLenum );
51 GLenum type = READ_DATA( sizeof( int ) + 32, GLenum );
52 int is_null = READ_DATA( sizeof( int ) + 36, int );
53 GLvoid *pixels;
54
55 if ( is_null )
56 pixels = NULL;
57 else
58 pixels = DATA_POINTER( sizeof( int ) + 40, GLvoid );
59
60 cr_unpackDispatch.TexImage3D( target, level, internalformat, width, height,
61 depth, border, format, type, pixels );
62 INCR_VAR_PTR();
63}
64#endif /* CR_OPENGL_VERSION_1_2 */
65
66void crUnpackTexImage2D( void )
67{
68 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
69 GLint level = READ_DATA( sizeof( int ) + 4, GLint );
70 GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint );
71 GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
72 GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei );
73 GLint border = READ_DATA( sizeof( int ) + 20, GLint );
74 GLenum format = READ_DATA( sizeof( int ) + 24, GLenum );
75 GLenum type = READ_DATA( sizeof( int ) + 28, GLenum );
76 int is_null = READ_DATA( sizeof( int ) + 32, int );
77 GLvoid *pixels;
78
79 if ( is_null )
80 pixels = NULL;
81 else
82 pixels = DATA_POINTER( sizeof( int ) + 36, GLvoid );
83
84 cr_unpackDispatch.TexImage2D( target, level, internalformat, width, height,
85 border, format, type, pixels );
86 INCR_VAR_PTR();
87}
88
89void crUnpackTexImage1D( void )
90{
91 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
92 GLint level = READ_DATA( sizeof( int ) + 4, GLint );
93 GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint );
94 GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
95 GLint border = READ_DATA( sizeof( int ) + 16, GLint );
96 GLenum format = READ_DATA( sizeof( int ) + 20, GLenum );
97 GLenum type = READ_DATA( sizeof( int ) + 24, GLenum );
98 int is_null = READ_DATA( sizeof( int ) + 28, int );
99 GLvoid *pixels;
100
101 if ( is_null )
102 pixels = NULL;
103 else
104 pixels = DATA_POINTER( sizeof( int ) + 32, GLvoid );
105
106 cr_unpackDispatch.TexImage1D( target, level, internalformat, width, border,
107 format, type, pixels );
108 INCR_VAR_PTR();
109}
110
111void crUnpackDeleteTextures( void )
112{
113 GLsizei n = READ_DATA( sizeof( int ) + 0, GLsizei );
114 GLuint *textures = DATA_POINTER( sizeof( int ) + 4, GLuint );
115
116 cr_unpackDispatch.DeleteTextures( n, textures );
117 INCR_VAR_PTR();
118}
119
120
121void crUnpackPrioritizeTextures( void )
122{
123 GLsizei n = READ_DATA( sizeof( int ) + 0, GLsizei );
124 GLuint *textures = DATA_POINTER( sizeof( int ) + 4, GLuint );
125 GLclampf *priorities = DATA_POINTER( sizeof( int ) + 4 + n*sizeof( GLuint ),
126 GLclampf );
127
128 cr_unpackDispatch.PrioritizeTextures( n, textures, priorities );
129 INCR_VAR_PTR();
130}
131
132void crUnpackTexParameterfv( void )
133{
134 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
135 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
136 GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
137
138 cr_unpackDispatch.TexParameterfv( target, pname, params );
139 INCR_VAR_PTR();
140}
141
142void crUnpackTexParameteriv( void )
143{
144 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
145 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
146 GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
147
148 cr_unpackDispatch.TexParameteriv( target, pname, params );
149 INCR_VAR_PTR();
150}
151
152void crUnpackTexParameterf( void )
153{
154 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
155 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
156 GLfloat param = READ_DATA( sizeof( int ) + 8, GLfloat );
157
158 cr_unpackDispatch.TexParameterf( target, pname, param );
159 INCR_VAR_PTR();
160}
161
162void crUnpackTexParameteri( void )
163{
164 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
165 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
166 GLint param = READ_DATA( sizeof( int ) + 8, GLint );
167
168 cr_unpackDispatch.TexParameteri( target, pname, param );
169 INCR_VAR_PTR();
170}
171
172#if defined(CR_OPENGL_VERSION_1_2)
173void crUnpackTexSubImage3D( void )
174{
175 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
176 GLint level = READ_DATA( sizeof( int ) + 4, GLint );
177 GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint );
178 GLint yoffset = READ_DATA( sizeof( int ) + 12, GLint );
179 GLint zoffset = READ_DATA( sizeof( int ) + 16, GLint );
180 GLsizei width = READ_DATA( sizeof( int ) + 20, GLsizei );
181 GLsizei height = READ_DATA( sizeof( int ) + 24, GLsizei );
182 GLsizei depth = READ_DATA( sizeof( int ) + 28, GLsizei );
183 GLenum format = READ_DATA( sizeof( int ) + 32, GLenum );
184 GLenum type = READ_DATA( sizeof( int ) + 36, GLenum );
185 GLvoid *pixels = DATA_POINTER( sizeof( int ) + 40, GLvoid );
186
187 cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
188 cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
189 cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
190 cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
191
192 cr_unpackDispatch.TexSubImage3D(target, level, xoffset, yoffset, zoffset,
193 width, height, depth, format, type, pixels);
194 INCR_VAR_PTR();
195}
196#endif /* CR_OPENGL_VERSION_1_2 */
197
198void crUnpackTexSubImage2D( void )
199{
200 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
201 GLint level = READ_DATA( sizeof( int ) + 4, GLint );
202 GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint );
203 GLint yoffset = READ_DATA( sizeof( int ) + 12, GLint );
204 GLsizei width = READ_DATA( sizeof( int ) + 16, GLsizei );
205 GLsizei height = READ_DATA( sizeof( int ) + 20, GLsizei );
206 GLenum format = READ_DATA( sizeof( int ) + 24, GLenum );
207 GLenum type = READ_DATA( sizeof( int ) + 28, GLenum );
208 GLvoid *pixels = DATA_POINTER( sizeof( int ) + 32, GLvoid );
209
210 cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
211 cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
212 cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
213 cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
214
215 cr_unpackDispatch.TexSubImage2D( target, level, xoffset, yoffset, width,
216 height, format, type, pixels );
217 INCR_VAR_PTR();
218}
219
220void crUnpackTexSubImage1D( void )
221{
222 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
223 GLint level = READ_DATA( sizeof( int ) + 4, GLint );
224 GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint );
225 GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
226 GLenum format = READ_DATA( sizeof( int ) + 16, GLenum );
227 GLenum type = READ_DATA( sizeof( int ) + 20, GLenum );
228 GLvoid *pixels = DATA_POINTER( sizeof( int ) + 24, GLvoid );
229
230 cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
231 cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
232 cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
233 cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
234
235 cr_unpackDispatch.TexSubImage1D( target, level, xoffset, width, format,
236 type, pixels );
237 INCR_VAR_PTR();
238}
239
240
241void crUnpackTexEnvfv( void )
242{
243 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
244 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
245 GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
246
247 cr_unpackDispatch.TexEnvfv( target, pname, params );
248 INCR_VAR_PTR();
249}
250
251void crUnpackTexEnviv( void )
252{
253 GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
254 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
255 GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
256
257 cr_unpackDispatch.TexEnviv( target, pname, params );
258 INCR_VAR_PTR();
259}
260
261#define DATA_POINTER_DOUBLE( offset )
262
263void crUnpackTexGendv( void )
264{
265 GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum );
266 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
267 GLdouble params[4];
268 unsigned int n_param = READ_DATA( 0, int ) - ( sizeof(int) + 8 );
269
270 if ( n_param > sizeof(params) )
271 crError( "crUnpackTexGendv: n_param=%d, expected <= %d\n", n_param,
272 (unsigned int)sizeof(params) );
273 crMemcpy( params, DATA_POINTER( sizeof( int ) + 8, GLdouble ), n_param );
274
275 cr_unpackDispatch.TexGendv( coord, pname, params );
276 INCR_VAR_PTR();
277}
278
279void crUnpackTexGenfv( void )
280{
281 GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum );
282 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
283 GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
284
285 cr_unpackDispatch.TexGenfv( coord, pname, params );
286 INCR_VAR_PTR();
287}
288
289void crUnpackTexGeniv( void )
290{
291 GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum );
292 GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
293 GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
294
295 cr_unpackDispatch.TexGeniv( coord, pname, params );
296 INCR_VAR_PTR();
297}
298
299void crUnpackExtendAreTexturesResident( void )
300{
301 GLsizei n = READ_DATA( 8, GLsizei );
302 const GLuint *textures = DATA_POINTER( 12, const GLuint );
303 SET_RETURN_PTR(12 + n * sizeof(GLuint));
304 SET_WRITEBACK_PTR(20 + n * sizeof(GLuint));
305 (void) cr_unpackDispatch.AreTexturesResident( n, textures, NULL );
306}
307
308
309void crUnpackExtendCompressedTexImage3DARB( void )
310{
311 GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum );
312 GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint );
313 GLenum internalformat = READ_DATA( 4 + sizeof(int) + 8, GLenum );
314 GLsizei width = READ_DATA( 4 + sizeof(int) + 12, GLsizei );
315 GLsizei height = READ_DATA( 4 + sizeof(int) + 16, GLsizei );
316 GLsizei depth = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
317 GLint border = READ_DATA( 4 + sizeof(int) + 24, GLint );
318 GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 28, GLsizei );
319 int is_null = READ_DATA( 4 + sizeof(int) + 32, int );
320 GLvoid *pixels;
321
322 if( is_null )
323 pixels = NULL;
324 else
325 pixels = DATA_POINTER( 4 + sizeof(int) + 36, GLvoid );
326
327 cr_unpackDispatch.CompressedTexImage3DARB(target, level, internalformat,
328 width, height, depth, border,
329 imagesize, pixels);
330}
331
332
333void crUnpackExtendCompressedTexImage2DARB( void )
334{
335 GLenum target = READ_DATA( 4 + sizeof( int ) + 0, GLenum );
336 GLint level = READ_DATA( 4 + sizeof( int ) + 4, GLint );
337 GLenum internalformat = READ_DATA( 4 + sizeof( int ) + 8, GLenum );
338 GLsizei width = READ_DATA( 4 + sizeof( int ) + 12, GLsizei );
339 GLsizei height = READ_DATA( 4 + sizeof( int ) + 16, GLsizei );
340 GLint border = READ_DATA( 4 + sizeof( int ) + 20, GLint );
341 GLsizei imagesize = READ_DATA( 4 + sizeof( int ) + 24, GLsizei );
342 int is_null = READ_DATA( 4 + sizeof( int ) + 28, int );
343 GLvoid *pixels;
344
345 if ( is_null )
346 pixels = NULL;
347 else
348 pixels = DATA_POINTER( 4 + sizeof( int ) + 32, GLvoid );
349
350 cr_unpackDispatch.CompressedTexImage2DARB( target, level, internalformat,
351 width, height, border, imagesize,
352 pixels );
353}
354
355
356void crUnpackExtendCompressedTexImage1DARB( void )
357{
358 GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum );
359 GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint );
360 GLenum internalformat = READ_DATA( 4 + sizeof(int) + 8, GLenum );
361 GLsizei width = READ_DATA( 4 + sizeof(int) + 12, GLsizei );
362 GLint border = READ_DATA( 4 + sizeof(int) + 16, GLint );
363 GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
364 int is_null = READ_DATA( 4 + sizeof(int) + 24, int );
365 GLvoid *pixels;
366
367 if( is_null )
368 pixels = NULL;
369 else
370 pixels = DATA_POINTER( 4 + sizeof(int) + 28, GLvoid );
371
372 cr_unpackDispatch.CompressedTexImage1DARB(target, level, internalformat,
373 width, border, imagesize, pixels);
374}
375
376
377void crUnpackExtendCompressedTexSubImage3DARB( void )
378{
379 GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum );
380 GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint );
381 GLint xoffset = READ_DATA( 4 + sizeof(int) + 8, GLint );
382 GLint yoffset = READ_DATA( 4 + sizeof(int) + 12, GLint );
383 GLint zoffset = READ_DATA( 4 + sizeof(int) + 16, GLint );
384 GLsizei width = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
385 GLsizei height = READ_DATA( 4 + sizeof(int) + 24, GLsizei );
386 GLsizei depth = READ_DATA( 4 + sizeof(int) + 28, GLsizei );
387 GLenum format = READ_DATA( 4 + sizeof(int) + 32, GLenum );
388 GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 36, GLsizei );
389 int is_null = READ_DATA( 4 + sizeof(int) + 40, int );
390 GLvoid *pixels;
391
392 if( is_null )
393 pixels = NULL;
394 else
395 pixels = DATA_POINTER( 4 + sizeof(int) + 44, GLvoid );
396
397 cr_unpackDispatch.CompressedTexSubImage3DARB(target, level, xoffset,
398 yoffset, zoffset, width,
399 height, depth, format,
400 imagesize, pixels);
401}
402
403
404void crUnpackExtendCompressedTexSubImage2DARB( void )
405{
406 GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum );
407 GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint );
408 GLint xoffset = READ_DATA( 4 + sizeof(int) + 8, GLint );
409 GLint yoffset = READ_DATA( 4 + sizeof(int) + 12, GLint );
410 GLsizei width = READ_DATA( 4 + sizeof(int) + 16, GLsizei );
411 GLsizei height = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
412 GLenum format = READ_DATA( 4 + sizeof(int) + 24, GLenum );
413 GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 28, GLsizei );
414 int is_null = READ_DATA( 4 + sizeof(int) + 32, int );
415 GLvoid *pixels;
416
417 if( is_null )
418 pixels = NULL;
419 else
420 pixels = DATA_POINTER( 4 + sizeof(int) + 36, GLvoid );
421
422 cr_unpackDispatch.CompressedTexSubImage2DARB(target, level, xoffset,
423 yoffset, width, height,
424 format, imagesize, pixels);
425}
426
427
428void crUnpackExtendCompressedTexSubImage1DARB( void )
429{
430 GLenum target = READ_DATA( 4 + sizeof(int) + 0, GLenum );
431 GLint level = READ_DATA( 4 + sizeof(int) + 4, GLint );
432 GLint xoffset = READ_DATA( 4 + sizeof(int) + 8, GLint );
433 GLsizei width = READ_DATA( 4 + sizeof(int) + 12, GLsizei );
434 GLenum format = READ_DATA( 4 + sizeof(int) + 16, GLenum );
435 GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
436 int is_null = READ_DATA( 4 + sizeof(int) + 24, int );
437 GLvoid *pixels;
438
439 if( is_null )
440 pixels = NULL;
441 else
442 pixels = DATA_POINTER( 4 + sizeof(int) + 28, GLvoid );
443
444 cr_unpackDispatch.CompressedTexSubImage1DARB(target, level, xoffset, width,
445 format, imagesize, pixels);
446}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette