mesa: glArrayElement support for integer-valued arrays
[mesa.git] / src / mesa / main / api_arrayelt.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.1
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /* Author:
26 * Keith Whitwell <keith@tungstengraphics.com>
27 */
28
29 #include "glheader.h"
30 #include "api_arrayelt.h"
31 #include "bufferobj.h"
32 #include "context.h"
33 #include "imports.h"
34 #include "macros.h"
35 #include "main/dispatch.h"
36
37 typedef void (GLAPIENTRY *array_func)( const void * );
38
39 typedef struct {
40 const struct gl_client_array *array;
41 int offset;
42 } AEarray;
43
44 typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
45
46 typedef struct {
47 const struct gl_client_array *array;
48 attrib_func func;
49 GLuint index;
50 } AEattrib;
51
52 typedef struct {
53 AEarray arrays[32];
54 AEattrib attribs[VERT_ATTRIB_MAX + 1];
55 GLuint NewState;
56
57 struct gl_buffer_object *vbo[VERT_ATTRIB_MAX];
58 GLuint nr_vbos;
59 GLboolean mapped_vbos;
60
61 } AEcontext;
62
63 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
64
65
66 /*
67 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
68 * in the range [0, 7]. Luckily these type tokens are sequentially
69 * numbered in gl.h, except for GL_DOUBLE.
70 */
71 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
72
73
74 #if FEATURE_arrayelt
75
76
77 static const int ColorFuncs[2][8] = {
78 {
79 _gloffset_Color3bv,
80 _gloffset_Color3ubv,
81 _gloffset_Color3sv,
82 _gloffset_Color3usv,
83 _gloffset_Color3iv,
84 _gloffset_Color3uiv,
85 _gloffset_Color3fv,
86 _gloffset_Color3dv,
87 },
88 {
89 _gloffset_Color4bv,
90 _gloffset_Color4ubv,
91 _gloffset_Color4sv,
92 _gloffset_Color4usv,
93 _gloffset_Color4iv,
94 _gloffset_Color4uiv,
95 _gloffset_Color4fv,
96 _gloffset_Color4dv,
97 },
98 };
99
100 static const int VertexFuncs[3][8] = {
101 {
102 -1,
103 -1,
104 _gloffset_Vertex2sv,
105 -1,
106 _gloffset_Vertex2iv,
107 -1,
108 _gloffset_Vertex2fv,
109 _gloffset_Vertex2dv,
110 },
111 {
112 -1,
113 -1,
114 _gloffset_Vertex3sv,
115 -1,
116 _gloffset_Vertex3iv,
117 -1,
118 _gloffset_Vertex3fv,
119 _gloffset_Vertex3dv,
120 },
121 {
122 -1,
123 -1,
124 _gloffset_Vertex4sv,
125 -1,
126 _gloffset_Vertex4iv,
127 -1,
128 _gloffset_Vertex4fv,
129 _gloffset_Vertex4dv,
130 },
131 };
132
133 static const int IndexFuncs[8] = {
134 -1,
135 _gloffset_Indexubv,
136 _gloffset_Indexsv,
137 -1,
138 _gloffset_Indexiv,
139 -1,
140 _gloffset_Indexfv,
141 _gloffset_Indexdv,
142 };
143
144 static const int NormalFuncs[8] = {
145 _gloffset_Normal3bv,
146 -1,
147 _gloffset_Normal3sv,
148 -1,
149 _gloffset_Normal3iv,
150 -1,
151 _gloffset_Normal3fv,
152 _gloffset_Normal3dv,
153 };
154
155 /* Note: _gloffset_* for these may not be a compile-time constant. */
156 static int SecondaryColorFuncs[8];
157 static int FogCoordFuncs[8];
158
159
160 /**
161 ** GL_NV_vertex_program
162 **/
163
164 /* GL_BYTE attributes */
165
166 static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
167 {
168 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
169 }
170
171 static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
172 {
173 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
174 }
175
176 static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
177 {
178 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
179 }
180
181 static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
182 {
183 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
184 }
185
186 static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
187 {
188 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
189 BYTE_TO_FLOAT(v[1]),
190 BYTE_TO_FLOAT(v[2])));
191 }
192
193 static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
194 {
195 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
196 }
197
198 static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
199 {
200 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
201 BYTE_TO_FLOAT(v[1]),
202 BYTE_TO_FLOAT(v[2]),
203 BYTE_TO_FLOAT(v[3])));
204 }
205
206 static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
207 {
208 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
209 }
210
211 /* GL_UNSIGNED_BYTE attributes */
212
213 static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
214 {
215 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
216 }
217
218 static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
219 {
220 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
221 }
222
223 static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
224 {
225 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
226 UBYTE_TO_FLOAT(v[1])));
227 }
228
229 static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
230 {
231 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
232 }
233
234 static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
235 {
236 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
237 UBYTE_TO_FLOAT(v[1]),
238 UBYTE_TO_FLOAT(v[2])));
239 }
240 static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
241 {
242 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
243 }
244
245 static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
246 {
247 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
248 UBYTE_TO_FLOAT(v[1]),
249 UBYTE_TO_FLOAT(v[2]),
250 UBYTE_TO_FLOAT(v[3])));
251 }
252
253 static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
254 {
255 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
256 }
257
258 /* GL_SHORT attributes */
259
260 static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
261 {
262 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
263 }
264
265 static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
266 {
267 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
268 }
269
270 static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
271 {
272 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
273 SHORT_TO_FLOAT(v[1])));
274 }
275
276 static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
277 {
278 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
279 }
280
281 static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
282 {
283 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
284 SHORT_TO_FLOAT(v[1]),
285 SHORT_TO_FLOAT(v[2])));
286 }
287
288 static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
289 {
290 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
291 }
292
293 static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
294 {
295 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
296 SHORT_TO_FLOAT(v[1]),
297 SHORT_TO_FLOAT(v[2]),
298 SHORT_TO_FLOAT(v[3])));
299 }
300
301 static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
302 {
303 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
304 }
305
306 /* GL_UNSIGNED_SHORT attributes */
307
308 static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
309 {
310 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
311 }
312
313 static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
314 {
315 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
316 }
317
318 static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
319 {
320 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
321 USHORT_TO_FLOAT(v[1])));
322 }
323
324 static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
325 {
326 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
327 }
328
329 static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
330 {
331 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
332 USHORT_TO_FLOAT(v[1]),
333 USHORT_TO_FLOAT(v[2])));
334 }
335
336 static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
337 {
338 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
339 }
340
341 static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
342 {
343 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
344 USHORT_TO_FLOAT(v[1]),
345 USHORT_TO_FLOAT(v[2]),
346 USHORT_TO_FLOAT(v[3])));
347 }
348
349 static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
350 {
351 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
352 }
353
354 /* GL_INT attributes */
355
356 static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
357 {
358 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
359 }
360
361 static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
362 {
363 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
364 }
365
366 static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
367 {
368 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
369 INT_TO_FLOAT(v[1])));
370 }
371
372 static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
373 {
374 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
375 }
376
377 static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
378 {
379 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
380 INT_TO_FLOAT(v[1]),
381 INT_TO_FLOAT(v[2])));
382 }
383
384 static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
385 {
386 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
387 }
388
389 static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
390 {
391 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
392 INT_TO_FLOAT(v[1]),
393 INT_TO_FLOAT(v[2]),
394 INT_TO_FLOAT(v[3])));
395 }
396
397 static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
398 {
399 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
400 }
401
402 /* GL_UNSIGNED_INT attributes */
403
404 static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
405 {
406 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
407 }
408
409 static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
410 {
411 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
412 }
413
414 static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
415 {
416 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
417 UINT_TO_FLOAT(v[1])));
418 }
419
420 static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
421 {
422 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
423 }
424
425 static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
426 {
427 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
428 UINT_TO_FLOAT(v[1]),
429 UINT_TO_FLOAT(v[2])));
430 }
431
432 static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
433 {
434 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
435 }
436
437 static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
438 {
439 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
440 UINT_TO_FLOAT(v[1]),
441 UINT_TO_FLOAT(v[2]),
442 UINT_TO_FLOAT(v[3])));
443 }
444
445 static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
446 {
447 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
448 }
449
450 /* GL_FLOAT attributes */
451
452 static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v)
453 {
454 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
455 }
456
457 static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v)
458 {
459 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
460 }
461
462 static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v)
463 {
464 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
465 }
466
467 static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v)
468 {
469 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
470 }
471
472 /* GL_DOUBLE attributes */
473
474 static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v)
475 {
476 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
477 }
478
479 static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v)
480 {
481 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
482 }
483
484 static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v)
485 {
486 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
487 }
488
489 static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v)
490 {
491 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
492 }
493
494
495 /*
496 * Array [size][type] of VertexAttrib functions
497 */
498 static attrib_func AttribFuncsNV[2][4][8] = {
499 {
500 /* non-normalized */
501 {
502 /* size 1 */
503 (attrib_func) VertexAttrib1bvNV,
504 (attrib_func) VertexAttrib1ubvNV,
505 (attrib_func) VertexAttrib1svNV,
506 (attrib_func) VertexAttrib1usvNV,
507 (attrib_func) VertexAttrib1ivNV,
508 (attrib_func) VertexAttrib1uivNV,
509 (attrib_func) VertexAttrib1fvNV,
510 (attrib_func) VertexAttrib1dvNV
511 },
512 {
513 /* size 2 */
514 (attrib_func) VertexAttrib2bvNV,
515 (attrib_func) VertexAttrib2ubvNV,
516 (attrib_func) VertexAttrib2svNV,
517 (attrib_func) VertexAttrib2usvNV,
518 (attrib_func) VertexAttrib2ivNV,
519 (attrib_func) VertexAttrib2uivNV,
520 (attrib_func) VertexAttrib2fvNV,
521 (attrib_func) VertexAttrib2dvNV
522 },
523 {
524 /* size 3 */
525 (attrib_func) VertexAttrib3bvNV,
526 (attrib_func) VertexAttrib3ubvNV,
527 (attrib_func) VertexAttrib3svNV,
528 (attrib_func) VertexAttrib3usvNV,
529 (attrib_func) VertexAttrib3ivNV,
530 (attrib_func) VertexAttrib3uivNV,
531 (attrib_func) VertexAttrib3fvNV,
532 (attrib_func) VertexAttrib3dvNV
533 },
534 {
535 /* size 4 */
536 (attrib_func) VertexAttrib4bvNV,
537 (attrib_func) VertexAttrib4ubvNV,
538 (attrib_func) VertexAttrib4svNV,
539 (attrib_func) VertexAttrib4usvNV,
540 (attrib_func) VertexAttrib4ivNV,
541 (attrib_func) VertexAttrib4uivNV,
542 (attrib_func) VertexAttrib4fvNV,
543 (attrib_func) VertexAttrib4dvNV
544 }
545 },
546 {
547 /* normalized (except for float/double) */
548 {
549 /* size 1 */
550 (attrib_func) VertexAttrib1NbvNV,
551 (attrib_func) VertexAttrib1NubvNV,
552 (attrib_func) VertexAttrib1NsvNV,
553 (attrib_func) VertexAttrib1NusvNV,
554 (attrib_func) VertexAttrib1NivNV,
555 (attrib_func) VertexAttrib1NuivNV,
556 (attrib_func) VertexAttrib1fvNV,
557 (attrib_func) VertexAttrib1dvNV
558 },
559 {
560 /* size 2 */
561 (attrib_func) VertexAttrib2NbvNV,
562 (attrib_func) VertexAttrib2NubvNV,
563 (attrib_func) VertexAttrib2NsvNV,
564 (attrib_func) VertexAttrib2NusvNV,
565 (attrib_func) VertexAttrib2NivNV,
566 (attrib_func) VertexAttrib2NuivNV,
567 (attrib_func) VertexAttrib2fvNV,
568 (attrib_func) VertexAttrib2dvNV
569 },
570 {
571 /* size 3 */
572 (attrib_func) VertexAttrib3NbvNV,
573 (attrib_func) VertexAttrib3NubvNV,
574 (attrib_func) VertexAttrib3NsvNV,
575 (attrib_func) VertexAttrib3NusvNV,
576 (attrib_func) VertexAttrib3NivNV,
577 (attrib_func) VertexAttrib3NuivNV,
578 (attrib_func) VertexAttrib3fvNV,
579 (attrib_func) VertexAttrib3dvNV
580 },
581 {
582 /* size 4 */
583 (attrib_func) VertexAttrib4NbvNV,
584 (attrib_func) VertexAttrib4NubvNV,
585 (attrib_func) VertexAttrib4NsvNV,
586 (attrib_func) VertexAttrib4NusvNV,
587 (attrib_func) VertexAttrib4NivNV,
588 (attrib_func) VertexAttrib4NuivNV,
589 (attrib_func) VertexAttrib4fvNV,
590 (attrib_func) VertexAttrib4dvNV
591 }
592 }
593 };
594
595
596 /**
597 ** GL_ARB_vertex_program
598 **/
599
600 /* GL_BYTE attributes */
601
602 static void GLAPIENTRY VertexAttrib1NbvARB(GLuint index, const GLbyte *v)
603 {
604 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
605 }
606
607 static void GLAPIENTRY VertexAttrib1bvARB(GLuint index, const GLbyte *v)
608 {
609 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
610 }
611
612 static void GLAPIENTRY VertexAttrib2NbvARB(GLuint index, const GLbyte *v)
613 {
614 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
615 }
616
617 static void GLAPIENTRY VertexAttrib2bvARB(GLuint index, const GLbyte *v)
618 {
619 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
620 }
621
622 static void GLAPIENTRY VertexAttrib3NbvARB(GLuint index, const GLbyte *v)
623 {
624 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
625 BYTE_TO_FLOAT(v[1]),
626 BYTE_TO_FLOAT(v[2])));
627 }
628
629 static void GLAPIENTRY VertexAttrib3bvARB(GLuint index, const GLbyte *v)
630 {
631 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
632 }
633
634 static void GLAPIENTRY VertexAttrib4NbvARB(GLuint index, const GLbyte *v)
635 {
636 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
637 BYTE_TO_FLOAT(v[1]),
638 BYTE_TO_FLOAT(v[2]),
639 BYTE_TO_FLOAT(v[3])));
640 }
641
642 static void GLAPIENTRY VertexAttrib4bvARB(GLuint index, const GLbyte *v)
643 {
644 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
645 }
646
647 /* GL_UNSIGNED_BYTE attributes */
648
649 static void GLAPIENTRY VertexAttrib1NubvARB(GLuint index, const GLubyte *v)
650 {
651 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
652 }
653
654 static void GLAPIENTRY VertexAttrib1ubvARB(GLuint index, const GLubyte *v)
655 {
656 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
657 }
658
659 static void GLAPIENTRY VertexAttrib2NubvARB(GLuint index, const GLubyte *v)
660 {
661 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
662 UBYTE_TO_FLOAT(v[1])));
663 }
664
665 static void GLAPIENTRY VertexAttrib2ubvARB(GLuint index, const GLubyte *v)
666 {
667 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
668 }
669
670 static void GLAPIENTRY VertexAttrib3NubvARB(GLuint index, const GLubyte *v)
671 {
672 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
673 UBYTE_TO_FLOAT(v[1]),
674 UBYTE_TO_FLOAT(v[2])));
675 }
676 static void GLAPIENTRY VertexAttrib3ubvARB(GLuint index, const GLubyte *v)
677 {
678 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
679 }
680
681 static void GLAPIENTRY VertexAttrib4NubvARB(GLuint index, const GLubyte *v)
682 {
683 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
684 UBYTE_TO_FLOAT(v[1]),
685 UBYTE_TO_FLOAT(v[2]),
686 UBYTE_TO_FLOAT(v[3])));
687 }
688
689 static void GLAPIENTRY VertexAttrib4ubvARB(GLuint index, const GLubyte *v)
690 {
691 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
692 }
693
694 /* GL_SHORT attributes */
695
696 static void GLAPIENTRY VertexAttrib1NsvARB(GLuint index, const GLshort *v)
697 {
698 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
699 }
700
701 static void GLAPIENTRY VertexAttrib1svARB(GLuint index, const GLshort *v)
702 {
703 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
704 }
705
706 static void GLAPIENTRY VertexAttrib2NsvARB(GLuint index, const GLshort *v)
707 {
708 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
709 SHORT_TO_FLOAT(v[1])));
710 }
711
712 static void GLAPIENTRY VertexAttrib2svARB(GLuint index, const GLshort *v)
713 {
714 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
715 }
716
717 static void GLAPIENTRY VertexAttrib3NsvARB(GLuint index, const GLshort *v)
718 {
719 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
720 SHORT_TO_FLOAT(v[1]),
721 SHORT_TO_FLOAT(v[2])));
722 }
723
724 static void GLAPIENTRY VertexAttrib3svARB(GLuint index, const GLshort *v)
725 {
726 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
727 }
728
729 static void GLAPIENTRY VertexAttrib4NsvARB(GLuint index, const GLshort *v)
730 {
731 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
732 SHORT_TO_FLOAT(v[1]),
733 SHORT_TO_FLOAT(v[2]),
734 SHORT_TO_FLOAT(v[3])));
735 }
736
737 static void GLAPIENTRY VertexAttrib4svARB(GLuint index, const GLshort *v)
738 {
739 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
740 }
741
742 /* GL_UNSIGNED_SHORT attributes */
743
744 static void GLAPIENTRY VertexAttrib1NusvARB(GLuint index, const GLushort *v)
745 {
746 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
747 }
748
749 static void GLAPIENTRY VertexAttrib1usvARB(GLuint index, const GLushort *v)
750 {
751 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
752 }
753
754 static void GLAPIENTRY VertexAttrib2NusvARB(GLuint index, const GLushort *v)
755 {
756 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
757 USHORT_TO_FLOAT(v[1])));
758 }
759
760 static void GLAPIENTRY VertexAttrib2usvARB(GLuint index, const GLushort *v)
761 {
762 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
763 }
764
765 static void GLAPIENTRY VertexAttrib3NusvARB(GLuint index, const GLushort *v)
766 {
767 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
768 USHORT_TO_FLOAT(v[1]),
769 USHORT_TO_FLOAT(v[2])));
770 }
771
772 static void GLAPIENTRY VertexAttrib3usvARB(GLuint index, const GLushort *v)
773 {
774 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
775 }
776
777 static void GLAPIENTRY VertexAttrib4NusvARB(GLuint index, const GLushort *v)
778 {
779 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
780 USHORT_TO_FLOAT(v[1]),
781 USHORT_TO_FLOAT(v[2]),
782 USHORT_TO_FLOAT(v[3])));
783 }
784
785 static void GLAPIENTRY VertexAttrib4usvARB(GLuint index, const GLushort *v)
786 {
787 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
788 }
789
790 /* GL_INT attributes */
791
792 static void GLAPIENTRY VertexAttrib1NivARB(GLuint index, const GLint *v)
793 {
794 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
795 }
796
797 static void GLAPIENTRY VertexAttrib1ivARB(GLuint index, const GLint *v)
798 {
799 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
800 }
801
802 static void GLAPIENTRY VertexAttrib2NivARB(GLuint index, const GLint *v)
803 {
804 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
805 INT_TO_FLOAT(v[1])));
806 }
807
808 static void GLAPIENTRY VertexAttrib2ivARB(GLuint index, const GLint *v)
809 {
810 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
811 }
812
813 static void GLAPIENTRY VertexAttrib3NivARB(GLuint index, const GLint *v)
814 {
815 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
816 INT_TO_FLOAT(v[1]),
817 INT_TO_FLOAT(v[2])));
818 }
819
820 static void GLAPIENTRY VertexAttrib3ivARB(GLuint index, const GLint *v)
821 {
822 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
823 }
824
825 static void GLAPIENTRY VertexAttrib4NivARB(GLuint index, const GLint *v)
826 {
827 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
828 INT_TO_FLOAT(v[1]),
829 INT_TO_FLOAT(v[2]),
830 INT_TO_FLOAT(v[3])));
831 }
832
833 static void GLAPIENTRY VertexAttrib4ivARB(GLuint index, const GLint *v)
834 {
835 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
836 }
837
838 /* GL_UNSIGNED_INT attributes */
839
840 static void GLAPIENTRY VertexAttrib1NuivARB(GLuint index, const GLuint *v)
841 {
842 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
843 }
844
845 static void GLAPIENTRY VertexAttrib1uivARB(GLuint index, const GLuint *v)
846 {
847 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
848 }
849
850 static void GLAPIENTRY VertexAttrib2NuivARB(GLuint index, const GLuint *v)
851 {
852 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
853 UINT_TO_FLOAT(v[1])));
854 }
855
856 static void GLAPIENTRY VertexAttrib2uivARB(GLuint index, const GLuint *v)
857 {
858 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
859 }
860
861 static void GLAPIENTRY VertexAttrib3NuivARB(GLuint index, const GLuint *v)
862 {
863 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
864 UINT_TO_FLOAT(v[1]),
865 UINT_TO_FLOAT(v[2])));
866 }
867
868 static void GLAPIENTRY VertexAttrib3uivARB(GLuint index, const GLuint *v)
869 {
870 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
871 }
872
873 static void GLAPIENTRY VertexAttrib4NuivARB(GLuint index, const GLuint *v)
874 {
875 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
876 UINT_TO_FLOAT(v[1]),
877 UINT_TO_FLOAT(v[2]),
878 UINT_TO_FLOAT(v[3])));
879 }
880
881 static void GLAPIENTRY VertexAttrib4uivARB(GLuint index, const GLuint *v)
882 {
883 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
884 }
885
886 /* GL_FLOAT attributes */
887
888 static void GLAPIENTRY VertexAttrib1fvARB(GLuint index, const GLfloat *v)
889 {
890 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v));
891 }
892
893 static void GLAPIENTRY VertexAttrib2fvARB(GLuint index, const GLfloat *v)
894 {
895 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v));
896 }
897
898 static void GLAPIENTRY VertexAttrib3fvARB(GLuint index, const GLfloat *v)
899 {
900 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v));
901 }
902
903 static void GLAPIENTRY VertexAttrib4fvARB(GLuint index, const GLfloat *v)
904 {
905 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v));
906 }
907
908 /* GL_DOUBLE attributes */
909
910 static void GLAPIENTRY VertexAttrib1dvARB(GLuint index, const GLdouble *v)
911 {
912 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v));
913 }
914
915 static void GLAPIENTRY VertexAttrib2dvARB(GLuint index, const GLdouble *v)
916 {
917 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v));
918 }
919
920 static void GLAPIENTRY VertexAttrib3dvARB(GLuint index, const GLdouble *v)
921 {
922 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v));
923 }
924
925 static void GLAPIENTRY VertexAttrib4dvARB(GLuint index, const GLdouble *v)
926 {
927 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v));
928 }
929
930
931 /**
932 * Integer-valued attributes
933 */
934 static void
935 VertexAttribI1bv(GLuint index, const GLbyte *v)
936 {
937 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
938 }
939
940 static void
941 VertexAttribI2bv(GLuint index, const GLbyte *v)
942 {
943 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
944 }
945
946 static void
947 VertexAttribI3bv(GLuint index, const GLbyte *v)
948 {
949 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
950 }
951
952 static void
953 VertexAttribI4bv(GLuint index, const GLbyte *v)
954 {
955 CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
956 }
957
958
959 static void
960 VertexAttribI1ubv(GLuint index, const GLubyte *v)
961 {
962 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
963 }
964
965 static void
966 VertexAttribI2ubv(GLuint index, const GLubyte *v)
967 {
968 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
969 }
970
971 static void
972 VertexAttribI3ubv(GLuint index, const GLubyte *v)
973 {
974 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
975 }
976
977 static void
978 VertexAttribI4ubv(GLuint index, const GLubyte *v)
979 {
980 CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
981 }
982
983
984
985 static void
986 VertexAttribI1sv(GLuint index, const GLshort *v)
987 {
988 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
989 }
990
991 static void
992 VertexAttribI2sv(GLuint index, const GLshort *v)
993 {
994 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
995 }
996
997 static void
998 VertexAttribI3sv(GLuint index, const GLshort *v)
999 {
1000 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1001 }
1002
1003 static void
1004 VertexAttribI4sv(GLuint index, const GLshort *v)
1005 {
1006 CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
1007 }
1008
1009
1010 static void
1011 VertexAttribI1usv(GLuint index, const GLushort *v)
1012 {
1013 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1014 }
1015
1016 static void
1017 VertexAttribI2usv(GLuint index, const GLushort *v)
1018 {
1019 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1020 }
1021
1022 static void
1023 VertexAttribI3usv(GLuint index, const GLushort *v)
1024 {
1025 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1026 }
1027
1028 static void
1029 VertexAttribI4usv(GLuint index, const GLushort *v)
1030 {
1031 CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
1032 }
1033
1034
1035
1036 static void
1037 VertexAttribI1iv(GLuint index, const GLint *v)
1038 {
1039 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
1040 }
1041
1042 static void
1043 VertexAttribI2iv(GLuint index, const GLint *v)
1044 {
1045 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
1046 }
1047
1048 static void
1049 VertexAttribI3iv(GLuint index, const GLint *v)
1050 {
1051 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1052 }
1053
1054 static void
1055 VertexAttribI4iv(GLuint index, const GLint *v)
1056 {
1057 CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
1058 }
1059
1060
1061 static void
1062 VertexAttribI1uiv(GLuint index, const GLuint *v)
1063 {
1064 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1065 }
1066
1067 static void
1068 VertexAttribI2uiv(GLuint index, const GLuint *v)
1069 {
1070 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1071 }
1072
1073 static void
1074 VertexAttribI3uiv(GLuint index, const GLuint *v)
1075 {
1076 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1077 }
1078
1079 static void
1080 VertexAttribI4uiv(GLuint index, const GLuint *v)
1081 {
1082 CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
1083 }
1084
1085
1086
1087
1088 /*
1089 * Array [size][type] of VertexAttrib functions
1090 */
1091 static attrib_func AttribFuncsARB[3][4][8] = {
1092 {
1093 /* non-normalized */
1094 {
1095 /* size 1 */
1096 (attrib_func) VertexAttrib1bvARB,
1097 (attrib_func) VertexAttrib1ubvARB,
1098 (attrib_func) VertexAttrib1svARB,
1099 (attrib_func) VertexAttrib1usvARB,
1100 (attrib_func) VertexAttrib1ivARB,
1101 (attrib_func) VertexAttrib1uivARB,
1102 (attrib_func) VertexAttrib1fvARB,
1103 (attrib_func) VertexAttrib1dvARB
1104 },
1105 {
1106 /* size 2 */
1107 (attrib_func) VertexAttrib2bvARB,
1108 (attrib_func) VertexAttrib2ubvARB,
1109 (attrib_func) VertexAttrib2svARB,
1110 (attrib_func) VertexAttrib2usvARB,
1111 (attrib_func) VertexAttrib2ivARB,
1112 (attrib_func) VertexAttrib2uivARB,
1113 (attrib_func) VertexAttrib2fvARB,
1114 (attrib_func) VertexAttrib2dvARB
1115 },
1116 {
1117 /* size 3 */
1118 (attrib_func) VertexAttrib3bvARB,
1119 (attrib_func) VertexAttrib3ubvARB,
1120 (attrib_func) VertexAttrib3svARB,
1121 (attrib_func) VertexAttrib3usvARB,
1122 (attrib_func) VertexAttrib3ivARB,
1123 (attrib_func) VertexAttrib3uivARB,
1124 (attrib_func) VertexAttrib3fvARB,
1125 (attrib_func) VertexAttrib3dvARB
1126 },
1127 {
1128 /* size 4 */
1129 (attrib_func) VertexAttrib4bvARB,
1130 (attrib_func) VertexAttrib4ubvARB,
1131 (attrib_func) VertexAttrib4svARB,
1132 (attrib_func) VertexAttrib4usvARB,
1133 (attrib_func) VertexAttrib4ivARB,
1134 (attrib_func) VertexAttrib4uivARB,
1135 (attrib_func) VertexAttrib4fvARB,
1136 (attrib_func) VertexAttrib4dvARB
1137 }
1138 },
1139 {
1140 /* normalized (except for float/double) */
1141 {
1142 /* size 1 */
1143 (attrib_func) VertexAttrib1NbvARB,
1144 (attrib_func) VertexAttrib1NubvARB,
1145 (attrib_func) VertexAttrib1NsvARB,
1146 (attrib_func) VertexAttrib1NusvARB,
1147 (attrib_func) VertexAttrib1NivARB,
1148 (attrib_func) VertexAttrib1NuivARB,
1149 (attrib_func) VertexAttrib1fvARB,
1150 (attrib_func) VertexAttrib1dvARB
1151 },
1152 {
1153 /* size 2 */
1154 (attrib_func) VertexAttrib2NbvARB,
1155 (attrib_func) VertexAttrib2NubvARB,
1156 (attrib_func) VertexAttrib2NsvARB,
1157 (attrib_func) VertexAttrib2NusvARB,
1158 (attrib_func) VertexAttrib2NivARB,
1159 (attrib_func) VertexAttrib2NuivARB,
1160 (attrib_func) VertexAttrib2fvARB,
1161 (attrib_func) VertexAttrib2dvARB
1162 },
1163 {
1164 /* size 3 */
1165 (attrib_func) VertexAttrib3NbvARB,
1166 (attrib_func) VertexAttrib3NubvARB,
1167 (attrib_func) VertexAttrib3NsvARB,
1168 (attrib_func) VertexAttrib3NusvARB,
1169 (attrib_func) VertexAttrib3NivARB,
1170 (attrib_func) VertexAttrib3NuivARB,
1171 (attrib_func) VertexAttrib3fvARB,
1172 (attrib_func) VertexAttrib3dvARB
1173 },
1174 {
1175 /* size 4 */
1176 (attrib_func) VertexAttrib4NbvARB,
1177 (attrib_func) VertexAttrib4NubvARB,
1178 (attrib_func) VertexAttrib4NsvARB,
1179 (attrib_func) VertexAttrib4NusvARB,
1180 (attrib_func) VertexAttrib4NivARB,
1181 (attrib_func) VertexAttrib4NuivARB,
1182 (attrib_func) VertexAttrib4fvARB,
1183 (attrib_func) VertexAttrib4dvARB
1184 }
1185 },
1186
1187 {
1188 /* integer-valued */
1189 {
1190 /* size 1 */
1191 (attrib_func) VertexAttribI1bv,
1192 (attrib_func) VertexAttribI1ubv,
1193 (attrib_func) VertexAttribI1sv,
1194 (attrib_func) VertexAttribI1usv,
1195 (attrib_func) VertexAttribI1iv,
1196 (attrib_func) VertexAttribI1uiv,
1197 NULL, /* GL_FLOAT */
1198 NULL /* GL_DOUBLE */
1199 },
1200 {
1201 /* size 2 */
1202 (attrib_func) VertexAttribI2bv,
1203 (attrib_func) VertexAttribI2ubv,
1204 (attrib_func) VertexAttribI2sv,
1205 (attrib_func) VertexAttribI2usv,
1206 (attrib_func) VertexAttribI2iv,
1207 (attrib_func) VertexAttribI2uiv,
1208 NULL, /* GL_FLOAT */
1209 NULL /* GL_DOUBLE */
1210 },
1211 {
1212 /* size 3 */
1213 (attrib_func) VertexAttribI3bv,
1214 (attrib_func) VertexAttribI3ubv,
1215 (attrib_func) VertexAttribI3sv,
1216 (attrib_func) VertexAttribI3usv,
1217 (attrib_func) VertexAttribI3iv,
1218 (attrib_func) VertexAttribI3uiv,
1219 NULL, /* GL_FLOAT */
1220 NULL /* GL_DOUBLE */
1221 },
1222 {
1223 /* size 4 */
1224 (attrib_func) VertexAttribI4bv,
1225 (attrib_func) VertexAttribI4ubv,
1226 (attrib_func) VertexAttribI4sv,
1227 (attrib_func) VertexAttribI4usv,
1228 (attrib_func) VertexAttribI4iv,
1229 (attrib_func) VertexAttribI4uiv,
1230 NULL, /* GL_FLOAT */
1231 NULL /* GL_DOUBLE */
1232 }
1233 }
1234 };
1235
1236 /**********************************************************************/
1237
1238
1239 GLboolean _ae_create_context( struct gl_context *ctx )
1240 {
1241 if (ctx->aelt_context)
1242 return GL_TRUE;
1243
1244 /* These _gloffset_* values may not be compile-time constants */
1245 SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT;
1246 SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT;
1247 SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT;
1248 SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT;
1249 SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT;
1250 SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT;
1251 SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
1252 SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT;
1253
1254 FogCoordFuncs[0] = -1;
1255 FogCoordFuncs[1] = -1;
1256 FogCoordFuncs[2] = -1;
1257 FogCoordFuncs[3] = -1;
1258 FogCoordFuncs[4] = -1;
1259 FogCoordFuncs[5] = -1;
1260 FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
1261 FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
1262
1263 ctx->aelt_context = CALLOC( sizeof(AEcontext) );
1264 if (!ctx->aelt_context)
1265 return GL_FALSE;
1266
1267 AE_CONTEXT(ctx)->NewState = ~0;
1268 return GL_TRUE;
1269 }
1270
1271
1272 void _ae_destroy_context( struct gl_context *ctx )
1273 {
1274 if ( AE_CONTEXT( ctx ) ) {
1275 FREE( ctx->aelt_context );
1276 ctx->aelt_context = NULL;
1277 }
1278 }
1279
1280 static void check_vbo( AEcontext *actx,
1281 struct gl_buffer_object *vbo )
1282 {
1283 if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) {
1284 GLuint i;
1285 for (i = 0; i < actx->nr_vbos; i++)
1286 if (actx->vbo[i] == vbo)
1287 return;
1288 assert(actx->nr_vbos < VERT_ATTRIB_MAX);
1289 actx->vbo[actx->nr_vbos++] = vbo;
1290 }
1291 }
1292
1293
1294 /**
1295 * Make a list of per-vertex functions to call for each glArrayElement call.
1296 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1297 * etc).
1298 * Note: this may be called during display list construction.
1299 */
1300 static void _ae_update_state( struct gl_context *ctx )
1301 {
1302 AEcontext *actx = AE_CONTEXT(ctx);
1303 AEarray *aa = actx->arrays;
1304 AEattrib *at = actx->attribs;
1305 GLuint i;
1306 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
1307
1308 actx->nr_vbos = 0;
1309
1310 /* conventional vertex arrays */
1311 if (arrayObj->Index.Enabled) {
1312 aa->array = &arrayObj->Index;
1313 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
1314 check_vbo(actx, aa->array->BufferObj);
1315 aa++;
1316 }
1317 if (arrayObj->EdgeFlag.Enabled) {
1318 aa->array = &arrayObj->EdgeFlag;
1319 aa->offset = _gloffset_EdgeFlagv;
1320 check_vbo(actx, aa->array->BufferObj);
1321 aa++;
1322 }
1323 if (arrayObj->Normal.Enabled) {
1324 aa->array = &arrayObj->Normal;
1325 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
1326 check_vbo(actx, aa->array->BufferObj);
1327 aa++;
1328 }
1329 if (arrayObj->Color.Enabled) {
1330 aa->array = &arrayObj->Color;
1331 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
1332 check_vbo(actx, aa->array->BufferObj);
1333 aa++;
1334 }
1335 if (arrayObj->SecondaryColor.Enabled) {
1336 aa->array = &arrayObj->SecondaryColor;
1337 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
1338 check_vbo(actx, aa->array->BufferObj);
1339 aa++;
1340 }
1341 if (arrayObj->FogCoord.Enabled) {
1342 aa->array = &arrayObj->FogCoord;
1343 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
1344 check_vbo(actx, aa->array->BufferObj);
1345 aa++;
1346 }
1347 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
1348 struct gl_client_array *attribArray = &arrayObj->TexCoord[i];
1349 if (attribArray->Enabled) {
1350 /* NOTE: we use generic glVertexAttribNV functions here.
1351 * If we ever remove GL_NV_vertex_program this will have to change.
1352 */
1353 at->array = attribArray;
1354 ASSERT(!at->array->Normalized);
1355 at->func = AttribFuncsNV[at->array->Normalized]
1356 [at->array->Size-1]
1357 [TYPE_IDX(at->array->Type)];
1358 at->index = VERT_ATTRIB_TEX0 + i;
1359 check_vbo(actx, at->array->BufferObj);
1360 at++;
1361 }
1362 }
1363
1364 /* generic vertex attribute arrays */
1365 for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) { /* skip zero! */
1366 struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i];
1367 if (attribArray->Enabled) {
1368 at->array = attribArray;
1369 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1370 * function pointer here (for float arrays) since the pointer may
1371 * change from one execution of _ae_ArrayElement() to
1372 * the next. Doing so caused UT to break.
1373 */
1374 if (ctx->VertexProgram._Enabled
1375 && ctx->VertexProgram.Current->IsNVProgram) {
1376 at->func = AttribFuncsNV[at->array->Normalized]
1377 [at->array->Size-1]
1378 [TYPE_IDX(at->array->Type)];
1379 }
1380 else {
1381 GLint intOrNorm;
1382 if (at->array->Integer)
1383 intOrNorm = 2;
1384 else if (at->array->Normalized)
1385 intOrNorm = 1;
1386 else
1387 intOrNorm = 0;
1388
1389 at->func = AttribFuncsARB[intOrNorm]
1390 [at->array->Size-1]
1391 [TYPE_IDX(at->array->Type)];
1392 }
1393 at->index = i;
1394 check_vbo(actx, at->array->BufferObj);
1395 at++;
1396 }
1397 }
1398
1399 /* finally, vertex position */
1400 if (arrayObj->VertexAttrib[0].Enabled) {
1401 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1402 * issued as the last (provoking) attribute).
1403 */
1404 aa->array = &arrayObj->VertexAttrib[0];
1405 assert(aa->array->Size >= 2); /* XXX fix someday? */
1406 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1407 check_vbo(actx, aa->array->BufferObj);
1408 aa++;
1409 }
1410 else if (arrayObj->Vertex.Enabled) {
1411 aa->array = &arrayObj->Vertex;
1412 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1413 check_vbo(actx, aa->array->BufferObj);
1414 aa++;
1415 }
1416
1417 check_vbo(actx, ctx->Array.ElementArrayBufferObj);
1418
1419 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
1420 ASSERT(aa - actx->arrays < 32);
1421 at->func = NULL; /* terminate the list */
1422 aa->offset = -1; /* terminate the list */
1423
1424 actx->NewState = 0;
1425 }
1426
1427 void _ae_map_vbos( struct gl_context *ctx )
1428 {
1429 AEcontext *actx = AE_CONTEXT(ctx);
1430 GLuint i;
1431
1432 if (actx->mapped_vbos)
1433 return;
1434
1435 if (actx->NewState)
1436 _ae_update_state(ctx);
1437
1438 for (i = 0; i < actx->nr_vbos; i++)
1439 ctx->Driver.MapBuffer(ctx,
1440 GL_ARRAY_BUFFER_ARB,
1441 GL_DYNAMIC_DRAW_ARB,
1442 actx->vbo[i]);
1443
1444 if (actx->nr_vbos)
1445 actx->mapped_vbos = GL_TRUE;
1446 }
1447
1448 void _ae_unmap_vbos( struct gl_context *ctx )
1449 {
1450 AEcontext *actx = AE_CONTEXT(ctx);
1451 GLuint i;
1452
1453 if (!actx->mapped_vbos)
1454 return;
1455
1456 assert (!actx->NewState);
1457
1458 for (i = 0; i < actx->nr_vbos; i++)
1459 ctx->Driver.UnmapBuffer(ctx,
1460 GL_ARRAY_BUFFER_ARB,
1461 actx->vbo[i]);
1462
1463 actx->mapped_vbos = GL_FALSE;
1464 }
1465
1466
1467 /**
1468 * Called via glArrayElement() and glDrawArrays().
1469 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1470 * for all enabled vertex arrays (for elt-th element).
1471 * Note: this may be called during display list construction.
1472 */
1473 void GLAPIENTRY _ae_ArrayElement( GLint elt )
1474 {
1475 GET_CURRENT_CONTEXT(ctx);
1476 const AEcontext *actx = AE_CONTEXT(ctx);
1477 const AEarray *aa;
1478 const AEattrib *at;
1479 const struct _glapi_table * const disp = GET_DISPATCH();
1480 GLboolean do_map;
1481
1482 if (actx->NewState) {
1483 assert(!actx->mapped_vbos);
1484 _ae_update_state( ctx );
1485 }
1486
1487 do_map = actx->nr_vbos && !actx->mapped_vbos;
1488
1489 /*
1490 */
1491 if (do_map)
1492 _ae_map_vbos(ctx);
1493
1494 /* generic attributes */
1495 for (at = actx->attribs; at->func; at++) {
1496 const GLubyte *src
1497 = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr)
1498 + elt * at->array->StrideB;
1499 at->func( at->index, src );
1500 }
1501
1502 /* conventional arrays */
1503 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
1504 const GLubyte *src
1505 = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr)
1506 + elt * aa->array->StrideB;
1507 CALL_by_offset( disp, (array_func), aa->offset,
1508 ((const void *) src) );
1509 }
1510
1511 if (do_map)
1512 _ae_unmap_vbos(ctx);
1513 }
1514
1515
1516 void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state )
1517 {
1518 AEcontext *actx = AE_CONTEXT(ctx);
1519
1520
1521 /* Only interested in this subset of mesa state. Need to prune
1522 * this down as both tnl/ and the drivers can raise statechanges
1523 * for arcane reasons in the middle of seemingly atomic operations
1524 * like DrawElements, over which we'd like to keep a known set of
1525 * arrays and vbo's mapped.
1526 *
1527 * Luckily, neither the drivers nor tnl muck with the state that
1528 * concerns us here:
1529 */
1530 new_state &= _NEW_ARRAY | _NEW_PROGRAM;
1531 if (new_state) {
1532 assert(!actx->mapped_vbos);
1533 actx->NewState |= new_state;
1534 }
1535 }
1536
1537
1538 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
1539 const GLvertexformat *vfmt)
1540 {
1541 SET_ArrayElement(disp, vfmt->ArrayElement);
1542 }
1543
1544
1545 #endif /* FEATURE_arrayelt */