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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
27 * This file implements the glArrayElement() function.
28 * It involves looking at the format/type of all the enabled vertex arrays
29 * and emitting a list of pointers to functions which set the per-vertex
30 * state for the element/index.
35 * Keith Whitwell <keith@tungstengraphics.com>
39 #include "api_arrayelt.h"
40 #include "bufferobj.h"
45 #include "main/dispatch.h"
47 typedef void (GLAPIENTRY *array_func)( const void * );
50 const struct gl_client_array *array;
54 typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
57 const struct gl_client_array *array;
64 AEattrib attribs[VERT_ATTRIB_MAX + 1];
67 /* List of VBOs we need to map before executing ArrayElements */
68 struct gl_buffer_object *vbo[VERT_ATTRIB_MAX];
70 GLboolean mapped_vbos; /**< Any currently mapped VBOs? */
75 static INLINE AEcontext *
76 AE_CONTEXT(struct gl_context *ctx)
78 return (AEcontext *) ctx->aelt_context;
83 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
84 * in the range [0, 7]. Luckily these type tokens are sequentially
85 * numbered in gl.h, except for GL_DOUBLE.
90 return t == GL_DOUBLE ? 7 : t & 7;
97 static const int ColorFuncs[2][NUM_TYPES] = {
120 static const int VertexFuncs[3][NUM_TYPES] = {
153 static const int IndexFuncs[NUM_TYPES] = {
164 static const int NormalFuncs[NUM_TYPES] = {
175 /* Note: _gloffset_* for these may not be a compile-time constant. */
176 static int SecondaryColorFuncs[NUM_TYPES];
177 static int FogCoordFuncs[NUM_TYPES];
181 ** GL_NV_vertex_program
184 /* GL_BYTE attributes */
186 static void GLAPIENTRY
187 VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
189 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
192 static void GLAPIENTRY
193 VertexAttrib1bvNV(GLuint index, const GLbyte *v)
195 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
198 static void GLAPIENTRY
199 VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
201 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
204 static void GLAPIENTRY
205 VertexAttrib2bvNV(GLuint index, const GLbyte *v)
207 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
210 static void GLAPIENTRY
211 VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
213 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
215 BYTE_TO_FLOAT(v[2])));
218 static void GLAPIENTRY
219 VertexAttrib3bvNV(GLuint index, const GLbyte *v)
221 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
224 static void GLAPIENTRY
225 VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
227 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
230 BYTE_TO_FLOAT(v[3])));
233 static void GLAPIENTRY
234 VertexAttrib4bvNV(GLuint index, const GLbyte *v)
236 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
239 /* GL_UNSIGNED_BYTE attributes */
241 static void GLAPIENTRY
242 VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
244 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
247 static void GLAPIENTRY
248 VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
250 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
253 static void GLAPIENTRY
254 VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
256 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
257 UBYTE_TO_FLOAT(v[1])));
260 static void GLAPIENTRY
261 VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
263 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
266 static void GLAPIENTRY
267 VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
269 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
270 UBYTE_TO_FLOAT(v[1]),
271 UBYTE_TO_FLOAT(v[2])));
273 static void GLAPIENTRY
274 VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
276 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
277 (GLfloat)v[1], (GLfloat)v[2]));
280 static void GLAPIENTRY
281 VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
283 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
284 UBYTE_TO_FLOAT(v[1]),
285 UBYTE_TO_FLOAT(v[2]),
286 UBYTE_TO_FLOAT(v[3])));
289 static void GLAPIENTRY
290 VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
292 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
293 (GLfloat)v[1], (GLfloat)v[2],
297 /* GL_SHORT attributes */
299 static void GLAPIENTRY
300 VertexAttrib1NsvNV(GLuint index, const GLshort *v)
302 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
305 static void GLAPIENTRY
306 VertexAttrib1svNV(GLuint index, const GLshort *v)
308 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
311 static void GLAPIENTRY
312 VertexAttrib2NsvNV(GLuint index, const GLshort *v)
314 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
315 SHORT_TO_FLOAT(v[1])));
318 static void GLAPIENTRY
319 VertexAttrib2svNV(GLuint index, const GLshort *v)
321 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
324 static void GLAPIENTRY
325 VertexAttrib3NsvNV(GLuint index, const GLshort *v)
327 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
328 SHORT_TO_FLOAT(v[1]),
329 SHORT_TO_FLOAT(v[2])));
332 static void GLAPIENTRY
333 VertexAttrib3svNV(GLuint index, const GLshort *v)
335 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
339 static void GLAPIENTRY
340 VertexAttrib4NsvNV(GLuint index, const GLshort *v)
342 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
343 SHORT_TO_FLOAT(v[1]),
344 SHORT_TO_FLOAT(v[2]),
345 SHORT_TO_FLOAT(v[3])));
348 static void GLAPIENTRY
349 VertexAttrib4svNV(GLuint index, const GLshort *v)
351 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
352 (GLfloat)v[2], (GLfloat)v[3]));
355 /* GL_UNSIGNED_SHORT attributes */
357 static void GLAPIENTRY
358 VertexAttrib1NusvNV(GLuint index, const GLushort *v)
360 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
363 static void GLAPIENTRY
364 VertexAttrib1usvNV(GLuint index, const GLushort *v)
366 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
369 static void GLAPIENTRY
370 VertexAttrib2NusvNV(GLuint index, const GLushort *v)
372 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
373 USHORT_TO_FLOAT(v[1])));
376 static void GLAPIENTRY
377 VertexAttrib2usvNV(GLuint index, const GLushort *v)
379 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
383 static void GLAPIENTRY
384 VertexAttrib3NusvNV(GLuint index, const GLushort *v)
386 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
387 USHORT_TO_FLOAT(v[1]),
388 USHORT_TO_FLOAT(v[2])));
391 static void GLAPIENTRY
392 VertexAttrib3usvNV(GLuint index, const GLushort *v)
394 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
398 static void GLAPIENTRY
399 VertexAttrib4NusvNV(GLuint index, const GLushort *v)
401 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
402 USHORT_TO_FLOAT(v[1]),
403 USHORT_TO_FLOAT(v[2]),
404 USHORT_TO_FLOAT(v[3])));
407 static void GLAPIENTRY
408 VertexAttrib4usvNV(GLuint index, const GLushort *v)
410 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
411 (GLfloat)v[2], (GLfloat)v[3]));
414 /* GL_INT attributes */
416 static void GLAPIENTRY
417 VertexAttrib1NivNV(GLuint index, const GLint *v)
419 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
422 static void GLAPIENTRY
423 VertexAttrib1ivNV(GLuint index, const GLint *v)
425 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
428 static void GLAPIENTRY
429 VertexAttrib2NivNV(GLuint index, const GLint *v)
431 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
432 INT_TO_FLOAT(v[1])));
435 static void GLAPIENTRY
436 VertexAttrib2ivNV(GLuint index, const GLint *v)
438 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
441 static void GLAPIENTRY
442 VertexAttrib3NivNV(GLuint index, const GLint *v)
444 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
446 INT_TO_FLOAT(v[2])));
449 static void GLAPIENTRY
450 VertexAttrib3ivNV(GLuint index, const GLint *v)
452 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
456 static void GLAPIENTRY
457 VertexAttrib4NivNV(GLuint index, const GLint *v)
459 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
462 INT_TO_FLOAT(v[3])));
465 static void GLAPIENTRY
466 VertexAttrib4ivNV(GLuint index, const GLint *v)
468 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
469 (GLfloat)v[2], (GLfloat)v[3]));
472 /* GL_UNSIGNED_INT attributes */
474 static void GLAPIENTRY
475 VertexAttrib1NuivNV(GLuint index, const GLuint *v)
477 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
480 static void GLAPIENTRY
481 VertexAttrib1uivNV(GLuint index, const GLuint *v)
483 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
486 static void GLAPIENTRY
487 VertexAttrib2NuivNV(GLuint index, const GLuint *v)
489 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
490 UINT_TO_FLOAT(v[1])));
493 static void GLAPIENTRY
494 VertexAttrib2uivNV(GLuint index, const GLuint *v)
496 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
500 static void GLAPIENTRY
501 VertexAttrib3NuivNV(GLuint index, const GLuint *v)
503 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
505 UINT_TO_FLOAT(v[2])));
508 static void GLAPIENTRY
509 VertexAttrib3uivNV(GLuint index, const GLuint *v)
511 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
515 static void GLAPIENTRY
516 VertexAttrib4NuivNV(GLuint index, const GLuint *v)
518 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
521 UINT_TO_FLOAT(v[3])));
524 static void GLAPIENTRY
525 VertexAttrib4uivNV(GLuint index, const GLuint *v)
527 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
528 (GLfloat)v[2], (GLfloat)v[3]));
531 /* GL_FLOAT attributes */
533 static void GLAPIENTRY
534 VertexAttrib1fvNV(GLuint index, const GLfloat *v)
536 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
539 static void GLAPIENTRY
540 VertexAttrib2fvNV(GLuint index, const GLfloat *v)
542 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
545 static void GLAPIENTRY
546 VertexAttrib3fvNV(GLuint index, const GLfloat *v)
548 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
551 static void GLAPIENTRY
552 VertexAttrib4fvNV(GLuint index, const GLfloat *v)
554 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
557 /* GL_DOUBLE attributes */
559 static void GLAPIENTRY
560 VertexAttrib1dvNV(GLuint index, const GLdouble *v)
562 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
565 static void GLAPIENTRY
566 VertexAttrib2dvNV(GLuint index, const GLdouble *v)
568 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
571 static void GLAPIENTRY
572 VertexAttrib3dvNV(GLuint index, const GLdouble *v)
574 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
577 static void GLAPIENTRY
578 VertexAttrib4dvNV(GLuint index, const GLdouble *v)
580 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
585 * Array [size][type] of VertexAttrib functions
587 static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = {
592 (attrib_func) VertexAttrib1bvNV,
593 (attrib_func) VertexAttrib1ubvNV,
594 (attrib_func) VertexAttrib1svNV,
595 (attrib_func) VertexAttrib1usvNV,
596 (attrib_func) VertexAttrib1ivNV,
597 (attrib_func) VertexAttrib1uivNV,
598 (attrib_func) VertexAttrib1fvNV,
599 (attrib_func) VertexAttrib1dvNV
603 (attrib_func) VertexAttrib2bvNV,
604 (attrib_func) VertexAttrib2ubvNV,
605 (attrib_func) VertexAttrib2svNV,
606 (attrib_func) VertexAttrib2usvNV,
607 (attrib_func) VertexAttrib2ivNV,
608 (attrib_func) VertexAttrib2uivNV,
609 (attrib_func) VertexAttrib2fvNV,
610 (attrib_func) VertexAttrib2dvNV
614 (attrib_func) VertexAttrib3bvNV,
615 (attrib_func) VertexAttrib3ubvNV,
616 (attrib_func) VertexAttrib3svNV,
617 (attrib_func) VertexAttrib3usvNV,
618 (attrib_func) VertexAttrib3ivNV,
619 (attrib_func) VertexAttrib3uivNV,
620 (attrib_func) VertexAttrib3fvNV,
621 (attrib_func) VertexAttrib3dvNV
625 (attrib_func) VertexAttrib4bvNV,
626 (attrib_func) VertexAttrib4ubvNV,
627 (attrib_func) VertexAttrib4svNV,
628 (attrib_func) VertexAttrib4usvNV,
629 (attrib_func) VertexAttrib4ivNV,
630 (attrib_func) VertexAttrib4uivNV,
631 (attrib_func) VertexAttrib4fvNV,
632 (attrib_func) VertexAttrib4dvNV
636 /* normalized (except for float/double) */
639 (attrib_func) VertexAttrib1NbvNV,
640 (attrib_func) VertexAttrib1NubvNV,
641 (attrib_func) VertexAttrib1NsvNV,
642 (attrib_func) VertexAttrib1NusvNV,
643 (attrib_func) VertexAttrib1NivNV,
644 (attrib_func) VertexAttrib1NuivNV,
645 (attrib_func) VertexAttrib1fvNV,
646 (attrib_func) VertexAttrib1dvNV
650 (attrib_func) VertexAttrib2NbvNV,
651 (attrib_func) VertexAttrib2NubvNV,
652 (attrib_func) VertexAttrib2NsvNV,
653 (attrib_func) VertexAttrib2NusvNV,
654 (attrib_func) VertexAttrib2NivNV,
655 (attrib_func) VertexAttrib2NuivNV,
656 (attrib_func) VertexAttrib2fvNV,
657 (attrib_func) VertexAttrib2dvNV
661 (attrib_func) VertexAttrib3NbvNV,
662 (attrib_func) VertexAttrib3NubvNV,
663 (attrib_func) VertexAttrib3NsvNV,
664 (attrib_func) VertexAttrib3NusvNV,
665 (attrib_func) VertexAttrib3NivNV,
666 (attrib_func) VertexAttrib3NuivNV,
667 (attrib_func) VertexAttrib3fvNV,
668 (attrib_func) VertexAttrib3dvNV
672 (attrib_func) VertexAttrib4NbvNV,
673 (attrib_func) VertexAttrib4NubvNV,
674 (attrib_func) VertexAttrib4NsvNV,
675 (attrib_func) VertexAttrib4NusvNV,
676 (attrib_func) VertexAttrib4NivNV,
677 (attrib_func) VertexAttrib4NuivNV,
678 (attrib_func) VertexAttrib4fvNV,
679 (attrib_func) VertexAttrib4dvNV
686 ** GL_ARB_vertex_program
689 /* GL_BYTE attributes */
691 static void GLAPIENTRY
692 VertexAttrib1NbvARB(GLuint index, const GLbyte *v)
694 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
697 static void GLAPIENTRY
698 VertexAttrib1bvARB(GLuint index, const GLbyte *v)
700 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
703 static void GLAPIENTRY
704 VertexAttrib2NbvARB(GLuint index, const GLbyte *v)
706 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
709 static void GLAPIENTRY
710 VertexAttrib2bvARB(GLuint index, const GLbyte *v)
712 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
715 static void GLAPIENTRY
716 VertexAttrib3NbvARB(GLuint index, const GLbyte *v)
718 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
720 BYTE_TO_FLOAT(v[2])));
723 static void GLAPIENTRY
724 VertexAttrib3bvARB(GLuint index, const GLbyte *v)
726 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
729 static void GLAPIENTRY
730 VertexAttrib4NbvARB(GLuint index, const GLbyte *v)
732 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
735 BYTE_TO_FLOAT(v[3])));
738 static void GLAPIENTRY
739 VertexAttrib4bvARB(GLuint index, const GLbyte *v)
741 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
744 /* GL_UNSIGNED_BYTE attributes */
746 static void GLAPIENTRY
747 VertexAttrib1NubvARB(GLuint index, const GLubyte *v)
749 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
752 static void GLAPIENTRY
753 VertexAttrib1ubvARB(GLuint index, const GLubyte *v)
755 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
758 static void GLAPIENTRY
759 VertexAttrib2NubvARB(GLuint index, const GLubyte *v)
761 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,
762 UBYTE_TO_FLOAT(v[0]),
763 UBYTE_TO_FLOAT(v[1])));
766 static void GLAPIENTRY
767 VertexAttrib2ubvARB(GLuint index, const GLubyte *v)
769 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,
770 (GLfloat)v[0], (GLfloat)v[1]));
773 static void GLAPIENTRY
774 VertexAttrib3NubvARB(GLuint index, const GLubyte *v)
776 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,
777 UBYTE_TO_FLOAT(v[0]),
778 UBYTE_TO_FLOAT(v[1]),
779 UBYTE_TO_FLOAT(v[2])));
781 static void GLAPIENTRY
782 VertexAttrib3ubvARB(GLuint index, const GLubyte *v)
784 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,
790 static void GLAPIENTRY
791 VertexAttrib4NubvARB(GLuint index, const GLubyte *v)
793 CALL_VertexAttrib4fARB(GET_DISPATCH(),
795 UBYTE_TO_FLOAT(v[0]),
796 UBYTE_TO_FLOAT(v[1]),
797 UBYTE_TO_FLOAT(v[2]),
798 UBYTE_TO_FLOAT(v[3])));
801 static void GLAPIENTRY
802 VertexAttrib4ubvARB(GLuint index, const GLubyte *v)
804 CALL_VertexAttrib4fARB(GET_DISPATCH(),
806 (GLfloat)v[0], (GLfloat)v[1],
807 (GLfloat)v[2], (GLfloat)v[3]));
810 /* GL_SHORT attributes */
812 static void GLAPIENTRY
813 VertexAttrib1NsvARB(GLuint index, const GLshort *v)
815 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
818 static void GLAPIENTRY
819 VertexAttrib1svARB(GLuint index, const GLshort *v)
821 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
824 static void GLAPIENTRY
825 VertexAttrib2NsvARB(GLuint index, const GLshort *v)
827 CALL_VertexAttrib2fARB(GET_DISPATCH(),
828 (index, SHORT_TO_FLOAT(v[0]),
829 SHORT_TO_FLOAT(v[1])));
832 static void GLAPIENTRY
833 VertexAttrib2svARB(GLuint index, const GLshort *v)
835 CALL_VertexAttrib2fARB(GET_DISPATCH(),
836 (index, (GLfloat)v[0], (GLfloat)v[1]));
839 static void GLAPIENTRY
840 VertexAttrib3NsvARB(GLuint index, const GLshort *v)
842 CALL_VertexAttrib3fARB(GET_DISPATCH(),
844 SHORT_TO_FLOAT(v[0]),
845 SHORT_TO_FLOAT(v[1]),
846 SHORT_TO_FLOAT(v[2])));
849 static void GLAPIENTRY
850 VertexAttrib3svARB(GLuint index, const GLshort *v)
852 CALL_VertexAttrib3fARB(GET_DISPATCH(),
854 (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
857 static void GLAPIENTRY
858 VertexAttrib4NsvARB(GLuint index, const GLshort *v)
860 CALL_VertexAttrib4fARB(GET_DISPATCH(),
862 SHORT_TO_FLOAT(v[0]),
863 SHORT_TO_FLOAT(v[1]),
864 SHORT_TO_FLOAT(v[2]),
865 SHORT_TO_FLOAT(v[3])));
868 static void GLAPIENTRY
869 VertexAttrib4svARB(GLuint index, const GLshort *v)
871 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
872 (GLfloat)v[2], (GLfloat)v[3]));
875 /* GL_UNSIGNED_SHORT attributes */
877 static void GLAPIENTRY
878 VertexAttrib1NusvARB(GLuint index, const GLushort *v)
880 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
883 static void GLAPIENTRY
884 VertexAttrib1usvARB(GLuint index, const GLushort *v)
886 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
889 static void GLAPIENTRY
890 VertexAttrib2NusvARB(GLuint index, const GLushort *v)
892 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
893 USHORT_TO_FLOAT(v[1])));
896 static void GLAPIENTRY
897 VertexAttrib2usvARB(GLuint index, const GLushort *v)
899 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
903 static void GLAPIENTRY
904 VertexAttrib3NusvARB(GLuint index, const GLushort *v)
906 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
907 USHORT_TO_FLOAT(v[1]),
908 USHORT_TO_FLOAT(v[2])));
911 static void GLAPIENTRY
912 VertexAttrib3usvARB(GLuint index, const GLushort *v)
914 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
915 (GLfloat)v[1], (GLfloat)v[2]));
918 static void GLAPIENTRY
919 VertexAttrib4NusvARB(GLuint index, const GLushort *v)
921 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
922 USHORT_TO_FLOAT(v[1]),
923 USHORT_TO_FLOAT(v[2]),
924 USHORT_TO_FLOAT(v[3])));
927 static void GLAPIENTRY
928 VertexAttrib4usvARB(GLuint index, const GLushort *v)
930 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
933 /* GL_INT attributes */
935 static void GLAPIENTRY
936 VertexAttrib1NivARB(GLuint index, const GLint *v)
938 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
941 static void GLAPIENTRY
942 VertexAttrib1ivARB(GLuint index, const GLint *v)
944 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
947 static void GLAPIENTRY
948 VertexAttrib2NivARB(GLuint index, const GLint *v)
950 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
951 INT_TO_FLOAT(v[1])));
954 static void GLAPIENTRY
955 VertexAttrib2ivARB(GLuint index, const GLint *v)
957 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
961 static void GLAPIENTRY
962 VertexAttrib3NivARB(GLuint index, const GLint *v)
964 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
966 INT_TO_FLOAT(v[2])));
969 static void GLAPIENTRY
970 VertexAttrib3ivARB(GLuint index, const GLint *v)
972 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
973 (GLfloat)v[1], (GLfloat)v[2]));
976 static void GLAPIENTRY
977 VertexAttrib4NivARB(GLuint index, const GLint *v)
979 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
982 INT_TO_FLOAT(v[3])));
985 static void GLAPIENTRY
986 VertexAttrib4ivARB(GLuint index, const GLint *v)
988 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
989 (GLfloat)v[2], (GLfloat)v[3]));
992 /* GL_UNSIGNED_INT attributes */
994 static void GLAPIENTRY
995 VertexAttrib1NuivARB(GLuint index, const GLuint *v)
997 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
1000 static void GLAPIENTRY
1001 VertexAttrib1uivARB(GLuint index, const GLuint *v)
1003 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
1006 static void GLAPIENTRY
1007 VertexAttrib2NuivARB(GLuint index, const GLuint *v)
1009 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
1010 UINT_TO_FLOAT(v[1])));
1013 static void GLAPIENTRY
1014 VertexAttrib2uivARB(GLuint index, const GLuint *v)
1016 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
1020 static void GLAPIENTRY
1021 VertexAttrib3NuivARB(GLuint index, const GLuint *v)
1023 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
1024 UINT_TO_FLOAT(v[1]),
1025 UINT_TO_FLOAT(v[2])));
1028 static void GLAPIENTRY
1029 VertexAttrib3uivARB(GLuint index, const GLuint *v)
1031 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
1032 (GLfloat)v[1], (GLfloat)v[2]));
1035 static void GLAPIENTRY
1036 VertexAttrib4NuivARB(GLuint index, const GLuint *v)
1038 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
1039 UINT_TO_FLOAT(v[1]),
1040 UINT_TO_FLOAT(v[2]),
1041 UINT_TO_FLOAT(v[3])));
1044 static void GLAPIENTRY
1045 VertexAttrib4uivARB(GLuint index, const GLuint *v)
1047 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
1048 (GLfloat)v[2], (GLfloat)v[3]));
1051 /* GL_FLOAT attributes */
1053 static void GLAPIENTRY
1054 VertexAttrib1fvARB(GLuint index, const GLfloat *v)
1056 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v));
1059 static void GLAPIENTRY
1060 VertexAttrib2fvARB(GLuint index, const GLfloat *v)
1062 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v));
1065 static void GLAPIENTRY
1066 VertexAttrib3fvARB(GLuint index, const GLfloat *v)
1068 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v));
1071 static void GLAPIENTRY
1072 VertexAttrib4fvARB(GLuint index, const GLfloat *v)
1074 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v));
1077 /* GL_DOUBLE attributes */
1079 static void GLAPIENTRY
1080 VertexAttrib1dvARB(GLuint index, const GLdouble *v)
1082 CALL_VertexAttrib1dv(GET_DISPATCH(), (index, v));
1085 static void GLAPIENTRY
1086 VertexAttrib2dvARB(GLuint index, const GLdouble *v)
1088 CALL_VertexAttrib2dv(GET_DISPATCH(), (index, v));
1091 static void GLAPIENTRY
1092 VertexAttrib3dvARB(GLuint index, const GLdouble *v)
1094 CALL_VertexAttrib3dv(GET_DISPATCH(), (index, v));
1097 static void GLAPIENTRY
1098 VertexAttrib4dvARB(GLuint index, const GLdouble *v)
1100 CALL_VertexAttrib4dv(GET_DISPATCH(), (index, v));
1105 * Integer-valued attributes
1107 static void GLAPIENTRY
1108 VertexAttribI1bv(GLuint index, const GLbyte *v)
1110 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
1113 static void GLAPIENTRY
1114 VertexAttribI2bv(GLuint index, const GLbyte *v)
1116 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
1119 static void GLAPIENTRY
1120 VertexAttribI3bv(GLuint index, const GLbyte *v)
1122 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1125 static void GLAPIENTRY
1126 VertexAttribI4bv(GLuint index, const GLbyte *v)
1128 CALL_VertexAttribI4bv(GET_DISPATCH(), (index, v));
1132 static void GLAPIENTRY
1133 VertexAttribI1ubv(GLuint index, const GLubyte *v)
1135 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1138 static void GLAPIENTRY
1139 VertexAttribI2ubv(GLuint index, const GLubyte *v)
1141 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1144 static void GLAPIENTRY
1145 VertexAttribI3ubv(GLuint index, const GLubyte *v)
1147 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1150 static void GLAPIENTRY
1151 VertexAttribI4ubv(GLuint index, const GLubyte *v)
1153 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index, v));
1158 static void GLAPIENTRY
1159 VertexAttribI1sv(GLuint index, const GLshort *v)
1161 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
1164 static void GLAPIENTRY
1165 VertexAttribI2sv(GLuint index, const GLshort *v)
1167 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
1170 static void GLAPIENTRY
1171 VertexAttribI3sv(GLuint index, const GLshort *v)
1173 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1176 static void GLAPIENTRY
1177 VertexAttribI4sv(GLuint index, const GLshort *v)
1179 CALL_VertexAttribI4sv(GET_DISPATCH(), (index, v));
1183 static void GLAPIENTRY
1184 VertexAttribI1usv(GLuint index, const GLushort *v)
1186 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1189 static void GLAPIENTRY
1190 VertexAttribI2usv(GLuint index, const GLushort *v)
1192 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1195 static void GLAPIENTRY
1196 VertexAttribI3usv(GLuint index, const GLushort *v)
1198 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1201 static void GLAPIENTRY
1202 VertexAttribI4usv(GLuint index, const GLushort *v)
1204 CALL_VertexAttribI4usv(GET_DISPATCH(), (index, v));
1209 static void GLAPIENTRY
1210 VertexAttribI1iv(GLuint index, const GLint *v)
1212 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
1215 static void GLAPIENTRY
1216 VertexAttribI2iv(GLuint index, const GLint *v)
1218 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
1221 static void GLAPIENTRY
1222 VertexAttribI3iv(GLuint index, const GLint *v)
1224 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1227 static void GLAPIENTRY
1228 VertexAttribI4iv(GLuint index, const GLint *v)
1230 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index, v));
1234 static void GLAPIENTRY
1235 VertexAttribI1uiv(GLuint index, const GLuint *v)
1237 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1240 static void GLAPIENTRY
1241 VertexAttribI2uiv(GLuint index, const GLuint *v)
1243 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1246 static void GLAPIENTRY
1247 VertexAttribI3uiv(GLuint index, const GLuint *v)
1249 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1252 static void GLAPIENTRY
1253 VertexAttribI4uiv(GLuint index, const GLuint *v)
1255 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index, v));
1260 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1263 static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = {
1265 /* non-normalized */
1268 (attrib_func) VertexAttrib1bvARB,
1269 (attrib_func) VertexAttrib1ubvARB,
1270 (attrib_func) VertexAttrib1svARB,
1271 (attrib_func) VertexAttrib1usvARB,
1272 (attrib_func) VertexAttrib1ivARB,
1273 (attrib_func) VertexAttrib1uivARB,
1274 (attrib_func) VertexAttrib1fvARB,
1275 (attrib_func) VertexAttrib1dvARB
1279 (attrib_func) VertexAttrib2bvARB,
1280 (attrib_func) VertexAttrib2ubvARB,
1281 (attrib_func) VertexAttrib2svARB,
1282 (attrib_func) VertexAttrib2usvARB,
1283 (attrib_func) VertexAttrib2ivARB,
1284 (attrib_func) VertexAttrib2uivARB,
1285 (attrib_func) VertexAttrib2fvARB,
1286 (attrib_func) VertexAttrib2dvARB
1290 (attrib_func) VertexAttrib3bvARB,
1291 (attrib_func) VertexAttrib3ubvARB,
1292 (attrib_func) VertexAttrib3svARB,
1293 (attrib_func) VertexAttrib3usvARB,
1294 (attrib_func) VertexAttrib3ivARB,
1295 (attrib_func) VertexAttrib3uivARB,
1296 (attrib_func) VertexAttrib3fvARB,
1297 (attrib_func) VertexAttrib3dvARB
1301 (attrib_func) VertexAttrib4bvARB,
1302 (attrib_func) VertexAttrib4ubvARB,
1303 (attrib_func) VertexAttrib4svARB,
1304 (attrib_func) VertexAttrib4usvARB,
1305 (attrib_func) VertexAttrib4ivARB,
1306 (attrib_func) VertexAttrib4uivARB,
1307 (attrib_func) VertexAttrib4fvARB,
1308 (attrib_func) VertexAttrib4dvARB
1312 /* normalized (except for float/double) */
1315 (attrib_func) VertexAttrib1NbvARB,
1316 (attrib_func) VertexAttrib1NubvARB,
1317 (attrib_func) VertexAttrib1NsvARB,
1318 (attrib_func) VertexAttrib1NusvARB,
1319 (attrib_func) VertexAttrib1NivARB,
1320 (attrib_func) VertexAttrib1NuivARB,
1321 (attrib_func) VertexAttrib1fvARB,
1322 (attrib_func) VertexAttrib1dvARB
1326 (attrib_func) VertexAttrib2NbvARB,
1327 (attrib_func) VertexAttrib2NubvARB,
1328 (attrib_func) VertexAttrib2NsvARB,
1329 (attrib_func) VertexAttrib2NusvARB,
1330 (attrib_func) VertexAttrib2NivARB,
1331 (attrib_func) VertexAttrib2NuivARB,
1332 (attrib_func) VertexAttrib2fvARB,
1333 (attrib_func) VertexAttrib2dvARB
1337 (attrib_func) VertexAttrib3NbvARB,
1338 (attrib_func) VertexAttrib3NubvARB,
1339 (attrib_func) VertexAttrib3NsvARB,
1340 (attrib_func) VertexAttrib3NusvARB,
1341 (attrib_func) VertexAttrib3NivARB,
1342 (attrib_func) VertexAttrib3NuivARB,
1343 (attrib_func) VertexAttrib3fvARB,
1344 (attrib_func) VertexAttrib3dvARB
1348 (attrib_func) VertexAttrib4NbvARB,
1349 (attrib_func) VertexAttrib4NubvARB,
1350 (attrib_func) VertexAttrib4NsvARB,
1351 (attrib_func) VertexAttrib4NusvARB,
1352 (attrib_func) VertexAttrib4NivARB,
1353 (attrib_func) VertexAttrib4NuivARB,
1354 (attrib_func) VertexAttrib4fvARB,
1355 (attrib_func) VertexAttrib4dvARB
1360 /* integer-valued */
1363 (attrib_func) VertexAttribI1bv,
1364 (attrib_func) VertexAttribI1ubv,
1365 (attrib_func) VertexAttribI1sv,
1366 (attrib_func) VertexAttribI1usv,
1367 (attrib_func) VertexAttribI1iv,
1368 (attrib_func) VertexAttribI1uiv,
1369 NULL, /* GL_FLOAT */
1370 NULL /* GL_DOUBLE */
1374 (attrib_func) VertexAttribI2bv,
1375 (attrib_func) VertexAttribI2ubv,
1376 (attrib_func) VertexAttribI2sv,
1377 (attrib_func) VertexAttribI2usv,
1378 (attrib_func) VertexAttribI2iv,
1379 (attrib_func) VertexAttribI2uiv,
1380 NULL, /* GL_FLOAT */
1381 NULL /* GL_DOUBLE */
1385 (attrib_func) VertexAttribI3bv,
1386 (attrib_func) VertexAttribI3ubv,
1387 (attrib_func) VertexAttribI3sv,
1388 (attrib_func) VertexAttribI3usv,
1389 (attrib_func) VertexAttribI3iv,
1390 (attrib_func) VertexAttribI3uiv,
1391 NULL, /* GL_FLOAT */
1392 NULL /* GL_DOUBLE */
1396 (attrib_func) VertexAttribI4bv,
1397 (attrib_func) VertexAttribI4ubv,
1398 (attrib_func) VertexAttribI4sv,
1399 (attrib_func) VertexAttribI4usv,
1400 (attrib_func) VertexAttribI4iv,
1401 (attrib_func) VertexAttribI4uiv,
1402 NULL, /* GL_FLOAT */
1403 NULL /* GL_DOUBLE */
1410 _ae_create_context(struct gl_context *ctx)
1412 if (ctx->aelt_context)
1415 /* These _gloffset_* values may not be compile-time constants */
1416 SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bv;
1417 SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubv;
1418 SecondaryColorFuncs[2] = _gloffset_SecondaryColor3sv;
1419 SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usv;
1420 SecondaryColorFuncs[4] = _gloffset_SecondaryColor3iv;
1421 SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uiv;
1422 SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
1423 SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dv;
1425 FogCoordFuncs[0] = -1;
1426 FogCoordFuncs[1] = -1;
1427 FogCoordFuncs[2] = -1;
1428 FogCoordFuncs[3] = -1;
1429 FogCoordFuncs[4] = -1;
1430 FogCoordFuncs[5] = -1;
1431 FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
1432 FogCoordFuncs[7] = _gloffset_FogCoorddv;
1434 ctx->aelt_context = calloc(1, sizeof(AEcontext));
1435 if (!ctx->aelt_context)
1438 AE_CONTEXT(ctx)->NewState = ~0;
1444 _ae_destroy_context(struct gl_context *ctx)
1446 if (AE_CONTEXT(ctx)) {
1447 free(ctx->aelt_context);
1448 ctx->aelt_context = NULL;
1454 * Check if the given vertex buffer object exists and is not mapped.
1455 * If so, add it to the list of buffers we must map before executing
1456 * an glArrayElement call.
1459 check_vbo(AEcontext *actx, struct gl_buffer_object *vbo)
1461 if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) {
1463 for (i = 0; i < actx->nr_vbos; i++)
1464 if (actx->vbo[i] == vbo)
1465 return; /* already in the list, we're done */
1466 assert(actx->nr_vbos < VERT_ATTRIB_MAX);
1467 actx->vbo[actx->nr_vbos++] = vbo;
1473 * Make a list of per-vertex functions to call for each glArrayElement call.
1474 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1476 * Note: this may be called during display list construction.
1479 _ae_update_state(struct gl_context *ctx)
1481 AEcontext *actx = AE_CONTEXT(ctx);
1482 AEarray *aa = actx->arrays; /* non-indexed arrays (ex: glNormal) */
1483 AEattrib *at = actx->attribs; /* indexed arrays (ex: glMultiTexCoord) */
1485 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
1489 /* conventional vertex arrays */
1490 if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
1491 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
1492 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
1493 check_vbo(actx, aa->array->BufferObj);
1496 if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
1497 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG];
1498 aa->offset = _gloffset_EdgeFlagv;
1499 check_vbo(actx, aa->array->BufferObj);
1502 if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
1503 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL];
1504 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
1505 check_vbo(actx, aa->array->BufferObj);
1508 if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
1509 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0];
1510 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
1511 check_vbo(actx, aa->array->BufferObj);
1514 if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
1515 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1];
1516 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
1517 check_vbo(actx, aa->array->BufferObj);
1520 if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
1521 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG];
1522 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
1523 check_vbo(actx, aa->array->BufferObj);
1526 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
1527 struct gl_client_array *attribArray =
1528 &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)];
1529 if (attribArray->Enabled) {
1530 /* NOTE: we use generic glVertexAttribNV functions here.
1531 * If we ever remove GL_NV_vertex_program this will have to change.
1533 at->array = attribArray;
1534 ASSERT(!at->array->Normalized);
1535 at->func = AttribFuncsNV[at->array->Normalized]
1537 [TYPE_IDX(at->array->Type)];
1538 at->index = VERT_ATTRIB_TEX0 + i;
1539 check_vbo(actx, at->array->BufferObj);
1544 /* generic vertex attribute arrays */
1545 for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */
1546 struct gl_client_array *attribArray =
1547 &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
1548 if (attribArray->Enabled) {
1550 at->array = attribArray;
1551 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1552 * function pointer here (for float arrays) since the pointer may
1553 * change from one execution of _ae_ArrayElement() to
1554 * the next. Doing so caused UT to break.
1556 if (at->array->Integer)
1558 else if (at->array->Normalized)
1563 at->func = AttribFuncsARB[intOrNorm]
1565 [TYPE_IDX(at->array->Type)];
1568 check_vbo(actx, at->array->BufferObj);
1573 /* finally, vertex position */
1574 if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
1575 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1576 * issued as the last (provoking) attribute).
1578 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0];
1579 assert(aa->array->Size >= 2); /* XXX fix someday? */
1580 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1581 check_vbo(actx, aa->array->BufferObj);
1584 else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
1585 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_POS];
1586 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1587 check_vbo(actx, aa->array->BufferObj);
1591 check_vbo(actx, arrayObj->ElementArrayBufferObj);
1593 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
1594 ASSERT(aa - actx->arrays < 32);
1595 at->func = NULL; /* terminate the list */
1596 aa->offset = -1; /* terminate the list */
1603 * Before replaying glArrayElements calls we need to map (for reading) any
1604 * VBOs referenced by the enabled vertex arrays.
1607 _ae_map_vbos(struct gl_context *ctx)
1609 AEcontext *actx = AE_CONTEXT(ctx);
1612 if (actx->mapped_vbos)
1616 _ae_update_state(ctx);
1618 for (i = 0; i < actx->nr_vbos; i++)
1619 ctx->Driver.MapBufferRange(ctx, 0,
1625 actx->mapped_vbos = GL_TRUE;
1633 _ae_unmap_vbos(struct gl_context *ctx)
1635 AEcontext *actx = AE_CONTEXT(ctx);
1638 if (!actx->mapped_vbos)
1641 assert (!actx->NewState);
1643 for (i = 0; i < actx->nr_vbos; i++)
1644 ctx->Driver.UnmapBuffer(ctx, actx->vbo[i]);
1646 actx->mapped_vbos = GL_FALSE;
1651 * Called via glArrayElement() and glDrawArrays().
1652 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1653 * for all enabled vertex arrays (for elt-th element).
1654 * Note: this may be called during display list construction.
1657 _ae_ArrayElement(GLint elt)
1659 GET_CURRENT_CONTEXT(ctx);
1660 const AEcontext *actx = AE_CONTEXT(ctx);
1663 const struct _glapi_table * const disp = GET_DISPATCH();
1666 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1667 * then we call PrimitiveRestartNV and return.
1669 if (ctx->Array.PrimitiveRestart && (elt == ctx->Array.RestartIndex)) {
1670 CALL_PrimitiveRestartNV((struct _glapi_table *)disp, ());
1674 if (actx->NewState) {
1675 assert(!actx->mapped_vbos);
1676 _ae_update_state(ctx);
1679 /* Determine if we need to map/unmap VBOs */
1680 do_map = actx->nr_vbos && !actx->mapped_vbos;
1685 /* emit generic attribute elements */
1686 for (at = actx->attribs; at->func; at++) {
1688 = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr)
1689 + elt * at->array->StrideB;
1690 at->func(at->index, src);
1693 /* emit conventional arrays elements */
1694 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
1696 = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr)
1697 + elt * aa->array->StrideB;
1698 CALL_by_offset(disp, (array_func), aa->offset, ((const void *) src));
1702 _ae_unmap_vbos(ctx);
1707 _ae_invalidate_state(struct gl_context *ctx, GLuint new_state)
1709 AEcontext *actx = AE_CONTEXT(ctx);
1711 /* Only interested in this subset of mesa state. Need to prune
1712 * this down as both tnl/ and the drivers can raise statechanges
1713 * for arcane reasons in the middle of seemingly atomic operations
1714 * like DrawElements, over which we'd like to keep a known set of
1715 * arrays and vbo's mapped.
1717 * Luckily, neither the drivers nor tnl muck with the state that
1720 new_state &= _NEW_ARRAY | _NEW_PROGRAM;
1722 assert(!actx->mapped_vbos);
1723 actx->NewState |= new_state;
1729 _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
1730 const GLvertexformat *vfmt)
1732 SET_ArrayElement(disp, vfmt->ArrayElement);