2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
26 * This file implements the glArrayElement() function.
27 * It involves looking at the format/type of all the enabled vertex arrays
28 * and emitting a list of pointers to functions which set the per-vertex
29 * state for the element/index.
34 * Keith Whitwell <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 /* List of VBOs we need to map before executing ArrayElements */
67 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
69 GLboolean mapped_vbos
; /**< Any currently mapped VBOs? */
74 static INLINE AEcontext
*
75 AE_CONTEXT(struct gl_context
*ctx
)
77 return (AEcontext
*) ctx
->aelt_context
;
82 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
83 * in the range [0, 7]. Luckily these type tokens are sequentially
84 * numbered in gl.h, except for GL_DOUBLE.
89 return t
== GL_DOUBLE
? 7 : t
& 7;
96 static const int ColorFuncs
[2][NUM_TYPES
] = {
119 static const int VertexFuncs
[3][NUM_TYPES
] = {
152 static const int IndexFuncs
[NUM_TYPES
] = {
163 static const int NormalFuncs
[NUM_TYPES
] = {
174 /* Note: _gloffset_* for these may not be a compile-time constant. */
175 static int SecondaryColorFuncs
[NUM_TYPES
];
176 static int FogCoordFuncs
[NUM_TYPES
];
180 ** GL_NV_vertex_program
183 /* GL_BYTE attributes */
185 static void GLAPIENTRY
186 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
188 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
191 static void GLAPIENTRY
192 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
194 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
197 static void GLAPIENTRY
198 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
200 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
203 static void GLAPIENTRY
204 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
206 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
209 static void GLAPIENTRY
210 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
212 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
214 BYTE_TO_FLOAT(v
[2])));
217 static void GLAPIENTRY
218 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
220 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
223 static void GLAPIENTRY
224 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
226 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
229 BYTE_TO_FLOAT(v
[3])));
232 static void GLAPIENTRY
233 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
235 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
238 /* GL_UNSIGNED_BYTE attributes */
240 static void GLAPIENTRY
241 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
243 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
246 static void GLAPIENTRY
247 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
249 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
252 static void GLAPIENTRY
253 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
255 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
256 UBYTE_TO_FLOAT(v
[1])));
259 static void GLAPIENTRY
260 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
262 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
265 static void GLAPIENTRY
266 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
268 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
269 UBYTE_TO_FLOAT(v
[1]),
270 UBYTE_TO_FLOAT(v
[2])));
272 static void GLAPIENTRY
273 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
275 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
276 (GLfloat
)v
[1], (GLfloat
)v
[2]));
279 static void GLAPIENTRY
280 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
282 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
283 UBYTE_TO_FLOAT(v
[1]),
284 UBYTE_TO_FLOAT(v
[2]),
285 UBYTE_TO_FLOAT(v
[3])));
288 static void GLAPIENTRY
289 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
291 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
292 (GLfloat
)v
[1], (GLfloat
)v
[2],
296 /* GL_SHORT attributes */
298 static void GLAPIENTRY
299 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
301 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
304 static void GLAPIENTRY
305 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
307 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
310 static void GLAPIENTRY
311 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
313 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
314 SHORT_TO_FLOAT(v
[1])));
317 static void GLAPIENTRY
318 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
320 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
323 static void GLAPIENTRY
324 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
326 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
327 SHORT_TO_FLOAT(v
[1]),
328 SHORT_TO_FLOAT(v
[2])));
331 static void GLAPIENTRY
332 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
334 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
338 static void GLAPIENTRY
339 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
341 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
342 SHORT_TO_FLOAT(v
[1]),
343 SHORT_TO_FLOAT(v
[2]),
344 SHORT_TO_FLOAT(v
[3])));
347 static void GLAPIENTRY
348 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
350 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
351 (GLfloat
)v
[2], (GLfloat
)v
[3]));
354 /* GL_UNSIGNED_SHORT attributes */
356 static void GLAPIENTRY
357 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
359 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
362 static void GLAPIENTRY
363 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
365 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
368 static void GLAPIENTRY
369 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
371 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
372 USHORT_TO_FLOAT(v
[1])));
375 static void GLAPIENTRY
376 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
378 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
382 static void GLAPIENTRY
383 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
385 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
386 USHORT_TO_FLOAT(v
[1]),
387 USHORT_TO_FLOAT(v
[2])));
390 static void GLAPIENTRY
391 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
393 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
397 static void GLAPIENTRY
398 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
400 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
401 USHORT_TO_FLOAT(v
[1]),
402 USHORT_TO_FLOAT(v
[2]),
403 USHORT_TO_FLOAT(v
[3])));
406 static void GLAPIENTRY
407 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
409 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
410 (GLfloat
)v
[2], (GLfloat
)v
[3]));
413 /* GL_INT attributes */
415 static void GLAPIENTRY
416 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
418 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
421 static void GLAPIENTRY
422 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
424 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
427 static void GLAPIENTRY
428 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
430 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
431 INT_TO_FLOAT(v
[1])));
434 static void GLAPIENTRY
435 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
437 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
440 static void GLAPIENTRY
441 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
443 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
445 INT_TO_FLOAT(v
[2])));
448 static void GLAPIENTRY
449 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
451 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
455 static void GLAPIENTRY
456 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
458 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
461 INT_TO_FLOAT(v
[3])));
464 static void GLAPIENTRY
465 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
467 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
468 (GLfloat
)v
[2], (GLfloat
)v
[3]));
471 /* GL_UNSIGNED_INT attributes */
473 static void GLAPIENTRY
474 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
476 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
479 static void GLAPIENTRY
480 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
482 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
485 static void GLAPIENTRY
486 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
488 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
489 UINT_TO_FLOAT(v
[1])));
492 static void GLAPIENTRY
493 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
495 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
499 static void GLAPIENTRY
500 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
502 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
504 UINT_TO_FLOAT(v
[2])));
507 static void GLAPIENTRY
508 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
510 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
514 static void GLAPIENTRY
515 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
517 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
520 UINT_TO_FLOAT(v
[3])));
523 static void GLAPIENTRY
524 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
526 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
527 (GLfloat
)v
[2], (GLfloat
)v
[3]));
530 /* GL_FLOAT attributes */
532 static void GLAPIENTRY
533 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
535 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
538 static void GLAPIENTRY
539 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
541 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
544 static void GLAPIENTRY
545 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
547 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
550 static void GLAPIENTRY
551 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
553 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
556 /* GL_DOUBLE attributes */
558 static void GLAPIENTRY
559 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
561 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
564 static void GLAPIENTRY
565 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
567 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
570 static void GLAPIENTRY
571 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
573 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
576 static void GLAPIENTRY
577 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
579 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
584 * Array [size][type] of VertexAttrib functions
586 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
591 (attrib_func
) VertexAttrib1bvNV
,
592 (attrib_func
) VertexAttrib1ubvNV
,
593 (attrib_func
) VertexAttrib1svNV
,
594 (attrib_func
) VertexAttrib1usvNV
,
595 (attrib_func
) VertexAttrib1ivNV
,
596 (attrib_func
) VertexAttrib1uivNV
,
597 (attrib_func
) VertexAttrib1fvNV
,
598 (attrib_func
) VertexAttrib1dvNV
602 (attrib_func
) VertexAttrib2bvNV
,
603 (attrib_func
) VertexAttrib2ubvNV
,
604 (attrib_func
) VertexAttrib2svNV
,
605 (attrib_func
) VertexAttrib2usvNV
,
606 (attrib_func
) VertexAttrib2ivNV
,
607 (attrib_func
) VertexAttrib2uivNV
,
608 (attrib_func
) VertexAttrib2fvNV
,
609 (attrib_func
) VertexAttrib2dvNV
613 (attrib_func
) VertexAttrib3bvNV
,
614 (attrib_func
) VertexAttrib3ubvNV
,
615 (attrib_func
) VertexAttrib3svNV
,
616 (attrib_func
) VertexAttrib3usvNV
,
617 (attrib_func
) VertexAttrib3ivNV
,
618 (attrib_func
) VertexAttrib3uivNV
,
619 (attrib_func
) VertexAttrib3fvNV
,
620 (attrib_func
) VertexAttrib3dvNV
624 (attrib_func
) VertexAttrib4bvNV
,
625 (attrib_func
) VertexAttrib4ubvNV
,
626 (attrib_func
) VertexAttrib4svNV
,
627 (attrib_func
) VertexAttrib4usvNV
,
628 (attrib_func
) VertexAttrib4ivNV
,
629 (attrib_func
) VertexAttrib4uivNV
,
630 (attrib_func
) VertexAttrib4fvNV
,
631 (attrib_func
) VertexAttrib4dvNV
635 /* normalized (except for float/double) */
638 (attrib_func
) VertexAttrib1NbvNV
,
639 (attrib_func
) VertexAttrib1NubvNV
,
640 (attrib_func
) VertexAttrib1NsvNV
,
641 (attrib_func
) VertexAttrib1NusvNV
,
642 (attrib_func
) VertexAttrib1NivNV
,
643 (attrib_func
) VertexAttrib1NuivNV
,
644 (attrib_func
) VertexAttrib1fvNV
,
645 (attrib_func
) VertexAttrib1dvNV
649 (attrib_func
) VertexAttrib2NbvNV
,
650 (attrib_func
) VertexAttrib2NubvNV
,
651 (attrib_func
) VertexAttrib2NsvNV
,
652 (attrib_func
) VertexAttrib2NusvNV
,
653 (attrib_func
) VertexAttrib2NivNV
,
654 (attrib_func
) VertexAttrib2NuivNV
,
655 (attrib_func
) VertexAttrib2fvNV
,
656 (attrib_func
) VertexAttrib2dvNV
660 (attrib_func
) VertexAttrib3NbvNV
,
661 (attrib_func
) VertexAttrib3NubvNV
,
662 (attrib_func
) VertexAttrib3NsvNV
,
663 (attrib_func
) VertexAttrib3NusvNV
,
664 (attrib_func
) VertexAttrib3NivNV
,
665 (attrib_func
) VertexAttrib3NuivNV
,
666 (attrib_func
) VertexAttrib3fvNV
,
667 (attrib_func
) VertexAttrib3dvNV
671 (attrib_func
) VertexAttrib4NbvNV
,
672 (attrib_func
) VertexAttrib4NubvNV
,
673 (attrib_func
) VertexAttrib4NsvNV
,
674 (attrib_func
) VertexAttrib4NusvNV
,
675 (attrib_func
) VertexAttrib4NivNV
,
676 (attrib_func
) VertexAttrib4NuivNV
,
677 (attrib_func
) VertexAttrib4fvNV
,
678 (attrib_func
) VertexAttrib4dvNV
685 ** GL_ARB_vertex_program
688 /* GL_BYTE attributes */
690 static void GLAPIENTRY
691 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
693 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
696 static void GLAPIENTRY
697 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
699 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
702 static void GLAPIENTRY
703 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
705 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
708 static void GLAPIENTRY
709 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
711 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
714 static void GLAPIENTRY
715 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
717 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
719 BYTE_TO_FLOAT(v
[2])));
722 static void GLAPIENTRY
723 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
725 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
728 static void GLAPIENTRY
729 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
731 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
734 BYTE_TO_FLOAT(v
[3])));
737 static void GLAPIENTRY
738 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
740 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
743 /* GL_UNSIGNED_BYTE attributes */
745 static void GLAPIENTRY
746 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
748 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
751 static void GLAPIENTRY
752 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
754 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
757 static void GLAPIENTRY
758 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
760 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
761 UBYTE_TO_FLOAT(v
[0]),
762 UBYTE_TO_FLOAT(v
[1])));
765 static void GLAPIENTRY
766 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
768 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
769 (GLfloat
)v
[0], (GLfloat
)v
[1]));
772 static void GLAPIENTRY
773 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
775 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
776 UBYTE_TO_FLOAT(v
[0]),
777 UBYTE_TO_FLOAT(v
[1]),
778 UBYTE_TO_FLOAT(v
[2])));
780 static void GLAPIENTRY
781 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
783 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
789 static void GLAPIENTRY
790 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
792 CALL_VertexAttrib4fARB(GET_DISPATCH(),
794 UBYTE_TO_FLOAT(v
[0]),
795 UBYTE_TO_FLOAT(v
[1]),
796 UBYTE_TO_FLOAT(v
[2]),
797 UBYTE_TO_FLOAT(v
[3])));
800 static void GLAPIENTRY
801 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
803 CALL_VertexAttrib4fARB(GET_DISPATCH(),
805 (GLfloat
)v
[0], (GLfloat
)v
[1],
806 (GLfloat
)v
[2], (GLfloat
)v
[3]));
809 /* GL_SHORT attributes */
811 static void GLAPIENTRY
812 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
814 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
817 static void GLAPIENTRY
818 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
820 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
823 static void GLAPIENTRY
824 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
826 CALL_VertexAttrib2fARB(GET_DISPATCH(),
827 (index
, SHORT_TO_FLOAT(v
[0]),
828 SHORT_TO_FLOAT(v
[1])));
831 static void GLAPIENTRY
832 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
834 CALL_VertexAttrib2fARB(GET_DISPATCH(),
835 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
838 static void GLAPIENTRY
839 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
841 CALL_VertexAttrib3fARB(GET_DISPATCH(),
843 SHORT_TO_FLOAT(v
[0]),
844 SHORT_TO_FLOAT(v
[1]),
845 SHORT_TO_FLOAT(v
[2])));
848 static void GLAPIENTRY
849 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
851 CALL_VertexAttrib3fARB(GET_DISPATCH(),
853 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
856 static void GLAPIENTRY
857 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
859 CALL_VertexAttrib4fARB(GET_DISPATCH(),
861 SHORT_TO_FLOAT(v
[0]),
862 SHORT_TO_FLOAT(v
[1]),
863 SHORT_TO_FLOAT(v
[2]),
864 SHORT_TO_FLOAT(v
[3])));
867 static void GLAPIENTRY
868 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
870 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
871 (GLfloat
)v
[2], (GLfloat
)v
[3]));
874 /* GL_UNSIGNED_SHORT attributes */
876 static void GLAPIENTRY
877 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
879 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
882 static void GLAPIENTRY
883 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
885 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
888 static void GLAPIENTRY
889 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
891 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
892 USHORT_TO_FLOAT(v
[1])));
895 static void GLAPIENTRY
896 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
898 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
902 static void GLAPIENTRY
903 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
905 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
906 USHORT_TO_FLOAT(v
[1]),
907 USHORT_TO_FLOAT(v
[2])));
910 static void GLAPIENTRY
911 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
913 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
914 (GLfloat
)v
[1], (GLfloat
)v
[2]));
917 static void GLAPIENTRY
918 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
920 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
921 USHORT_TO_FLOAT(v
[1]),
922 USHORT_TO_FLOAT(v
[2]),
923 USHORT_TO_FLOAT(v
[3])));
926 static void GLAPIENTRY
927 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
929 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
932 /* GL_INT attributes */
934 static void GLAPIENTRY
935 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
937 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
940 static void GLAPIENTRY
941 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
943 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
946 static void GLAPIENTRY
947 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
949 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
950 INT_TO_FLOAT(v
[1])));
953 static void GLAPIENTRY
954 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
956 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
960 static void GLAPIENTRY
961 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
963 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
965 INT_TO_FLOAT(v
[2])));
968 static void GLAPIENTRY
969 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
971 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
972 (GLfloat
)v
[1], (GLfloat
)v
[2]));
975 static void GLAPIENTRY
976 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
978 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
981 INT_TO_FLOAT(v
[3])));
984 static void GLAPIENTRY
985 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
987 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
988 (GLfloat
)v
[2], (GLfloat
)v
[3]));
991 /* GL_UNSIGNED_INT attributes */
993 static void GLAPIENTRY
994 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
996 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
999 static void GLAPIENTRY
1000 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
1002 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
1005 static void GLAPIENTRY
1006 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
1008 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1009 UINT_TO_FLOAT(v
[1])));
1012 static void GLAPIENTRY
1013 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1015 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1019 static void GLAPIENTRY
1020 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1022 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1023 UINT_TO_FLOAT(v
[1]),
1024 UINT_TO_FLOAT(v
[2])));
1027 static void GLAPIENTRY
1028 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1030 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1031 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1034 static void GLAPIENTRY
1035 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1037 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1038 UINT_TO_FLOAT(v
[1]),
1039 UINT_TO_FLOAT(v
[2]),
1040 UINT_TO_FLOAT(v
[3])));
1043 static void GLAPIENTRY
1044 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1046 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1047 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1050 /* GL_FLOAT attributes */
1052 static void GLAPIENTRY
1053 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1055 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1058 static void GLAPIENTRY
1059 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1061 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1064 static void GLAPIENTRY
1065 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1067 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1070 static void GLAPIENTRY
1071 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1073 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1076 /* GL_DOUBLE attributes */
1078 static void GLAPIENTRY
1079 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1081 CALL_VertexAttrib1dv(GET_DISPATCH(), (index
, v
));
1084 static void GLAPIENTRY
1085 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1087 CALL_VertexAttrib2dv(GET_DISPATCH(), (index
, v
));
1090 static void GLAPIENTRY
1091 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1093 CALL_VertexAttrib3dv(GET_DISPATCH(), (index
, v
));
1096 static void GLAPIENTRY
1097 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1099 CALL_VertexAttrib4dv(GET_DISPATCH(), (index
, v
));
1104 * Integer-valued attributes
1106 static void GLAPIENTRY
1107 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1109 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1112 static void GLAPIENTRY
1113 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1115 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1118 static void GLAPIENTRY
1119 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1121 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1124 static void GLAPIENTRY
1125 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1127 CALL_VertexAttribI4bv(GET_DISPATCH(), (index
, v
));
1131 static void GLAPIENTRY
1132 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1134 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1137 static void GLAPIENTRY
1138 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1140 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1143 static void GLAPIENTRY
1144 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1146 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1149 static void GLAPIENTRY
1150 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1152 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index
, v
));
1157 static void GLAPIENTRY
1158 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1160 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1163 static void GLAPIENTRY
1164 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1166 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1169 static void GLAPIENTRY
1170 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1172 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1175 static void GLAPIENTRY
1176 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1178 CALL_VertexAttribI4sv(GET_DISPATCH(), (index
, v
));
1182 static void GLAPIENTRY
1183 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1185 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1188 static void GLAPIENTRY
1189 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1191 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1194 static void GLAPIENTRY
1195 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1197 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1200 static void GLAPIENTRY
1201 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1203 CALL_VertexAttribI4usv(GET_DISPATCH(), (index
, v
));
1208 static void GLAPIENTRY
1209 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1211 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1214 static void GLAPIENTRY
1215 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1217 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1220 static void GLAPIENTRY
1221 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1223 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1226 static void GLAPIENTRY
1227 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1229 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1233 static void GLAPIENTRY
1234 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1236 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1239 static void GLAPIENTRY
1240 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1242 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1245 static void GLAPIENTRY
1246 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1248 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1251 static void GLAPIENTRY
1252 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1254 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1259 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1262 static attrib_func AttribFuncsARB
[3][4][NUM_TYPES
] = {
1264 /* non-normalized */
1267 (attrib_func
) VertexAttrib1bvARB
,
1268 (attrib_func
) VertexAttrib1ubvARB
,
1269 (attrib_func
) VertexAttrib1svARB
,
1270 (attrib_func
) VertexAttrib1usvARB
,
1271 (attrib_func
) VertexAttrib1ivARB
,
1272 (attrib_func
) VertexAttrib1uivARB
,
1273 (attrib_func
) VertexAttrib1fvARB
,
1274 (attrib_func
) VertexAttrib1dvARB
1278 (attrib_func
) VertexAttrib2bvARB
,
1279 (attrib_func
) VertexAttrib2ubvARB
,
1280 (attrib_func
) VertexAttrib2svARB
,
1281 (attrib_func
) VertexAttrib2usvARB
,
1282 (attrib_func
) VertexAttrib2ivARB
,
1283 (attrib_func
) VertexAttrib2uivARB
,
1284 (attrib_func
) VertexAttrib2fvARB
,
1285 (attrib_func
) VertexAttrib2dvARB
1289 (attrib_func
) VertexAttrib3bvARB
,
1290 (attrib_func
) VertexAttrib3ubvARB
,
1291 (attrib_func
) VertexAttrib3svARB
,
1292 (attrib_func
) VertexAttrib3usvARB
,
1293 (attrib_func
) VertexAttrib3ivARB
,
1294 (attrib_func
) VertexAttrib3uivARB
,
1295 (attrib_func
) VertexAttrib3fvARB
,
1296 (attrib_func
) VertexAttrib3dvARB
1300 (attrib_func
) VertexAttrib4bvARB
,
1301 (attrib_func
) VertexAttrib4ubvARB
,
1302 (attrib_func
) VertexAttrib4svARB
,
1303 (attrib_func
) VertexAttrib4usvARB
,
1304 (attrib_func
) VertexAttrib4ivARB
,
1305 (attrib_func
) VertexAttrib4uivARB
,
1306 (attrib_func
) VertexAttrib4fvARB
,
1307 (attrib_func
) VertexAttrib4dvARB
1311 /* normalized (except for float/double) */
1314 (attrib_func
) VertexAttrib1NbvARB
,
1315 (attrib_func
) VertexAttrib1NubvARB
,
1316 (attrib_func
) VertexAttrib1NsvARB
,
1317 (attrib_func
) VertexAttrib1NusvARB
,
1318 (attrib_func
) VertexAttrib1NivARB
,
1319 (attrib_func
) VertexAttrib1NuivARB
,
1320 (attrib_func
) VertexAttrib1fvARB
,
1321 (attrib_func
) VertexAttrib1dvARB
1325 (attrib_func
) VertexAttrib2NbvARB
,
1326 (attrib_func
) VertexAttrib2NubvARB
,
1327 (attrib_func
) VertexAttrib2NsvARB
,
1328 (attrib_func
) VertexAttrib2NusvARB
,
1329 (attrib_func
) VertexAttrib2NivARB
,
1330 (attrib_func
) VertexAttrib2NuivARB
,
1331 (attrib_func
) VertexAttrib2fvARB
,
1332 (attrib_func
) VertexAttrib2dvARB
1336 (attrib_func
) VertexAttrib3NbvARB
,
1337 (attrib_func
) VertexAttrib3NubvARB
,
1338 (attrib_func
) VertexAttrib3NsvARB
,
1339 (attrib_func
) VertexAttrib3NusvARB
,
1340 (attrib_func
) VertexAttrib3NivARB
,
1341 (attrib_func
) VertexAttrib3NuivARB
,
1342 (attrib_func
) VertexAttrib3fvARB
,
1343 (attrib_func
) VertexAttrib3dvARB
1347 (attrib_func
) VertexAttrib4NbvARB
,
1348 (attrib_func
) VertexAttrib4NubvARB
,
1349 (attrib_func
) VertexAttrib4NsvARB
,
1350 (attrib_func
) VertexAttrib4NusvARB
,
1351 (attrib_func
) VertexAttrib4NivARB
,
1352 (attrib_func
) VertexAttrib4NuivARB
,
1353 (attrib_func
) VertexAttrib4fvARB
,
1354 (attrib_func
) VertexAttrib4dvARB
1359 /* integer-valued */
1362 (attrib_func
) VertexAttribI1bv
,
1363 (attrib_func
) VertexAttribI1ubv
,
1364 (attrib_func
) VertexAttribI1sv
,
1365 (attrib_func
) VertexAttribI1usv
,
1366 (attrib_func
) VertexAttribI1iv
,
1367 (attrib_func
) VertexAttribI1uiv
,
1368 NULL
, /* GL_FLOAT */
1369 NULL
/* GL_DOUBLE */
1373 (attrib_func
) VertexAttribI2bv
,
1374 (attrib_func
) VertexAttribI2ubv
,
1375 (attrib_func
) VertexAttribI2sv
,
1376 (attrib_func
) VertexAttribI2usv
,
1377 (attrib_func
) VertexAttribI2iv
,
1378 (attrib_func
) VertexAttribI2uiv
,
1379 NULL
, /* GL_FLOAT */
1380 NULL
/* GL_DOUBLE */
1384 (attrib_func
) VertexAttribI3bv
,
1385 (attrib_func
) VertexAttribI3ubv
,
1386 (attrib_func
) VertexAttribI3sv
,
1387 (attrib_func
) VertexAttribI3usv
,
1388 (attrib_func
) VertexAttribI3iv
,
1389 (attrib_func
) VertexAttribI3uiv
,
1390 NULL
, /* GL_FLOAT */
1391 NULL
/* GL_DOUBLE */
1395 (attrib_func
) VertexAttribI4bv
,
1396 (attrib_func
) VertexAttribI4ubv
,
1397 (attrib_func
) VertexAttribI4sv
,
1398 (attrib_func
) VertexAttribI4usv
,
1399 (attrib_func
) VertexAttribI4iv
,
1400 (attrib_func
) VertexAttribI4uiv
,
1401 NULL
, /* GL_FLOAT */
1402 NULL
/* GL_DOUBLE */
1409 _ae_create_context(struct gl_context
*ctx
)
1411 if (ctx
->aelt_context
)
1414 /* These _gloffset_* values may not be compile-time constants */
1415 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bv
;
1416 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubv
;
1417 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3sv
;
1418 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usv
;
1419 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3iv
;
1420 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uiv
;
1421 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1422 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dv
;
1424 FogCoordFuncs
[0] = -1;
1425 FogCoordFuncs
[1] = -1;
1426 FogCoordFuncs
[2] = -1;
1427 FogCoordFuncs
[3] = -1;
1428 FogCoordFuncs
[4] = -1;
1429 FogCoordFuncs
[5] = -1;
1430 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1431 FogCoordFuncs
[7] = _gloffset_FogCoorddv
;
1433 ctx
->aelt_context
= calloc(1, sizeof(AEcontext
));
1434 if (!ctx
->aelt_context
)
1437 AE_CONTEXT(ctx
)->NewState
= ~0;
1443 _ae_destroy_context(struct gl_context
*ctx
)
1445 if (AE_CONTEXT(ctx
)) {
1446 free(ctx
->aelt_context
);
1447 ctx
->aelt_context
= NULL
;
1453 * Check if the given vertex buffer object exists and is not mapped.
1454 * If so, add it to the list of buffers we must map before executing
1455 * an glArrayElement call.
1458 check_vbo(AEcontext
*actx
, struct gl_buffer_object
*vbo
)
1460 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1462 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1463 if (actx
->vbo
[i
] == vbo
)
1464 return; /* already in the list, we're done */
1465 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1466 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1472 * Make a list of per-vertex functions to call for each glArrayElement call.
1473 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1475 * Note: this may be called during display list construction.
1478 _ae_update_state(struct gl_context
*ctx
)
1480 AEcontext
*actx
= AE_CONTEXT(ctx
);
1481 AEarray
*aa
= actx
->arrays
; /* non-indexed arrays (ex: glNormal) */
1482 AEattrib
*at
= actx
->attribs
; /* indexed arrays (ex: glMultiTexCoord) */
1484 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1488 /* conventional vertex arrays */
1489 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
) {
1490 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1491 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1492 check_vbo(actx
, aa
->array
->BufferObj
);
1495 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
) {
1496 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1497 aa
->offset
= _gloffset_EdgeFlagv
;
1498 check_vbo(actx
, aa
->array
->BufferObj
);
1501 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
) {
1502 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1503 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1504 check_vbo(actx
, aa
->array
->BufferObj
);
1507 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
) {
1508 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1509 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1510 check_vbo(actx
, aa
->array
->BufferObj
);
1513 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
) {
1514 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1515 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1516 check_vbo(actx
, aa
->array
->BufferObj
);
1519 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
) {
1520 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
];
1521 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1522 check_vbo(actx
, aa
->array
->BufferObj
);
1525 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1526 struct gl_client_array
*attribArray
=
1527 &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1528 if (attribArray
->Enabled
) {
1529 /* NOTE: we use generic glVertexAttribNV functions here.
1530 * If we ever remove GL_NV_vertex_program this will have to change.
1532 at
->array
= attribArray
;
1533 ASSERT(!at
->array
->Normalized
);
1534 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1536 [TYPE_IDX(at
->array
->Type
)];
1537 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1538 check_vbo(actx
, at
->array
->BufferObj
);
1543 /* generic vertex attribute arrays */
1544 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1545 struct gl_client_array
*attribArray
=
1546 &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1547 if (attribArray
->Enabled
) {
1549 at
->array
= attribArray
;
1550 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1551 * function pointer here (for float arrays) since the pointer may
1552 * change from one execution of _ae_ArrayElement() to
1553 * the next. Doing so caused UT to break.
1555 if (at
->array
->Integer
)
1557 else if (at
->array
->Normalized
)
1562 at
->func
= AttribFuncsARB
[intOrNorm
]
1564 [TYPE_IDX(at
->array
->Type
)];
1567 check_vbo(actx
, at
->array
->BufferObj
);
1572 /* finally, vertex position */
1573 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
) {
1574 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1575 * issued as the last (provoking) attribute).
1577 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1578 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1579 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1580 check_vbo(actx
, aa
->array
->BufferObj
);
1583 else if (arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
) {
1584 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
];
1585 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1586 check_vbo(actx
, aa
->array
->BufferObj
);
1590 check_vbo(actx
, arrayObj
->ElementArrayBufferObj
);
1592 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1593 ASSERT(aa
- actx
->arrays
< 32);
1594 at
->func
= NULL
; /* terminate the list */
1595 aa
->offset
= -1; /* terminate the list */
1602 * Before replaying glArrayElements calls we need to map (for reading) any
1603 * VBOs referenced by the enabled vertex arrays.
1606 _ae_map_vbos(struct gl_context
*ctx
)
1608 AEcontext
*actx
= AE_CONTEXT(ctx
);
1611 if (actx
->mapped_vbos
)
1615 _ae_update_state(ctx
);
1617 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1618 ctx
->Driver
.MapBufferRange(ctx
, 0,
1624 actx
->mapped_vbos
= GL_TRUE
;
1632 _ae_unmap_vbos(struct gl_context
*ctx
)
1634 AEcontext
*actx
= AE_CONTEXT(ctx
);
1637 if (!actx
->mapped_vbos
)
1640 assert (!actx
->NewState
);
1642 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1643 ctx
->Driver
.UnmapBuffer(ctx
, actx
->vbo
[i
]);
1645 actx
->mapped_vbos
= GL_FALSE
;
1650 * Called via glArrayElement() and glDrawArrays().
1651 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1652 * for all enabled vertex arrays (for elt-th element).
1653 * Note: this may be called during display list construction.
1656 _ae_ArrayElement(GLint elt
)
1658 GET_CURRENT_CONTEXT(ctx
);
1659 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1662 const struct _glapi_table
* const disp
= GET_DISPATCH();
1665 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1666 * then we call PrimitiveRestartNV and return.
1668 if (ctx
->Array
.PrimitiveRestart
&& (elt
== ctx
->Array
.RestartIndex
)) {
1669 CALL_PrimitiveRestartNV((struct _glapi_table
*)disp
, ());
1673 if (actx
->NewState
) {
1674 assert(!actx
->mapped_vbos
);
1675 _ae_update_state(ctx
);
1678 /* Determine if we need to map/unmap VBOs */
1679 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1684 /* emit generic attribute elements */
1685 for (at
= actx
->attribs
; at
->func
; at
++) {
1687 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1688 + elt
* at
->array
->StrideB
;
1689 at
->func(at
->index
, src
);
1692 /* emit conventional arrays elements */
1693 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1695 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1696 + elt
* aa
->array
->StrideB
;
1697 CALL_by_offset(disp
, (array_func
), aa
->offset
, ((const void *) src
));
1701 _ae_unmap_vbos(ctx
);
1706 _ae_invalidate_state(struct gl_context
*ctx
, GLuint new_state
)
1708 AEcontext
*actx
= AE_CONTEXT(ctx
);
1710 /* Only interested in this subset of mesa state. Need to prune
1711 * this down as both tnl/ and the drivers can raise statechanges
1712 * for arcane reasons in the middle of seemingly atomic operations
1713 * like DrawElements, over which we'd like to keep a known set of
1714 * arrays and vbo's mapped.
1716 * Luckily, neither the drivers nor tnl muck with the state that
1719 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1721 assert(!actx
->mapped_vbos
);
1722 actx
->NewState
|= new_state
;
1728 _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1729 const GLvertexformat
*vfmt
)
1731 SET_ArrayElement(disp
, vfmt
->ArrayElement
);