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 "chromium.h"
|
---|
8 | #include "cr_error.h"
|
---|
9 | #include "cr_mem.h"
|
---|
10 | #include "cr_pixeldata.h"
|
---|
11 | #include "server_dispatch.h"
|
---|
12 | #include "server.h"
|
---|
13 |
|
---|
14 | void SERVER_DISPATCH_APIENTRY
|
---|
15 | crServerDispatchGetTexImage(GLenum target, GLint level, GLenum format,
|
---|
16 | GLenum type, GLvoid * pixels)
|
---|
17 | {
|
---|
18 | GLsizei width, height, depth, size;
|
---|
19 | GLvoid *buffer = NULL;
|
---|
20 |
|
---|
21 | cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
|
---|
22 | cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
|
---|
23 | cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
|
---|
24 |
|
---|
25 | size = crTextureSize(format, type, width, height, depth);
|
---|
26 |
|
---|
27 | if (size && (buffer = crAlloc(size))) {
|
---|
28 | /* Note, the other pixel PACK parameters (default values) should
|
---|
29 | * be OK at this point.
|
---|
30 | */
|
---|
31 | cr_server.head_spu->dispatch_table.PixelStorei(GL_PACK_ALIGNMENT, 1);
|
---|
32 | cr_server.head_spu->dispatch_table.GetTexImage(target, level, format,
|
---|
33 | type, buffer);
|
---|
34 | crServerReturnValue( buffer, size );
|
---|
35 | crFree(buffer);
|
---|
36 | }
|
---|
37 | else {
|
---|
38 | /* need to return _something_ to avoid blowing up */
|
---|
39 | GLuint dummy = 0;
|
---|
40 | crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | #if CR_ARB_texture_compression
|
---|
46 |
|
---|
47 | void SERVER_DISPATCH_APIENTRY
|
---|
48 | crServerDispatchGetCompressedTexImageARB(GLenum target, GLint level,
|
---|
49 | GLvoid *img)
|
---|
50 | {
|
---|
51 | GLint size;
|
---|
52 | GLvoid *buffer=NULL;
|
---|
53 |
|
---|
54 | cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size);
|
---|
55 |
|
---|
56 | if (size && (buffer = crAlloc(size))) {
|
---|
57 | /* XXX the pixel PACK parameter should be OK at this point */
|
---|
58 | cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level,
|
---|
59 | buffer);
|
---|
60 | crServerReturnValue( buffer, size );
|
---|
61 | crFree(buffer);
|
---|
62 | }
|
---|
63 | else {
|
---|
64 | /* need to return _something_ to avoid blowing up */
|
---|
65 | GLuint dummy = 0;
|
---|
66 | crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | #endif /* CR_ARB_texture_compression */
|
---|