VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_pixelmap.c@ 39847

Last change on this file since 39847 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: 1.9 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 "packer.h"
8#include "cr_mem.h"
9#include "cr_glstate.h"
10
11static unsigned char * __gl_HandlePixelMapData(GLenum map, GLsizei mapsize, int size_of_value, const GLvoid *values)
12{
13 int nodata = (values == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB);
14 int packet_length =
15 sizeof( map ) +
16 sizeof( mapsize ) + sizeof(int) + sizeof(GLint);
17 unsigned char *data_ptr;
18
19 if (!nodata)
20 {
21 packet_length += mapsize*size_of_value;
22 }
23
24 data_ptr = (unsigned char *) crPackAlloc( packet_length );
25
26 WRITE_DATA( 0, GLenum, map );
27 WRITE_DATA( 4, GLsizei, mapsize );
28 WRITE_DATA( 8, int, nodata);
29 WRITE_DATA( 12, GLint, (GLint)(uintptr_t)values);
30
31 if (!nodata)
32 {
33 crMemcpy( data_ptr + 16, values, mapsize*size_of_value );
34 }
35
36 return data_ptr;
37}
38
39void PACK_APIENTRY crPackPixelMapfv(GLenum map, GLsizei mapsize,
40 const GLfloat *values)
41{
42 unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values );
43
44 crHugePacket( CR_PIXELMAPFV_OPCODE, data_ptr );
45 crPackFree( data_ptr );
46}
47
48void PACK_APIENTRY crPackPixelMapuiv(GLenum map, GLsizei mapsize,
49 const GLuint *values)
50{
51 unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values );
52
53 crHugePacket( CR_PIXELMAPUIV_OPCODE, data_ptr );
54 crPackFree( data_ptr );
55}
56
57void PACK_APIENTRY crPackPixelMapusv(GLenum map, GLsizei mapsize,
58 const GLushort *values)
59{
60 unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values );
61
62 crHugePacket( CR_PIXELMAPUSV_OPCODE, data_ptr );
63 crPackFree( data_ptr );
64}
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