2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
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 <keithw@vmware.com>
39 #include "api_arrayelt.h"
40 #include "bufferobj.h"
45 #include "main/dispatch.h"
48 typedef void (GLAPIENTRY
*array_func
)( const void * );
51 const struct gl_vertex_attrib_array
*array
;
52 const struct gl_vertex_buffer_binding
*binding
;
56 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
59 const struct gl_vertex_attrib_array
*array
;
60 const struct gl_vertex_buffer_binding
*binding
;
67 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
70 /* List of VBOs we need to map before executing ArrayElements */
71 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
73 GLboolean mapped_vbos
; /**< Any currently mapped VBOs? */
78 static inline AEcontext
*
79 AE_CONTEXT(struct gl_context
*ctx
)
81 return (AEcontext
*) ctx
->aelt_context
;
86 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
87 * in the range [0, 7]. Luckily these type tokens are sequentially
88 * numbered in gl.h, except for GL_DOUBLE.
93 return t
== GL_DOUBLE
? 7 : t
& 7;
100 static const int ColorFuncs
[2][NUM_TYPES
] = {
123 static const int VertexFuncs
[3][NUM_TYPES
] = {
156 static const int IndexFuncs
[NUM_TYPES
] = {
167 static const int NormalFuncs
[NUM_TYPES
] = {
178 /* Note: _gloffset_* for these may not be a compile-time constant. */
179 static int SecondaryColorFuncs
[NUM_TYPES
];
180 static int FogCoordFuncs
[NUM_TYPES
];
184 ** GL_NV_vertex_program
187 /* GL_BYTE attributes */
189 static void GLAPIENTRY
190 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
192 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
195 static void GLAPIENTRY
196 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
198 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
201 static void GLAPIENTRY
202 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
204 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
207 static void GLAPIENTRY
208 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
210 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
213 static void GLAPIENTRY
214 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
216 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
218 BYTE_TO_FLOAT(v
[2])));
221 static void GLAPIENTRY
222 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
224 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
227 static void GLAPIENTRY
228 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
230 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
233 BYTE_TO_FLOAT(v
[3])));
236 static void GLAPIENTRY
237 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
239 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
242 /* GL_UNSIGNED_BYTE attributes */
244 static void GLAPIENTRY
245 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
247 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
250 static void GLAPIENTRY
251 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
253 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
256 static void GLAPIENTRY
257 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
259 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
260 UBYTE_TO_FLOAT(v
[1])));
263 static void GLAPIENTRY
264 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
266 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
269 static void GLAPIENTRY
270 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
272 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
273 UBYTE_TO_FLOAT(v
[1]),
274 UBYTE_TO_FLOAT(v
[2])));
276 static void GLAPIENTRY
277 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
279 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
280 (GLfloat
)v
[1], (GLfloat
)v
[2]));
283 static void GLAPIENTRY
284 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
286 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
287 UBYTE_TO_FLOAT(v
[1]),
288 UBYTE_TO_FLOAT(v
[2]),
289 UBYTE_TO_FLOAT(v
[3])));
292 static void GLAPIENTRY
293 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
295 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
296 (GLfloat
)v
[1], (GLfloat
)v
[2],
300 /* GL_SHORT attributes */
302 static void GLAPIENTRY
303 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
305 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
308 static void GLAPIENTRY
309 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
311 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
314 static void GLAPIENTRY
315 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
317 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
318 SHORT_TO_FLOAT(v
[1])));
321 static void GLAPIENTRY
322 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
324 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
327 static void GLAPIENTRY
328 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
330 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
331 SHORT_TO_FLOAT(v
[1]),
332 SHORT_TO_FLOAT(v
[2])));
335 static void GLAPIENTRY
336 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
338 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
342 static void GLAPIENTRY
343 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
345 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
346 SHORT_TO_FLOAT(v
[1]),
347 SHORT_TO_FLOAT(v
[2]),
348 SHORT_TO_FLOAT(v
[3])));
351 static void GLAPIENTRY
352 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
354 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
355 (GLfloat
)v
[2], (GLfloat
)v
[3]));
358 /* GL_UNSIGNED_SHORT attributes */
360 static void GLAPIENTRY
361 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
363 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
366 static void GLAPIENTRY
367 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
369 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
372 static void GLAPIENTRY
373 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
375 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
376 USHORT_TO_FLOAT(v
[1])));
379 static void GLAPIENTRY
380 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
382 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
386 static void GLAPIENTRY
387 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
389 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
390 USHORT_TO_FLOAT(v
[1]),
391 USHORT_TO_FLOAT(v
[2])));
394 static void GLAPIENTRY
395 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
397 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
401 static void GLAPIENTRY
402 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
404 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
405 USHORT_TO_FLOAT(v
[1]),
406 USHORT_TO_FLOAT(v
[2]),
407 USHORT_TO_FLOAT(v
[3])));
410 static void GLAPIENTRY
411 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
413 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
414 (GLfloat
)v
[2], (GLfloat
)v
[3]));
417 /* GL_INT attributes */
419 static void GLAPIENTRY
420 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
422 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
425 static void GLAPIENTRY
426 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
428 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
431 static void GLAPIENTRY
432 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
434 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
435 INT_TO_FLOAT(v
[1])));
438 static void GLAPIENTRY
439 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
441 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
444 static void GLAPIENTRY
445 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
447 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
449 INT_TO_FLOAT(v
[2])));
452 static void GLAPIENTRY
453 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
455 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
459 static void GLAPIENTRY
460 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
462 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
465 INT_TO_FLOAT(v
[3])));
468 static void GLAPIENTRY
469 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
471 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
472 (GLfloat
)v
[2], (GLfloat
)v
[3]));
475 /* GL_UNSIGNED_INT attributes */
477 static void GLAPIENTRY
478 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
480 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
483 static void GLAPIENTRY
484 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
486 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
489 static void GLAPIENTRY
490 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
492 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
493 UINT_TO_FLOAT(v
[1])));
496 static void GLAPIENTRY
497 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
499 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
503 static void GLAPIENTRY
504 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
506 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
508 UINT_TO_FLOAT(v
[2])));
511 static void GLAPIENTRY
512 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
514 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
518 static void GLAPIENTRY
519 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
521 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
524 UINT_TO_FLOAT(v
[3])));
527 static void GLAPIENTRY
528 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
530 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
531 (GLfloat
)v
[2], (GLfloat
)v
[3]));
534 /* GL_FLOAT attributes */
536 static void GLAPIENTRY
537 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
539 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
542 static void GLAPIENTRY
543 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
545 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
548 static void GLAPIENTRY
549 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
551 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
554 static void GLAPIENTRY
555 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
557 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
560 /* GL_DOUBLE attributes */
562 static void GLAPIENTRY
563 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
565 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
568 static void GLAPIENTRY
569 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
571 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
574 static void GLAPIENTRY
575 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
577 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
580 static void GLAPIENTRY
581 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
583 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
588 * Array [size][type] of VertexAttrib functions
590 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
595 (attrib_func
) VertexAttrib1bvNV
,
596 (attrib_func
) VertexAttrib1ubvNV
,
597 (attrib_func
) VertexAttrib1svNV
,
598 (attrib_func
) VertexAttrib1usvNV
,
599 (attrib_func
) VertexAttrib1ivNV
,
600 (attrib_func
) VertexAttrib1uivNV
,
601 (attrib_func
) VertexAttrib1fvNV
,
602 (attrib_func
) VertexAttrib1dvNV
606 (attrib_func
) VertexAttrib2bvNV
,
607 (attrib_func
) VertexAttrib2ubvNV
,
608 (attrib_func
) VertexAttrib2svNV
,
609 (attrib_func
) VertexAttrib2usvNV
,
610 (attrib_func
) VertexAttrib2ivNV
,
611 (attrib_func
) VertexAttrib2uivNV
,
612 (attrib_func
) VertexAttrib2fvNV
,
613 (attrib_func
) VertexAttrib2dvNV
617 (attrib_func
) VertexAttrib3bvNV
,
618 (attrib_func
) VertexAttrib3ubvNV
,
619 (attrib_func
) VertexAttrib3svNV
,
620 (attrib_func
) VertexAttrib3usvNV
,
621 (attrib_func
) VertexAttrib3ivNV
,
622 (attrib_func
) VertexAttrib3uivNV
,
623 (attrib_func
) VertexAttrib3fvNV
,
624 (attrib_func
) VertexAttrib3dvNV
628 (attrib_func
) VertexAttrib4bvNV
,
629 (attrib_func
) VertexAttrib4ubvNV
,
630 (attrib_func
) VertexAttrib4svNV
,
631 (attrib_func
) VertexAttrib4usvNV
,
632 (attrib_func
) VertexAttrib4ivNV
,
633 (attrib_func
) VertexAttrib4uivNV
,
634 (attrib_func
) VertexAttrib4fvNV
,
635 (attrib_func
) VertexAttrib4dvNV
639 /* normalized (except for float/double) */
642 (attrib_func
) VertexAttrib1NbvNV
,
643 (attrib_func
) VertexAttrib1NubvNV
,
644 (attrib_func
) VertexAttrib1NsvNV
,
645 (attrib_func
) VertexAttrib1NusvNV
,
646 (attrib_func
) VertexAttrib1NivNV
,
647 (attrib_func
) VertexAttrib1NuivNV
,
648 (attrib_func
) VertexAttrib1fvNV
,
649 (attrib_func
) VertexAttrib1dvNV
653 (attrib_func
) VertexAttrib2NbvNV
,
654 (attrib_func
) VertexAttrib2NubvNV
,
655 (attrib_func
) VertexAttrib2NsvNV
,
656 (attrib_func
) VertexAttrib2NusvNV
,
657 (attrib_func
) VertexAttrib2NivNV
,
658 (attrib_func
) VertexAttrib2NuivNV
,
659 (attrib_func
) VertexAttrib2fvNV
,
660 (attrib_func
) VertexAttrib2dvNV
664 (attrib_func
) VertexAttrib3NbvNV
,
665 (attrib_func
) VertexAttrib3NubvNV
,
666 (attrib_func
) VertexAttrib3NsvNV
,
667 (attrib_func
) VertexAttrib3NusvNV
,
668 (attrib_func
) VertexAttrib3NivNV
,
669 (attrib_func
) VertexAttrib3NuivNV
,
670 (attrib_func
) VertexAttrib3fvNV
,
671 (attrib_func
) VertexAttrib3dvNV
675 (attrib_func
) VertexAttrib4NbvNV
,
676 (attrib_func
) VertexAttrib4NubvNV
,
677 (attrib_func
) VertexAttrib4NsvNV
,
678 (attrib_func
) VertexAttrib4NusvNV
,
679 (attrib_func
) VertexAttrib4NivNV
,
680 (attrib_func
) VertexAttrib4NuivNV
,
681 (attrib_func
) VertexAttrib4fvNV
,
682 (attrib_func
) VertexAttrib4dvNV
689 ** GL_ARB_vertex_program
692 /* GL_BYTE attributes */
694 static void GLAPIENTRY
695 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
697 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
700 static void GLAPIENTRY
701 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
703 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
706 static void GLAPIENTRY
707 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
709 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
712 static void GLAPIENTRY
713 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
715 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
718 static void GLAPIENTRY
719 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
721 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
723 BYTE_TO_FLOAT(v
[2])));
726 static void GLAPIENTRY
727 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
729 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
732 static void GLAPIENTRY
733 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
735 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
738 BYTE_TO_FLOAT(v
[3])));
741 static void GLAPIENTRY
742 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
744 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
747 /* GL_UNSIGNED_BYTE attributes */
749 static void GLAPIENTRY
750 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
752 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
755 static void GLAPIENTRY
756 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
758 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
761 static void GLAPIENTRY
762 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
764 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
765 UBYTE_TO_FLOAT(v
[0]),
766 UBYTE_TO_FLOAT(v
[1])));
769 static void GLAPIENTRY
770 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
772 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
773 (GLfloat
)v
[0], (GLfloat
)v
[1]));
776 static void GLAPIENTRY
777 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
779 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
780 UBYTE_TO_FLOAT(v
[0]),
781 UBYTE_TO_FLOAT(v
[1]),
782 UBYTE_TO_FLOAT(v
[2])));
784 static void GLAPIENTRY
785 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
787 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
793 static void GLAPIENTRY
794 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
796 CALL_VertexAttrib4fARB(GET_DISPATCH(),
798 UBYTE_TO_FLOAT(v
[0]),
799 UBYTE_TO_FLOAT(v
[1]),
800 UBYTE_TO_FLOAT(v
[2]),
801 UBYTE_TO_FLOAT(v
[3])));
804 static void GLAPIENTRY
805 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
807 CALL_VertexAttrib4fARB(GET_DISPATCH(),
809 (GLfloat
)v
[0], (GLfloat
)v
[1],
810 (GLfloat
)v
[2], (GLfloat
)v
[3]));
813 /* GL_SHORT attributes */
815 static void GLAPIENTRY
816 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
818 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
821 static void GLAPIENTRY
822 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
824 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
827 static void GLAPIENTRY
828 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
830 CALL_VertexAttrib2fARB(GET_DISPATCH(),
831 (index
, SHORT_TO_FLOAT(v
[0]),
832 SHORT_TO_FLOAT(v
[1])));
835 static void GLAPIENTRY
836 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
838 CALL_VertexAttrib2fARB(GET_DISPATCH(),
839 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
842 static void GLAPIENTRY
843 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
845 CALL_VertexAttrib3fARB(GET_DISPATCH(),
847 SHORT_TO_FLOAT(v
[0]),
848 SHORT_TO_FLOAT(v
[1]),
849 SHORT_TO_FLOAT(v
[2])));
852 static void GLAPIENTRY
853 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
855 CALL_VertexAttrib3fARB(GET_DISPATCH(),
857 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
860 static void GLAPIENTRY
861 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
863 CALL_VertexAttrib4fARB(GET_DISPATCH(),
865 SHORT_TO_FLOAT(v
[0]),
866 SHORT_TO_FLOAT(v
[1]),
867 SHORT_TO_FLOAT(v
[2]),
868 SHORT_TO_FLOAT(v
[3])));
871 static void GLAPIENTRY
872 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
874 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
875 (GLfloat
)v
[2], (GLfloat
)v
[3]));
878 /* GL_UNSIGNED_SHORT attributes */
880 static void GLAPIENTRY
881 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
883 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
886 static void GLAPIENTRY
887 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
889 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
892 static void GLAPIENTRY
893 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
895 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
896 USHORT_TO_FLOAT(v
[1])));
899 static void GLAPIENTRY
900 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
902 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
906 static void GLAPIENTRY
907 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
909 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
910 USHORT_TO_FLOAT(v
[1]),
911 USHORT_TO_FLOAT(v
[2])));
914 static void GLAPIENTRY
915 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
917 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
918 (GLfloat
)v
[1], (GLfloat
)v
[2]));
921 static void GLAPIENTRY
922 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
924 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
925 USHORT_TO_FLOAT(v
[1]),
926 USHORT_TO_FLOAT(v
[2]),
927 USHORT_TO_FLOAT(v
[3])));
930 static void GLAPIENTRY
931 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
933 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
936 /* GL_INT attributes */
938 static void GLAPIENTRY
939 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
941 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
944 static void GLAPIENTRY
945 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
947 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
950 static void GLAPIENTRY
951 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
953 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
954 INT_TO_FLOAT(v
[1])));
957 static void GLAPIENTRY
958 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
960 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
964 static void GLAPIENTRY
965 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
967 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
969 INT_TO_FLOAT(v
[2])));
972 static void GLAPIENTRY
973 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
975 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
976 (GLfloat
)v
[1], (GLfloat
)v
[2]));
979 static void GLAPIENTRY
980 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
982 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
985 INT_TO_FLOAT(v
[3])));
988 static void GLAPIENTRY
989 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
991 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
992 (GLfloat
)v
[2], (GLfloat
)v
[3]));
995 /* GL_UNSIGNED_INT attributes */
997 static void GLAPIENTRY
998 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
1000 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
1003 static void GLAPIENTRY
1004 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
1006 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
1009 static void GLAPIENTRY
1010 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
1012 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1013 UINT_TO_FLOAT(v
[1])));
1016 static void GLAPIENTRY
1017 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1019 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1023 static void GLAPIENTRY
1024 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1026 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1027 UINT_TO_FLOAT(v
[1]),
1028 UINT_TO_FLOAT(v
[2])));
1031 static void GLAPIENTRY
1032 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1034 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1035 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1038 static void GLAPIENTRY
1039 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1041 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1042 UINT_TO_FLOAT(v
[1]),
1043 UINT_TO_FLOAT(v
[2]),
1044 UINT_TO_FLOAT(v
[3])));
1047 static void GLAPIENTRY
1048 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1050 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1051 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1054 /* GL_FLOAT attributes */
1056 static void GLAPIENTRY
1057 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1059 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1062 static void GLAPIENTRY
1063 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1065 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1068 static void GLAPIENTRY
1069 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1071 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1074 static void GLAPIENTRY
1075 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1077 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1080 /* GL_DOUBLE attributes */
1082 static void GLAPIENTRY
1083 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1085 CALL_VertexAttrib1dv(GET_DISPATCH(), (index
, v
));
1088 static void GLAPIENTRY
1089 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1091 CALL_VertexAttrib2dv(GET_DISPATCH(), (index
, v
));
1094 static void GLAPIENTRY
1095 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1097 CALL_VertexAttrib3dv(GET_DISPATCH(), (index
, v
));
1100 static void GLAPIENTRY
1101 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1103 CALL_VertexAttrib4dv(GET_DISPATCH(), (index
, v
));
1108 * Integer-valued attributes
1110 static void GLAPIENTRY
1111 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1113 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1116 static void GLAPIENTRY
1117 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1119 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1122 static void GLAPIENTRY
1123 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1125 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1128 static void GLAPIENTRY
1129 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1131 CALL_VertexAttribI4bv(GET_DISPATCH(), (index
, v
));
1135 static void GLAPIENTRY
1136 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1138 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1141 static void GLAPIENTRY
1142 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1144 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1147 static void GLAPIENTRY
1148 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1150 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1153 static void GLAPIENTRY
1154 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1156 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index
, v
));
1161 static void GLAPIENTRY
1162 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1164 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1167 static void GLAPIENTRY
1168 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1170 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1173 static void GLAPIENTRY
1174 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1176 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1179 static void GLAPIENTRY
1180 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1182 CALL_VertexAttribI4sv(GET_DISPATCH(), (index
, v
));
1186 static void GLAPIENTRY
1187 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1189 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1192 static void GLAPIENTRY
1193 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1195 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1198 static void GLAPIENTRY
1199 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1201 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1204 static void GLAPIENTRY
1205 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1207 CALL_VertexAttribI4usv(GET_DISPATCH(), (index
, v
));
1212 static void GLAPIENTRY
1213 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1215 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1218 static void GLAPIENTRY
1219 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1221 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1224 static void GLAPIENTRY
1225 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1227 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1230 static void GLAPIENTRY
1231 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1233 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1237 static void GLAPIENTRY
1238 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1240 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1243 static void GLAPIENTRY
1244 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1246 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1249 static void GLAPIENTRY
1250 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1252 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1255 static void GLAPIENTRY
1256 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1258 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1261 /* GL_DOUBLE unconverted attributes */
1263 static void GLAPIENTRY
1264 VertexAttribL1dv(GLuint index
, const GLdouble
*v
)
1266 CALL_VertexAttribL1dv(GET_DISPATCH(), (index
, v
));
1269 static void GLAPIENTRY
1270 VertexAttribL2dv(GLuint index
, const GLdouble
*v
)
1272 CALL_VertexAttribL2dv(GET_DISPATCH(), (index
, v
));
1275 static void GLAPIENTRY
1276 VertexAttribL3dv(GLuint index
, const GLdouble
*v
)
1278 CALL_VertexAttribL3dv(GET_DISPATCH(), (index
, v
));
1281 static void GLAPIENTRY
1282 VertexAttribL4dv(GLuint index
, const GLdouble
*v
)
1284 CALL_VertexAttribL4dv(GET_DISPATCH(), (index
, v
));
1288 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1291 static attrib_func AttribFuncsARB
[4][4][NUM_TYPES
] = {
1293 /* non-normalized */
1296 (attrib_func
) VertexAttrib1bvARB
,
1297 (attrib_func
) VertexAttrib1ubvARB
,
1298 (attrib_func
) VertexAttrib1svARB
,
1299 (attrib_func
) VertexAttrib1usvARB
,
1300 (attrib_func
) VertexAttrib1ivARB
,
1301 (attrib_func
) VertexAttrib1uivARB
,
1302 (attrib_func
) VertexAttrib1fvARB
,
1303 (attrib_func
) VertexAttrib1dvARB
1307 (attrib_func
) VertexAttrib2bvARB
,
1308 (attrib_func
) VertexAttrib2ubvARB
,
1309 (attrib_func
) VertexAttrib2svARB
,
1310 (attrib_func
) VertexAttrib2usvARB
,
1311 (attrib_func
) VertexAttrib2ivARB
,
1312 (attrib_func
) VertexAttrib2uivARB
,
1313 (attrib_func
) VertexAttrib2fvARB
,
1314 (attrib_func
) VertexAttrib2dvARB
1318 (attrib_func
) VertexAttrib3bvARB
,
1319 (attrib_func
) VertexAttrib3ubvARB
,
1320 (attrib_func
) VertexAttrib3svARB
,
1321 (attrib_func
) VertexAttrib3usvARB
,
1322 (attrib_func
) VertexAttrib3ivARB
,
1323 (attrib_func
) VertexAttrib3uivARB
,
1324 (attrib_func
) VertexAttrib3fvARB
,
1325 (attrib_func
) VertexAttrib3dvARB
1329 (attrib_func
) VertexAttrib4bvARB
,
1330 (attrib_func
) VertexAttrib4ubvARB
,
1331 (attrib_func
) VertexAttrib4svARB
,
1332 (attrib_func
) VertexAttrib4usvARB
,
1333 (attrib_func
) VertexAttrib4ivARB
,
1334 (attrib_func
) VertexAttrib4uivARB
,
1335 (attrib_func
) VertexAttrib4fvARB
,
1336 (attrib_func
) VertexAttrib4dvARB
1340 /* normalized (except for float/double) */
1343 (attrib_func
) VertexAttrib1NbvARB
,
1344 (attrib_func
) VertexAttrib1NubvARB
,
1345 (attrib_func
) VertexAttrib1NsvARB
,
1346 (attrib_func
) VertexAttrib1NusvARB
,
1347 (attrib_func
) VertexAttrib1NivARB
,
1348 (attrib_func
) VertexAttrib1NuivARB
,
1349 (attrib_func
) VertexAttrib1fvARB
,
1350 (attrib_func
) VertexAttrib1dvARB
1354 (attrib_func
) VertexAttrib2NbvARB
,
1355 (attrib_func
) VertexAttrib2NubvARB
,
1356 (attrib_func
) VertexAttrib2NsvARB
,
1357 (attrib_func
) VertexAttrib2NusvARB
,
1358 (attrib_func
) VertexAttrib2NivARB
,
1359 (attrib_func
) VertexAttrib2NuivARB
,
1360 (attrib_func
) VertexAttrib2fvARB
,
1361 (attrib_func
) VertexAttrib2dvARB
1365 (attrib_func
) VertexAttrib3NbvARB
,
1366 (attrib_func
) VertexAttrib3NubvARB
,
1367 (attrib_func
) VertexAttrib3NsvARB
,
1368 (attrib_func
) VertexAttrib3NusvARB
,
1369 (attrib_func
) VertexAttrib3NivARB
,
1370 (attrib_func
) VertexAttrib3NuivARB
,
1371 (attrib_func
) VertexAttrib3fvARB
,
1372 (attrib_func
) VertexAttrib3dvARB
1376 (attrib_func
) VertexAttrib4NbvARB
,
1377 (attrib_func
) VertexAttrib4NubvARB
,
1378 (attrib_func
) VertexAttrib4NsvARB
,
1379 (attrib_func
) VertexAttrib4NusvARB
,
1380 (attrib_func
) VertexAttrib4NivARB
,
1381 (attrib_func
) VertexAttrib4NuivARB
,
1382 (attrib_func
) VertexAttrib4fvARB
,
1383 (attrib_func
) VertexAttrib4dvARB
1388 /* integer-valued */
1391 (attrib_func
) VertexAttribI1bv
,
1392 (attrib_func
) VertexAttribI1ubv
,
1393 (attrib_func
) VertexAttribI1sv
,
1394 (attrib_func
) VertexAttribI1usv
,
1395 (attrib_func
) VertexAttribI1iv
,
1396 (attrib_func
) VertexAttribI1uiv
,
1397 NULL
, /* GL_FLOAT */
1398 NULL
/* GL_DOUBLE */
1402 (attrib_func
) VertexAttribI2bv
,
1403 (attrib_func
) VertexAttribI2ubv
,
1404 (attrib_func
) VertexAttribI2sv
,
1405 (attrib_func
) VertexAttribI2usv
,
1406 (attrib_func
) VertexAttribI2iv
,
1407 (attrib_func
) VertexAttribI2uiv
,
1408 NULL
, /* GL_FLOAT */
1409 NULL
/* GL_DOUBLE */
1413 (attrib_func
) VertexAttribI3bv
,
1414 (attrib_func
) VertexAttribI3ubv
,
1415 (attrib_func
) VertexAttribI3sv
,
1416 (attrib_func
) VertexAttribI3usv
,
1417 (attrib_func
) VertexAttribI3iv
,
1418 (attrib_func
) VertexAttribI3uiv
,
1419 NULL
, /* GL_FLOAT */
1420 NULL
/* GL_DOUBLE */
1424 (attrib_func
) VertexAttribI4bv
,
1425 (attrib_func
) VertexAttribI4ubv
,
1426 (attrib_func
) VertexAttribI4sv
,
1427 (attrib_func
) VertexAttribI4usv
,
1428 (attrib_func
) VertexAttribI4iv
,
1429 (attrib_func
) VertexAttribI4uiv
,
1430 NULL
, /* GL_FLOAT */
1431 NULL
/* GL_DOUBLE */
1445 (attrib_func
) VertexAttribL1dv
,
1456 (attrib_func
) VertexAttribL2dv
,
1467 (attrib_func
) VertexAttribL3dv
,
1478 (attrib_func
) VertexAttribL4dv
,
1486 _ae_create_context(struct gl_context
*ctx
)
1488 if (ctx
->aelt_context
)
1491 /* These _gloffset_* values may not be compile-time constants */
1492 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bv
;
1493 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubv
;
1494 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3sv
;
1495 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usv
;
1496 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3iv
;
1497 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uiv
;
1498 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1499 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dv
;
1501 FogCoordFuncs
[0] = -1;
1502 FogCoordFuncs
[1] = -1;
1503 FogCoordFuncs
[2] = -1;
1504 FogCoordFuncs
[3] = -1;
1505 FogCoordFuncs
[4] = -1;
1506 FogCoordFuncs
[5] = -1;
1507 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1508 FogCoordFuncs
[7] = _gloffset_FogCoorddv
;
1510 ctx
->aelt_context
= calloc(1, sizeof(AEcontext
));
1511 if (!ctx
->aelt_context
)
1514 AE_CONTEXT(ctx
)->NewState
= ~0;
1520 _ae_destroy_context(struct gl_context
*ctx
)
1522 if (AE_CONTEXT(ctx
)) {
1523 free(ctx
->aelt_context
);
1524 ctx
->aelt_context
= NULL
;
1530 * Check if the given vertex buffer object exists and is not mapped.
1531 * If so, add it to the list of buffers we must map before executing
1532 * an glArrayElement call.
1535 check_vbo(AEcontext
*actx
, struct gl_buffer_object
*vbo
)
1537 if (_mesa_is_bufferobj(vbo
) &&
1538 !_mesa_bufferobj_mapped(vbo
, MAP_INTERNAL
)) {
1540 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1541 if (actx
->vbo
[i
] == vbo
)
1542 return; /* already in the list, we're done */
1543 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1544 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1550 * Make a list of per-vertex functions to call for each glArrayElement call.
1551 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1553 * Note: this may be called during display list construction.
1556 _ae_update_state(struct gl_context
*ctx
)
1558 AEcontext
*actx
= AE_CONTEXT(ctx
);
1559 AEarray
*aa
= actx
->arrays
; /* non-indexed arrays (ex: glNormal) */
1560 AEattrib
*at
= actx
->attribs
; /* indexed arrays (ex: glMultiTexCoord) */
1562 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1566 /* conventional vertex arrays */
1567 if (vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
) {
1568 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1569 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1570 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1571 check_vbo(actx
, aa
->binding
->BufferObj
);
1575 if (vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
) {
1576 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1577 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1578 aa
->offset
= _gloffset_EdgeFlagv
;
1579 check_vbo(actx
, aa
->binding
->BufferObj
);
1583 if (vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
) {
1584 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1585 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1586 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1587 check_vbo(actx
, aa
->binding
->BufferObj
);
1591 if (vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
) {
1592 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1593 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1594 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1595 check_vbo(actx
, aa
->binding
->BufferObj
);
1599 if (vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
) {
1600 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1601 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1602 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1603 check_vbo(actx
, aa
->binding
->BufferObj
);
1607 if (vao
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
) {
1608 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_FOG
];
1609 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1610 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1611 check_vbo(actx
, aa
->binding
->BufferObj
);
1615 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1616 struct gl_vertex_attrib_array
*attribArray
=
1617 &vao
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1618 if (attribArray
->Enabled
) {
1619 /* NOTE: we use generic glVertexAttribNV functions here.
1620 * If we ever remove GL_NV_vertex_program this will have to change.
1622 at
->array
= attribArray
;
1623 at
->binding
= &vao
->VertexBinding
[attribArray
->VertexBinding
];
1624 assert(!at
->array
->Normalized
);
1625 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1627 [TYPE_IDX(at
->array
->Type
)];
1628 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1629 check_vbo(actx
, at
->binding
->BufferObj
);
1634 /* generic vertex attribute arrays */
1635 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1636 struct gl_vertex_attrib_array
*attribArray
=
1637 &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1638 if (attribArray
->Enabled
) {
1640 at
->array
= attribArray
;
1641 at
->binding
= &vao
->VertexBinding
[attribArray
->VertexBinding
];
1642 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1643 * function pointer here (for float arrays) since the pointer may
1644 * change from one execution of _ae_ArrayElement() to
1645 * the next. Doing so caused UT to break.
1647 if (at
->array
->Doubles
)
1649 else if (at
->array
->Integer
)
1651 else if (at
->array
->Normalized
)
1656 at
->func
= AttribFuncsARB
[intOrNorm
]
1658 [TYPE_IDX(at
->array
->Type
)];
1661 check_vbo(actx
, at
->binding
->BufferObj
);
1666 /* finally, vertex position */
1667 if (vao
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
) {
1668 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1669 * issued as the last (provoking) attribute).
1671 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1672 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1673 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1674 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1675 check_vbo(actx
, aa
->binding
->BufferObj
);
1678 else if (vao
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
) {
1679 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_POS
];
1680 aa
->binding
= &vao
->VertexBinding
[aa
->array
->VertexBinding
];
1681 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1682 check_vbo(actx
, aa
->binding
->BufferObj
);
1686 check_vbo(actx
, vao
->IndexBufferObj
);
1688 assert(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1689 assert(aa
- actx
->arrays
< 32);
1690 at
->func
= NULL
; /* terminate the list */
1691 aa
->offset
= -1; /* terminate the list */
1698 * Before replaying glArrayElements calls we need to map (for reading) any
1699 * VBOs referenced by the enabled vertex arrays.
1702 _ae_map_vbos(struct gl_context
*ctx
)
1704 AEcontext
*actx
= AE_CONTEXT(ctx
);
1707 if (actx
->mapped_vbos
)
1711 _ae_update_state(ctx
);
1713 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1714 ctx
->Driver
.MapBufferRange(ctx
, 0,
1721 actx
->mapped_vbos
= GL_TRUE
;
1729 _ae_unmap_vbos(struct gl_context
*ctx
)
1731 AEcontext
*actx
= AE_CONTEXT(ctx
);
1734 if (!actx
->mapped_vbos
)
1737 assert (!actx
->NewState
);
1739 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1740 ctx
->Driver
.UnmapBuffer(ctx
, actx
->vbo
[i
], MAP_INTERNAL
);
1742 actx
->mapped_vbos
= GL_FALSE
;
1747 * Called via glArrayElement() and glDrawArrays().
1748 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1749 * for all enabled vertex arrays (for elt-th element).
1750 * Note: this may be called during display list construction.
1753 _ae_ArrayElement(GLint elt
)
1755 GET_CURRENT_CONTEXT(ctx
);
1756 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1759 const struct _glapi_table
* const disp
= GET_DISPATCH();
1762 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1763 * then we call PrimitiveRestartNV and return.
1765 if (ctx
->Array
.PrimitiveRestart
&& (elt
== ctx
->Array
.RestartIndex
)) {
1766 CALL_PrimitiveRestartNV((struct _glapi_table
*)disp
, ());
1770 if (actx
->NewState
) {
1771 assert(!actx
->mapped_vbos
);
1772 _ae_update_state(ctx
);
1775 /* Determine if we need to map/unmap VBOs */
1776 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1781 /* emit generic attribute elements */
1782 for (at
= actx
->attribs
; at
->func
; at
++) {
1784 = ADD_POINTERS(at
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1785 _mesa_vertex_attrib_address(at
->array
, at
->binding
))
1786 + elt
* at
->binding
->Stride
;
1787 at
->func(at
->index
, src
);
1790 /* emit conventional arrays elements */
1791 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1793 = ADD_POINTERS(aa
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1794 _mesa_vertex_attrib_address(aa
->array
, aa
->binding
))
1795 + elt
* aa
->binding
->Stride
;
1796 CALL_by_offset(disp
, (array_func
), aa
->offset
, ((const void *) src
));
1800 _ae_unmap_vbos(ctx
);
1805 _ae_invalidate_state(struct gl_context
*ctx
, GLuint new_state
)
1807 AEcontext
*actx
= AE_CONTEXT(ctx
);
1809 /* Only interested in this subset of mesa state. Need to prune
1810 * this down as both tnl/ and the drivers can raise statechanges
1811 * for arcane reasons in the middle of seemingly atomic operations
1812 * like DrawElements, over which we'd like to keep a known set of
1813 * arrays and vbo's mapped.
1815 * Luckily, neither the drivers nor tnl muck with the state that
1818 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1820 assert(!actx
->mapped_vbos
);
1821 actx
->NewState
|= new_state
;
1827 _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1828 const GLvertexformat
*vfmt
)
1830 SET_ArrayElement(disp
, vfmt
->ArrayElement
);