VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.c@ 28197

Last change on this file since 28197 was 27983, checked in by vboxsync, 15 years ago

crOpenGL: fix 32/64bit bug

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.6 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 "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
14void SERVER_DISPATCH_APIENTRY
15crServerDispatchGetTexImage(GLenum target, GLint level, GLenum format,
16 GLenum type, GLvoid * pixels)
17{
18 GLsizei width, height, depth, size;
19 GLvoid *buffer = NULL;
20
21
22#ifdef CR_ARB_pixel_buffer_object
23 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
24 {
25 GLvoid *pbo_offset;
26
27 /*pixels are actualy a pointer to location of 8byte network pointer in hgcm buffer
28 regarless of guest/host bitness we're using only 4lower bytes as there're no
29 pbo>4gb (yet?)
30 */
31 pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)pixels));
32
33 cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, pbo_offset);
34
35 return;
36 }
37#endif
38
39 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
40 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
41 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
42
43 size = crTextureSize(format, type, width, height, depth);
44
45 if (size && (buffer = crAlloc(size))) {
46 /* Note, the other pixel PACK parameters (default values) should
47 * be OK at this point.
48 */
49 cr_server.head_spu->dispatch_table.PixelStorei(GL_PACK_ALIGNMENT, 1);
50 cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, buffer);
51 crServerReturnValue( buffer, size );
52 crFree(buffer);
53 }
54 else {
55 /* need to return _something_ to avoid blowing up */
56 GLuint dummy = 0;
57 crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
58 }
59}
60
61
62#if CR_ARB_texture_compression
63
64void SERVER_DISPATCH_APIENTRY
65crServerDispatchGetCompressedTexImageARB(GLenum target, GLint level,
66 GLvoid *img)
67{
68 GLint size;
69 GLvoid *buffer=NULL;
70
71#ifdef CR_ARB_pixel_buffer_object
72 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
73 {
74 GLvoid *pbo_offset;
75
76 pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)img));
77
78 cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, pbo_offset);
79
80 return;
81 }
82#endif
83
84 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size);
85
86 if (size && (buffer = crAlloc(size))) {
87 /* XXX the pixel PACK parameter should be OK at this point */
88 cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, buffer);
89 crServerReturnValue( buffer, size );
90 crFree(buffer);
91 }
92 else {
93 /* need to return _something_ to avoid blowing up */
94 GLuint dummy = 0;
95 crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
96 }
97}
98
99#endif /* CR_ARB_texture_compression */
100
101void SERVER_DISPATCH_APIENTRY crServerDispatchGetPolygonStipple( GLubyte * mask )
102{
103#ifdef CR_ARB_pixel_buffer_object
104 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
105 {
106 GLvoid *pbo_offset;
107
108 pbo_offset = (GLubyte*) ((uintptr_t) *((GLint*)mask));
109
110 cr_server.head_spu->dispatch_table.GetPolygonStipple(pbo_offset);
111 }
112 else
113#endif
114 {
115 GLubyte local_mask[128];
116
117 cr_server.head_spu->dispatch_table.GetPolygonStipple( local_mask );
118 crServerReturnValue( &(local_mask[0]), 128*sizeof(GLubyte) );
119 }
120}
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