2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * This file implements the glArrayElement() function.
27 * It involves looking at the format/type of all the enabled vertex arrays
28 * and emitting a list of pointers to functions which set the per-vertex
29 * state for the element/index.
34 * Keith Whitwell <keith@tungstengraphics.com>
38 #include "api_arrayelt.h"
39 #include "bufferobj.h"
43 #include "mfeatures.h"
45 #include "main/dispatch.h"
47 typedef void (GLAPIENTRY
*array_func
)( const void * );
50 const struct gl_client_array
*array
;
54 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
57 const struct gl_client_array
*array
;
64 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
67 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
69 GLboolean mapped_vbos
;
73 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
77 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
78 * in the range [0, 7]. Luckily these type tokens are sequentially
79 * numbered in gl.h, except for GL_DOUBLE.
81 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
89 static const int ColorFuncs
[2][NUM_TYPES
] = {
112 static const int VertexFuncs
[3][NUM_TYPES
] = {
145 static const int IndexFuncs
[NUM_TYPES
] = {
156 static const int NormalFuncs
[NUM_TYPES
] = {
167 /* Note: _gloffset_* for these may not be a compile-time constant. */
168 static int SecondaryColorFuncs
[NUM_TYPES
];
169 static int FogCoordFuncs
[NUM_TYPES
];
173 ** GL_NV_vertex_program
176 /* GL_BYTE attributes */
178 static void GLAPIENTRY
179 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
181 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
184 static void GLAPIENTRY
185 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
187 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
190 static void GLAPIENTRY
191 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
193 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
196 static void GLAPIENTRY
197 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
199 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
202 static void GLAPIENTRY
203 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
205 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
207 BYTE_TO_FLOAT(v
[2])));
210 static void GLAPIENTRY
211 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
213 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
216 static void GLAPIENTRY
217 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
219 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
222 BYTE_TO_FLOAT(v
[3])));
225 static void GLAPIENTRY
226 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
228 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
231 /* GL_UNSIGNED_BYTE attributes */
233 static void GLAPIENTRY
234 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
236 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
239 static void GLAPIENTRY
240 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
242 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
245 static void GLAPIENTRY
246 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
248 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
249 UBYTE_TO_FLOAT(v
[1])));
252 static void GLAPIENTRY
253 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
255 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
258 static void GLAPIENTRY
259 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
261 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
262 UBYTE_TO_FLOAT(v
[1]),
263 UBYTE_TO_FLOAT(v
[2])));
265 static void GLAPIENTRY
266 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
268 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
269 (GLfloat
)v
[1], (GLfloat
)v
[2]));
272 static void GLAPIENTRY
273 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
275 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
276 UBYTE_TO_FLOAT(v
[1]),
277 UBYTE_TO_FLOAT(v
[2]),
278 UBYTE_TO_FLOAT(v
[3])));
281 static void GLAPIENTRY
282 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
284 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
285 (GLfloat
)v
[1], (GLfloat
)v
[2],
289 /* GL_SHORT attributes */
291 static void GLAPIENTRY
292 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
294 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
297 static void GLAPIENTRY
298 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
300 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
303 static void GLAPIENTRY
304 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
306 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
307 SHORT_TO_FLOAT(v
[1])));
310 static void GLAPIENTRY
311 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
313 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
316 static void GLAPIENTRY
317 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
319 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
320 SHORT_TO_FLOAT(v
[1]),
321 SHORT_TO_FLOAT(v
[2])));
324 static void GLAPIENTRY
325 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
327 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
331 static void GLAPIENTRY
332 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
334 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
335 SHORT_TO_FLOAT(v
[1]),
336 SHORT_TO_FLOAT(v
[2]),
337 SHORT_TO_FLOAT(v
[3])));
340 static void GLAPIENTRY
341 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
343 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
344 (GLfloat
)v
[2], (GLfloat
)v
[3]));
347 /* GL_UNSIGNED_SHORT attributes */
349 static void GLAPIENTRY
350 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
352 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
355 static void GLAPIENTRY
356 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
358 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
361 static void GLAPIENTRY
362 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
364 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
365 USHORT_TO_FLOAT(v
[1])));
368 static void GLAPIENTRY
369 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
371 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
375 static void GLAPIENTRY
376 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
378 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
379 USHORT_TO_FLOAT(v
[1]),
380 USHORT_TO_FLOAT(v
[2])));
383 static void GLAPIENTRY
384 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
386 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
390 static void GLAPIENTRY
391 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
393 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
394 USHORT_TO_FLOAT(v
[1]),
395 USHORT_TO_FLOAT(v
[2]),
396 USHORT_TO_FLOAT(v
[3])));
399 static void GLAPIENTRY
400 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
402 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
403 (GLfloat
)v
[2], (GLfloat
)v
[3]));
406 /* GL_INT attributes */
408 static void GLAPIENTRY
409 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
411 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
414 static void GLAPIENTRY
415 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
417 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
420 static void GLAPIENTRY
421 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
423 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
424 INT_TO_FLOAT(v
[1])));
427 static void GLAPIENTRY
428 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
430 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
433 static void GLAPIENTRY
434 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
436 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
438 INT_TO_FLOAT(v
[2])));
441 static void GLAPIENTRY
442 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
444 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
448 static void GLAPIENTRY
449 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
451 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
454 INT_TO_FLOAT(v
[3])));
457 static void GLAPIENTRY
458 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
460 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
461 (GLfloat
)v
[2], (GLfloat
)v
[3]));
464 /* GL_UNSIGNED_INT attributes */
466 static void GLAPIENTRY
467 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
469 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
472 static void GLAPIENTRY
473 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
475 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
478 static void GLAPIENTRY
479 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
481 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
482 UINT_TO_FLOAT(v
[1])));
485 static void GLAPIENTRY
486 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
488 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
492 static void GLAPIENTRY
493 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
495 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
497 UINT_TO_FLOAT(v
[2])));
500 static void GLAPIENTRY
501 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
503 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
507 static void GLAPIENTRY
508 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
510 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
513 UINT_TO_FLOAT(v
[3])));
516 static void GLAPIENTRY
517 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
519 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
520 (GLfloat
)v
[2], (GLfloat
)v
[3]));
523 /* GL_FLOAT attributes */
525 static void GLAPIENTRY
526 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
528 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
531 static void GLAPIENTRY
532 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
534 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
537 static void GLAPIENTRY
538 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
540 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
543 static void GLAPIENTRY
544 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
546 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
549 /* GL_DOUBLE attributes */
551 static void GLAPIENTRY
552 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
554 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
557 static void GLAPIENTRY
558 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
560 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
563 static void GLAPIENTRY
564 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
566 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
569 static void GLAPIENTRY
570 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
572 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
577 * Array [size][type] of VertexAttrib functions
579 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
584 (attrib_func
) VertexAttrib1bvNV
,
585 (attrib_func
) VertexAttrib1ubvNV
,
586 (attrib_func
) VertexAttrib1svNV
,
587 (attrib_func
) VertexAttrib1usvNV
,
588 (attrib_func
) VertexAttrib1ivNV
,
589 (attrib_func
) VertexAttrib1uivNV
,
590 (attrib_func
) VertexAttrib1fvNV
,
591 (attrib_func
) VertexAttrib1dvNV
595 (attrib_func
) VertexAttrib2bvNV
,
596 (attrib_func
) VertexAttrib2ubvNV
,
597 (attrib_func
) VertexAttrib2svNV
,
598 (attrib_func
) VertexAttrib2usvNV
,
599 (attrib_func
) VertexAttrib2ivNV
,
600 (attrib_func
) VertexAttrib2uivNV
,
601 (attrib_func
) VertexAttrib2fvNV
,
602 (attrib_func
) VertexAttrib2dvNV
606 (attrib_func
) VertexAttrib3bvNV
,
607 (attrib_func
) VertexAttrib3ubvNV
,
608 (attrib_func
) VertexAttrib3svNV
,
609 (attrib_func
) VertexAttrib3usvNV
,
610 (attrib_func
) VertexAttrib3ivNV
,
611 (attrib_func
) VertexAttrib3uivNV
,
612 (attrib_func
) VertexAttrib3fvNV
,
613 (attrib_func
) VertexAttrib3dvNV
617 (attrib_func
) VertexAttrib4bvNV
,
618 (attrib_func
) VertexAttrib4ubvNV
,
619 (attrib_func
) VertexAttrib4svNV
,
620 (attrib_func
) VertexAttrib4usvNV
,
621 (attrib_func
) VertexAttrib4ivNV
,
622 (attrib_func
) VertexAttrib4uivNV
,
623 (attrib_func
) VertexAttrib4fvNV
,
624 (attrib_func
) VertexAttrib4dvNV
628 /* normalized (except for float/double) */
631 (attrib_func
) VertexAttrib1NbvNV
,
632 (attrib_func
) VertexAttrib1NubvNV
,
633 (attrib_func
) VertexAttrib1NsvNV
,
634 (attrib_func
) VertexAttrib1NusvNV
,
635 (attrib_func
) VertexAttrib1NivNV
,
636 (attrib_func
) VertexAttrib1NuivNV
,
637 (attrib_func
) VertexAttrib1fvNV
,
638 (attrib_func
) VertexAttrib1dvNV
642 (attrib_func
) VertexAttrib2NbvNV
,
643 (attrib_func
) VertexAttrib2NubvNV
,
644 (attrib_func
) VertexAttrib2NsvNV
,
645 (attrib_func
) VertexAttrib2NusvNV
,
646 (attrib_func
) VertexAttrib2NivNV
,
647 (attrib_func
) VertexAttrib2NuivNV
,
648 (attrib_func
) VertexAttrib2fvNV
,
649 (attrib_func
) VertexAttrib2dvNV
653 (attrib_func
) VertexAttrib3NbvNV
,
654 (attrib_func
) VertexAttrib3NubvNV
,
655 (attrib_func
) VertexAttrib3NsvNV
,
656 (attrib_func
) VertexAttrib3NusvNV
,
657 (attrib_func
) VertexAttrib3NivNV
,
658 (attrib_func
) VertexAttrib3NuivNV
,
659 (attrib_func
) VertexAttrib3fvNV
,
660 (attrib_func
) VertexAttrib3dvNV
664 (attrib_func
) VertexAttrib4NbvNV
,
665 (attrib_func
) VertexAttrib4NubvNV
,
666 (attrib_func
) VertexAttrib4NsvNV
,
667 (attrib_func
) VertexAttrib4NusvNV
,
668 (attrib_func
) VertexAttrib4NivNV
,
669 (attrib_func
) VertexAttrib4NuivNV
,
670 (attrib_func
) VertexAttrib4fvNV
,
671 (attrib_func
) VertexAttrib4dvNV
678 ** GL_ARB_vertex_program
681 /* GL_BYTE attributes */
683 static void GLAPIENTRY
684 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
686 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
689 static void GLAPIENTRY
690 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
692 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
695 static void GLAPIENTRY
696 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
698 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
701 static void GLAPIENTRY
702 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
704 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
707 static void GLAPIENTRY
708 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
710 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
712 BYTE_TO_FLOAT(v
[2])));
715 static void GLAPIENTRY
716 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
718 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
721 static void GLAPIENTRY
722 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
724 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
727 BYTE_TO_FLOAT(v
[3])));
730 static void GLAPIENTRY
731 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
733 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
736 /* GL_UNSIGNED_BYTE attributes */
738 static void GLAPIENTRY
739 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
741 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
744 static void GLAPIENTRY
745 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
747 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
750 static void GLAPIENTRY
751 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
753 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
754 UBYTE_TO_FLOAT(v
[0]),
755 UBYTE_TO_FLOAT(v
[1])));
758 static void GLAPIENTRY
759 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
761 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
762 (GLfloat
)v
[0], (GLfloat
)v
[1]));
765 static void GLAPIENTRY
766 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
768 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
769 UBYTE_TO_FLOAT(v
[0]),
770 UBYTE_TO_FLOAT(v
[1]),
771 UBYTE_TO_FLOAT(v
[2])));
773 static void GLAPIENTRY
774 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
776 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
782 static void GLAPIENTRY
783 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
785 CALL_VertexAttrib4fARB(GET_DISPATCH(),
787 UBYTE_TO_FLOAT(v
[0]),
788 UBYTE_TO_FLOAT(v
[1]),
789 UBYTE_TO_FLOAT(v
[2]),
790 UBYTE_TO_FLOAT(v
[3])));
793 static void GLAPIENTRY
794 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
796 CALL_VertexAttrib4fARB(GET_DISPATCH(),
798 (GLfloat
)v
[0], (GLfloat
)v
[1],
799 (GLfloat
)v
[2], (GLfloat
)v
[3]));
802 /* GL_SHORT attributes */
804 static void GLAPIENTRY
805 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
807 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
810 static void GLAPIENTRY
811 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
813 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
816 static void GLAPIENTRY
817 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
819 CALL_VertexAttrib2fARB(GET_DISPATCH(),
820 (index
, SHORT_TO_FLOAT(v
[0]),
821 SHORT_TO_FLOAT(v
[1])));
824 static void GLAPIENTRY
825 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
827 CALL_VertexAttrib2fARB(GET_DISPATCH(),
828 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
831 static void GLAPIENTRY
832 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
834 CALL_VertexAttrib3fARB(GET_DISPATCH(),
836 SHORT_TO_FLOAT(v
[0]),
837 SHORT_TO_FLOAT(v
[1]),
838 SHORT_TO_FLOAT(v
[2])));
841 static void GLAPIENTRY
842 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
844 CALL_VertexAttrib3fARB(GET_DISPATCH(),
846 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
849 static void GLAPIENTRY
850 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
852 CALL_VertexAttrib4fARB(GET_DISPATCH(),
854 SHORT_TO_FLOAT(v
[0]),
855 SHORT_TO_FLOAT(v
[1]),
856 SHORT_TO_FLOAT(v
[2]),
857 SHORT_TO_FLOAT(v
[3])));
860 static void GLAPIENTRY
861 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
863 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
864 (GLfloat
)v
[2], (GLfloat
)v
[3]));
867 /* GL_UNSIGNED_SHORT attributes */
869 static void GLAPIENTRY
870 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
872 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
875 static void GLAPIENTRY
876 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
878 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
881 static void GLAPIENTRY
882 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
884 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
885 USHORT_TO_FLOAT(v
[1])));
888 static void GLAPIENTRY
889 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
891 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
895 static void GLAPIENTRY
896 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
898 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
899 USHORT_TO_FLOAT(v
[1]),
900 USHORT_TO_FLOAT(v
[2])));
903 static void GLAPIENTRY
904 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
906 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
907 (GLfloat
)v
[1], (GLfloat
)v
[2]));
910 static void GLAPIENTRY
911 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
913 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
914 USHORT_TO_FLOAT(v
[1]),
915 USHORT_TO_FLOAT(v
[2]),
916 USHORT_TO_FLOAT(v
[3])));
919 static void GLAPIENTRY
920 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
922 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
925 /* GL_INT attributes */
927 static void GLAPIENTRY
928 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
930 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
933 static void GLAPIENTRY
934 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
936 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
939 static void GLAPIENTRY
940 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
942 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
943 INT_TO_FLOAT(v
[1])));
946 static void GLAPIENTRY
947 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
949 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
953 static void GLAPIENTRY
954 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
956 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
958 INT_TO_FLOAT(v
[2])));
961 static void GLAPIENTRY
962 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
964 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
965 (GLfloat
)v
[1], (GLfloat
)v
[2]));
968 static void GLAPIENTRY
969 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
971 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
974 INT_TO_FLOAT(v
[3])));
977 static void GLAPIENTRY
978 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
980 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
981 (GLfloat
)v
[2], (GLfloat
)v
[3]));
984 /* GL_UNSIGNED_INT attributes */
986 static void GLAPIENTRY
987 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
989 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
992 static void GLAPIENTRY
993 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
995 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
998 static void GLAPIENTRY
999 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
1001 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1002 UINT_TO_FLOAT(v
[1])));
1005 static void GLAPIENTRY
1006 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1008 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1012 static void GLAPIENTRY
1013 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1015 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1016 UINT_TO_FLOAT(v
[1]),
1017 UINT_TO_FLOAT(v
[2])));
1020 static void GLAPIENTRY
1021 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1023 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1024 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1027 static void GLAPIENTRY
1028 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1030 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1031 UINT_TO_FLOAT(v
[1]),
1032 UINT_TO_FLOAT(v
[2]),
1033 UINT_TO_FLOAT(v
[3])));
1036 static void GLAPIENTRY
1037 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1039 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1040 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1043 /* GL_FLOAT attributes */
1045 static void GLAPIENTRY
1046 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1048 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1051 static void GLAPIENTRY
1052 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1054 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1057 static void GLAPIENTRY
1058 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1060 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1063 static void GLAPIENTRY
1064 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1066 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1069 /* GL_DOUBLE attributes */
1071 static void GLAPIENTRY
1072 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1074 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
1077 static void GLAPIENTRY
1078 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1080 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
1083 static void GLAPIENTRY
1084 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1086 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
1089 static void GLAPIENTRY
1090 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1092 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
1097 * Integer-valued attributes
1099 static void GLAPIENTRY
1100 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1102 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1105 static void GLAPIENTRY
1106 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1108 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1111 static void GLAPIENTRY
1112 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1114 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1117 static void GLAPIENTRY
1118 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1120 CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index
, v
));
1124 static void GLAPIENTRY
1125 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1127 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1130 static void GLAPIENTRY
1131 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1133 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1136 static void GLAPIENTRY
1137 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1139 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1142 static void GLAPIENTRY
1143 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1145 CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index
, v
));
1150 static void GLAPIENTRY
1151 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1153 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1156 static void GLAPIENTRY
1157 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1159 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1162 static void GLAPIENTRY
1163 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1165 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1168 static void GLAPIENTRY
1169 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1171 CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index
, v
));
1175 static void GLAPIENTRY
1176 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1178 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1181 static void GLAPIENTRY
1182 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1184 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1187 static void GLAPIENTRY
1188 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1190 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1193 static void GLAPIENTRY
1194 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1196 CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index
, v
));
1201 static void GLAPIENTRY
1202 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1204 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1207 static void GLAPIENTRY
1208 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1210 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1213 static void GLAPIENTRY
1214 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1216 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1219 static void GLAPIENTRY
1220 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1222 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1226 static void GLAPIENTRY
1227 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1229 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1232 static void GLAPIENTRY
1233 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1235 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1238 static void GLAPIENTRY
1239 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1241 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1244 static void GLAPIENTRY
1245 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1247 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1254 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1257 static attrib_func AttribFuncsARB
[3][4][NUM_TYPES
] = {
1259 /* non-normalized */
1262 (attrib_func
) VertexAttrib1bvARB
,
1263 (attrib_func
) VertexAttrib1ubvARB
,
1264 (attrib_func
) VertexAttrib1svARB
,
1265 (attrib_func
) VertexAttrib1usvARB
,
1266 (attrib_func
) VertexAttrib1ivARB
,
1267 (attrib_func
) VertexAttrib1uivARB
,
1268 (attrib_func
) VertexAttrib1fvARB
,
1269 (attrib_func
) VertexAttrib1dvARB
1273 (attrib_func
) VertexAttrib2bvARB
,
1274 (attrib_func
) VertexAttrib2ubvARB
,
1275 (attrib_func
) VertexAttrib2svARB
,
1276 (attrib_func
) VertexAttrib2usvARB
,
1277 (attrib_func
) VertexAttrib2ivARB
,
1278 (attrib_func
) VertexAttrib2uivARB
,
1279 (attrib_func
) VertexAttrib2fvARB
,
1280 (attrib_func
) VertexAttrib2dvARB
1284 (attrib_func
) VertexAttrib3bvARB
,
1285 (attrib_func
) VertexAttrib3ubvARB
,
1286 (attrib_func
) VertexAttrib3svARB
,
1287 (attrib_func
) VertexAttrib3usvARB
,
1288 (attrib_func
) VertexAttrib3ivARB
,
1289 (attrib_func
) VertexAttrib3uivARB
,
1290 (attrib_func
) VertexAttrib3fvARB
,
1291 (attrib_func
) VertexAttrib3dvARB
1295 (attrib_func
) VertexAttrib4bvARB
,
1296 (attrib_func
) VertexAttrib4ubvARB
,
1297 (attrib_func
) VertexAttrib4svARB
,
1298 (attrib_func
) VertexAttrib4usvARB
,
1299 (attrib_func
) VertexAttrib4ivARB
,
1300 (attrib_func
) VertexAttrib4uivARB
,
1301 (attrib_func
) VertexAttrib4fvARB
,
1302 (attrib_func
) VertexAttrib4dvARB
1306 /* normalized (except for float/double) */
1309 (attrib_func
) VertexAttrib1NbvARB
,
1310 (attrib_func
) VertexAttrib1NubvARB
,
1311 (attrib_func
) VertexAttrib1NsvARB
,
1312 (attrib_func
) VertexAttrib1NusvARB
,
1313 (attrib_func
) VertexAttrib1NivARB
,
1314 (attrib_func
) VertexAttrib1NuivARB
,
1315 (attrib_func
) VertexAttrib1fvARB
,
1316 (attrib_func
) VertexAttrib1dvARB
1320 (attrib_func
) VertexAttrib2NbvARB
,
1321 (attrib_func
) VertexAttrib2NubvARB
,
1322 (attrib_func
) VertexAttrib2NsvARB
,
1323 (attrib_func
) VertexAttrib2NusvARB
,
1324 (attrib_func
) VertexAttrib2NivARB
,
1325 (attrib_func
) VertexAttrib2NuivARB
,
1326 (attrib_func
) VertexAttrib2fvARB
,
1327 (attrib_func
) VertexAttrib2dvARB
1331 (attrib_func
) VertexAttrib3NbvARB
,
1332 (attrib_func
) VertexAttrib3NubvARB
,
1333 (attrib_func
) VertexAttrib3NsvARB
,
1334 (attrib_func
) VertexAttrib3NusvARB
,
1335 (attrib_func
) VertexAttrib3NivARB
,
1336 (attrib_func
) VertexAttrib3NuivARB
,
1337 (attrib_func
) VertexAttrib3fvARB
,
1338 (attrib_func
) VertexAttrib3dvARB
1342 (attrib_func
) VertexAttrib4NbvARB
,
1343 (attrib_func
) VertexAttrib4NubvARB
,
1344 (attrib_func
) VertexAttrib4NsvARB
,
1345 (attrib_func
) VertexAttrib4NusvARB
,
1346 (attrib_func
) VertexAttrib4NivARB
,
1347 (attrib_func
) VertexAttrib4NuivARB
,
1348 (attrib_func
) VertexAttrib4fvARB
,
1349 (attrib_func
) VertexAttrib4dvARB
1354 /* integer-valued */
1357 (attrib_func
) VertexAttribI1bv
,
1358 (attrib_func
) VertexAttribI1ubv
,
1359 (attrib_func
) VertexAttribI1sv
,
1360 (attrib_func
) VertexAttribI1usv
,
1361 (attrib_func
) VertexAttribI1iv
,
1362 (attrib_func
) VertexAttribI1uiv
,
1363 NULL
, /* GL_FLOAT */
1364 NULL
/* GL_DOUBLE */
1368 (attrib_func
) VertexAttribI2bv
,
1369 (attrib_func
) VertexAttribI2ubv
,
1370 (attrib_func
) VertexAttribI2sv
,
1371 (attrib_func
) VertexAttribI2usv
,
1372 (attrib_func
) VertexAttribI2iv
,
1373 (attrib_func
) VertexAttribI2uiv
,
1374 NULL
, /* GL_FLOAT */
1375 NULL
/* GL_DOUBLE */
1379 (attrib_func
) VertexAttribI3bv
,
1380 (attrib_func
) VertexAttribI3ubv
,
1381 (attrib_func
) VertexAttribI3sv
,
1382 (attrib_func
) VertexAttribI3usv
,
1383 (attrib_func
) VertexAttribI3iv
,
1384 (attrib_func
) VertexAttribI3uiv
,
1385 NULL
, /* GL_FLOAT */
1386 NULL
/* GL_DOUBLE */
1390 (attrib_func
) VertexAttribI4bv
,
1391 (attrib_func
) VertexAttribI4ubv
,
1392 (attrib_func
) VertexAttribI4sv
,
1393 (attrib_func
) VertexAttribI4usv
,
1394 (attrib_func
) VertexAttribI4iv
,
1395 (attrib_func
) VertexAttribI4uiv
,
1396 NULL
, /* GL_FLOAT */
1397 NULL
/* GL_DOUBLE */
1402 /**********************************************************************/
1405 GLboolean
_ae_create_context( struct gl_context
*ctx
)
1407 if (ctx
->aelt_context
)
1410 /* These _gloffset_* values may not be compile-time constants */
1411 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1412 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1413 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1414 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1415 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1416 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1417 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1418 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1420 FogCoordFuncs
[0] = -1;
1421 FogCoordFuncs
[1] = -1;
1422 FogCoordFuncs
[2] = -1;
1423 FogCoordFuncs
[3] = -1;
1424 FogCoordFuncs
[4] = -1;
1425 FogCoordFuncs
[5] = -1;
1426 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1427 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1429 ctx
->aelt_context
= CALLOC( sizeof(AEcontext
) );
1430 if (!ctx
->aelt_context
)
1433 AE_CONTEXT(ctx
)->NewState
= ~0;
1438 void _ae_destroy_context( struct gl_context
*ctx
)
1440 if ( AE_CONTEXT( ctx
) ) {
1441 FREE( ctx
->aelt_context
);
1442 ctx
->aelt_context
= NULL
;
1446 static void check_vbo( AEcontext
*actx
,
1447 struct gl_buffer_object
*vbo
)
1449 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1451 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1452 if (actx
->vbo
[i
] == vbo
)
1454 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1455 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1461 * Make a list of per-vertex functions to call for each glArrayElement call.
1462 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1464 * Note: this may be called during display list construction.
1466 static void _ae_update_state( struct gl_context
*ctx
)
1468 AEcontext
*actx
= AE_CONTEXT(ctx
);
1469 AEarray
*aa
= actx
->arrays
;
1470 AEattrib
*at
= actx
->attribs
;
1472 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1476 /* conventional vertex arrays */
1477 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
) {
1478 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1479 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1480 check_vbo(actx
, aa
->array
->BufferObj
);
1483 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
) {
1484 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1485 aa
->offset
= _gloffset_EdgeFlagv
;
1486 check_vbo(actx
, aa
->array
->BufferObj
);
1489 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
) {
1490 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1491 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1492 check_vbo(actx
, aa
->array
->BufferObj
);
1495 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
) {
1496 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1497 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1498 check_vbo(actx
, aa
->array
->BufferObj
);
1501 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
) {
1502 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1503 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1504 check_vbo(actx
, aa
->array
->BufferObj
);
1507 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
) {
1508 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
];
1509 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1510 check_vbo(actx
, aa
->array
->BufferObj
);
1513 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1514 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1515 if (attribArray
->Enabled
) {
1516 /* NOTE: we use generic glVertexAttribNV functions here.
1517 * If we ever remove GL_NV_vertex_program this will have to change.
1519 at
->array
= attribArray
;
1520 ASSERT(!at
->array
->Normalized
);
1521 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1523 [TYPE_IDX(at
->array
->Type
)];
1524 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1525 check_vbo(actx
, at
->array
->BufferObj
);
1530 /* generic vertex attribute arrays */
1531 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1532 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1533 if (attribArray
->Enabled
) {
1534 at
->array
= attribArray
;
1535 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1536 * function pointer here (for float arrays) since the pointer may
1537 * change from one execution of _ae_ArrayElement() to
1538 * the next. Doing so caused UT to break.
1540 if (ctx
->VertexProgram
._Enabled
1541 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1542 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1544 [TYPE_IDX(at
->array
->Type
)];
1548 if (at
->array
->Integer
)
1550 else if (at
->array
->Normalized
)
1555 at
->func
= AttribFuncsARB
[intOrNorm
]
1557 [TYPE_IDX(at
->array
->Type
)];
1560 check_vbo(actx
, at
->array
->BufferObj
);
1565 /* finally, vertex position */
1566 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
) {
1567 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1568 * issued as the last (provoking) attribute).
1570 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1571 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1572 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1573 check_vbo(actx
, aa
->array
->BufferObj
);
1576 else if (arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
) {
1577 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
];
1578 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1579 check_vbo(actx
, aa
->array
->BufferObj
);
1583 check_vbo(actx
, arrayObj
->ElementArrayBufferObj
);
1585 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1586 ASSERT(aa
- actx
->arrays
< 32);
1587 at
->func
= NULL
; /* terminate the list */
1588 aa
->offset
= -1; /* terminate the list */
1593 void _ae_map_vbos( struct gl_context
*ctx
)
1595 AEcontext
*actx
= AE_CONTEXT(ctx
);
1598 if (actx
->mapped_vbos
)
1602 _ae_update_state(ctx
);
1604 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1605 ctx
->Driver
.MapBufferRange(ctx
, 0,
1611 actx
->mapped_vbos
= GL_TRUE
;
1614 void _ae_unmap_vbos( struct gl_context
*ctx
)
1616 AEcontext
*actx
= AE_CONTEXT(ctx
);
1619 if (!actx
->mapped_vbos
)
1622 assert (!actx
->NewState
);
1624 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1625 ctx
->Driver
.UnmapBuffer(ctx
, actx
->vbo
[i
]);
1627 actx
->mapped_vbos
= GL_FALSE
;
1632 * Called via glArrayElement() and glDrawArrays().
1633 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1634 * for all enabled vertex arrays (for elt-th element).
1635 * Note: this may be called during display list construction.
1637 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1639 GET_CURRENT_CONTEXT(ctx
);
1640 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1643 const struct _glapi_table
* const disp
= GET_DISPATCH();
1646 if (actx
->NewState
) {
1647 assert(!actx
->mapped_vbos
);
1648 _ae_update_state( ctx
);
1651 /* Determine if w need to map/unmap VBOs */
1652 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1657 /* emit generic attribute elements */
1658 for (at
= actx
->attribs
; at
->func
; at
++) {
1660 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1661 + elt
* at
->array
->StrideB
;
1662 at
->func( at
->index
, src
);
1665 /* emit conventional arrays elements */
1666 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1668 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1669 + elt
* aa
->array
->StrideB
;
1670 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1671 ((const void *) src
) );
1675 _ae_unmap_vbos(ctx
);
1679 void _ae_invalidate_state( struct gl_context
*ctx
, GLuint new_state
)
1681 AEcontext
*actx
= AE_CONTEXT(ctx
);
1684 /* Only interested in this subset of mesa state. Need to prune
1685 * this down as both tnl/ and the drivers can raise statechanges
1686 * for arcane reasons in the middle of seemingly atomic operations
1687 * like DrawElements, over which we'd like to keep a known set of
1688 * arrays and vbo's mapped.
1690 * Luckily, neither the drivers nor tnl muck with the state that
1693 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1695 assert(!actx
->mapped_vbos
);
1696 actx
->NewState
|= new_state
;
1701 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1702 const GLvertexformat
*vfmt
)
1704 SET_ArrayElement(disp
, vfmt
->ArrayElement
);
1708 #endif /* FEATURE_arrayelt */