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