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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "packer.h"
#include "cr_opcodes.h"
#include "cr_error.h"
#include "cr_mem.h"
/* Note -- for these packets, the ustride and vstride are implicit,
* and are computed into the packet instead of copied.
*/
static int __gl_Map2NumComponents( GLenum target )
{
switch( target )
{
case GL_MAP2_VERTEX_3:
case GL_MAP2_NORMAL:
case GL_MAP2_TEXTURE_COORD_3:
return 3;
case GL_MAP2_VERTEX_4:
case GL_MAP2_COLOR_4:
case GL_MAP2_TEXTURE_COORD_4:
case GL_MAP1_VERTEX_ATTRIB0_4_NV:
case GL_MAP1_VERTEX_ATTRIB1_4_NV:
case GL_MAP1_VERTEX_ATTRIB2_4_NV:
case GL_MAP1_VERTEX_ATTRIB3_4_NV:
case GL_MAP1_VERTEX_ATTRIB4_4_NV:
case GL_MAP1_VERTEX_ATTRIB5_4_NV:
case GL_MAP1_VERTEX_ATTRIB6_4_NV:
case GL_MAP1_VERTEX_ATTRIB7_4_NV:
case GL_MAP1_VERTEX_ATTRIB8_4_NV:
case GL_MAP1_VERTEX_ATTRIB9_4_NV:
case GL_MAP1_VERTEX_ATTRIB10_4_NV:
case GL_MAP1_VERTEX_ATTRIB11_4_NV:
case GL_MAP1_VERTEX_ATTRIB12_4_NV:
case GL_MAP1_VERTEX_ATTRIB13_4_NV:
case GL_MAP1_VERTEX_ATTRIB14_4_NV:
case GL_MAP1_VERTEX_ATTRIB15_4_NV:
case GL_MAP2_VERTEX_ATTRIB0_4_NV:
case GL_MAP2_VERTEX_ATTRIB1_4_NV:
case GL_MAP2_VERTEX_ATTRIB2_4_NV:
case GL_MAP2_VERTEX_ATTRIB3_4_NV:
case GL_MAP2_VERTEX_ATTRIB4_4_NV:
case GL_MAP2_VERTEX_ATTRIB5_4_NV:
case GL_MAP2_VERTEX_ATTRIB6_4_NV:
case GL_MAP2_VERTEX_ATTRIB7_4_NV:
case GL_MAP2_VERTEX_ATTRIB8_4_NV:
case GL_MAP2_VERTEX_ATTRIB9_4_NV:
case GL_MAP2_VERTEX_ATTRIB10_4_NV:
case GL_MAP2_VERTEX_ATTRIB11_4_NV:
case GL_MAP2_VERTEX_ATTRIB12_4_NV:
case GL_MAP2_VERTEX_ATTRIB13_4_NV:
case GL_MAP2_VERTEX_ATTRIB14_4_NV:
case GL_MAP2_VERTEX_ATTRIB15_4_NV:
return 4;
case GL_MAP2_INDEX:
case GL_MAP2_TEXTURE_COORD_1:
return 1;
case GL_MAP2_TEXTURE_COORD_2:
return 2;
default:
return -1;
}
}
static int __gl_Map1NumComponents( GLenum target )
{
switch( target )
{
case GL_MAP1_VERTEX_3:
case GL_MAP1_NORMAL:
case GL_MAP1_TEXTURE_COORD_3:
return 3;
case GL_MAP1_VERTEX_4:
case GL_MAP1_COLOR_4:
case GL_MAP1_TEXTURE_COORD_4:
return 4;
case GL_MAP1_INDEX:
case GL_MAP1_TEXTURE_COORD_1:
return 1;
case GL_MAP1_TEXTURE_COORD_2:
return 2;
default:
return -1;
}
}
void PACK_APIENTRY crPackMap2d(GLenum target, GLdouble u1,
GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2,
GLint vstride, GLint vorder, const GLdouble *points)
{
unsigned char *data_ptr;
int u,v;
GLdouble *dest_data, *src_data;
int packet_length =
sizeof( target ) +
sizeof( u1 ) +
sizeof( u2 ) +
sizeof( uorder ) +
sizeof( ustride ) +
sizeof( v1 ) +
sizeof( v2 ) +
sizeof( vorder ) +
sizeof( vstride );
int num_components = __gl_Map2NumComponents( target );
if (num_components < 0)
{
__PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
"crPackMap2d(bad target)" );
return;
}
packet_length += num_components*uorder*vorder*sizeof( *points );
data_ptr = (unsigned char *) crPackAlloc( packet_length );
WRITE_DATA( 0, GLenum, target );
WRITE_DOUBLE( 4, u1 );
WRITE_DOUBLE( 12, u2 );
WRITE_DATA( 20, GLint, num_components );
WRITE_DATA( 24, GLint, uorder );
WRITE_DOUBLE( 28, v1 );
WRITE_DOUBLE( 36, v2 );
WRITE_DATA( 44, GLint, num_components*uorder );
WRITE_DATA( 48, GLint, vorder );
dest_data = (GLdouble *) (data_ptr + 52);
src_data = (GLdouble *) points;
for (v = 0 ; v < vorder ; v++)
{
for (u = 0 ; u < uorder ; u++)
{
crMemcpy( dest_data, src_data, num_components * sizeof( *points ) );
dest_data += num_components;
src_data += ustride;
}
src_data += vstride - ustride*uorder;
}
crHugePacket( CR_MAP2D_OPCODE, data_ptr );
crPackFree( data_ptr );
}
void PACK_APIENTRY crPackMap2f(GLenum target, GLfloat u1,
GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2,
GLint vstride, GLint vorder, const GLfloat *points)
{
unsigned char *data_ptr;
int u,v;
GLfloat *dest_data, *src_data;
int packet_length =
sizeof( target ) +
sizeof( u1 ) +
sizeof( u2 ) +
sizeof( uorder ) +
sizeof( ustride ) +
sizeof( v1 ) +
sizeof( v2 ) +
sizeof( vorder ) +
sizeof( vstride );
int num_components = __gl_Map2NumComponents( target );
if (num_components < 0)
{
__PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
"crPackMap2f(bad target)" );
return;
}
packet_length += num_components*uorder*vorder*sizeof( *points );
data_ptr = (unsigned char *) crPackAlloc( packet_length );
WRITE_DATA( 0, GLenum, target );
WRITE_DATA( 4, GLfloat, u1 );
WRITE_DATA( 8, GLfloat, u2 );
WRITE_DATA( 12, GLint, num_components );
WRITE_DATA( 16, GLint, uorder );
WRITE_DATA( 20, GLfloat, v1 );
WRITE_DATA( 24, GLfloat, v2 );
WRITE_DATA( 28, GLint, num_components*uorder );
WRITE_DATA( 32, GLint, vorder );
dest_data = (GLfloat *) (data_ptr + 36);
src_data = (GLfloat *) points;
for (v = 0 ; v < vorder ; v++)
{
for (u = 0 ; u < uorder ; u++)
{
crMemcpy( dest_data, src_data, num_components * sizeof( *points ) );
dest_data += num_components;
src_data += ustride;
}
src_data += vstride - ustride*uorder;
}
crHugePacket( CR_MAP2F_OPCODE, data_ptr );
crPackFree( data_ptr );
}
void PACK_APIENTRY crPackMap1d( GLenum target, GLdouble u1,
GLdouble u2, GLint stride, GLint order, const GLdouble *points )
{
unsigned char *data_ptr;
int packet_length =
sizeof( target ) +
sizeof( u1 ) +
sizeof( u2 ) +
sizeof( stride ) +
sizeof( order );
int num_components = __gl_Map1NumComponents( target );
GLdouble *src_data, *dest_data;
int u;
if (num_components < 0)
{
__PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
"crPackMap1d(bad target)" );
return;
}
packet_length += num_components * order * sizeof( *points );
data_ptr = (unsigned char *) crPackAlloc( packet_length );
WRITE_DATA( 0, GLenum, target );
WRITE_DOUBLE( 4, u1 );
WRITE_DOUBLE( 12, u2 );
WRITE_DATA( 20, GLint, num_components );
WRITE_DATA( 24, GLint, order );
dest_data = (GLdouble *) (data_ptr + 28);
src_data = (GLdouble *) points;
for (u = 0 ; u < order ; u++)
{
crMemcpy( dest_data, src_data, num_components * sizeof( *points ) );
dest_data += num_components;
src_data += stride;
}
crHugePacket( CR_MAP1D_OPCODE, data_ptr );
crPackFree( data_ptr );
}
void PACK_APIENTRY crPackMap1f( GLenum target, GLfloat u1,
GLfloat u2, GLint stride, GLint order, const GLfloat *points )
{
unsigned char *data_ptr;
int packet_length =
sizeof( target ) +
sizeof( u1 ) +
sizeof( u2 ) +
sizeof( stride ) +
sizeof( order );
int num_components = __gl_Map1NumComponents( target );
GLfloat *src_data, *dest_data;
int u;
if (num_components < 0)
{
__PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
"crPackMap1f(bad target)" );
return;
}
packet_length += num_components * order * sizeof( *points );
data_ptr = (unsigned char *) crPackAlloc( packet_length );
WRITE_DATA( 0, GLenum, target );
WRITE_DATA( 4, GLfloat, u1 );
WRITE_DATA( 8, GLfloat, u2 );
WRITE_DATA( 12, GLint, num_components );
WRITE_DATA( 16, GLint, order );
dest_data = (GLfloat *) (data_ptr + 20);
src_data = (GLfloat *) points;
for (u = 0 ; u < order ; u++)
{
crMemcpy( dest_data, src_data, num_components * sizeof( *points ) );
dest_data += num_components;
src_data += stride;
}
crHugePacket( CR_MAP1F_OPCODE, data_ptr );
crPackFree( data_ptr );
}
|