2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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 * THE AUTHORS 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.
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.
34 * Keith Whitwell <keith@tungstengraphics.com>
38 #include "api_arrayelt.h"
39 #include "bufferobj.h"
44 #include "main/dispatch.h"
46 typedef void (GLAPIENTRY
*array_func
)( const void * );
49 const struct gl_client_array
*array
;
53 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
56 const struct gl_client_array
*array
;
63 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
66 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
68 GLboolean mapped_vbos
;
72 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
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.
80 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
85 static const int ColorFuncs
[2][NUM_TYPES
] = {
108 static const int VertexFuncs
[3][NUM_TYPES
] = {
141 static const int IndexFuncs
[NUM_TYPES
] = {
152 static const int NormalFuncs
[NUM_TYPES
] = {
163 /* Note: _gloffset_* for these may not be a compile-time constant. */
164 static int SecondaryColorFuncs
[NUM_TYPES
];
165 static int FogCoordFuncs
[NUM_TYPES
];
169 ** GL_NV_vertex_program
172 /* GL_BYTE attributes */
174 static void GLAPIENTRY
175 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
177 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
180 static void GLAPIENTRY
181 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
183 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
186 static void GLAPIENTRY
187 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
189 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
192 static void GLAPIENTRY
193 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
195 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
198 static void GLAPIENTRY
199 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
201 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
203 BYTE_TO_FLOAT(v
[2])));
206 static void GLAPIENTRY
207 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
209 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
212 static void GLAPIENTRY
213 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
215 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
218 BYTE_TO_FLOAT(v
[3])));
221 static void GLAPIENTRY
222 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
224 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
227 /* GL_UNSIGNED_BYTE attributes */
229 static void GLAPIENTRY
230 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
232 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
235 static void GLAPIENTRY
236 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
238 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
241 static void GLAPIENTRY
242 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
244 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
245 UBYTE_TO_FLOAT(v
[1])));
248 static void GLAPIENTRY
249 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
251 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
254 static void GLAPIENTRY
255 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
257 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
258 UBYTE_TO_FLOAT(v
[1]),
259 UBYTE_TO_FLOAT(v
[2])));
261 static void GLAPIENTRY
262 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
264 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
265 (GLfloat
)v
[1], (GLfloat
)v
[2]));
268 static void GLAPIENTRY
269 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
271 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
272 UBYTE_TO_FLOAT(v
[1]),
273 UBYTE_TO_FLOAT(v
[2]),
274 UBYTE_TO_FLOAT(v
[3])));
277 static void GLAPIENTRY
278 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
280 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
281 (GLfloat
)v
[1], (GLfloat
)v
[2],
285 /* GL_SHORT attributes */
287 static void GLAPIENTRY
288 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
290 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
293 static void GLAPIENTRY
294 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
296 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
299 static void GLAPIENTRY
300 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
302 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
303 SHORT_TO_FLOAT(v
[1])));
306 static void GLAPIENTRY
307 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
309 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
312 static void GLAPIENTRY
313 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
315 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
316 SHORT_TO_FLOAT(v
[1]),
317 SHORT_TO_FLOAT(v
[2])));
320 static void GLAPIENTRY
321 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
323 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
327 static void GLAPIENTRY
328 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
330 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
331 SHORT_TO_FLOAT(v
[1]),
332 SHORT_TO_FLOAT(v
[2]),
333 SHORT_TO_FLOAT(v
[3])));
336 static void GLAPIENTRY
337 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
339 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
340 (GLfloat
)v
[2], (GLfloat
)v
[3]));
343 /* GL_UNSIGNED_SHORT attributes */
345 static void GLAPIENTRY
346 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
348 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
351 static void GLAPIENTRY
352 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
354 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
357 static void GLAPIENTRY
358 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
360 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
361 USHORT_TO_FLOAT(v
[1])));
364 static void GLAPIENTRY
365 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
367 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
371 static void GLAPIENTRY
372 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
374 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
375 USHORT_TO_FLOAT(v
[1]),
376 USHORT_TO_FLOAT(v
[2])));
379 static void GLAPIENTRY
380 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
382 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
386 static void GLAPIENTRY
387 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
389 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
390 USHORT_TO_FLOAT(v
[1]),
391 USHORT_TO_FLOAT(v
[2]),
392 USHORT_TO_FLOAT(v
[3])));
395 static void GLAPIENTRY
396 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
398 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
399 (GLfloat
)v
[2], (GLfloat
)v
[3]));
402 /* GL_INT attributes */
404 static void GLAPIENTRY
405 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
407 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
410 static void GLAPIENTRY
411 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
413 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
416 static void GLAPIENTRY
417 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
419 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
420 INT_TO_FLOAT(v
[1])));
423 static void GLAPIENTRY
424 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
426 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
429 static void GLAPIENTRY
430 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
432 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
434 INT_TO_FLOAT(v
[2])));
437 static void GLAPIENTRY
438 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
440 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
444 static void GLAPIENTRY
445 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
447 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
450 INT_TO_FLOAT(v
[3])));
453 static void GLAPIENTRY
454 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
456 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
457 (GLfloat
)v
[2], (GLfloat
)v
[3]));
460 /* GL_UNSIGNED_INT attributes */
462 static void GLAPIENTRY
463 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
465 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
468 static void GLAPIENTRY
469 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
471 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
474 static void GLAPIENTRY
475 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
477 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
478 UINT_TO_FLOAT(v
[1])));
481 static void GLAPIENTRY
482 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
484 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
488 static void GLAPIENTRY
489 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
491 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
493 UINT_TO_FLOAT(v
[2])));
496 static void GLAPIENTRY
497 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
499 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
503 static void GLAPIENTRY
504 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
506 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
509 UINT_TO_FLOAT(v
[3])));
512 static void GLAPIENTRY
513 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
515 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
516 (GLfloat
)v
[2], (GLfloat
)v
[3]));
519 /* GL_FLOAT attributes */
521 static void GLAPIENTRY
522 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
524 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
527 static void GLAPIENTRY
528 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
530 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
533 static void GLAPIENTRY
534 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
536 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
539 static void GLAPIENTRY
540 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
542 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
545 /* GL_DOUBLE attributes */
547 static void GLAPIENTRY
548 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
550 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
553 static void GLAPIENTRY
554 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
556 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
559 static void GLAPIENTRY
560 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
562 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
565 static void GLAPIENTRY
566 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
568 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
573 * Array [size][type] of VertexAttrib functions
575 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
580 (attrib_func
) VertexAttrib1bvNV
,
581 (attrib_func
) VertexAttrib1ubvNV
,
582 (attrib_func
) VertexAttrib1svNV
,
583 (attrib_func
) VertexAttrib1usvNV
,
584 (attrib_func
) VertexAttrib1ivNV
,
585 (attrib_func
) VertexAttrib1uivNV
,
586 (attrib_func
) VertexAttrib1fvNV
,
587 (attrib_func
) VertexAttrib1dvNV
591 (attrib_func
) VertexAttrib2bvNV
,
592 (attrib_func
) VertexAttrib2ubvNV
,
593 (attrib_func
) VertexAttrib2svNV
,
594 (attrib_func
) VertexAttrib2usvNV
,
595 (attrib_func
) VertexAttrib2ivNV
,
596 (attrib_func
) VertexAttrib2uivNV
,
597 (attrib_func
) VertexAttrib2fvNV
,
598 (attrib_func
) VertexAttrib2dvNV
602 (attrib_func
) VertexAttrib3bvNV
,
603 (attrib_func
) VertexAttrib3ubvNV
,
604 (attrib_func
) VertexAttrib3svNV
,
605 (attrib_func
) VertexAttrib3usvNV
,
606 (attrib_func
) VertexAttrib3ivNV
,
607 (attrib_func
) VertexAttrib3uivNV
,
608 (attrib_func
) VertexAttrib3fvNV
,
609 (attrib_func
) VertexAttrib3dvNV
613 (attrib_func
) VertexAttrib4bvNV
,
614 (attrib_func
) VertexAttrib4ubvNV
,
615 (attrib_func
) VertexAttrib4svNV
,
616 (attrib_func
) VertexAttrib4usvNV
,
617 (attrib_func
) VertexAttrib4ivNV
,
618 (attrib_func
) VertexAttrib4uivNV
,
619 (attrib_func
) VertexAttrib4fvNV
,
620 (attrib_func
) VertexAttrib4dvNV
624 /* normalized (except for float/double) */
627 (attrib_func
) VertexAttrib1NbvNV
,
628 (attrib_func
) VertexAttrib1NubvNV
,
629 (attrib_func
) VertexAttrib1NsvNV
,
630 (attrib_func
) VertexAttrib1NusvNV
,
631 (attrib_func
) VertexAttrib1NivNV
,
632 (attrib_func
) VertexAttrib1NuivNV
,
633 (attrib_func
) VertexAttrib1fvNV
,
634 (attrib_func
) VertexAttrib1dvNV
638 (attrib_func
) VertexAttrib2NbvNV
,
639 (attrib_func
) VertexAttrib2NubvNV
,
640 (attrib_func
) VertexAttrib2NsvNV
,
641 (attrib_func
) VertexAttrib2NusvNV
,
642 (attrib_func
) VertexAttrib2NivNV
,
643 (attrib_func
) VertexAttrib2NuivNV
,
644 (attrib_func
) VertexAttrib2fvNV
,
645 (attrib_func
) VertexAttrib2dvNV
649 (attrib_func
) VertexAttrib3NbvNV
,
650 (attrib_func
) VertexAttrib3NubvNV
,
651 (attrib_func
) VertexAttrib3NsvNV
,
652 (attrib_func
) VertexAttrib3NusvNV
,
653 (attrib_func
) VertexAttrib3NivNV
,
654 (attrib_func
) VertexAttrib3NuivNV
,
655 (attrib_func
) VertexAttrib3fvNV
,
656 (attrib_func
) VertexAttrib3dvNV
660 (attrib_func
) VertexAttrib4NbvNV
,
661 (attrib_func
) VertexAttrib4NubvNV
,
662 (attrib_func
) VertexAttrib4NsvNV
,
663 (attrib_func
) VertexAttrib4NusvNV
,
664 (attrib_func
) VertexAttrib4NivNV
,
665 (attrib_func
) VertexAttrib4NuivNV
,
666 (attrib_func
) VertexAttrib4fvNV
,
667 (attrib_func
) VertexAttrib4dvNV
674 ** GL_ARB_vertex_program
677 /* GL_BYTE attributes */
679 static void GLAPIENTRY
680 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
682 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
685 static void GLAPIENTRY
686 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
688 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
691 static void GLAPIENTRY
692 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
694 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
697 static void GLAPIENTRY
698 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
700 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
703 static void GLAPIENTRY
704 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
706 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
708 BYTE_TO_FLOAT(v
[2])));
711 static void GLAPIENTRY
712 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
714 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
717 static void GLAPIENTRY
718 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
720 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
723 BYTE_TO_FLOAT(v
[3])));
726 static void GLAPIENTRY
727 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
729 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
732 /* GL_UNSIGNED_BYTE attributes */
734 static void GLAPIENTRY
735 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
737 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
740 static void GLAPIENTRY
741 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
743 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
746 static void GLAPIENTRY
747 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
749 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
750 UBYTE_TO_FLOAT(v
[0]),
751 UBYTE_TO_FLOAT(v
[1])));
754 static void GLAPIENTRY
755 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
757 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
758 (GLfloat
)v
[0], (GLfloat
)v
[1]));
761 static void GLAPIENTRY
762 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
764 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
765 UBYTE_TO_FLOAT(v
[0]),
766 UBYTE_TO_FLOAT(v
[1]),
767 UBYTE_TO_FLOAT(v
[2])));
769 static void GLAPIENTRY
770 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
772 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
778 static void GLAPIENTRY
779 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
781 CALL_VertexAttrib4fARB(GET_DISPATCH(),
783 UBYTE_TO_FLOAT(v
[0]),
784 UBYTE_TO_FLOAT(v
[1]),
785 UBYTE_TO_FLOAT(v
[2]),
786 UBYTE_TO_FLOAT(v
[3])));
789 static void GLAPIENTRY
790 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
792 CALL_VertexAttrib4fARB(GET_DISPATCH(),
794 (GLfloat
)v
[0], (GLfloat
)v
[1],
795 (GLfloat
)v
[2], (GLfloat
)v
[3]));
798 /* GL_SHORT attributes */
800 static void GLAPIENTRY
801 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
803 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
806 static void GLAPIENTRY
807 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
809 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
812 static void GLAPIENTRY
813 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
815 CALL_VertexAttrib2fARB(GET_DISPATCH(),
816 (index
, SHORT_TO_FLOAT(v
[0]),
817 SHORT_TO_FLOAT(v
[1])));
820 static void GLAPIENTRY
821 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
823 CALL_VertexAttrib2fARB(GET_DISPATCH(),
824 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
827 static void GLAPIENTRY
828 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
830 CALL_VertexAttrib3fARB(GET_DISPATCH(),
832 SHORT_TO_FLOAT(v
[0]),
833 SHORT_TO_FLOAT(v
[1]),
834 SHORT_TO_FLOAT(v
[2])));
837 static void GLAPIENTRY
838 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
840 CALL_VertexAttrib3fARB(GET_DISPATCH(),
842 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
845 static void GLAPIENTRY
846 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
848 CALL_VertexAttrib4fARB(GET_DISPATCH(),
850 SHORT_TO_FLOAT(v
[0]),
851 SHORT_TO_FLOAT(v
[1]),
852 SHORT_TO_FLOAT(v
[2]),
853 SHORT_TO_FLOAT(v
[3])));
856 static void GLAPIENTRY
857 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
859 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
860 (GLfloat
)v
[2], (GLfloat
)v
[3]));
863 /* GL_UNSIGNED_SHORT attributes */
865 static void GLAPIENTRY
866 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
868 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
871 static void GLAPIENTRY
872 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
874 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
877 static void GLAPIENTRY
878 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
880 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
881 USHORT_TO_FLOAT(v
[1])));
884 static void GLAPIENTRY
885 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
887 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
891 static void GLAPIENTRY
892 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
894 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
895 USHORT_TO_FLOAT(v
[1]),
896 USHORT_TO_FLOAT(v
[2])));
899 static void GLAPIENTRY
900 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
902 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
903 (GLfloat
)v
[1], (GLfloat
)v
[2]));
906 static void GLAPIENTRY
907 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
909 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
910 USHORT_TO_FLOAT(v
[1]),
911 USHORT_TO_FLOAT(v
[2]),
912 USHORT_TO_FLOAT(v
[3])));
915 static void GLAPIENTRY
916 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
918 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
921 /* GL_INT attributes */
923 static void GLAPIENTRY
924 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
926 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
929 static void GLAPIENTRY
930 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
932 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
935 static void GLAPIENTRY
936 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
938 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
939 INT_TO_FLOAT(v
[1])));
942 static void GLAPIENTRY
943 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
945 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
949 static void GLAPIENTRY
950 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
952 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
954 INT_TO_FLOAT(v
[2])));
957 static void GLAPIENTRY
958 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
960 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
961 (GLfloat
)v
[1], (GLfloat
)v
[2]));
964 static void GLAPIENTRY
965 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
967 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
970 INT_TO_FLOAT(v
[3])));
973 static void GLAPIENTRY
974 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
976 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
977 (GLfloat
)v
[2], (GLfloat
)v
[3]));
980 /* GL_UNSIGNED_INT attributes */
982 static void GLAPIENTRY
983 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
985 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
988 static void GLAPIENTRY
989 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
991 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
994 static void GLAPIENTRY
995 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
997 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
998 UINT_TO_FLOAT(v
[1])));
1001 static void GLAPIENTRY
1002 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1004 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1008 static void GLAPIENTRY
1009 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1011 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1012 UINT_TO_FLOAT(v
[1]),
1013 UINT_TO_FLOAT(v
[2])));
1016 static void GLAPIENTRY
1017 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1019 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1020 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1023 static void GLAPIENTRY
1024 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1026 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1027 UINT_TO_FLOAT(v
[1]),
1028 UINT_TO_FLOAT(v
[2]),
1029 UINT_TO_FLOAT(v
[3])));
1032 static void GLAPIENTRY
1033 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1035 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1036 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1039 /* GL_FLOAT attributes */
1041 static void GLAPIENTRY
1042 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1044 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1047 static void GLAPIENTRY
1048 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1050 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1053 static void GLAPIENTRY
1054 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1056 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1059 static void GLAPIENTRY
1060 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1062 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1065 /* GL_DOUBLE attributes */
1067 static void GLAPIENTRY
1068 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1070 CALL_VertexAttrib1dv(GET_DISPATCH(), (index
, v
));
1073 static void GLAPIENTRY
1074 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1076 CALL_VertexAttrib2dv(GET_DISPATCH(), (index
, v
));
1079 static void GLAPIENTRY
1080 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1082 CALL_VertexAttrib3dv(GET_DISPATCH(), (index
, v
));
1085 static void GLAPIENTRY
1086 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1088 CALL_VertexAttrib4dv(GET_DISPATCH(), (index
, v
));
1093 * Integer-valued attributes
1095 static void GLAPIENTRY
1096 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1098 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1101 static void GLAPIENTRY
1102 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1104 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1107 static void GLAPIENTRY
1108 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1110 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1113 static void GLAPIENTRY
1114 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1116 CALL_VertexAttribI4bv(GET_DISPATCH(), (index
, v
));
1120 static void GLAPIENTRY
1121 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1123 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1126 static void GLAPIENTRY
1127 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1129 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1132 static void GLAPIENTRY
1133 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1135 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1138 static void GLAPIENTRY
1139 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1141 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index
, v
));
1146 static void GLAPIENTRY
1147 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1149 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1152 static void GLAPIENTRY
1153 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1155 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1158 static void GLAPIENTRY
1159 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1161 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1164 static void GLAPIENTRY
1165 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1167 CALL_VertexAttribI4sv(GET_DISPATCH(), (index
, v
));
1171 static void GLAPIENTRY
1172 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1174 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1177 static void GLAPIENTRY
1178 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1180 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1183 static void GLAPIENTRY
1184 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1186 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1189 static void GLAPIENTRY
1190 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1192 CALL_VertexAttribI4usv(GET_DISPATCH(), (index
, v
));
1197 static void GLAPIENTRY
1198 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1200 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1203 static void GLAPIENTRY
1204 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1206 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1209 static void GLAPIENTRY
1210 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1212 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1215 static void GLAPIENTRY
1216 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1218 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1222 static void GLAPIENTRY
1223 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1225 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1228 static void GLAPIENTRY
1229 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1231 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1234 static void GLAPIENTRY
1235 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1237 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1240 static void GLAPIENTRY
1241 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1243 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1250 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1253 static attrib_func AttribFuncsARB
[3][4][NUM_TYPES
] = {
1255 /* non-normalized */
1258 (attrib_func
) VertexAttrib1bvARB
,
1259 (attrib_func
) VertexAttrib1ubvARB
,
1260 (attrib_func
) VertexAttrib1svARB
,
1261 (attrib_func
) VertexAttrib1usvARB
,
1262 (attrib_func
) VertexAttrib1ivARB
,
1263 (attrib_func
) VertexAttrib1uivARB
,
1264 (attrib_func
) VertexAttrib1fvARB
,
1265 (attrib_func
) VertexAttrib1dvARB
1269 (attrib_func
) VertexAttrib2bvARB
,
1270 (attrib_func
) VertexAttrib2ubvARB
,
1271 (attrib_func
) VertexAttrib2svARB
,
1272 (attrib_func
) VertexAttrib2usvARB
,
1273 (attrib_func
) VertexAttrib2ivARB
,
1274 (attrib_func
) VertexAttrib2uivARB
,
1275 (attrib_func
) VertexAttrib2fvARB
,
1276 (attrib_func
) VertexAttrib2dvARB
1280 (attrib_func
) VertexAttrib3bvARB
,
1281 (attrib_func
) VertexAttrib3ubvARB
,
1282 (attrib_func
) VertexAttrib3svARB
,
1283 (attrib_func
) VertexAttrib3usvARB
,
1284 (attrib_func
) VertexAttrib3ivARB
,
1285 (attrib_func
) VertexAttrib3uivARB
,
1286 (attrib_func
) VertexAttrib3fvARB
,
1287 (attrib_func
) VertexAttrib3dvARB
1291 (attrib_func
) VertexAttrib4bvARB
,
1292 (attrib_func
) VertexAttrib4ubvARB
,
1293 (attrib_func
) VertexAttrib4svARB
,
1294 (attrib_func
) VertexAttrib4usvARB
,
1295 (attrib_func
) VertexAttrib4ivARB
,
1296 (attrib_func
) VertexAttrib4uivARB
,
1297 (attrib_func
) VertexAttrib4fvARB
,
1298 (attrib_func
) VertexAttrib4dvARB
1302 /* normalized (except for float/double) */
1305 (attrib_func
) VertexAttrib1NbvARB
,
1306 (attrib_func
) VertexAttrib1NubvARB
,
1307 (attrib_func
) VertexAttrib1NsvARB
,
1308 (attrib_func
) VertexAttrib1NusvARB
,
1309 (attrib_func
) VertexAttrib1NivARB
,
1310 (attrib_func
) VertexAttrib1NuivARB
,
1311 (attrib_func
) VertexAttrib1fvARB
,
1312 (attrib_func
) VertexAttrib1dvARB
1316 (attrib_func
) VertexAttrib2NbvARB
,
1317 (attrib_func
) VertexAttrib2NubvARB
,
1318 (attrib_func
) VertexAttrib2NsvARB
,
1319 (attrib_func
) VertexAttrib2NusvARB
,
1320 (attrib_func
) VertexAttrib2NivARB
,
1321 (attrib_func
) VertexAttrib2NuivARB
,
1322 (attrib_func
) VertexAttrib2fvARB
,
1323 (attrib_func
) VertexAttrib2dvARB
1327 (attrib_func
) VertexAttrib3NbvARB
,
1328 (attrib_func
) VertexAttrib3NubvARB
,
1329 (attrib_func
) VertexAttrib3NsvARB
,
1330 (attrib_func
) VertexAttrib3NusvARB
,
1331 (attrib_func
) VertexAttrib3NivARB
,
1332 (attrib_func
) VertexAttrib3NuivARB
,
1333 (attrib_func
) VertexAttrib3fvARB
,
1334 (attrib_func
) VertexAttrib3dvARB
1338 (attrib_func
) VertexAttrib4NbvARB
,
1339 (attrib_func
) VertexAttrib4NubvARB
,
1340 (attrib_func
) VertexAttrib4NsvARB
,
1341 (attrib_func
) VertexAttrib4NusvARB
,
1342 (attrib_func
) VertexAttrib4NivARB
,
1343 (attrib_func
) VertexAttrib4NuivARB
,
1344 (attrib_func
) VertexAttrib4fvARB
,
1345 (attrib_func
) VertexAttrib4dvARB
1350 /* integer-valued */
1353 (attrib_func
) VertexAttribI1bv
,
1354 (attrib_func
) VertexAttribI1ubv
,
1355 (attrib_func
) VertexAttribI1sv
,
1356 (attrib_func
) VertexAttribI1usv
,
1357 (attrib_func
) VertexAttribI1iv
,
1358 (attrib_func
) VertexAttribI1uiv
,
1359 NULL
, /* GL_FLOAT */
1360 NULL
/* GL_DOUBLE */
1364 (attrib_func
) VertexAttribI2bv
,
1365 (attrib_func
) VertexAttribI2ubv
,
1366 (attrib_func
) VertexAttribI2sv
,
1367 (attrib_func
) VertexAttribI2usv
,
1368 (attrib_func
) VertexAttribI2iv
,
1369 (attrib_func
) VertexAttribI2uiv
,
1370 NULL
, /* GL_FLOAT */
1371 NULL
/* GL_DOUBLE */
1375 (attrib_func
) VertexAttribI3bv
,
1376 (attrib_func
) VertexAttribI3ubv
,
1377 (attrib_func
) VertexAttribI3sv
,
1378 (attrib_func
) VertexAttribI3usv
,
1379 (attrib_func
) VertexAttribI3iv
,
1380 (attrib_func
) VertexAttribI3uiv
,
1381 NULL
, /* GL_FLOAT */
1382 NULL
/* GL_DOUBLE */
1386 (attrib_func
) VertexAttribI4bv
,
1387 (attrib_func
) VertexAttribI4ubv
,
1388 (attrib_func
) VertexAttribI4sv
,
1389 (attrib_func
) VertexAttribI4usv
,
1390 (attrib_func
) VertexAttribI4iv
,
1391 (attrib_func
) VertexAttribI4uiv
,
1392 NULL
, /* GL_FLOAT */
1393 NULL
/* GL_DOUBLE */
1398 /**********************************************************************/
1401 GLboolean
_ae_create_context( struct gl_context
*ctx
)
1403 if (ctx
->aelt_context
)
1406 /* These _gloffset_* values may not be compile-time constants */
1407 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bv
;
1408 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubv
;
1409 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3sv
;
1410 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usv
;
1411 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3iv
;
1412 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uiv
;
1413 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1414 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dv
;
1416 FogCoordFuncs
[0] = -1;
1417 FogCoordFuncs
[1] = -1;
1418 FogCoordFuncs
[2] = -1;
1419 FogCoordFuncs
[3] = -1;
1420 FogCoordFuncs
[4] = -1;
1421 FogCoordFuncs
[5] = -1;
1422 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1423 FogCoordFuncs
[7] = _gloffset_FogCoorddv
;
1425 ctx
->aelt_context
= calloc(1, sizeof(AEcontext
));
1426 if (!ctx
->aelt_context
)
1429 AE_CONTEXT(ctx
)->NewState
= ~0;
1434 void _ae_destroy_context( struct gl_context
*ctx
)
1436 if ( AE_CONTEXT( ctx
) ) {
1437 free(ctx
->aelt_context
);
1438 ctx
->aelt_context
= NULL
;
1442 static void check_vbo( AEcontext
*actx
,
1443 struct gl_buffer_object
*vbo
)
1445 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1447 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1448 if (actx
->vbo
[i
] == vbo
)
1450 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1451 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1457 * Make a list of per-vertex functions to call for each glArrayElement call.
1458 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1460 * Note: this may be called during display list construction.
1462 static void _ae_update_state( struct gl_context
*ctx
)
1464 AEcontext
*actx
= AE_CONTEXT(ctx
);
1465 AEarray
*aa
= actx
->arrays
;
1466 AEattrib
*at
= actx
->attribs
;
1468 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1472 /* conventional vertex arrays */
1473 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
) {
1474 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1475 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1476 check_vbo(actx
, aa
->array
->BufferObj
);
1479 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
) {
1480 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1481 aa
->offset
= _gloffset_EdgeFlagv
;
1482 check_vbo(actx
, aa
->array
->BufferObj
);
1485 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
) {
1486 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1487 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1488 check_vbo(actx
, aa
->array
->BufferObj
);
1491 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
) {
1492 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1493 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1494 check_vbo(actx
, aa
->array
->BufferObj
);
1497 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
) {
1498 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1499 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1500 check_vbo(actx
, aa
->array
->BufferObj
);
1503 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
) {
1504 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
];
1505 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1506 check_vbo(actx
, aa
->array
->BufferObj
);
1509 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1510 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1511 if (attribArray
->Enabled
) {
1512 /* NOTE: we use generic glVertexAttribNV functions here.
1513 * If we ever remove GL_NV_vertex_program this will have to change.
1515 at
->array
= attribArray
;
1516 ASSERT(!at
->array
->Normalized
);
1517 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1519 [TYPE_IDX(at
->array
->Type
)];
1520 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1521 check_vbo(actx
, at
->array
->BufferObj
);
1526 /* generic vertex attribute arrays */
1527 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1528 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1529 if (attribArray
->Enabled
) {
1531 at
->array
= attribArray
;
1532 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1533 * function pointer here (for float arrays) since the pointer may
1534 * change from one execution of _ae_ArrayElement() to
1535 * the next. Doing so caused UT to break.
1537 if (at
->array
->Integer
)
1539 else if (at
->array
->Normalized
)
1544 at
->func
= AttribFuncsARB
[intOrNorm
]
1546 [TYPE_IDX(at
->array
->Type
)];
1549 check_vbo(actx
, at
->array
->BufferObj
);
1554 /* finally, vertex position */
1555 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
) {
1556 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1557 * issued as the last (provoking) attribute).
1559 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1560 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1561 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1562 check_vbo(actx
, aa
->array
->BufferObj
);
1565 else if (arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
) {
1566 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
];
1567 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1568 check_vbo(actx
, aa
->array
->BufferObj
);
1572 check_vbo(actx
, arrayObj
->ElementArrayBufferObj
);
1574 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1575 ASSERT(aa
- actx
->arrays
< 32);
1576 at
->func
= NULL
; /* terminate the list */
1577 aa
->offset
= -1; /* terminate the list */
1582 void _ae_map_vbos( struct gl_context
*ctx
)
1584 AEcontext
*actx
= AE_CONTEXT(ctx
);
1587 if (actx
->mapped_vbos
)
1591 _ae_update_state(ctx
);
1593 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1594 ctx
->Driver
.MapBufferRange(ctx
, 0,
1600 actx
->mapped_vbos
= GL_TRUE
;
1603 void _ae_unmap_vbos( struct gl_context
*ctx
)
1605 AEcontext
*actx
= AE_CONTEXT(ctx
);
1608 if (!actx
->mapped_vbos
)
1611 assert (!actx
->NewState
);
1613 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1614 ctx
->Driver
.UnmapBuffer(ctx
, actx
->vbo
[i
]);
1616 actx
->mapped_vbos
= GL_FALSE
;
1621 * Called via glArrayElement() and glDrawArrays().
1622 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1623 * for all enabled vertex arrays (for elt-th element).
1624 * Note: this may be called during display list construction.
1626 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1628 GET_CURRENT_CONTEXT(ctx
);
1629 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1632 const struct _glapi_table
* const disp
= GET_DISPATCH();
1635 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1636 * then we call PrimitiveRestartNV and return.
1638 if (ctx
->Array
._PrimitiveRestart
&& (elt
== ctx
->Array
._RestartIndex
)) {
1639 CALL_PrimitiveRestartNV((struct _glapi_table
*)disp
, ());
1643 if (actx
->NewState
) {
1644 assert(!actx
->mapped_vbos
);
1645 _ae_update_state( ctx
);
1648 /* Determine if we need to map/unmap VBOs */
1649 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1654 /* emit generic attribute elements */
1655 for (at
= actx
->attribs
; at
->func
; at
++) {
1657 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1658 + elt
* at
->array
->StrideB
;
1659 at
->func( at
->index
, src
);
1662 /* emit conventional arrays elements */
1663 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1665 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1666 + elt
* aa
->array
->StrideB
;
1667 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1668 ((const void *) src
) );
1672 _ae_unmap_vbos(ctx
);
1676 void _ae_invalidate_state( struct gl_context
*ctx
, GLuint new_state
)
1678 AEcontext
*actx
= AE_CONTEXT(ctx
);
1681 /* Only interested in this subset of mesa state. Need to prune
1682 * this down as both tnl/ and the drivers can raise statechanges
1683 * for arcane reasons in the middle of seemingly atomic operations
1684 * like DrawElements, over which we'd like to keep a known set of
1685 * arrays and vbo's mapped.
1687 * Luckily, neither the drivers nor tnl muck with the state that
1690 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1692 assert(!actx
->mapped_vbos
);
1693 actx
->NewState
|= new_state
;
1698 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1699 const GLvertexformat
*vfmt
)
1701 SET_ArrayElement(disp
, vfmt
->ArrayElement
);