VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c@ 18950

Last change on this file since 18950 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: 7.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#include "cr_packfunctions.h"
7#include "cr_glstate.h"
8#include "cr_pixeldata.h"
9#include "cr_version.h"
10#include "packspu.h"
11#include "packspu_proto.h"
12
13void PACKSPU_APIENTRY packspu_PixelStoref( GLenum pname, GLfloat param )
14{
15 /* NOTE: we do not send pixel store parameters to the server!
16 * When we pack a glDrawPixels or glTexImage2D image we interpret
17 * the user's pixel store parameters at that time and pack the
18 * image in a canonical layout (see util/pixel.c).
19 */
20 crStatePixelStoref( pname, param );
21}
22
23void PACKSPU_APIENTRY packspu_PixelStorei( GLenum pname, GLint param )
24{
25 crStatePixelStorei( pname, param );
26}
27
28void PACKSPU_APIENTRY packspu_DrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
29{
30 GET_THREAD(thread);
31 ContextInfo *ctx = thread->currentContext;
32 CRClientState *clientState = &(ctx->clientState->client);
33 if (pack_spu.swap)
34 crPackDrawPixelsSWAP( width, height, format, type, pixels, &(clientState->unpack) );
35 else
36 crPackDrawPixels( width, height, format, type, pixels, &(clientState->unpack) );
37}
38
39void PACKSPU_APIENTRY packspu_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels )
40{
41 GET_THREAD(thread);
42 ContextInfo *ctx = thread->currentContext;
43 CRClientState *clientState = &(ctx->clientState->client);
44 int writeback;
45 pack_spu.ReadPixels++;
46 if (pack_spu.swap)
47 crPackReadPixelsSWAP( x, y, width, height, format, type, pixels,
48 &(clientState->pack), &writeback );
49 else
50 crPackReadPixels( x, y, width, height, format, type, pixels,
51 &(clientState->pack), &writeback );
52 packspuFlush( (void *) thread );
53 while (pack_spu.ReadPixels)
54 crNetRecv();
55}
56
57void PACKSPU_APIENTRY packspu_CopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type )
58{
59 GET_THREAD(thread);
60 if (pack_spu.swap)
61 crPackCopyPixelsSWAP( x, y, width, height, type );
62 else
63 crPackCopyPixels( x, y, width, height, type );
64 /* XXX why flush here? */
65 packspuFlush( (void *) thread );
66}
67
68void PACKSPU_APIENTRY packspu_Bitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap )
69{
70 GET_CONTEXT(ctx);
71 CRClientState *clientState = &(ctx->clientState->client);
72 if (pack_spu.swap)
73 crPackBitmapSWAP( width, height, xorig, yorig, xmove, ymove, bitmap, &(clientState->unpack) );
74 else
75 crPackBitmap( width, height, xorig, yorig, xmove, ymove, bitmap, &(clientState->unpack) );
76}
77
78void PACKSPU_APIENTRY packspu_TexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
79{
80 GET_CONTEXT(ctx);
81 CRClientState *clientState = &(ctx->clientState->client);
82 if (pack_spu.swap)
83 crPackTexImage1DSWAP( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
84 else
85 crPackTexImage1D( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
86}
87
88void PACKSPU_APIENTRY packspu_TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
89{
90 GET_CONTEXT(ctx);
91 CRClientState *clientState = &(ctx->clientState->client);
92 if (pack_spu.swap)
93 crPackTexImage2DSWAP( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
94 else
95 crPackTexImage2D( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
96}
97
98#ifdef GL_EXT_texture3D
99void PACKSPU_APIENTRY packspu_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
100{
101 GET_CONTEXT(ctx);
102 CRClientState *clientState = &(ctx->clientState->client);
103 if (pack_spu.swap)
104 crPackTexImage3DEXTSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
105 else
106 crPackTexImage3DEXT( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
107}
108#endif
109
110#ifdef CR_OPENGL_VERSION_1_2
111void PACKSPU_APIENTRY packspu_TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
112{
113 GET_CONTEXT(ctx);
114 CRClientState *clientState = &(ctx->clientState->client);
115 if (pack_spu.swap)
116 crPackTexImage3DSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
117 else
118 crPackTexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
119}
120#endif /* CR_OPENGL_VERSION_1_2 */
121
122void PACKSPU_APIENTRY packspu_TexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
123{
124 GET_CONTEXT(ctx);
125 CRClientState *clientState = &(ctx->clientState->client);
126 if (pack_spu.swap)
127 crPackTexSubImage1DSWAP( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
128 else
129 crPackTexSubImage1D( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
130}
131
132void PACKSPU_APIENTRY packspu_TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
133{
134 GET_CONTEXT(ctx);
135 CRClientState *clientState = &(ctx->clientState->client);
136 if (pack_spu.swap)
137 crPackTexSubImage2DSWAP( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
138 else
139 crPackTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
140}
141
142#ifdef CR_OPENGL_VERSION_1_2
143void PACKSPU_APIENTRY packspu_TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels )
144{
145 GET_CONTEXT(ctx);
146 CRClientState *clientState = &(ctx->clientState->client);
147 if (pack_spu.swap)
148 crPackTexSubImage3DSWAP( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
149 else
150 crPackTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
151}
152#endif /* CR_OPENGL_VERSION_1_2 */
153
154void PACKSPU_APIENTRY packspu_ZPixCR( GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum ztype, GLint zparm, GLint length, const GLvoid *pixels )
155{
156 GET_CONTEXT(ctx);
157 CRClientState *clientState = &(ctx->clientState->client);
158 if (pack_spu.swap)
159 crPackZPixCRSWAP( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
160 else
161 crPackZPixCR( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
162}
163
164void PACKSPU_APIENTRY packspu_GetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels)
165{
166 GET_THREAD(thread);
167 ContextInfo *ctx = thread->currentContext;
168 CRClientState *clientState = &(ctx->clientState->client);
169 int writeback = 1;
170 /* XXX note: we're not observing the pixel pack parameters here.
171 * To do so, we'd have to allocate a temporary image buffer (how large???)
172 * and copy the image to the user's buffer using the pixel pack params.
173 */
174 if (pack_spu.swap)
175 crPackGetTexImageSWAP( target, level, format, type, pixels, &(clientState->pack), &writeback );
176 else
177 crPackGetTexImage( target, level, format, type, pixels, &(clientState->pack), &writeback );
178 packspuFlush( (void *) thread );
179 while (writeback)
180 crNetRecv();
181}
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