2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
26 * This file implements the glArrayElement() function.
27 * It involves looking at the format/type of all the enabled vertex arrays
28 * and emitting a list of pointers to functions which set the per-vertex
29 * state for the element/index.
34 * Keith Whitwell <keithw@vmware.com>
39 #include "api_arrayelt.h"
40 #include "bufferobj.h"
45 #include "main/dispatch.h"
48 typedef void (GLAPIENTRY
*array_func
)( const void * );
51 const struct gl_array_attributes
*array
;
52 const struct gl_vertex_buffer_binding
*binding
;
56 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
59 const struct gl_array_attributes
*array
;
60 const struct gl_vertex_buffer_binding
*binding
;
67 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
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;
94 _ae_is_state_dirty(struct gl_context
*ctx
)
96 return AE_CONTEXT(ctx
)->dirty_state
;
103 static const int ColorFuncs
[2][NUM_TYPES
] = {
126 static const int VertexFuncs
[3][NUM_TYPES
] = {
159 static const int IndexFuncs
[NUM_TYPES
] = {
170 static const int NormalFuncs
[NUM_TYPES
] = {
181 /* Note: _gloffset_* for these may not be a compile-time constant. */
182 static int SecondaryColorFuncs
[NUM_TYPES
];
183 static int FogCoordFuncs
[NUM_TYPES
];
187 ** GL_NV_vertex_program
190 /* GL_BYTE attributes */
192 static void GLAPIENTRY
193 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
195 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
198 static void GLAPIENTRY
199 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
201 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
204 static void GLAPIENTRY
205 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
207 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
210 static void GLAPIENTRY
211 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
213 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
216 static void GLAPIENTRY
217 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
219 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
221 BYTE_TO_FLOAT(v
[2])));
224 static void GLAPIENTRY
225 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
227 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
230 static void GLAPIENTRY
231 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
233 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
236 BYTE_TO_FLOAT(v
[3])));
239 static void GLAPIENTRY
240 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
242 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
245 /* GL_UNSIGNED_BYTE attributes */
247 static void GLAPIENTRY
248 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
250 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
253 static void GLAPIENTRY
254 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
256 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
259 static void GLAPIENTRY
260 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
262 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
263 UBYTE_TO_FLOAT(v
[1])));
266 static void GLAPIENTRY
267 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
269 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
272 static void GLAPIENTRY
273 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
275 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
276 UBYTE_TO_FLOAT(v
[1]),
277 UBYTE_TO_FLOAT(v
[2])));
279 static void GLAPIENTRY
280 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
282 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
283 (GLfloat
)v
[1], (GLfloat
)v
[2]));
286 static void GLAPIENTRY
287 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
289 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
290 UBYTE_TO_FLOAT(v
[1]),
291 UBYTE_TO_FLOAT(v
[2]),
292 UBYTE_TO_FLOAT(v
[3])));
295 static void GLAPIENTRY
296 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
298 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
299 (GLfloat
)v
[1], (GLfloat
)v
[2],
303 /* GL_SHORT attributes */
305 static void GLAPIENTRY
306 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
308 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
311 static void GLAPIENTRY
312 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
314 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
317 static void GLAPIENTRY
318 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
320 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
321 SHORT_TO_FLOAT(v
[1])));
324 static void GLAPIENTRY
325 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
327 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
330 static void GLAPIENTRY
331 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
333 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
334 SHORT_TO_FLOAT(v
[1]),
335 SHORT_TO_FLOAT(v
[2])));
338 static void GLAPIENTRY
339 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
341 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
345 static void GLAPIENTRY
346 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
348 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
349 SHORT_TO_FLOAT(v
[1]),
350 SHORT_TO_FLOAT(v
[2]),
351 SHORT_TO_FLOAT(v
[3])));
354 static void GLAPIENTRY
355 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
357 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
358 (GLfloat
)v
[2], (GLfloat
)v
[3]));
361 /* GL_UNSIGNED_SHORT attributes */
363 static void GLAPIENTRY
364 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
366 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
369 static void GLAPIENTRY
370 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
372 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
375 static void GLAPIENTRY
376 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
378 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
379 USHORT_TO_FLOAT(v
[1])));
382 static void GLAPIENTRY
383 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
385 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
389 static void GLAPIENTRY
390 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
392 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
393 USHORT_TO_FLOAT(v
[1]),
394 USHORT_TO_FLOAT(v
[2])));
397 static void GLAPIENTRY
398 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
400 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
404 static void GLAPIENTRY
405 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
407 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
408 USHORT_TO_FLOAT(v
[1]),
409 USHORT_TO_FLOAT(v
[2]),
410 USHORT_TO_FLOAT(v
[3])));
413 static void GLAPIENTRY
414 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
416 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
417 (GLfloat
)v
[2], (GLfloat
)v
[3]));
420 /* GL_INT attributes */
422 static void GLAPIENTRY
423 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
425 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
428 static void GLAPIENTRY
429 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
431 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
434 static void GLAPIENTRY
435 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
437 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
438 INT_TO_FLOAT(v
[1])));
441 static void GLAPIENTRY
442 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
444 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
447 static void GLAPIENTRY
448 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
450 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
452 INT_TO_FLOAT(v
[2])));
455 static void GLAPIENTRY
456 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
458 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
462 static void GLAPIENTRY
463 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
465 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
468 INT_TO_FLOAT(v
[3])));
471 static void GLAPIENTRY
472 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
474 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
475 (GLfloat
)v
[2], (GLfloat
)v
[3]));
478 /* GL_UNSIGNED_INT attributes */
480 static void GLAPIENTRY
481 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
483 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
486 static void GLAPIENTRY
487 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
489 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
492 static void GLAPIENTRY
493 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
495 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
496 UINT_TO_FLOAT(v
[1])));
499 static void GLAPIENTRY
500 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
502 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
506 static void GLAPIENTRY
507 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
509 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
511 UINT_TO_FLOAT(v
[2])));
514 static void GLAPIENTRY
515 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
517 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
521 static void GLAPIENTRY
522 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
524 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
527 UINT_TO_FLOAT(v
[3])));
530 static void GLAPIENTRY
531 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
533 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
534 (GLfloat
)v
[2], (GLfloat
)v
[3]));
537 /* GL_FLOAT attributes */
539 static void GLAPIENTRY
540 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
542 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
545 static void GLAPIENTRY
546 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
548 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
551 static void GLAPIENTRY
552 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
554 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
557 static void GLAPIENTRY
558 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
560 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
563 /* GL_DOUBLE attributes */
565 static void GLAPIENTRY
566 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
568 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
571 static void GLAPIENTRY
572 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
574 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
577 static void GLAPIENTRY
578 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
580 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
583 static void GLAPIENTRY
584 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
586 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
591 * Array [size][type] of VertexAttrib functions
593 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
598 (attrib_func
) VertexAttrib1bvNV
,
599 (attrib_func
) VertexAttrib1ubvNV
,
600 (attrib_func
) VertexAttrib1svNV
,
601 (attrib_func
) VertexAttrib1usvNV
,
602 (attrib_func
) VertexAttrib1ivNV
,
603 (attrib_func
) VertexAttrib1uivNV
,
604 (attrib_func
) VertexAttrib1fvNV
,
605 (attrib_func
) VertexAttrib1dvNV
609 (attrib_func
) VertexAttrib2bvNV
,
610 (attrib_func
) VertexAttrib2ubvNV
,
611 (attrib_func
) VertexAttrib2svNV
,
612 (attrib_func
) VertexAttrib2usvNV
,
613 (attrib_func
) VertexAttrib2ivNV
,
614 (attrib_func
) VertexAttrib2uivNV
,
615 (attrib_func
) VertexAttrib2fvNV
,
616 (attrib_func
) VertexAttrib2dvNV
620 (attrib_func
) VertexAttrib3bvNV
,
621 (attrib_func
) VertexAttrib3ubvNV
,
622 (attrib_func
) VertexAttrib3svNV
,
623 (attrib_func
) VertexAttrib3usvNV
,
624 (attrib_func
) VertexAttrib3ivNV
,
625 (attrib_func
) VertexAttrib3uivNV
,
626 (attrib_func
) VertexAttrib3fvNV
,
627 (attrib_func
) VertexAttrib3dvNV
631 (attrib_func
) VertexAttrib4bvNV
,
632 (attrib_func
) VertexAttrib4ubvNV
,
633 (attrib_func
) VertexAttrib4svNV
,
634 (attrib_func
) VertexAttrib4usvNV
,
635 (attrib_func
) VertexAttrib4ivNV
,
636 (attrib_func
) VertexAttrib4uivNV
,
637 (attrib_func
) VertexAttrib4fvNV
,
638 (attrib_func
) VertexAttrib4dvNV
642 /* normalized (except for float/double) */
645 (attrib_func
) VertexAttrib1NbvNV
,
646 (attrib_func
) VertexAttrib1NubvNV
,
647 (attrib_func
) VertexAttrib1NsvNV
,
648 (attrib_func
) VertexAttrib1NusvNV
,
649 (attrib_func
) VertexAttrib1NivNV
,
650 (attrib_func
) VertexAttrib1NuivNV
,
651 (attrib_func
) VertexAttrib1fvNV
,
652 (attrib_func
) VertexAttrib1dvNV
656 (attrib_func
) VertexAttrib2NbvNV
,
657 (attrib_func
) VertexAttrib2NubvNV
,
658 (attrib_func
) VertexAttrib2NsvNV
,
659 (attrib_func
) VertexAttrib2NusvNV
,
660 (attrib_func
) VertexAttrib2NivNV
,
661 (attrib_func
) VertexAttrib2NuivNV
,
662 (attrib_func
) VertexAttrib2fvNV
,
663 (attrib_func
) VertexAttrib2dvNV
667 (attrib_func
) VertexAttrib3NbvNV
,
668 (attrib_func
) VertexAttrib3NubvNV
,
669 (attrib_func
) VertexAttrib3NsvNV
,
670 (attrib_func
) VertexAttrib3NusvNV
,
671 (attrib_func
) VertexAttrib3NivNV
,
672 (attrib_func
) VertexAttrib3NuivNV
,
673 (attrib_func
) VertexAttrib3fvNV
,
674 (attrib_func
) VertexAttrib3dvNV
678 (attrib_func
) VertexAttrib4NbvNV
,
679 (attrib_func
) VertexAttrib4NubvNV
,
680 (attrib_func
) VertexAttrib4NsvNV
,
681 (attrib_func
) VertexAttrib4NusvNV
,
682 (attrib_func
) VertexAttrib4NivNV
,
683 (attrib_func
) VertexAttrib4NuivNV
,
684 (attrib_func
) VertexAttrib4fvNV
,
685 (attrib_func
) VertexAttrib4dvNV
692 ** GL_ARB_vertex_program
695 /* GL_BYTE attributes */
697 static void GLAPIENTRY
698 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
700 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
703 static void GLAPIENTRY
704 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
706 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
709 static void GLAPIENTRY
710 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
712 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
715 static void GLAPIENTRY
716 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
718 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
721 static void GLAPIENTRY
722 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
724 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
726 BYTE_TO_FLOAT(v
[2])));
729 static void GLAPIENTRY
730 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
732 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
735 static void GLAPIENTRY
736 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
738 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
741 BYTE_TO_FLOAT(v
[3])));
744 static void GLAPIENTRY
745 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
747 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
750 /* GL_UNSIGNED_BYTE attributes */
752 static void GLAPIENTRY
753 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
755 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
758 static void GLAPIENTRY
759 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
761 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
764 static void GLAPIENTRY
765 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
767 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
768 UBYTE_TO_FLOAT(v
[0]),
769 UBYTE_TO_FLOAT(v
[1])));
772 static void GLAPIENTRY
773 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
775 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
776 (GLfloat
)v
[0], (GLfloat
)v
[1]));
779 static void GLAPIENTRY
780 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
782 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
783 UBYTE_TO_FLOAT(v
[0]),
784 UBYTE_TO_FLOAT(v
[1]),
785 UBYTE_TO_FLOAT(v
[2])));
787 static void GLAPIENTRY
788 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
790 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
796 static void GLAPIENTRY
797 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
799 CALL_VertexAttrib4fARB(GET_DISPATCH(),
801 UBYTE_TO_FLOAT(v
[0]),
802 UBYTE_TO_FLOAT(v
[1]),
803 UBYTE_TO_FLOAT(v
[2]),
804 UBYTE_TO_FLOAT(v
[3])));
807 static void GLAPIENTRY
808 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
810 CALL_VertexAttrib4fARB(GET_DISPATCH(),
812 (GLfloat
)v
[0], (GLfloat
)v
[1],
813 (GLfloat
)v
[2], (GLfloat
)v
[3]));
816 /* GL_SHORT attributes */
818 static void GLAPIENTRY
819 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
821 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
824 static void GLAPIENTRY
825 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
827 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
830 static void GLAPIENTRY
831 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
833 CALL_VertexAttrib2fARB(GET_DISPATCH(),
834 (index
, SHORT_TO_FLOAT(v
[0]),
835 SHORT_TO_FLOAT(v
[1])));
838 static void GLAPIENTRY
839 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
841 CALL_VertexAttrib2fARB(GET_DISPATCH(),
842 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
845 static void GLAPIENTRY
846 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
848 CALL_VertexAttrib3fARB(GET_DISPATCH(),
850 SHORT_TO_FLOAT(v
[0]),
851 SHORT_TO_FLOAT(v
[1]),
852 SHORT_TO_FLOAT(v
[2])));
855 static void GLAPIENTRY
856 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
858 CALL_VertexAttrib3fARB(GET_DISPATCH(),
860 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
863 static void GLAPIENTRY
864 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
866 CALL_VertexAttrib4fARB(GET_DISPATCH(),
868 SHORT_TO_FLOAT(v
[0]),
869 SHORT_TO_FLOAT(v
[1]),
870 SHORT_TO_FLOAT(v
[2]),
871 SHORT_TO_FLOAT(v
[3])));
874 static void GLAPIENTRY
875 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
877 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
878 (GLfloat
)v
[2], (GLfloat
)v
[3]));
881 /* GL_UNSIGNED_SHORT attributes */
883 static void GLAPIENTRY
884 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
886 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
889 static void GLAPIENTRY
890 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
892 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
895 static void GLAPIENTRY
896 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
898 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
899 USHORT_TO_FLOAT(v
[1])));
902 static void GLAPIENTRY
903 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
905 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
909 static void GLAPIENTRY
910 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
912 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
913 USHORT_TO_FLOAT(v
[1]),
914 USHORT_TO_FLOAT(v
[2])));
917 static void GLAPIENTRY
918 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
920 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
921 (GLfloat
)v
[1], (GLfloat
)v
[2]));
924 static void GLAPIENTRY
925 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
927 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
928 USHORT_TO_FLOAT(v
[1]),
929 USHORT_TO_FLOAT(v
[2]),
930 USHORT_TO_FLOAT(v
[3])));
933 static void GLAPIENTRY
934 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
936 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
939 /* GL_INT attributes */
941 static void GLAPIENTRY
942 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
944 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
947 static void GLAPIENTRY
948 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
950 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
953 static void GLAPIENTRY
954 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
956 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
957 INT_TO_FLOAT(v
[1])));
960 static void GLAPIENTRY
961 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
963 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
967 static void GLAPIENTRY
968 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
970 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
972 INT_TO_FLOAT(v
[2])));
975 static void GLAPIENTRY
976 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
978 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
979 (GLfloat
)v
[1], (GLfloat
)v
[2]));
982 static void GLAPIENTRY
983 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
985 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
988 INT_TO_FLOAT(v
[3])));
991 static void GLAPIENTRY
992 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
994 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
995 (GLfloat
)v
[2], (GLfloat
)v
[3]));
998 /* GL_UNSIGNED_INT attributes */
1000 static void GLAPIENTRY
1001 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
1003 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
1006 static void GLAPIENTRY
1007 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
1009 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
1012 static void GLAPIENTRY
1013 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
1015 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1016 UINT_TO_FLOAT(v
[1])));
1019 static void GLAPIENTRY
1020 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1022 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1026 static void GLAPIENTRY
1027 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1029 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1030 UINT_TO_FLOAT(v
[1]),
1031 UINT_TO_FLOAT(v
[2])));
1034 static void GLAPIENTRY
1035 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1037 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1038 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1041 static void GLAPIENTRY
1042 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1044 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1045 UINT_TO_FLOAT(v
[1]),
1046 UINT_TO_FLOAT(v
[2]),
1047 UINT_TO_FLOAT(v
[3])));
1050 static void GLAPIENTRY
1051 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1053 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1054 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1057 /* GL_FLOAT attributes */
1059 static void GLAPIENTRY
1060 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1062 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1065 static void GLAPIENTRY
1066 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1068 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1071 static void GLAPIENTRY
1072 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1074 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1077 static void GLAPIENTRY
1078 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1080 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1083 /* GL_DOUBLE attributes */
1085 static void GLAPIENTRY
1086 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1088 CALL_VertexAttrib1dv(GET_DISPATCH(), (index
, v
));
1091 static void GLAPIENTRY
1092 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1094 CALL_VertexAttrib2dv(GET_DISPATCH(), (index
, v
));
1097 static void GLAPIENTRY
1098 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1100 CALL_VertexAttrib3dv(GET_DISPATCH(), (index
, v
));
1103 static void GLAPIENTRY
1104 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1106 CALL_VertexAttrib4dv(GET_DISPATCH(), (index
, v
));
1111 * Integer-valued attributes
1113 static void GLAPIENTRY
1114 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1116 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1119 static void GLAPIENTRY
1120 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1122 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1125 static void GLAPIENTRY
1126 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1128 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1131 static void GLAPIENTRY
1132 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1134 CALL_VertexAttribI4bv(GET_DISPATCH(), (index
, v
));
1138 static void GLAPIENTRY
1139 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1141 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1144 static void GLAPIENTRY
1145 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1147 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1150 static void GLAPIENTRY
1151 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1153 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1156 static void GLAPIENTRY
1157 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1159 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index
, v
));
1164 static void GLAPIENTRY
1165 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1167 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1170 static void GLAPIENTRY
1171 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1173 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1176 static void GLAPIENTRY
1177 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1179 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1182 static void GLAPIENTRY
1183 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1185 CALL_VertexAttribI4sv(GET_DISPATCH(), (index
, v
));
1189 static void GLAPIENTRY
1190 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1192 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1195 static void GLAPIENTRY
1196 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1198 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1201 static void GLAPIENTRY
1202 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1204 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1207 static void GLAPIENTRY
1208 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1210 CALL_VertexAttribI4usv(GET_DISPATCH(), (index
, v
));
1215 static void GLAPIENTRY
1216 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1218 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1221 static void GLAPIENTRY
1222 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1224 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1227 static void GLAPIENTRY
1228 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1230 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1233 static void GLAPIENTRY
1234 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1236 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1240 static void GLAPIENTRY
1241 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1243 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1246 static void GLAPIENTRY
1247 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1249 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1252 static void GLAPIENTRY
1253 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1255 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1258 static void GLAPIENTRY
1259 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1261 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1264 /* GL_DOUBLE unconverted attributes */
1266 static void GLAPIENTRY
1267 VertexAttribL1dv(GLuint index
, const GLdouble
*v
)
1269 CALL_VertexAttribL1dv(GET_DISPATCH(), (index
, v
));
1272 static void GLAPIENTRY
1273 VertexAttribL2dv(GLuint index
, const GLdouble
*v
)
1275 CALL_VertexAttribL2dv(GET_DISPATCH(), (index
, v
));
1278 static void GLAPIENTRY
1279 VertexAttribL3dv(GLuint index
, const GLdouble
*v
)
1281 CALL_VertexAttribL3dv(GET_DISPATCH(), (index
, v
));
1284 static void GLAPIENTRY
1285 VertexAttribL4dv(GLuint index
, const GLdouble
*v
)
1287 CALL_VertexAttribL4dv(GET_DISPATCH(), (index
, v
));
1291 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1294 static const attrib_func AttribFuncsARB
[4][4][NUM_TYPES
] = {
1296 /* non-normalized */
1299 (attrib_func
) VertexAttrib1bvARB
,
1300 (attrib_func
) VertexAttrib1ubvARB
,
1301 (attrib_func
) VertexAttrib1svARB
,
1302 (attrib_func
) VertexAttrib1usvARB
,
1303 (attrib_func
) VertexAttrib1ivARB
,
1304 (attrib_func
) VertexAttrib1uivARB
,
1305 (attrib_func
) VertexAttrib1fvARB
,
1306 (attrib_func
) VertexAttrib1dvARB
1310 (attrib_func
) VertexAttrib2bvARB
,
1311 (attrib_func
) VertexAttrib2ubvARB
,
1312 (attrib_func
) VertexAttrib2svARB
,
1313 (attrib_func
) VertexAttrib2usvARB
,
1314 (attrib_func
) VertexAttrib2ivARB
,
1315 (attrib_func
) VertexAttrib2uivARB
,
1316 (attrib_func
) VertexAttrib2fvARB
,
1317 (attrib_func
) VertexAttrib2dvARB
1321 (attrib_func
) VertexAttrib3bvARB
,
1322 (attrib_func
) VertexAttrib3ubvARB
,
1323 (attrib_func
) VertexAttrib3svARB
,
1324 (attrib_func
) VertexAttrib3usvARB
,
1325 (attrib_func
) VertexAttrib3ivARB
,
1326 (attrib_func
) VertexAttrib3uivARB
,
1327 (attrib_func
) VertexAttrib3fvARB
,
1328 (attrib_func
) VertexAttrib3dvARB
1332 (attrib_func
) VertexAttrib4bvARB
,
1333 (attrib_func
) VertexAttrib4ubvARB
,
1334 (attrib_func
) VertexAttrib4svARB
,
1335 (attrib_func
) VertexAttrib4usvARB
,
1336 (attrib_func
) VertexAttrib4ivARB
,
1337 (attrib_func
) VertexAttrib4uivARB
,
1338 (attrib_func
) VertexAttrib4fvARB
,
1339 (attrib_func
) VertexAttrib4dvARB
1343 /* normalized (except for float/double) */
1346 (attrib_func
) VertexAttrib1NbvARB
,
1347 (attrib_func
) VertexAttrib1NubvARB
,
1348 (attrib_func
) VertexAttrib1NsvARB
,
1349 (attrib_func
) VertexAttrib1NusvARB
,
1350 (attrib_func
) VertexAttrib1NivARB
,
1351 (attrib_func
) VertexAttrib1NuivARB
,
1352 (attrib_func
) VertexAttrib1fvARB
,
1353 (attrib_func
) VertexAttrib1dvARB
1357 (attrib_func
) VertexAttrib2NbvARB
,
1358 (attrib_func
) VertexAttrib2NubvARB
,
1359 (attrib_func
) VertexAttrib2NsvARB
,
1360 (attrib_func
) VertexAttrib2NusvARB
,
1361 (attrib_func
) VertexAttrib2NivARB
,
1362 (attrib_func
) VertexAttrib2NuivARB
,
1363 (attrib_func
) VertexAttrib2fvARB
,
1364 (attrib_func
) VertexAttrib2dvARB
1368 (attrib_func
) VertexAttrib3NbvARB
,
1369 (attrib_func
) VertexAttrib3NubvARB
,
1370 (attrib_func
) VertexAttrib3NsvARB
,
1371 (attrib_func
) VertexAttrib3NusvARB
,
1372 (attrib_func
) VertexAttrib3NivARB
,
1373 (attrib_func
) VertexAttrib3NuivARB
,
1374 (attrib_func
) VertexAttrib3fvARB
,
1375 (attrib_func
) VertexAttrib3dvARB
1379 (attrib_func
) VertexAttrib4NbvARB
,
1380 (attrib_func
) VertexAttrib4NubvARB
,
1381 (attrib_func
) VertexAttrib4NsvARB
,
1382 (attrib_func
) VertexAttrib4NusvARB
,
1383 (attrib_func
) VertexAttrib4NivARB
,
1384 (attrib_func
) VertexAttrib4NuivARB
,
1385 (attrib_func
) VertexAttrib4fvARB
,
1386 (attrib_func
) VertexAttrib4dvARB
1391 /* integer-valued */
1394 (attrib_func
) VertexAttribI1bv
,
1395 (attrib_func
) VertexAttribI1ubv
,
1396 (attrib_func
) VertexAttribI1sv
,
1397 (attrib_func
) VertexAttribI1usv
,
1398 (attrib_func
) VertexAttribI1iv
,
1399 (attrib_func
) VertexAttribI1uiv
,
1400 NULL
, /* GL_FLOAT */
1401 NULL
/* GL_DOUBLE */
1405 (attrib_func
) VertexAttribI2bv
,
1406 (attrib_func
) VertexAttribI2ubv
,
1407 (attrib_func
) VertexAttribI2sv
,
1408 (attrib_func
) VertexAttribI2usv
,
1409 (attrib_func
) VertexAttribI2iv
,
1410 (attrib_func
) VertexAttribI2uiv
,
1411 NULL
, /* GL_FLOAT */
1412 NULL
/* GL_DOUBLE */
1416 (attrib_func
) VertexAttribI3bv
,
1417 (attrib_func
) VertexAttribI3ubv
,
1418 (attrib_func
) VertexAttribI3sv
,
1419 (attrib_func
) VertexAttribI3usv
,
1420 (attrib_func
) VertexAttribI3iv
,
1421 (attrib_func
) VertexAttribI3uiv
,
1422 NULL
, /* GL_FLOAT */
1423 NULL
/* GL_DOUBLE */
1427 (attrib_func
) VertexAttribI4bv
,
1428 (attrib_func
) VertexAttribI4ubv
,
1429 (attrib_func
) VertexAttribI4sv
,
1430 (attrib_func
) VertexAttribI4usv
,
1431 (attrib_func
) VertexAttribI4iv
,
1432 (attrib_func
) VertexAttribI4uiv
,
1433 NULL
, /* GL_FLOAT */
1434 NULL
/* GL_DOUBLE */
1448 (attrib_func
) VertexAttribL1dv
,
1459 (attrib_func
) VertexAttribL2dv
,
1470 (attrib_func
) VertexAttribL3dv
,
1481 (attrib_func
) VertexAttribL4dv
,
1489 _ae_create_context(struct gl_context
*ctx
)
1491 if (ctx
->aelt_context
)
1494 /* These _gloffset_* values may not be compile-time constants */
1495 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bv
;
1496 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubv
;
1497 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3sv
;
1498 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usv
;
1499 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3iv
;
1500 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uiv
;
1501 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1502 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dv
;
1504 FogCoordFuncs
[0] = -1;
1505 FogCoordFuncs
[1] = -1;
1506 FogCoordFuncs
[2] = -1;
1507 FogCoordFuncs
[3] = -1;
1508 FogCoordFuncs
[4] = -1;
1509 FogCoordFuncs
[5] = -1;
1510 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1511 FogCoordFuncs
[7] = _gloffset_FogCoorddv
;
1513 ctx
->aelt_context
= calloc(1, sizeof(AEcontext
));
1514 if (!ctx
->aelt_context
)
1517 AE_CONTEXT(ctx
)->dirty_state
= true;
1523 _ae_destroy_context(struct gl_context
*ctx
)
1525 if (AE_CONTEXT(ctx
)) {
1526 free(ctx
->aelt_context
);
1527 ctx
->aelt_context
= NULL
;
1533 * Make a list of per-vertex functions to call for each glArrayElement call.
1534 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1536 * Note: this may be called during display list construction.
1539 _ae_update_state(struct gl_context
*ctx
)
1541 AEcontext
*actx
= AE_CONTEXT(ctx
);
1542 AEarray
*aa
= actx
->arrays
; /* non-indexed arrays (ex: glNormal) */
1543 AEattrib
*at
= actx
->attribs
; /* indexed arrays (ex: glMultiTexCoord) */
1545 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1547 /* conventional vertex arrays */
1548 if (vao
->Enabled
& VERT_BIT_COLOR_INDEX
) {
1549 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1550 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1551 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1555 if (vao
->Enabled
& VERT_BIT_EDGEFLAG
) {
1556 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1557 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1558 aa
->offset
= _gloffset_EdgeFlagv
;
1562 if (vao
->Enabled
& VERT_BIT_NORMAL
) {
1563 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1564 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1565 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1569 if (vao
->Enabled
& VERT_BIT_COLOR0
) {
1570 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1571 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1572 aa
->offset
= ColorFuncs
[aa
->array
->Format
.Size
-3][TYPE_IDX(aa
->array
->Format
.Type
)];
1576 if (vao
->Enabled
& VERT_BIT_COLOR1
) {
1577 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1578 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1579 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1583 if (vao
->Enabled
& VERT_BIT_FOG
) {
1584 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_FOG
];
1585 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1586 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1590 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1591 if (vao
->Enabled
& VERT_BIT_TEX(i
)) {
1592 struct gl_array_attributes
*attribArray
=
1593 &vao
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1594 /* NOTE: we use generic glVertexAttribNV functions here.
1595 * If we ever remove GL_NV_vertex_program this will have to change.
1597 at
->array
= attribArray
;
1598 at
->binding
= &vao
->BufferBinding
[attribArray
->BufferBindingIndex
];
1599 assert(!at
->array
->Format
.Normalized
);
1600 at
->func
= AttribFuncsNV
[at
->array
->Format
.Normalized
]
1601 [at
->array
->Format
.Size
-1]
1602 [TYPE_IDX(at
->array
->Format
.Type
)];
1603 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1608 /* generic vertex attribute arrays */
1609 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1610 if (vao
->Enabled
& VERT_BIT_GENERIC(i
)) {
1611 struct gl_array_attributes
*attribArray
=
1612 &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1614 at
->array
= attribArray
;
1615 at
->binding
= &vao
->BufferBinding
[attribArray
->BufferBindingIndex
];
1616 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1617 * function pointer here (for float arrays) since the pointer may
1618 * change from one execution of _ae_ArrayElement() to
1619 * the next. Doing so caused UT to break.
1621 if (at
->array
->Format
.Doubles
)
1623 else if (at
->array
->Format
.Integer
)
1625 else if (at
->array
->Format
.Normalized
)
1630 at
->func
= AttribFuncsARB
[intOrNorm
]
1631 [at
->array
->Format
.Size
-1]
1632 [TYPE_IDX(at
->array
->Format
.Type
)];
1639 /* finally, vertex position */
1640 if (vao
->Enabled
& VERT_BIT_GENERIC0
) {
1641 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1642 * issued as the last (provoking) attribute).
1644 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1645 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1646 assert(aa
->array
->Format
.Size
>= 2); /* XXX fix someday? */
1647 aa
->offset
= VertexFuncs
[aa
->array
->Format
.Size
-2][TYPE_IDX(aa
->array
->Format
.Type
)];
1650 else if (vao
->Enabled
& VERT_BIT_POS
) {
1651 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_POS
];
1652 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1653 aa
->offset
= VertexFuncs
[aa
->array
->Format
.Size
-2][TYPE_IDX(aa
->array
->Format
.Type
)];
1657 assert(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1658 assert(aa
- actx
->arrays
< 32);
1659 at
->func
= NULL
; /* terminate the list */
1660 aa
->offset
= -1; /* terminate the list */
1662 actx
->dirty_state
= false;
1667 _mesa_array_element(struct gl_context
*ctx
,
1668 struct _glapi_table
*disp
, GLint elt
)
1670 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1672 if (actx
->dirty_state
)
1673 _ae_update_state(ctx
);
1675 /* emit generic attribute elements */
1676 for (const AEattrib
*at
= actx
->attribs
; at
->func
; at
++) {
1678 = ADD_POINTERS(at
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1679 _mesa_vertex_attrib_address(at
->array
, at
->binding
))
1680 + elt
* at
->binding
->Stride
;
1681 at
->func(at
->index
, src
);
1684 /* emit conventional arrays elements */
1685 for (const AEarray
*aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1687 = ADD_POINTERS(aa
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1688 _mesa_vertex_attrib_address(aa
->array
, aa
->binding
))
1689 + elt
* aa
->binding
->Stride
;
1690 CALL_by_offset(disp
, (array_func
), aa
->offset
, ((const void *) src
));
1696 * Called via glArrayElement() and glDrawArrays().
1697 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1698 * for all enabled vertex arrays (for elt-th element).
1699 * Note: this may be called during display list construction.
1702 _ae_ArrayElement(GLint elt
)
1704 GET_CURRENT_CONTEXT(ctx
);
1705 const struct _glapi_table
* const disp
= GET_DISPATCH();
1706 struct gl_vertex_array_object
*vao
;
1708 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1709 * then we call PrimitiveRestartNV and return.
1711 if (ctx
->Array
.PrimitiveRestart
&& (elt
== ctx
->Array
.RestartIndex
)) {
1712 CALL_PrimitiveRestartNV((struct _glapi_table
*)disp
, ());
1716 vao
= ctx
->Array
.VAO
;
1717 _mesa_vao_map_arrays(ctx
, vao
, GL_MAP_READ_BIT
);
1719 _mesa_array_element(ctx
, (struct _glapi_table
*)disp
, elt
);
1721 _mesa_vao_unmap_arrays(ctx
, vao
);
1726 _ae_invalidate_state(struct gl_context
*ctx
)
1728 AEcontext
*actx
= AE_CONTEXT(ctx
);
1730 /* Only interested in this subset of mesa state. Need to prune
1731 * this down as both tnl/ and the drivers can raise statechanges
1732 * for arcane reasons in the middle of seemingly atomic operations
1733 * like DrawElements, over which we'd like to keep a known set of
1734 * arrays and vbo's mapped.
1736 * Luckily, neither the drivers nor tnl muck with the state that
1739 assert(ctx
->NewState
& _NEW_ARRAY
);
1741 actx
->dirty_state
= true;
1746 _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1747 const GLvertexformat
*vfmt
)
1749 SET_ArrayElement(disp
, vfmt
->ArrayElement
);