1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "packer.h"
#include "cr_error.h"
#include "cr_mem.h"
static int __gl_CallListsNumBytes( GLenum type )
{
switch( type )
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_2_BYTES:
return 1;
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_3_BYTES:
return 2;
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
case GL_4_BYTES:
return 4;
default:
return -1;
}
}
void PACK_APIENTRY crPackCallLists(GLint n, GLenum type,
const GLvoid *lists )
{
unsigned char *data_ptr;
int packet_length;
int num_bytes = __gl_CallListsNumBytes( type ) * n;
if (num_bytes < 0)
{
__PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
"crPackCallLists(bad type)" );
return;
}
packet_length =
sizeof( n ) +
sizeof( type ) +
num_bytes;
data_ptr = (unsigned char *) crPackAlloc( packet_length );
WRITE_DATA( 0, GLint, n );
WRITE_DATA( 4, GLenum, type );
crMemcpy( data_ptr + 8, lists, num_bytes );
crHugePacket( CR_CALLLISTS_OPCODE, data_ptr );
crPackFree( data_ptr );
}
void PACK_APIENTRY crPackNewList( GLuint list, GLenum mode )
{
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
(void) pc;
if (CR_CMDBLOCK_IS_STARTED(pc, CRPACKBLOCKSTATE_OP_NEWLIST))
{
WARN(("recursive NewList?"));
return;
}
CR_CMDBLOCK_BEGIN( pc, CRPACKBLOCKSTATE_OP_NEWLIST );
CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, 16, GL_FALSE );
WRITE_DATA( 0, GLint, 16 );
WRITE_DATA( 4, GLenum, CR_NEWLIST_EXTEND_OPCODE );
WRITE_DATA( 8, GLuint, list );
WRITE_DATA( 12, GLenum, mode );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
pc->buffer.in_List = GL_TRUE;
pc->buffer.holds_List = GL_TRUE;
CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackEndList( void )
{
CR_GET_PACKER_CONTEXT(pc);
unsigned char *data_ptr;
CR_GET_BUFFERED_POINTER( pc, 8 );
WRITE_DATA( 0, GLint, 8 );
WRITE_DATA( 4, GLenum, CR_ENDLIST_EXTEND_OPCODE );
WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
pc->buffer.in_List = GL_FALSE;
CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_NEWLIST );
CR_UNLOCK_PACKER_CONTEXT(pc);
}
|