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 |
|
---|
11 | static 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 |
|
---|
39 | void 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 |
|
---|
48 | void 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 |
|
---|
57 | void 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 | }
|
---|