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_error.h"
|
---|
9 | #include "cr_mem.h"
|
---|
10 |
|
---|
11 | static int __gl_CallListsNumBytes( GLenum type )
|
---|
12 | {
|
---|
13 | switch( type )
|
---|
14 | {
|
---|
15 | case GL_BYTE:
|
---|
16 | case GL_UNSIGNED_BYTE:
|
---|
17 | case GL_2_BYTES:
|
---|
18 | return 1;
|
---|
19 | case GL_SHORT:
|
---|
20 | case GL_UNSIGNED_SHORT:
|
---|
21 | case GL_3_BYTES:
|
---|
22 | return 2;
|
---|
23 | case GL_INT:
|
---|
24 | case GL_UNSIGNED_INT:
|
---|
25 | case GL_FLOAT:
|
---|
26 | case GL_4_BYTES:
|
---|
27 | return 4;
|
---|
28 | default:
|
---|
29 | return -1;
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | void PACK_APIENTRY crPackCallLists(GLint n, GLenum type,
|
---|
34 | const GLvoid *lists )
|
---|
35 | {
|
---|
36 | unsigned char *data_ptr;
|
---|
37 | int packet_length;
|
---|
38 |
|
---|
39 | int num_bytes = __gl_CallListsNumBytes( type ) * n;
|
---|
40 | if (num_bytes < 0)
|
---|
41 | {
|
---|
42 | __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
43 | "crPackCallLists(bad type)" );
|
---|
44 | return;
|
---|
45 | }
|
---|
46 |
|
---|
47 | packet_length =
|
---|
48 | sizeof( n ) +
|
---|
49 | sizeof( type ) +
|
---|
50 | num_bytes;
|
---|
51 |
|
---|
52 | data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
53 | WRITE_DATA( 0, GLint, n );
|
---|
54 | WRITE_DATA( 4, GLenum, type );
|
---|
55 | crMemcpy( data_ptr + 8, lists, num_bytes );
|
---|
56 |
|
---|
57 | crHugePacket( CR_CALLLISTS_OPCODE, data_ptr );
|
---|
58 | crPackFree( data_ptr );
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 | void PACK_APIENTRY crPackNewList( GLuint list, GLenum mode )
|
---|
64 | {
|
---|
65 | CR_GET_PACKER_CONTEXT(pc);
|
---|
66 | unsigned char *data_ptr;
|
---|
67 | (void) pc;
|
---|
68 | CR_GET_BUFFERED_POINTER( pc, 16 );
|
---|
69 | WRITE_DATA( 0, GLint, 16 );
|
---|
70 | WRITE_DATA( 4, GLenum, CR_NEWLIST_EXTEND_OPCODE );
|
---|
71 | WRITE_DATA( 8, GLuint, list );
|
---|
72 | WRITE_DATA( 12, GLenum, mode );
|
---|
73 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
74 | pc->buffer.in_List = GL_TRUE;
|
---|
75 | pc->buffer.holds_List = GL_TRUE;
|
---|
76 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
77 | }
|
---|
78 |
|
---|
79 | void PACK_APIENTRY crPackEndList( void )
|
---|
80 | {
|
---|
81 | CR_GET_PACKER_CONTEXT(pc);
|
---|
82 | unsigned char *data_ptr;
|
---|
83 | CR_GET_BUFFERED_POINTER( pc, 8 );
|
---|
84 | WRITE_DATA( 0, GLint, 8 );
|
---|
85 | WRITE_DATA( 4, GLenum, CR_ENDLIST_EXTEND_OPCODE );
|
---|
86 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
87 | pc->buffer.in_List = GL_FALSE;
|
---|
88 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
89 | }
|
---|