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