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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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"
43 #include "main/dispatch.h"
45 typedef void (GLAPIENTRY
*array_func
)( const void * );
48 const struct gl_client_array
*array
;
52 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
55 const struct gl_client_array
*array
;
62 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
65 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
67 GLboolean mapped_vbos
;
71 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
75 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
76 * in the range [0, 7]. Luckily these type tokens are sequentially
77 * numbered in gl.h, except for GL_DOUBLE.
79 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
87 static const int ColorFuncs
[2][NUM_TYPES
] = {
110 static const int VertexFuncs
[3][NUM_TYPES
] = {
143 static const int IndexFuncs
[NUM_TYPES
] = {
154 static const int NormalFuncs
[NUM_TYPES
] = {
165 /* Note: _gloffset_* for these may not be a compile-time constant. */
166 static int SecondaryColorFuncs
[NUM_TYPES
];
167 static int FogCoordFuncs
[NUM_TYPES
];
171 ** GL_NV_vertex_program
174 /* GL_BYTE attributes */
177 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
179 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
183 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
185 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
189 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
191 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
195 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
197 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
201 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
203 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
205 BYTE_TO_FLOAT(v
[2])));
209 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
211 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
215 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
217 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
220 BYTE_TO_FLOAT(v
[3])));
224 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
226 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
229 /* GL_UNSIGNED_BYTE attributes */
232 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
234 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
238 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
240 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
244 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
246 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
247 UBYTE_TO_FLOAT(v
[1])));
251 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
253 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
257 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
259 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
260 UBYTE_TO_FLOAT(v
[1]),
261 UBYTE_TO_FLOAT(v
[2])));
264 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
266 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
267 (GLfloat
)v
[1], (GLfloat
)v
[2]));
271 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
273 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
274 UBYTE_TO_FLOAT(v
[1]),
275 UBYTE_TO_FLOAT(v
[2]),
276 UBYTE_TO_FLOAT(v
[3])));
280 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
282 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
283 (GLfloat
)v
[1], (GLfloat
)v
[2],
287 /* GL_SHORT attributes */
290 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
292 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
296 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
298 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
302 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
304 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
305 SHORT_TO_FLOAT(v
[1])));
309 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
311 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
315 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
317 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
318 SHORT_TO_FLOAT(v
[1]),
319 SHORT_TO_FLOAT(v
[2])));
323 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
325 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
330 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
332 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
333 SHORT_TO_FLOAT(v
[1]),
334 SHORT_TO_FLOAT(v
[2]),
335 SHORT_TO_FLOAT(v
[3])));
339 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
341 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
342 (GLfloat
)v
[2], (GLfloat
)v
[3]));
345 /* GL_UNSIGNED_SHORT attributes */
348 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
350 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
354 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
356 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
360 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
362 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
363 USHORT_TO_FLOAT(v
[1])));
367 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
369 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
374 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
376 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
377 USHORT_TO_FLOAT(v
[1]),
378 USHORT_TO_FLOAT(v
[2])));
382 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
384 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
389 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
391 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
392 USHORT_TO_FLOAT(v
[1]),
393 USHORT_TO_FLOAT(v
[2]),
394 USHORT_TO_FLOAT(v
[3])));
398 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
400 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
401 (GLfloat
)v
[2], (GLfloat
)v
[3]));
404 /* GL_INT attributes */
407 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
409 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
413 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
415 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
419 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
421 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
422 INT_TO_FLOAT(v
[1])));
426 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
428 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
432 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
434 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
436 INT_TO_FLOAT(v
[2])));
440 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
442 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
447 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
449 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
452 INT_TO_FLOAT(v
[3])));
456 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
458 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
459 (GLfloat
)v
[2], (GLfloat
)v
[3]));
462 /* GL_UNSIGNED_INT attributes */
465 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
467 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
471 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
473 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
477 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
479 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
480 UINT_TO_FLOAT(v
[1])));
484 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
486 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
491 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
493 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
495 UINT_TO_FLOAT(v
[2])));
499 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
501 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
506 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
508 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
511 UINT_TO_FLOAT(v
[3])));
515 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
517 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
518 (GLfloat
)v
[2], (GLfloat
)v
[3]));
521 /* GL_FLOAT attributes */
524 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
526 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
530 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
532 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
536 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
538 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
542 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
544 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
547 /* GL_DOUBLE attributes */
550 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
552 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
556 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
558 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
562 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
564 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
568 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
570 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
575 * Array [size][type] of VertexAttrib functions
577 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
582 (attrib_func
) VertexAttrib1bvNV
,
583 (attrib_func
) VertexAttrib1ubvNV
,
584 (attrib_func
) VertexAttrib1svNV
,
585 (attrib_func
) VertexAttrib1usvNV
,
586 (attrib_func
) VertexAttrib1ivNV
,
587 (attrib_func
) VertexAttrib1uivNV
,
588 (attrib_func
) VertexAttrib1fvNV
,
589 (attrib_func
) VertexAttrib1dvNV
593 (attrib_func
) VertexAttrib2bvNV
,
594 (attrib_func
) VertexAttrib2ubvNV
,
595 (attrib_func
) VertexAttrib2svNV
,
596 (attrib_func
) VertexAttrib2usvNV
,
597 (attrib_func
) VertexAttrib2ivNV
,
598 (attrib_func
) VertexAttrib2uivNV
,
599 (attrib_func
) VertexAttrib2fvNV
,
600 (attrib_func
) VertexAttrib2dvNV
604 (attrib_func
) VertexAttrib3bvNV
,
605 (attrib_func
) VertexAttrib3ubvNV
,
606 (attrib_func
) VertexAttrib3svNV
,
607 (attrib_func
) VertexAttrib3usvNV
,
608 (attrib_func
) VertexAttrib3ivNV
,
609 (attrib_func
) VertexAttrib3uivNV
,
610 (attrib_func
) VertexAttrib3fvNV
,
611 (attrib_func
) VertexAttrib3dvNV
615 (attrib_func
) VertexAttrib4bvNV
,
616 (attrib_func
) VertexAttrib4ubvNV
,
617 (attrib_func
) VertexAttrib4svNV
,
618 (attrib_func
) VertexAttrib4usvNV
,
619 (attrib_func
) VertexAttrib4ivNV
,
620 (attrib_func
) VertexAttrib4uivNV
,
621 (attrib_func
) VertexAttrib4fvNV
,
622 (attrib_func
) VertexAttrib4dvNV
626 /* normalized (except for float/double) */
629 (attrib_func
) VertexAttrib1NbvNV
,
630 (attrib_func
) VertexAttrib1NubvNV
,
631 (attrib_func
) VertexAttrib1NsvNV
,
632 (attrib_func
) VertexAttrib1NusvNV
,
633 (attrib_func
) VertexAttrib1NivNV
,
634 (attrib_func
) VertexAttrib1NuivNV
,
635 (attrib_func
) VertexAttrib1fvNV
,
636 (attrib_func
) VertexAttrib1dvNV
640 (attrib_func
) VertexAttrib2NbvNV
,
641 (attrib_func
) VertexAttrib2NubvNV
,
642 (attrib_func
) VertexAttrib2NsvNV
,
643 (attrib_func
) VertexAttrib2NusvNV
,
644 (attrib_func
) VertexAttrib2NivNV
,
645 (attrib_func
) VertexAttrib2NuivNV
,
646 (attrib_func
) VertexAttrib2fvNV
,
647 (attrib_func
) VertexAttrib2dvNV
651 (attrib_func
) VertexAttrib3NbvNV
,
652 (attrib_func
) VertexAttrib3NubvNV
,
653 (attrib_func
) VertexAttrib3NsvNV
,
654 (attrib_func
) VertexAttrib3NusvNV
,
655 (attrib_func
) VertexAttrib3NivNV
,
656 (attrib_func
) VertexAttrib3NuivNV
,
657 (attrib_func
) VertexAttrib3fvNV
,
658 (attrib_func
) VertexAttrib3dvNV
662 (attrib_func
) VertexAttrib4NbvNV
,
663 (attrib_func
) VertexAttrib4NubvNV
,
664 (attrib_func
) VertexAttrib4NsvNV
,
665 (attrib_func
) VertexAttrib4NusvNV
,
666 (attrib_func
) VertexAttrib4NivNV
,
667 (attrib_func
) VertexAttrib4NuivNV
,
668 (attrib_func
) VertexAttrib4fvNV
,
669 (attrib_func
) VertexAttrib4dvNV
676 ** GL_ARB_vertex_program
679 /* GL_BYTE attributes */
682 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
684 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
688 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
690 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
694 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
696 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
700 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
702 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
706 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
708 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
710 BYTE_TO_FLOAT(v
[2])));
714 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
716 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
720 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
722 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
725 BYTE_TO_FLOAT(v
[3])));
729 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
731 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
734 /* GL_UNSIGNED_BYTE attributes */
737 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
739 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
743 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
745 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
749 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
751 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
752 UBYTE_TO_FLOAT(v
[0]),
753 UBYTE_TO_FLOAT(v
[1])));
757 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
759 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
760 (GLfloat
)v
[0], (GLfloat
)v
[1]));
764 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
766 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
767 UBYTE_TO_FLOAT(v
[0]),
768 UBYTE_TO_FLOAT(v
[1]),
769 UBYTE_TO_FLOAT(v
[2])));
772 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
774 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
781 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
783 CALL_VertexAttrib4fARB(GET_DISPATCH(),
785 UBYTE_TO_FLOAT(v
[0]),
786 UBYTE_TO_FLOAT(v
[1]),
787 UBYTE_TO_FLOAT(v
[2]),
788 UBYTE_TO_FLOAT(v
[3])));
792 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
794 CALL_VertexAttrib4fARB(GET_DISPATCH(),
796 (GLfloat
)v
[0], (GLfloat
)v
[1],
797 (GLfloat
)v
[2], (GLfloat
)v
[3]));
800 /* GL_SHORT attributes */
803 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
805 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
809 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
811 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
815 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
817 CALL_VertexAttrib2fARB(GET_DISPATCH(),
818 (index
, SHORT_TO_FLOAT(v
[0]),
819 SHORT_TO_FLOAT(v
[1])));
823 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
825 CALL_VertexAttrib2fARB(GET_DISPATCH(),
826 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
830 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
832 CALL_VertexAttrib3fARB(GET_DISPATCH(),
834 SHORT_TO_FLOAT(v
[0]),
835 SHORT_TO_FLOAT(v
[1]),
836 SHORT_TO_FLOAT(v
[2])));
840 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
842 CALL_VertexAttrib3fARB(GET_DISPATCH(),
844 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
848 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
850 CALL_VertexAttrib4fARB(GET_DISPATCH(),
852 SHORT_TO_FLOAT(v
[0]),
853 SHORT_TO_FLOAT(v
[1]),
854 SHORT_TO_FLOAT(v
[2]),
855 SHORT_TO_FLOAT(v
[3])));
859 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
861 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
862 (GLfloat
)v
[2], (GLfloat
)v
[3]));
865 /* GL_UNSIGNED_SHORT attributes */
868 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
870 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
874 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
876 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
880 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
882 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
883 USHORT_TO_FLOAT(v
[1])));
887 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
889 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
894 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
896 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
897 USHORT_TO_FLOAT(v
[1]),
898 USHORT_TO_FLOAT(v
[2])));
902 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
904 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
905 (GLfloat
)v
[1], (GLfloat
)v
[2]));
909 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
911 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
912 USHORT_TO_FLOAT(v
[1]),
913 USHORT_TO_FLOAT(v
[2]),
914 USHORT_TO_FLOAT(v
[3])));
918 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
920 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
923 /* GL_INT attributes */
926 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
928 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
932 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
934 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
938 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
940 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
941 INT_TO_FLOAT(v
[1])));
945 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
947 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
952 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
954 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
956 INT_TO_FLOAT(v
[2])));
960 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
962 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
963 (GLfloat
)v
[1], (GLfloat
)v
[2]));
967 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
969 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
972 INT_TO_FLOAT(v
[3])));
976 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
978 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
979 (GLfloat
)v
[2], (GLfloat
)v
[3]));
982 /* GL_UNSIGNED_INT attributes */
985 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
987 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
991 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
993 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
997 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
999 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1000 UINT_TO_FLOAT(v
[1])));
1004 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1006 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1011 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1013 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1014 UINT_TO_FLOAT(v
[1]),
1015 UINT_TO_FLOAT(v
[2])));
1019 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1021 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1022 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1026 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1028 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1029 UINT_TO_FLOAT(v
[1]),
1030 UINT_TO_FLOAT(v
[2]),
1031 UINT_TO_FLOAT(v
[3])));
1035 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1037 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1038 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1041 /* GL_FLOAT attributes */
1044 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1046 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1050 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1052 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1056 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1058 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1062 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1064 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1067 /* GL_DOUBLE attributes */
1070 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1072 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
1076 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1078 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
1082 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1084 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
1088 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1090 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
1095 * Integer-valued attributes
1098 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1100 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1104 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1106 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1110 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1112 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1116 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1118 CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index
, v
));
1123 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1125 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1129 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1131 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1135 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1137 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1141 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1143 CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index
, v
));
1149 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1151 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1155 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1157 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1161 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1163 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1167 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1169 CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index
, v
));
1174 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1176 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1180 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1182 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1186 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1188 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1192 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1194 CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index
, v
));
1200 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1202 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1206 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1208 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1212 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1214 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1218 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1220 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1225 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1227 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1231 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1233 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1237 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1239 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1243 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1245 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1252 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1255 static attrib_func AttribFuncsARB
[3][4][NUM_TYPES
] = {
1257 /* non-normalized */
1260 (attrib_func
) VertexAttrib1bvARB
,
1261 (attrib_func
) VertexAttrib1ubvARB
,
1262 (attrib_func
) VertexAttrib1svARB
,
1263 (attrib_func
) VertexAttrib1usvARB
,
1264 (attrib_func
) VertexAttrib1ivARB
,
1265 (attrib_func
) VertexAttrib1uivARB
,
1266 (attrib_func
) VertexAttrib1fvARB
,
1267 (attrib_func
) VertexAttrib1dvARB
1271 (attrib_func
) VertexAttrib2bvARB
,
1272 (attrib_func
) VertexAttrib2ubvARB
,
1273 (attrib_func
) VertexAttrib2svARB
,
1274 (attrib_func
) VertexAttrib2usvARB
,
1275 (attrib_func
) VertexAttrib2ivARB
,
1276 (attrib_func
) VertexAttrib2uivARB
,
1277 (attrib_func
) VertexAttrib2fvARB
,
1278 (attrib_func
) VertexAttrib2dvARB
1282 (attrib_func
) VertexAttrib3bvARB
,
1283 (attrib_func
) VertexAttrib3ubvARB
,
1284 (attrib_func
) VertexAttrib3svARB
,
1285 (attrib_func
) VertexAttrib3usvARB
,
1286 (attrib_func
) VertexAttrib3ivARB
,
1287 (attrib_func
) VertexAttrib3uivARB
,
1288 (attrib_func
) VertexAttrib3fvARB
,
1289 (attrib_func
) VertexAttrib3dvARB
1293 (attrib_func
) VertexAttrib4bvARB
,
1294 (attrib_func
) VertexAttrib4ubvARB
,
1295 (attrib_func
) VertexAttrib4svARB
,
1296 (attrib_func
) VertexAttrib4usvARB
,
1297 (attrib_func
) VertexAttrib4ivARB
,
1298 (attrib_func
) VertexAttrib4uivARB
,
1299 (attrib_func
) VertexAttrib4fvARB
,
1300 (attrib_func
) VertexAttrib4dvARB
1304 /* normalized (except for float/double) */
1307 (attrib_func
) VertexAttrib1NbvARB
,
1308 (attrib_func
) VertexAttrib1NubvARB
,
1309 (attrib_func
) VertexAttrib1NsvARB
,
1310 (attrib_func
) VertexAttrib1NusvARB
,
1311 (attrib_func
) VertexAttrib1NivARB
,
1312 (attrib_func
) VertexAttrib1NuivARB
,
1313 (attrib_func
) VertexAttrib1fvARB
,
1314 (attrib_func
) VertexAttrib1dvARB
1318 (attrib_func
) VertexAttrib2NbvARB
,
1319 (attrib_func
) VertexAttrib2NubvARB
,
1320 (attrib_func
) VertexAttrib2NsvARB
,
1321 (attrib_func
) VertexAttrib2NusvARB
,
1322 (attrib_func
) VertexAttrib2NivARB
,
1323 (attrib_func
) VertexAttrib2NuivARB
,
1324 (attrib_func
) VertexAttrib2fvARB
,
1325 (attrib_func
) VertexAttrib2dvARB
1329 (attrib_func
) VertexAttrib3NbvARB
,
1330 (attrib_func
) VertexAttrib3NubvARB
,
1331 (attrib_func
) VertexAttrib3NsvARB
,
1332 (attrib_func
) VertexAttrib3NusvARB
,
1333 (attrib_func
) VertexAttrib3NivARB
,
1334 (attrib_func
) VertexAttrib3NuivARB
,
1335 (attrib_func
) VertexAttrib3fvARB
,
1336 (attrib_func
) VertexAttrib3dvARB
1340 (attrib_func
) VertexAttrib4NbvARB
,
1341 (attrib_func
) VertexAttrib4NubvARB
,
1342 (attrib_func
) VertexAttrib4NsvARB
,
1343 (attrib_func
) VertexAttrib4NusvARB
,
1344 (attrib_func
) VertexAttrib4NivARB
,
1345 (attrib_func
) VertexAttrib4NuivARB
,
1346 (attrib_func
) VertexAttrib4fvARB
,
1347 (attrib_func
) VertexAttrib4dvARB
1352 /* integer-valued */
1355 (attrib_func
) VertexAttribI1bv
,
1356 (attrib_func
) VertexAttribI1ubv
,
1357 (attrib_func
) VertexAttribI1sv
,
1358 (attrib_func
) VertexAttribI1usv
,
1359 (attrib_func
) VertexAttribI1iv
,
1360 (attrib_func
) VertexAttribI1uiv
,
1361 NULL
, /* GL_FLOAT */
1362 NULL
/* GL_DOUBLE */
1366 (attrib_func
) VertexAttribI2bv
,
1367 (attrib_func
) VertexAttribI2ubv
,
1368 (attrib_func
) VertexAttribI2sv
,
1369 (attrib_func
) VertexAttribI2usv
,
1370 (attrib_func
) VertexAttribI2iv
,
1371 (attrib_func
) VertexAttribI2uiv
,
1372 NULL
, /* GL_FLOAT */
1373 NULL
/* GL_DOUBLE */
1377 (attrib_func
) VertexAttribI3bv
,
1378 (attrib_func
) VertexAttribI3ubv
,
1379 (attrib_func
) VertexAttribI3sv
,
1380 (attrib_func
) VertexAttribI3usv
,
1381 (attrib_func
) VertexAttribI3iv
,
1382 (attrib_func
) VertexAttribI3uiv
,
1383 NULL
, /* GL_FLOAT */
1384 NULL
/* GL_DOUBLE */
1388 (attrib_func
) VertexAttribI4bv
,
1389 (attrib_func
) VertexAttribI4ubv
,
1390 (attrib_func
) VertexAttribI4sv
,
1391 (attrib_func
) VertexAttribI4usv
,
1392 (attrib_func
) VertexAttribI4iv
,
1393 (attrib_func
) VertexAttribI4uiv
,
1394 NULL
, /* GL_FLOAT */
1395 NULL
/* GL_DOUBLE */
1400 /**********************************************************************/
1403 GLboolean
_ae_create_context( struct gl_context
*ctx
)
1405 if (ctx
->aelt_context
)
1408 /* These _gloffset_* values may not be compile-time constants */
1409 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1410 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1411 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1412 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1413 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1414 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1415 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1416 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1418 FogCoordFuncs
[0] = -1;
1419 FogCoordFuncs
[1] = -1;
1420 FogCoordFuncs
[2] = -1;
1421 FogCoordFuncs
[3] = -1;
1422 FogCoordFuncs
[4] = -1;
1423 FogCoordFuncs
[5] = -1;
1424 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1425 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1427 ctx
->aelt_context
= CALLOC( sizeof(AEcontext
) );
1428 if (!ctx
->aelt_context
)
1431 AE_CONTEXT(ctx
)->NewState
= ~0;
1436 void _ae_destroy_context( struct gl_context
*ctx
)
1438 if ( AE_CONTEXT( ctx
) ) {
1439 FREE( ctx
->aelt_context
);
1440 ctx
->aelt_context
= NULL
;
1444 static void check_vbo( AEcontext
*actx
,
1445 struct gl_buffer_object
*vbo
)
1447 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1449 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1450 if (actx
->vbo
[i
] == vbo
)
1452 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1453 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1459 * Make a list of per-vertex functions to call for each glArrayElement call.
1460 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1462 * Note: this may be called during display list construction.
1464 static void _ae_update_state( struct gl_context
*ctx
)
1466 AEcontext
*actx
= AE_CONTEXT(ctx
);
1467 AEarray
*aa
= actx
->arrays
;
1468 AEattrib
*at
= actx
->attribs
;
1470 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1474 /* conventional vertex arrays */
1475 if (arrayObj
->Index
.Enabled
) {
1476 aa
->array
= &arrayObj
->Index
;
1477 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1478 check_vbo(actx
, aa
->array
->BufferObj
);
1481 if (arrayObj
->EdgeFlag
.Enabled
) {
1482 aa
->array
= &arrayObj
->EdgeFlag
;
1483 aa
->offset
= _gloffset_EdgeFlagv
;
1484 check_vbo(actx
, aa
->array
->BufferObj
);
1487 if (arrayObj
->Normal
.Enabled
) {
1488 aa
->array
= &arrayObj
->Normal
;
1489 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1490 check_vbo(actx
, aa
->array
->BufferObj
);
1493 if (arrayObj
->Color
.Enabled
) {
1494 aa
->array
= &arrayObj
->Color
;
1495 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1496 check_vbo(actx
, aa
->array
->BufferObj
);
1499 if (arrayObj
->SecondaryColor
.Enabled
) {
1500 aa
->array
= &arrayObj
->SecondaryColor
;
1501 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1502 check_vbo(actx
, aa
->array
->BufferObj
);
1505 if (arrayObj
->FogCoord
.Enabled
) {
1506 aa
->array
= &arrayObj
->FogCoord
;
1507 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1508 check_vbo(actx
, aa
->array
->BufferObj
);
1511 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1512 struct gl_client_array
*attribArray
= &arrayObj
->TexCoord
[i
];
1513 if (attribArray
->Enabled
) {
1514 /* NOTE: we use generic glVertexAttribNV functions here.
1515 * If we ever remove GL_NV_vertex_program this will have to change.
1517 at
->array
= attribArray
;
1518 ASSERT(!at
->array
->Normalized
);
1519 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1521 [TYPE_IDX(at
->array
->Type
)];
1522 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1523 check_vbo(actx
, at
->array
->BufferObj
);
1528 /* generic vertex attribute arrays */
1529 for (i
= 1; i
< Elements(arrayObj
->VertexAttrib
); i
++) { /* skip zero! */
1530 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[i
];
1531 if (attribArray
->Enabled
) {
1532 at
->array
= attribArray
;
1533 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1534 * function pointer here (for float arrays) since the pointer may
1535 * change from one execution of _ae_ArrayElement() to
1536 * the next. Doing so caused UT to break.
1538 if (ctx
->VertexProgram
._Enabled
1539 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1540 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1542 [TYPE_IDX(at
->array
->Type
)];
1546 if (at
->array
->Integer
)
1548 else if (at
->array
->Normalized
)
1553 at
->func
= AttribFuncsARB
[intOrNorm
]
1555 [TYPE_IDX(at
->array
->Type
)];
1558 check_vbo(actx
, at
->array
->BufferObj
);
1563 /* finally, vertex position */
1564 if (arrayObj
->VertexAttrib
[0].Enabled
) {
1565 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1566 * issued as the last (provoking) attribute).
1568 aa
->array
= &arrayObj
->VertexAttrib
[0];
1569 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1570 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1571 check_vbo(actx
, aa
->array
->BufferObj
);
1574 else if (arrayObj
->Vertex
.Enabled
) {
1575 aa
->array
= &arrayObj
->Vertex
;
1576 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1577 check_vbo(actx
, aa
->array
->BufferObj
);
1581 check_vbo(actx
, ctx
->Array
.ElementArrayBufferObj
);
1583 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1584 ASSERT(aa
- actx
->arrays
< 32);
1585 at
->func
= NULL
; /* terminate the list */
1586 aa
->offset
= -1; /* terminate the list */
1591 void _ae_map_vbos( struct gl_context
*ctx
)
1593 AEcontext
*actx
= AE_CONTEXT(ctx
);
1596 if (actx
->mapped_vbos
)
1600 _ae_update_state(ctx
);
1602 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1603 ctx
->Driver
.MapBuffer(ctx
,
1604 GL_ARRAY_BUFFER_ARB
,
1605 GL_DYNAMIC_DRAW_ARB
,
1609 actx
->mapped_vbos
= GL_TRUE
;
1612 void _ae_unmap_vbos( struct gl_context
*ctx
)
1614 AEcontext
*actx
= AE_CONTEXT(ctx
);
1617 if (!actx
->mapped_vbos
)
1620 assert (!actx
->NewState
);
1622 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1623 ctx
->Driver
.UnmapBuffer(ctx
,
1624 GL_ARRAY_BUFFER_ARB
,
1627 actx
->mapped_vbos
= GL_FALSE
;
1632 * Called via glArrayElement() and glDrawArrays().
1633 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1634 * for all enabled vertex arrays (for elt-th element).
1635 * Note: this may be called during display list construction.
1637 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1639 GET_CURRENT_CONTEXT(ctx
);
1640 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1643 const struct _glapi_table
* const disp
= GET_DISPATCH();
1646 if (actx
->NewState
) {
1647 assert(!actx
->mapped_vbos
);
1648 _ae_update_state( ctx
);
1651 /* Determine if w need to map/unmap VBOs */
1652 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1657 /* emit generic attribute elements */
1658 for (at
= actx
->attribs
; at
->func
; at
++) {
1660 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1661 + elt
* at
->array
->StrideB
;
1662 at
->func( at
->index
, src
);
1665 /* emit conventional arrays elements */
1666 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1668 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1669 + elt
* aa
->array
->StrideB
;
1670 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1671 ((const void *) src
) );
1675 _ae_unmap_vbos(ctx
);
1679 void _ae_invalidate_state( struct gl_context
*ctx
, GLuint new_state
)
1681 AEcontext
*actx
= AE_CONTEXT(ctx
);
1684 /* Only interested in this subset of mesa state. Need to prune
1685 * this down as both tnl/ and the drivers can raise statechanges
1686 * for arcane reasons in the middle of seemingly atomic operations
1687 * like DrawElements, over which we'd like to keep a known set of
1688 * arrays and vbo's mapped.
1690 * Luckily, neither the drivers nor tnl muck with the state that
1693 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1695 assert(!actx
->mapped_vbos
);
1696 actx
->NewState
|= new_state
;
1701 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1702 const GLvertexformat
*vfmt
)
1704 SET_ArrayElement(disp
, vfmt
->ArrayElement
);
1708 #endif /* FEATURE_arrayelt */