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"
44 #include "main/dispatch.h"
46 typedef void (GLAPIENTRY
*array_func
)( const void * );
49 const struct gl_client_array
*array
;
53 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
56 const struct gl_client_array
*array
;
63 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
66 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
68 GLboolean mapped_vbos
;
72 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
76 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
77 * in the range [0, 7]. Luckily these type tokens are sequentially
78 * numbered in gl.h, except for GL_DOUBLE.
80 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
88 static const int ColorFuncs
[2][NUM_TYPES
] = {
111 static const int VertexFuncs
[3][NUM_TYPES
] = {
144 static const int IndexFuncs
[NUM_TYPES
] = {
155 static const int NormalFuncs
[NUM_TYPES
] = {
166 /* Note: _gloffset_* for these may not be a compile-time constant. */
167 static int SecondaryColorFuncs
[NUM_TYPES
];
168 static int FogCoordFuncs
[NUM_TYPES
];
172 ** GL_NV_vertex_program
175 /* GL_BYTE attributes */
178 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
180 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
184 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
186 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
190 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
192 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
196 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
198 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
202 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
204 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
206 BYTE_TO_FLOAT(v
[2])));
210 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
212 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
216 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
218 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
221 BYTE_TO_FLOAT(v
[3])));
225 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
227 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
230 /* GL_UNSIGNED_BYTE attributes */
233 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
235 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
239 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
241 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
245 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
247 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
248 UBYTE_TO_FLOAT(v
[1])));
252 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
254 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
258 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
260 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
261 UBYTE_TO_FLOAT(v
[1]),
262 UBYTE_TO_FLOAT(v
[2])));
265 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
267 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
268 (GLfloat
)v
[1], (GLfloat
)v
[2]));
272 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
274 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
275 UBYTE_TO_FLOAT(v
[1]),
276 UBYTE_TO_FLOAT(v
[2]),
277 UBYTE_TO_FLOAT(v
[3])));
281 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
283 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
284 (GLfloat
)v
[1], (GLfloat
)v
[2],
288 /* GL_SHORT attributes */
291 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
293 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
297 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
299 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
303 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
305 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
306 SHORT_TO_FLOAT(v
[1])));
310 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
312 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
316 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
318 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
319 SHORT_TO_FLOAT(v
[1]),
320 SHORT_TO_FLOAT(v
[2])));
324 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
326 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
331 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
333 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
334 SHORT_TO_FLOAT(v
[1]),
335 SHORT_TO_FLOAT(v
[2]),
336 SHORT_TO_FLOAT(v
[3])));
340 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
342 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
343 (GLfloat
)v
[2], (GLfloat
)v
[3]));
346 /* GL_UNSIGNED_SHORT attributes */
349 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
351 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
355 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
357 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
361 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
363 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
364 USHORT_TO_FLOAT(v
[1])));
368 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
370 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
375 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
377 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
378 USHORT_TO_FLOAT(v
[1]),
379 USHORT_TO_FLOAT(v
[2])));
383 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
385 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
390 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
392 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
393 USHORT_TO_FLOAT(v
[1]),
394 USHORT_TO_FLOAT(v
[2]),
395 USHORT_TO_FLOAT(v
[3])));
399 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
401 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
402 (GLfloat
)v
[2], (GLfloat
)v
[3]));
405 /* GL_INT attributes */
408 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
410 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
414 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
416 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
420 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
422 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
423 INT_TO_FLOAT(v
[1])));
427 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
429 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
433 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
435 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
437 INT_TO_FLOAT(v
[2])));
441 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
443 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
448 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
450 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
453 INT_TO_FLOAT(v
[3])));
457 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
459 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
460 (GLfloat
)v
[2], (GLfloat
)v
[3]));
463 /* GL_UNSIGNED_INT attributes */
466 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
468 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
472 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
474 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
478 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
480 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
481 UINT_TO_FLOAT(v
[1])));
485 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
487 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
492 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
494 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
496 UINT_TO_FLOAT(v
[2])));
500 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
502 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
507 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
509 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
512 UINT_TO_FLOAT(v
[3])));
516 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
518 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
519 (GLfloat
)v
[2], (GLfloat
)v
[3]));
522 /* GL_FLOAT attributes */
525 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
527 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
531 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
533 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
537 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
539 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
543 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
545 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
548 /* GL_DOUBLE attributes */
551 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
553 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
557 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
559 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
563 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
565 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
569 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
571 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
576 * Array [size][type] of VertexAttrib functions
578 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
583 (attrib_func
) VertexAttrib1bvNV
,
584 (attrib_func
) VertexAttrib1ubvNV
,
585 (attrib_func
) VertexAttrib1svNV
,
586 (attrib_func
) VertexAttrib1usvNV
,
587 (attrib_func
) VertexAttrib1ivNV
,
588 (attrib_func
) VertexAttrib1uivNV
,
589 (attrib_func
) VertexAttrib1fvNV
,
590 (attrib_func
) VertexAttrib1dvNV
594 (attrib_func
) VertexAttrib2bvNV
,
595 (attrib_func
) VertexAttrib2ubvNV
,
596 (attrib_func
) VertexAttrib2svNV
,
597 (attrib_func
) VertexAttrib2usvNV
,
598 (attrib_func
) VertexAttrib2ivNV
,
599 (attrib_func
) VertexAttrib2uivNV
,
600 (attrib_func
) VertexAttrib2fvNV
,
601 (attrib_func
) VertexAttrib2dvNV
605 (attrib_func
) VertexAttrib3bvNV
,
606 (attrib_func
) VertexAttrib3ubvNV
,
607 (attrib_func
) VertexAttrib3svNV
,
608 (attrib_func
) VertexAttrib3usvNV
,
609 (attrib_func
) VertexAttrib3ivNV
,
610 (attrib_func
) VertexAttrib3uivNV
,
611 (attrib_func
) VertexAttrib3fvNV
,
612 (attrib_func
) VertexAttrib3dvNV
616 (attrib_func
) VertexAttrib4bvNV
,
617 (attrib_func
) VertexAttrib4ubvNV
,
618 (attrib_func
) VertexAttrib4svNV
,
619 (attrib_func
) VertexAttrib4usvNV
,
620 (attrib_func
) VertexAttrib4ivNV
,
621 (attrib_func
) VertexAttrib4uivNV
,
622 (attrib_func
) VertexAttrib4fvNV
,
623 (attrib_func
) VertexAttrib4dvNV
627 /* normalized (except for float/double) */
630 (attrib_func
) VertexAttrib1NbvNV
,
631 (attrib_func
) VertexAttrib1NubvNV
,
632 (attrib_func
) VertexAttrib1NsvNV
,
633 (attrib_func
) VertexAttrib1NusvNV
,
634 (attrib_func
) VertexAttrib1NivNV
,
635 (attrib_func
) VertexAttrib1NuivNV
,
636 (attrib_func
) VertexAttrib1fvNV
,
637 (attrib_func
) VertexAttrib1dvNV
641 (attrib_func
) VertexAttrib2NbvNV
,
642 (attrib_func
) VertexAttrib2NubvNV
,
643 (attrib_func
) VertexAttrib2NsvNV
,
644 (attrib_func
) VertexAttrib2NusvNV
,
645 (attrib_func
) VertexAttrib2NivNV
,
646 (attrib_func
) VertexAttrib2NuivNV
,
647 (attrib_func
) VertexAttrib2fvNV
,
648 (attrib_func
) VertexAttrib2dvNV
652 (attrib_func
) VertexAttrib3NbvNV
,
653 (attrib_func
) VertexAttrib3NubvNV
,
654 (attrib_func
) VertexAttrib3NsvNV
,
655 (attrib_func
) VertexAttrib3NusvNV
,
656 (attrib_func
) VertexAttrib3NivNV
,
657 (attrib_func
) VertexAttrib3NuivNV
,
658 (attrib_func
) VertexAttrib3fvNV
,
659 (attrib_func
) VertexAttrib3dvNV
663 (attrib_func
) VertexAttrib4NbvNV
,
664 (attrib_func
) VertexAttrib4NubvNV
,
665 (attrib_func
) VertexAttrib4NsvNV
,
666 (attrib_func
) VertexAttrib4NusvNV
,
667 (attrib_func
) VertexAttrib4NivNV
,
668 (attrib_func
) VertexAttrib4NuivNV
,
669 (attrib_func
) VertexAttrib4fvNV
,
670 (attrib_func
) VertexAttrib4dvNV
677 ** GL_ARB_vertex_program
680 /* GL_BYTE attributes */
683 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
685 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
689 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
691 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
695 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
697 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
701 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
703 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
707 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
709 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
711 BYTE_TO_FLOAT(v
[2])));
715 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
717 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
721 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
723 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
726 BYTE_TO_FLOAT(v
[3])));
730 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
732 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
735 /* GL_UNSIGNED_BYTE attributes */
738 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
740 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
744 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
746 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
750 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
752 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
753 UBYTE_TO_FLOAT(v
[0]),
754 UBYTE_TO_FLOAT(v
[1])));
758 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
760 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
761 (GLfloat
)v
[0], (GLfloat
)v
[1]));
765 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
767 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
768 UBYTE_TO_FLOAT(v
[0]),
769 UBYTE_TO_FLOAT(v
[1]),
770 UBYTE_TO_FLOAT(v
[2])));
773 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
775 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
782 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
784 CALL_VertexAttrib4fARB(GET_DISPATCH(),
786 UBYTE_TO_FLOAT(v
[0]),
787 UBYTE_TO_FLOAT(v
[1]),
788 UBYTE_TO_FLOAT(v
[2]),
789 UBYTE_TO_FLOAT(v
[3])));
793 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
795 CALL_VertexAttrib4fARB(GET_DISPATCH(),
797 (GLfloat
)v
[0], (GLfloat
)v
[1],
798 (GLfloat
)v
[2], (GLfloat
)v
[3]));
801 /* GL_SHORT attributes */
804 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
806 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
810 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
812 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
816 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
818 CALL_VertexAttrib2fARB(GET_DISPATCH(),
819 (index
, SHORT_TO_FLOAT(v
[0]),
820 SHORT_TO_FLOAT(v
[1])));
824 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
826 CALL_VertexAttrib2fARB(GET_DISPATCH(),
827 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
831 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
833 CALL_VertexAttrib3fARB(GET_DISPATCH(),
835 SHORT_TO_FLOAT(v
[0]),
836 SHORT_TO_FLOAT(v
[1]),
837 SHORT_TO_FLOAT(v
[2])));
841 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
843 CALL_VertexAttrib3fARB(GET_DISPATCH(),
845 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
849 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
851 CALL_VertexAttrib4fARB(GET_DISPATCH(),
853 SHORT_TO_FLOAT(v
[0]),
854 SHORT_TO_FLOAT(v
[1]),
855 SHORT_TO_FLOAT(v
[2]),
856 SHORT_TO_FLOAT(v
[3])));
860 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
862 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
863 (GLfloat
)v
[2], (GLfloat
)v
[3]));
866 /* GL_UNSIGNED_SHORT attributes */
869 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
871 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
875 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
877 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
881 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
883 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
884 USHORT_TO_FLOAT(v
[1])));
888 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
890 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
895 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
897 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
898 USHORT_TO_FLOAT(v
[1]),
899 USHORT_TO_FLOAT(v
[2])));
903 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
905 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
906 (GLfloat
)v
[1], (GLfloat
)v
[2]));
910 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
912 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
913 USHORT_TO_FLOAT(v
[1]),
914 USHORT_TO_FLOAT(v
[2]),
915 USHORT_TO_FLOAT(v
[3])));
919 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
921 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
924 /* GL_INT attributes */
927 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
929 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
933 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
935 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
939 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
941 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
942 INT_TO_FLOAT(v
[1])));
946 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
948 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
953 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
955 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
957 INT_TO_FLOAT(v
[2])));
961 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
963 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
964 (GLfloat
)v
[1], (GLfloat
)v
[2]));
968 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
970 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
973 INT_TO_FLOAT(v
[3])));
977 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
979 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
980 (GLfloat
)v
[2], (GLfloat
)v
[3]));
983 /* GL_UNSIGNED_INT attributes */
986 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
988 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
992 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
994 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
998 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
1000 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1001 UINT_TO_FLOAT(v
[1])));
1005 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1007 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1012 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1014 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1015 UINT_TO_FLOAT(v
[1]),
1016 UINT_TO_FLOAT(v
[2])));
1020 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1022 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1023 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1027 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1029 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1030 UINT_TO_FLOAT(v
[1]),
1031 UINT_TO_FLOAT(v
[2]),
1032 UINT_TO_FLOAT(v
[3])));
1036 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1038 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1039 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1042 /* GL_FLOAT attributes */
1045 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1047 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1051 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1053 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1057 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1059 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1063 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1065 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1068 /* GL_DOUBLE attributes */
1071 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1073 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
1077 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1079 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
1083 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1085 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
1089 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1091 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
1096 * Integer-valued attributes
1099 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1101 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1105 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1107 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1111 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1113 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1117 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1119 CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index
, v
));
1124 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1126 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1130 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1132 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1136 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1138 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1142 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1144 CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index
, v
));
1150 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1152 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1156 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1158 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1162 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1164 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1168 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1170 CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index
, v
));
1175 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1177 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1181 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1183 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1187 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1189 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1193 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1195 CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index
, v
));
1201 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1203 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1207 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1209 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1213 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1215 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1219 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1221 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1226 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1228 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1232 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1234 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1238 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1240 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1244 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1246 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1253 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1256 static attrib_func AttribFuncsARB
[3][4][NUM_TYPES
] = {
1258 /* non-normalized */
1261 (attrib_func
) VertexAttrib1bvARB
,
1262 (attrib_func
) VertexAttrib1ubvARB
,
1263 (attrib_func
) VertexAttrib1svARB
,
1264 (attrib_func
) VertexAttrib1usvARB
,
1265 (attrib_func
) VertexAttrib1ivARB
,
1266 (attrib_func
) VertexAttrib1uivARB
,
1267 (attrib_func
) VertexAttrib1fvARB
,
1268 (attrib_func
) VertexAttrib1dvARB
1272 (attrib_func
) VertexAttrib2bvARB
,
1273 (attrib_func
) VertexAttrib2ubvARB
,
1274 (attrib_func
) VertexAttrib2svARB
,
1275 (attrib_func
) VertexAttrib2usvARB
,
1276 (attrib_func
) VertexAttrib2ivARB
,
1277 (attrib_func
) VertexAttrib2uivARB
,
1278 (attrib_func
) VertexAttrib2fvARB
,
1279 (attrib_func
) VertexAttrib2dvARB
1283 (attrib_func
) VertexAttrib3bvARB
,
1284 (attrib_func
) VertexAttrib3ubvARB
,
1285 (attrib_func
) VertexAttrib3svARB
,
1286 (attrib_func
) VertexAttrib3usvARB
,
1287 (attrib_func
) VertexAttrib3ivARB
,
1288 (attrib_func
) VertexAttrib3uivARB
,
1289 (attrib_func
) VertexAttrib3fvARB
,
1290 (attrib_func
) VertexAttrib3dvARB
1294 (attrib_func
) VertexAttrib4bvARB
,
1295 (attrib_func
) VertexAttrib4ubvARB
,
1296 (attrib_func
) VertexAttrib4svARB
,
1297 (attrib_func
) VertexAttrib4usvARB
,
1298 (attrib_func
) VertexAttrib4ivARB
,
1299 (attrib_func
) VertexAttrib4uivARB
,
1300 (attrib_func
) VertexAttrib4fvARB
,
1301 (attrib_func
) VertexAttrib4dvARB
1305 /* normalized (except for float/double) */
1308 (attrib_func
) VertexAttrib1NbvARB
,
1309 (attrib_func
) VertexAttrib1NubvARB
,
1310 (attrib_func
) VertexAttrib1NsvARB
,
1311 (attrib_func
) VertexAttrib1NusvARB
,
1312 (attrib_func
) VertexAttrib1NivARB
,
1313 (attrib_func
) VertexAttrib1NuivARB
,
1314 (attrib_func
) VertexAttrib1fvARB
,
1315 (attrib_func
) VertexAttrib1dvARB
1319 (attrib_func
) VertexAttrib2NbvARB
,
1320 (attrib_func
) VertexAttrib2NubvARB
,
1321 (attrib_func
) VertexAttrib2NsvARB
,
1322 (attrib_func
) VertexAttrib2NusvARB
,
1323 (attrib_func
) VertexAttrib2NivARB
,
1324 (attrib_func
) VertexAttrib2NuivARB
,
1325 (attrib_func
) VertexAttrib2fvARB
,
1326 (attrib_func
) VertexAttrib2dvARB
1330 (attrib_func
) VertexAttrib3NbvARB
,
1331 (attrib_func
) VertexAttrib3NubvARB
,
1332 (attrib_func
) VertexAttrib3NsvARB
,
1333 (attrib_func
) VertexAttrib3NusvARB
,
1334 (attrib_func
) VertexAttrib3NivARB
,
1335 (attrib_func
) VertexAttrib3NuivARB
,
1336 (attrib_func
) VertexAttrib3fvARB
,
1337 (attrib_func
) VertexAttrib3dvARB
1341 (attrib_func
) VertexAttrib4NbvARB
,
1342 (attrib_func
) VertexAttrib4NubvARB
,
1343 (attrib_func
) VertexAttrib4NsvARB
,
1344 (attrib_func
) VertexAttrib4NusvARB
,
1345 (attrib_func
) VertexAttrib4NivARB
,
1346 (attrib_func
) VertexAttrib4NuivARB
,
1347 (attrib_func
) VertexAttrib4fvARB
,
1348 (attrib_func
) VertexAttrib4dvARB
1353 /* integer-valued */
1356 (attrib_func
) VertexAttribI1bv
,
1357 (attrib_func
) VertexAttribI1ubv
,
1358 (attrib_func
) VertexAttribI1sv
,
1359 (attrib_func
) VertexAttribI1usv
,
1360 (attrib_func
) VertexAttribI1iv
,
1361 (attrib_func
) VertexAttribI1uiv
,
1362 NULL
, /* GL_FLOAT */
1363 NULL
/* GL_DOUBLE */
1367 (attrib_func
) VertexAttribI2bv
,
1368 (attrib_func
) VertexAttribI2ubv
,
1369 (attrib_func
) VertexAttribI2sv
,
1370 (attrib_func
) VertexAttribI2usv
,
1371 (attrib_func
) VertexAttribI2iv
,
1372 (attrib_func
) VertexAttribI2uiv
,
1373 NULL
, /* GL_FLOAT */
1374 NULL
/* GL_DOUBLE */
1378 (attrib_func
) VertexAttribI3bv
,
1379 (attrib_func
) VertexAttribI3ubv
,
1380 (attrib_func
) VertexAttribI3sv
,
1381 (attrib_func
) VertexAttribI3usv
,
1382 (attrib_func
) VertexAttribI3iv
,
1383 (attrib_func
) VertexAttribI3uiv
,
1384 NULL
, /* GL_FLOAT */
1385 NULL
/* GL_DOUBLE */
1389 (attrib_func
) VertexAttribI4bv
,
1390 (attrib_func
) VertexAttribI4ubv
,
1391 (attrib_func
) VertexAttribI4sv
,
1392 (attrib_func
) VertexAttribI4usv
,
1393 (attrib_func
) VertexAttribI4iv
,
1394 (attrib_func
) VertexAttribI4uiv
,
1395 NULL
, /* GL_FLOAT */
1396 NULL
/* GL_DOUBLE */
1401 /**********************************************************************/
1404 GLboolean
_ae_create_context( struct gl_context
*ctx
)
1406 if (ctx
->aelt_context
)
1409 /* These _gloffset_* values may not be compile-time constants */
1410 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1411 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1412 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1413 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1414 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1415 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1416 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1417 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1419 FogCoordFuncs
[0] = -1;
1420 FogCoordFuncs
[1] = -1;
1421 FogCoordFuncs
[2] = -1;
1422 FogCoordFuncs
[3] = -1;
1423 FogCoordFuncs
[4] = -1;
1424 FogCoordFuncs
[5] = -1;
1425 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1426 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1428 ctx
->aelt_context
= CALLOC( sizeof(AEcontext
) );
1429 if (!ctx
->aelt_context
)
1432 AE_CONTEXT(ctx
)->NewState
= ~0;
1437 void _ae_destroy_context( struct gl_context
*ctx
)
1439 if ( AE_CONTEXT( ctx
) ) {
1440 FREE( ctx
->aelt_context
);
1441 ctx
->aelt_context
= NULL
;
1445 static void check_vbo( AEcontext
*actx
,
1446 struct gl_buffer_object
*vbo
)
1448 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1450 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1451 if (actx
->vbo
[i
] == vbo
)
1453 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1454 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1460 * Make a list of per-vertex functions to call for each glArrayElement call.
1461 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1463 * Note: this may be called during display list construction.
1465 static void _ae_update_state( struct gl_context
*ctx
)
1467 AEcontext
*actx
= AE_CONTEXT(ctx
);
1468 AEarray
*aa
= actx
->arrays
;
1469 AEattrib
*at
= actx
->attribs
;
1471 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1475 /* conventional vertex arrays */
1476 if (arrayObj
->Index
.Enabled
) {
1477 aa
->array
= &arrayObj
->Index
;
1478 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1479 check_vbo(actx
, aa
->array
->BufferObj
);
1482 if (arrayObj
->EdgeFlag
.Enabled
) {
1483 aa
->array
= &arrayObj
->EdgeFlag
;
1484 aa
->offset
= _gloffset_EdgeFlagv
;
1485 check_vbo(actx
, aa
->array
->BufferObj
);
1488 if (arrayObj
->Normal
.Enabled
) {
1489 aa
->array
= &arrayObj
->Normal
;
1490 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1491 check_vbo(actx
, aa
->array
->BufferObj
);
1494 if (arrayObj
->Color
.Enabled
) {
1495 aa
->array
= &arrayObj
->Color
;
1496 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1497 check_vbo(actx
, aa
->array
->BufferObj
);
1500 if (arrayObj
->SecondaryColor
.Enabled
) {
1501 aa
->array
= &arrayObj
->SecondaryColor
;
1502 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1503 check_vbo(actx
, aa
->array
->BufferObj
);
1506 if (arrayObj
->FogCoord
.Enabled
) {
1507 aa
->array
= &arrayObj
->FogCoord
;
1508 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1509 check_vbo(actx
, aa
->array
->BufferObj
);
1512 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1513 struct gl_client_array
*attribArray
= &arrayObj
->TexCoord
[i
];
1514 if (attribArray
->Enabled
) {
1515 /* NOTE: we use generic glVertexAttribNV functions here.
1516 * If we ever remove GL_NV_vertex_program this will have to change.
1518 at
->array
= attribArray
;
1519 ASSERT(!at
->array
->Normalized
);
1520 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1522 [TYPE_IDX(at
->array
->Type
)];
1523 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1524 check_vbo(actx
, at
->array
->BufferObj
);
1529 /* generic vertex attribute arrays */
1530 for (i
= 1; i
< Elements(arrayObj
->VertexAttrib
); i
++) { /* skip zero! */
1531 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[i
];
1532 if (attribArray
->Enabled
) {
1533 at
->array
= attribArray
;
1534 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1535 * function pointer here (for float arrays) since the pointer may
1536 * change from one execution of _ae_ArrayElement() to
1537 * the next. Doing so caused UT to break.
1539 if (ctx
->VertexProgram
._Enabled
1540 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1541 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1543 [TYPE_IDX(at
->array
->Type
)];
1547 if (at
->array
->Integer
)
1549 else if (at
->array
->Normalized
)
1554 at
->func
= AttribFuncsARB
[intOrNorm
]
1556 [TYPE_IDX(at
->array
->Type
)];
1559 check_vbo(actx
, at
->array
->BufferObj
);
1564 /* finally, vertex position */
1565 if (arrayObj
->VertexAttrib
[0].Enabled
) {
1566 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1567 * issued as the last (provoking) attribute).
1569 aa
->array
= &arrayObj
->VertexAttrib
[0];
1570 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1571 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1572 check_vbo(actx
, aa
->array
->BufferObj
);
1575 else if (arrayObj
->Vertex
.Enabled
) {
1576 aa
->array
= &arrayObj
->Vertex
;
1577 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1578 check_vbo(actx
, aa
->array
->BufferObj
);
1582 check_vbo(actx
, ctx
->Array
.ElementArrayBufferObj
);
1584 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1585 ASSERT(aa
- actx
->arrays
< 32);
1586 at
->func
= NULL
; /* terminate the list */
1587 aa
->offset
= -1; /* terminate the list */
1592 void _ae_map_vbos( struct gl_context
*ctx
)
1594 AEcontext
*actx
= AE_CONTEXT(ctx
);
1597 if (actx
->mapped_vbos
)
1601 _ae_update_state(ctx
);
1603 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1604 ctx
->Driver
.MapBuffer(ctx
,
1605 GL_ARRAY_BUFFER_ARB
,
1606 GL_DYNAMIC_DRAW_ARB
,
1610 actx
->mapped_vbos
= GL_TRUE
;
1613 void _ae_unmap_vbos( struct gl_context
*ctx
)
1615 AEcontext
*actx
= AE_CONTEXT(ctx
);
1618 if (!actx
->mapped_vbos
)
1621 assert (!actx
->NewState
);
1623 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1624 ctx
->Driver
.UnmapBuffer(ctx
,
1625 GL_ARRAY_BUFFER_ARB
,
1628 actx
->mapped_vbos
= GL_FALSE
;
1633 * Called via glArrayElement() and glDrawArrays().
1634 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1635 * for all enabled vertex arrays (for elt-th element).
1636 * Note: this may be called during display list construction.
1638 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1640 GET_CURRENT_CONTEXT(ctx
);
1641 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1644 const struct _glapi_table
* const disp
= GET_DISPATCH();
1647 if (actx
->NewState
) {
1648 assert(!actx
->mapped_vbos
);
1649 _ae_update_state( ctx
);
1652 /* Determine if w need to map/unmap VBOs */
1653 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1658 /* emit generic attribute elements */
1659 for (at
= actx
->attribs
; at
->func
; at
++) {
1661 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1662 + elt
* at
->array
->StrideB
;
1663 at
->func( at
->index
, src
);
1666 /* emit conventional arrays elements */
1667 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1669 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1670 + elt
* aa
->array
->StrideB
;
1671 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1672 ((const void *) src
) );
1676 _ae_unmap_vbos(ctx
);
1680 void _ae_invalidate_state( struct gl_context
*ctx
, GLuint new_state
)
1682 AEcontext
*actx
= AE_CONTEXT(ctx
);
1685 /* Only interested in this subset of mesa state. Need to prune
1686 * this down as both tnl/ and the drivers can raise statechanges
1687 * for arcane reasons in the middle of seemingly atomic operations
1688 * like DrawElements, over which we'd like to keep a known set of
1689 * arrays and vbo's mapped.
1691 * Luckily, neither the drivers nor tnl muck with the state that
1694 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1696 assert(!actx
->mapped_vbos
);
1697 actx
->NewState
|= new_state
;
1702 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1703 const GLvertexformat
*vfmt
)
1705 SET_ArrayElement(disp
, vfmt
->ArrayElement
);
1709 #endif /* FEATURE_arrayelt */