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 | void PACK_APIENTRY crPackNewList( GLuint list, GLenum mode )
|
---|
62 | {
|
---|
63 | CR_GET_PACKER_CONTEXT(pc);
|
---|
64 | unsigned char *data_ptr;
|
---|
65 | (void) pc;
|
---|
66 |
|
---|
67 | if (CR_CMDBLOCK_IS_STARTED(pc, CRPACKBLOCKSTATE_OP_NEWLIST))
|
---|
68 | {
|
---|
69 | WARN(("recursive NewList?"));
|
---|
70 | return;
|
---|
71 | }
|
---|
72 |
|
---|
73 | CR_CMDBLOCK_BEGIN( pc, CRPACKBLOCKSTATE_OP_NEWLIST );
|
---|
74 | CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, 16, GL_FALSE );
|
---|
75 | WRITE_DATA( 0, GLint, 16 );
|
---|
76 | WRITE_DATA( 4, GLenum, CR_NEWLIST_EXTEND_OPCODE );
|
---|
77 | WRITE_DATA( 8, GLuint, list );
|
---|
78 | WRITE_DATA( 12, GLenum, mode );
|
---|
79 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
80 | pc->buffer.in_List = GL_TRUE;
|
---|
81 | pc->buffer.holds_List = GL_TRUE;
|
---|
82 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
83 | }
|
---|
84 |
|
---|
85 | void PACK_APIENTRY crPackEndList( void )
|
---|
86 | {
|
---|
87 | CR_GET_PACKER_CONTEXT(pc);
|
---|
88 | unsigned char *data_ptr;
|
---|
89 | CR_GET_BUFFERED_POINTER( pc, 8 );
|
---|
90 | WRITE_DATA( 0, GLint, 8 );
|
---|
91 | WRITE_DATA( 4, GLenum, CR_ENDLIST_EXTEND_OPCODE );
|
---|
92 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
93 | pc->buffer.in_List = GL_FALSE;
|
---|
94 | CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_NEWLIST );
|
---|
95 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
96 | }
|
---|