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 )
86 static const int ColorFuncs
[2][NUM_TYPES
] = {
109 static const int VertexFuncs
[3][NUM_TYPES
] = {
142 static const int IndexFuncs
[NUM_TYPES
] = {
153 static const int NormalFuncs
[NUM_TYPES
] = {
164 /* Note: _gloffset_* for these may not be a compile-time constant. */
165 static int SecondaryColorFuncs
[NUM_TYPES
];
166 static int FogCoordFuncs
[NUM_TYPES
];
170 ** GL_NV_vertex_program
173 /* GL_BYTE attributes */
175 static void GLAPIENTRY
176 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
178 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
181 static void GLAPIENTRY
182 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
184 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
187 static void GLAPIENTRY
188 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
190 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
193 static void GLAPIENTRY
194 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
196 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
199 static void GLAPIENTRY
200 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
202 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
204 BYTE_TO_FLOAT(v
[2])));
207 static void GLAPIENTRY
208 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
210 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
213 static void GLAPIENTRY
214 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
216 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
219 BYTE_TO_FLOAT(v
[3])));
222 static void GLAPIENTRY
223 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
225 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
228 /* GL_UNSIGNED_BYTE attributes */
230 static void GLAPIENTRY
231 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
233 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
236 static void GLAPIENTRY
237 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
239 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
242 static void GLAPIENTRY
243 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
245 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
246 UBYTE_TO_FLOAT(v
[1])));
249 static void GLAPIENTRY
250 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
252 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
255 static void GLAPIENTRY
256 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
258 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
259 UBYTE_TO_FLOAT(v
[1]),
260 UBYTE_TO_FLOAT(v
[2])));
262 static void GLAPIENTRY
263 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
265 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
266 (GLfloat
)v
[1], (GLfloat
)v
[2]));
269 static void GLAPIENTRY
270 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
272 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
273 UBYTE_TO_FLOAT(v
[1]),
274 UBYTE_TO_FLOAT(v
[2]),
275 UBYTE_TO_FLOAT(v
[3])));
278 static void GLAPIENTRY
279 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
281 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
282 (GLfloat
)v
[1], (GLfloat
)v
[2],
286 /* GL_SHORT attributes */
288 static void GLAPIENTRY
289 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
291 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
294 static void GLAPIENTRY
295 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
297 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
300 static void GLAPIENTRY
301 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
303 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
304 SHORT_TO_FLOAT(v
[1])));
307 static void GLAPIENTRY
308 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
310 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
313 static void GLAPIENTRY
314 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
316 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
317 SHORT_TO_FLOAT(v
[1]),
318 SHORT_TO_FLOAT(v
[2])));
321 static void GLAPIENTRY
322 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
324 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
328 static void GLAPIENTRY
329 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
331 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
332 SHORT_TO_FLOAT(v
[1]),
333 SHORT_TO_FLOAT(v
[2]),
334 SHORT_TO_FLOAT(v
[3])));
337 static void GLAPIENTRY
338 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
340 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
341 (GLfloat
)v
[2], (GLfloat
)v
[3]));
344 /* GL_UNSIGNED_SHORT attributes */
346 static void GLAPIENTRY
347 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
349 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
352 static void GLAPIENTRY
353 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
355 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
358 static void GLAPIENTRY
359 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
361 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
362 USHORT_TO_FLOAT(v
[1])));
365 static void GLAPIENTRY
366 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
368 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
372 static void GLAPIENTRY
373 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
375 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
376 USHORT_TO_FLOAT(v
[1]),
377 USHORT_TO_FLOAT(v
[2])));
380 static void GLAPIENTRY
381 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
383 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
387 static void GLAPIENTRY
388 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
390 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
391 USHORT_TO_FLOAT(v
[1]),
392 USHORT_TO_FLOAT(v
[2]),
393 USHORT_TO_FLOAT(v
[3])));
396 static void GLAPIENTRY
397 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
399 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
400 (GLfloat
)v
[2], (GLfloat
)v
[3]));
403 /* GL_INT attributes */
405 static void GLAPIENTRY
406 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
408 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
411 static void GLAPIENTRY
412 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
414 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
417 static void GLAPIENTRY
418 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
420 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
421 INT_TO_FLOAT(v
[1])));
424 static void GLAPIENTRY
425 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
427 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
430 static void GLAPIENTRY
431 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
433 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
435 INT_TO_FLOAT(v
[2])));
438 static void GLAPIENTRY
439 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
441 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
445 static void GLAPIENTRY
446 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
448 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
451 INT_TO_FLOAT(v
[3])));
454 static void GLAPIENTRY
455 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
457 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
458 (GLfloat
)v
[2], (GLfloat
)v
[3]));
461 /* GL_UNSIGNED_INT attributes */
463 static void GLAPIENTRY
464 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
466 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
469 static void GLAPIENTRY
470 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
472 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
475 static void GLAPIENTRY
476 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
478 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
479 UINT_TO_FLOAT(v
[1])));
482 static void GLAPIENTRY
483 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
485 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
489 static void GLAPIENTRY
490 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
492 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
494 UINT_TO_FLOAT(v
[2])));
497 static void GLAPIENTRY
498 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
500 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
504 static void GLAPIENTRY
505 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
507 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
510 UINT_TO_FLOAT(v
[3])));
513 static void GLAPIENTRY
514 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
516 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
517 (GLfloat
)v
[2], (GLfloat
)v
[3]));
520 /* GL_FLOAT attributes */
522 static void GLAPIENTRY
523 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
525 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
528 static void GLAPIENTRY
529 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
531 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
534 static void GLAPIENTRY
535 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
537 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
540 static void GLAPIENTRY
541 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
543 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
546 /* GL_DOUBLE attributes */
548 static void GLAPIENTRY
549 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
551 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
554 static void GLAPIENTRY
555 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
557 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
560 static void GLAPIENTRY
561 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
563 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
566 static void GLAPIENTRY
567 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
569 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
574 * Array [size][type] of VertexAttrib functions
576 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
581 (attrib_func
) VertexAttrib1bvNV
,
582 (attrib_func
) VertexAttrib1ubvNV
,
583 (attrib_func
) VertexAttrib1svNV
,
584 (attrib_func
) VertexAttrib1usvNV
,
585 (attrib_func
) VertexAttrib1ivNV
,
586 (attrib_func
) VertexAttrib1uivNV
,
587 (attrib_func
) VertexAttrib1fvNV
,
588 (attrib_func
) VertexAttrib1dvNV
592 (attrib_func
) VertexAttrib2bvNV
,
593 (attrib_func
) VertexAttrib2ubvNV
,
594 (attrib_func
) VertexAttrib2svNV
,
595 (attrib_func
) VertexAttrib2usvNV
,
596 (attrib_func
) VertexAttrib2ivNV
,
597 (attrib_func
) VertexAttrib2uivNV
,
598 (attrib_func
) VertexAttrib2fvNV
,
599 (attrib_func
) VertexAttrib2dvNV
603 (attrib_func
) VertexAttrib3bvNV
,
604 (attrib_func
) VertexAttrib3ubvNV
,
605 (attrib_func
) VertexAttrib3svNV
,
606 (attrib_func
) VertexAttrib3usvNV
,
607 (attrib_func
) VertexAttrib3ivNV
,
608 (attrib_func
) VertexAttrib3uivNV
,
609 (attrib_func
) VertexAttrib3fvNV
,
610 (attrib_func
) VertexAttrib3dvNV
614 (attrib_func
) VertexAttrib4bvNV
,
615 (attrib_func
) VertexAttrib4ubvNV
,
616 (attrib_func
) VertexAttrib4svNV
,
617 (attrib_func
) VertexAttrib4usvNV
,
618 (attrib_func
) VertexAttrib4ivNV
,
619 (attrib_func
) VertexAttrib4uivNV
,
620 (attrib_func
) VertexAttrib4fvNV
,
621 (attrib_func
) VertexAttrib4dvNV
625 /* normalized (except for float/double) */
628 (attrib_func
) VertexAttrib1NbvNV
,
629 (attrib_func
) VertexAttrib1NubvNV
,
630 (attrib_func
) VertexAttrib1NsvNV
,
631 (attrib_func
) VertexAttrib1NusvNV
,
632 (attrib_func
) VertexAttrib1NivNV
,
633 (attrib_func
) VertexAttrib1NuivNV
,
634 (attrib_func
) VertexAttrib1fvNV
,
635 (attrib_func
) VertexAttrib1dvNV
639 (attrib_func
) VertexAttrib2NbvNV
,
640 (attrib_func
) VertexAttrib2NubvNV
,
641 (attrib_func
) VertexAttrib2NsvNV
,
642 (attrib_func
) VertexAttrib2NusvNV
,
643 (attrib_func
) VertexAttrib2NivNV
,
644 (attrib_func
) VertexAttrib2NuivNV
,
645 (attrib_func
) VertexAttrib2fvNV
,
646 (attrib_func
) VertexAttrib2dvNV
650 (attrib_func
) VertexAttrib3NbvNV
,
651 (attrib_func
) VertexAttrib3NubvNV
,
652 (attrib_func
) VertexAttrib3NsvNV
,
653 (attrib_func
) VertexAttrib3NusvNV
,
654 (attrib_func
) VertexAttrib3NivNV
,
655 (attrib_func
) VertexAttrib3NuivNV
,
656 (attrib_func
) VertexAttrib3fvNV
,
657 (attrib_func
) VertexAttrib3dvNV
661 (attrib_func
) VertexAttrib4NbvNV
,
662 (attrib_func
) VertexAttrib4NubvNV
,
663 (attrib_func
) VertexAttrib4NsvNV
,
664 (attrib_func
) VertexAttrib4NusvNV
,
665 (attrib_func
) VertexAttrib4NivNV
,
666 (attrib_func
) VertexAttrib4NuivNV
,
667 (attrib_func
) VertexAttrib4fvNV
,
668 (attrib_func
) VertexAttrib4dvNV
675 ** GL_ARB_vertex_program
678 /* GL_BYTE attributes */
680 static void GLAPIENTRY
681 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
683 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
686 static void GLAPIENTRY
687 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
689 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
692 static void GLAPIENTRY
693 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
695 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
698 static void GLAPIENTRY
699 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
701 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
704 static void GLAPIENTRY
705 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
707 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
709 BYTE_TO_FLOAT(v
[2])));
712 static void GLAPIENTRY
713 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
715 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
718 static void GLAPIENTRY
719 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
721 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
724 BYTE_TO_FLOAT(v
[3])));
727 static void GLAPIENTRY
728 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
730 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
733 /* GL_UNSIGNED_BYTE attributes */
735 static void GLAPIENTRY
736 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
738 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
741 static void GLAPIENTRY
742 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
744 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
747 static void GLAPIENTRY
748 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
750 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
751 UBYTE_TO_FLOAT(v
[0]),
752 UBYTE_TO_FLOAT(v
[1])));
755 static void GLAPIENTRY
756 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
758 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
759 (GLfloat
)v
[0], (GLfloat
)v
[1]));
762 static void GLAPIENTRY
763 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
765 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
766 UBYTE_TO_FLOAT(v
[0]),
767 UBYTE_TO_FLOAT(v
[1]),
768 UBYTE_TO_FLOAT(v
[2])));
770 static void GLAPIENTRY
771 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
773 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
779 static void GLAPIENTRY
780 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
782 CALL_VertexAttrib4fARB(GET_DISPATCH(),
784 UBYTE_TO_FLOAT(v
[0]),
785 UBYTE_TO_FLOAT(v
[1]),
786 UBYTE_TO_FLOAT(v
[2]),
787 UBYTE_TO_FLOAT(v
[3])));
790 static void GLAPIENTRY
791 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
793 CALL_VertexAttrib4fARB(GET_DISPATCH(),
795 (GLfloat
)v
[0], (GLfloat
)v
[1],
796 (GLfloat
)v
[2], (GLfloat
)v
[3]));
799 /* GL_SHORT attributes */
801 static void GLAPIENTRY
802 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
804 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
807 static void GLAPIENTRY
808 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
810 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
813 static void GLAPIENTRY
814 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
816 CALL_VertexAttrib2fARB(GET_DISPATCH(),
817 (index
, SHORT_TO_FLOAT(v
[0]),
818 SHORT_TO_FLOAT(v
[1])));
821 static void GLAPIENTRY
822 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
824 CALL_VertexAttrib2fARB(GET_DISPATCH(),
825 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
828 static void GLAPIENTRY
829 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
831 CALL_VertexAttrib3fARB(GET_DISPATCH(),
833 SHORT_TO_FLOAT(v
[0]),
834 SHORT_TO_FLOAT(v
[1]),
835 SHORT_TO_FLOAT(v
[2])));
838 static void GLAPIENTRY
839 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
841 CALL_VertexAttrib3fARB(GET_DISPATCH(),
843 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
846 static void GLAPIENTRY
847 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
849 CALL_VertexAttrib4fARB(GET_DISPATCH(),
851 SHORT_TO_FLOAT(v
[0]),
852 SHORT_TO_FLOAT(v
[1]),
853 SHORT_TO_FLOAT(v
[2]),
854 SHORT_TO_FLOAT(v
[3])));
857 static void GLAPIENTRY
858 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
860 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
861 (GLfloat
)v
[2], (GLfloat
)v
[3]));
864 /* GL_UNSIGNED_SHORT attributes */
866 static void GLAPIENTRY
867 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
869 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
872 static void GLAPIENTRY
873 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
875 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
878 static void GLAPIENTRY
879 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
881 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
882 USHORT_TO_FLOAT(v
[1])));
885 static void GLAPIENTRY
886 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
888 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
892 static void GLAPIENTRY
893 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
895 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
896 USHORT_TO_FLOAT(v
[1]),
897 USHORT_TO_FLOAT(v
[2])));
900 static void GLAPIENTRY
901 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
903 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
904 (GLfloat
)v
[1], (GLfloat
)v
[2]));
907 static void GLAPIENTRY
908 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
910 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
911 USHORT_TO_FLOAT(v
[1]),
912 USHORT_TO_FLOAT(v
[2]),
913 USHORT_TO_FLOAT(v
[3])));
916 static void GLAPIENTRY
917 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
919 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
922 /* GL_INT attributes */
924 static void GLAPIENTRY
925 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
927 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
930 static void GLAPIENTRY
931 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
933 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
936 static void GLAPIENTRY
937 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
939 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
940 INT_TO_FLOAT(v
[1])));
943 static void GLAPIENTRY
944 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
946 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
950 static void GLAPIENTRY
951 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
953 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
955 INT_TO_FLOAT(v
[2])));
958 static void GLAPIENTRY
959 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
961 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
962 (GLfloat
)v
[1], (GLfloat
)v
[2]));
965 static void GLAPIENTRY
966 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
968 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
971 INT_TO_FLOAT(v
[3])));
974 static void GLAPIENTRY
975 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
977 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
978 (GLfloat
)v
[2], (GLfloat
)v
[3]));
981 /* GL_UNSIGNED_INT attributes */
983 static void GLAPIENTRY
984 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
986 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
989 static void GLAPIENTRY
990 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
992 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
995 static void GLAPIENTRY
996 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
998 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
999 UINT_TO_FLOAT(v
[1])));
1002 static void GLAPIENTRY
1003 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1005 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1009 static void GLAPIENTRY
1010 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1012 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1013 UINT_TO_FLOAT(v
[1]),
1014 UINT_TO_FLOAT(v
[2])));
1017 static void GLAPIENTRY
1018 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1020 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1021 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1024 static void GLAPIENTRY
1025 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1027 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1028 UINT_TO_FLOAT(v
[1]),
1029 UINT_TO_FLOAT(v
[2]),
1030 UINT_TO_FLOAT(v
[3])));
1033 static void GLAPIENTRY
1034 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1036 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1037 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1040 /* GL_FLOAT attributes */
1042 static void GLAPIENTRY
1043 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1045 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1048 static void GLAPIENTRY
1049 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1051 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1054 static void GLAPIENTRY
1055 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1057 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1060 static void GLAPIENTRY
1061 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1063 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1066 /* GL_DOUBLE attributes */
1068 static void GLAPIENTRY
1069 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1071 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
1074 static void GLAPIENTRY
1075 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1077 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
1080 static void GLAPIENTRY
1081 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1083 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
1086 static void GLAPIENTRY
1087 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1089 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
1094 * Integer-valued attributes
1096 static void GLAPIENTRY
1097 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1099 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1102 static void GLAPIENTRY
1103 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1105 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1108 static void GLAPIENTRY
1109 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1111 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1114 static void GLAPIENTRY
1115 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1117 CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index
, v
));
1121 static void GLAPIENTRY
1122 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1124 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1127 static void GLAPIENTRY
1128 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1130 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1133 static void GLAPIENTRY
1134 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1136 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1139 static void GLAPIENTRY
1140 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1142 CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index
, v
));
1147 static void GLAPIENTRY
1148 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1150 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1153 static void GLAPIENTRY
1154 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1156 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1159 static void GLAPIENTRY
1160 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1162 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1165 static void GLAPIENTRY
1166 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1168 CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index
, v
));
1172 static void GLAPIENTRY
1173 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1175 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1178 static void GLAPIENTRY
1179 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1181 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1184 static void GLAPIENTRY
1185 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1187 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1190 static void GLAPIENTRY
1191 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1193 CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index
, v
));
1198 static void GLAPIENTRY
1199 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1201 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1204 static void GLAPIENTRY
1205 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1207 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1210 static void GLAPIENTRY
1211 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1213 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1216 static void GLAPIENTRY
1217 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1219 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1223 static void GLAPIENTRY
1224 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1226 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1229 static void GLAPIENTRY
1230 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1232 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1235 static void GLAPIENTRY
1236 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1238 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1241 static void GLAPIENTRY
1242 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1244 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1251 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1254 static attrib_func AttribFuncsARB
[3][4][NUM_TYPES
] = {
1256 /* non-normalized */
1259 (attrib_func
) VertexAttrib1bvARB
,
1260 (attrib_func
) VertexAttrib1ubvARB
,
1261 (attrib_func
) VertexAttrib1svARB
,
1262 (attrib_func
) VertexAttrib1usvARB
,
1263 (attrib_func
) VertexAttrib1ivARB
,
1264 (attrib_func
) VertexAttrib1uivARB
,
1265 (attrib_func
) VertexAttrib1fvARB
,
1266 (attrib_func
) VertexAttrib1dvARB
1270 (attrib_func
) VertexAttrib2bvARB
,
1271 (attrib_func
) VertexAttrib2ubvARB
,
1272 (attrib_func
) VertexAttrib2svARB
,
1273 (attrib_func
) VertexAttrib2usvARB
,
1274 (attrib_func
) VertexAttrib2ivARB
,
1275 (attrib_func
) VertexAttrib2uivARB
,
1276 (attrib_func
) VertexAttrib2fvARB
,
1277 (attrib_func
) VertexAttrib2dvARB
1281 (attrib_func
) VertexAttrib3bvARB
,
1282 (attrib_func
) VertexAttrib3ubvARB
,
1283 (attrib_func
) VertexAttrib3svARB
,
1284 (attrib_func
) VertexAttrib3usvARB
,
1285 (attrib_func
) VertexAttrib3ivARB
,
1286 (attrib_func
) VertexAttrib3uivARB
,
1287 (attrib_func
) VertexAttrib3fvARB
,
1288 (attrib_func
) VertexAttrib3dvARB
1292 (attrib_func
) VertexAttrib4bvARB
,
1293 (attrib_func
) VertexAttrib4ubvARB
,
1294 (attrib_func
) VertexAttrib4svARB
,
1295 (attrib_func
) VertexAttrib4usvARB
,
1296 (attrib_func
) VertexAttrib4ivARB
,
1297 (attrib_func
) VertexAttrib4uivARB
,
1298 (attrib_func
) VertexAttrib4fvARB
,
1299 (attrib_func
) VertexAttrib4dvARB
1303 /* normalized (except for float/double) */
1306 (attrib_func
) VertexAttrib1NbvARB
,
1307 (attrib_func
) VertexAttrib1NubvARB
,
1308 (attrib_func
) VertexAttrib1NsvARB
,
1309 (attrib_func
) VertexAttrib1NusvARB
,
1310 (attrib_func
) VertexAttrib1NivARB
,
1311 (attrib_func
) VertexAttrib1NuivARB
,
1312 (attrib_func
) VertexAttrib1fvARB
,
1313 (attrib_func
) VertexAttrib1dvARB
1317 (attrib_func
) VertexAttrib2NbvARB
,
1318 (attrib_func
) VertexAttrib2NubvARB
,
1319 (attrib_func
) VertexAttrib2NsvARB
,
1320 (attrib_func
) VertexAttrib2NusvARB
,
1321 (attrib_func
) VertexAttrib2NivARB
,
1322 (attrib_func
) VertexAttrib2NuivARB
,
1323 (attrib_func
) VertexAttrib2fvARB
,
1324 (attrib_func
) VertexAttrib2dvARB
1328 (attrib_func
) VertexAttrib3NbvARB
,
1329 (attrib_func
) VertexAttrib3NubvARB
,
1330 (attrib_func
) VertexAttrib3NsvARB
,
1331 (attrib_func
) VertexAttrib3NusvARB
,
1332 (attrib_func
) VertexAttrib3NivARB
,
1333 (attrib_func
) VertexAttrib3NuivARB
,
1334 (attrib_func
) VertexAttrib3fvARB
,
1335 (attrib_func
) VertexAttrib3dvARB
1339 (attrib_func
) VertexAttrib4NbvARB
,
1340 (attrib_func
) VertexAttrib4NubvARB
,
1341 (attrib_func
) VertexAttrib4NsvARB
,
1342 (attrib_func
) VertexAttrib4NusvARB
,
1343 (attrib_func
) VertexAttrib4NivARB
,
1344 (attrib_func
) VertexAttrib4NuivARB
,
1345 (attrib_func
) VertexAttrib4fvARB
,
1346 (attrib_func
) VertexAttrib4dvARB
1351 /* integer-valued */
1354 (attrib_func
) VertexAttribI1bv
,
1355 (attrib_func
) VertexAttribI1ubv
,
1356 (attrib_func
) VertexAttribI1sv
,
1357 (attrib_func
) VertexAttribI1usv
,
1358 (attrib_func
) VertexAttribI1iv
,
1359 (attrib_func
) VertexAttribI1uiv
,
1360 NULL
, /* GL_FLOAT */
1361 NULL
/* GL_DOUBLE */
1365 (attrib_func
) VertexAttribI2bv
,
1366 (attrib_func
) VertexAttribI2ubv
,
1367 (attrib_func
) VertexAttribI2sv
,
1368 (attrib_func
) VertexAttribI2usv
,
1369 (attrib_func
) VertexAttribI2iv
,
1370 (attrib_func
) VertexAttribI2uiv
,
1371 NULL
, /* GL_FLOAT */
1372 NULL
/* GL_DOUBLE */
1376 (attrib_func
) VertexAttribI3bv
,
1377 (attrib_func
) VertexAttribI3ubv
,
1378 (attrib_func
) VertexAttribI3sv
,
1379 (attrib_func
) VertexAttribI3usv
,
1380 (attrib_func
) VertexAttribI3iv
,
1381 (attrib_func
) VertexAttribI3uiv
,
1382 NULL
, /* GL_FLOAT */
1383 NULL
/* GL_DOUBLE */
1387 (attrib_func
) VertexAttribI4bv
,
1388 (attrib_func
) VertexAttribI4ubv
,
1389 (attrib_func
) VertexAttribI4sv
,
1390 (attrib_func
) VertexAttribI4usv
,
1391 (attrib_func
) VertexAttribI4iv
,
1392 (attrib_func
) VertexAttribI4uiv
,
1393 NULL
, /* GL_FLOAT */
1394 NULL
/* GL_DOUBLE */
1399 /**********************************************************************/
1402 GLboolean
_ae_create_context( struct gl_context
*ctx
)
1404 if (ctx
->aelt_context
)
1407 /* These _gloffset_* values may not be compile-time constants */
1408 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1409 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1410 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1411 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1412 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1413 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1414 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1415 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1417 FogCoordFuncs
[0] = -1;
1418 FogCoordFuncs
[1] = -1;
1419 FogCoordFuncs
[2] = -1;
1420 FogCoordFuncs
[3] = -1;
1421 FogCoordFuncs
[4] = -1;
1422 FogCoordFuncs
[5] = -1;
1423 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1424 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1426 ctx
->aelt_context
= calloc(1, sizeof(AEcontext
));
1427 if (!ctx
->aelt_context
)
1430 AE_CONTEXT(ctx
)->NewState
= ~0;
1435 void _ae_destroy_context( struct gl_context
*ctx
)
1437 if ( AE_CONTEXT( ctx
) ) {
1438 free(ctx
->aelt_context
);
1439 ctx
->aelt_context
= NULL
;
1443 static void check_vbo( AEcontext
*actx
,
1444 struct gl_buffer_object
*vbo
)
1446 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1448 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1449 if (actx
->vbo
[i
] == vbo
)
1451 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1452 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1458 * Make a list of per-vertex functions to call for each glArrayElement call.
1459 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1461 * Note: this may be called during display list construction.
1463 static void _ae_update_state( struct gl_context
*ctx
)
1465 AEcontext
*actx
= AE_CONTEXT(ctx
);
1466 AEarray
*aa
= actx
->arrays
;
1467 AEattrib
*at
= actx
->attribs
;
1469 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1473 /* conventional vertex arrays */
1474 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
) {
1475 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1476 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1477 check_vbo(actx
, aa
->array
->BufferObj
);
1480 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
) {
1481 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1482 aa
->offset
= _gloffset_EdgeFlagv
;
1483 check_vbo(actx
, aa
->array
->BufferObj
);
1486 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
) {
1487 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1488 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1489 check_vbo(actx
, aa
->array
->BufferObj
);
1492 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
) {
1493 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1494 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1495 check_vbo(actx
, aa
->array
->BufferObj
);
1498 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
) {
1499 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1500 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1501 check_vbo(actx
, aa
->array
->BufferObj
);
1504 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
) {
1505 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
];
1506 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1507 check_vbo(actx
, aa
->array
->BufferObj
);
1510 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1511 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1512 if (attribArray
->Enabled
) {
1513 /* NOTE: we use generic glVertexAttribNV functions here.
1514 * If we ever remove GL_NV_vertex_program this will have to change.
1516 at
->array
= attribArray
;
1517 ASSERT(!at
->array
->Normalized
);
1518 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1520 [TYPE_IDX(at
->array
->Type
)];
1521 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1522 check_vbo(actx
, at
->array
->BufferObj
);
1527 /* generic vertex attribute arrays */
1528 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1529 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1530 if (attribArray
->Enabled
) {
1531 at
->array
= attribArray
;
1532 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1533 * function pointer here (for float arrays) since the pointer may
1534 * change from one execution of _ae_ArrayElement() to
1535 * the next. Doing so caused UT to break.
1537 if (ctx
->VertexProgram
._Enabled
1538 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1539 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1541 [TYPE_IDX(at
->array
->Type
)];
1545 if (at
->array
->Integer
)
1547 else if (at
->array
->Normalized
)
1552 at
->func
= AttribFuncsARB
[intOrNorm
]
1554 [TYPE_IDX(at
->array
->Type
)];
1557 check_vbo(actx
, at
->array
->BufferObj
);
1562 /* finally, vertex position */
1563 if (arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
) {
1564 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1565 * issued as the last (provoking) attribute).
1567 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1568 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1569 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1570 check_vbo(actx
, aa
->array
->BufferObj
);
1573 else if (arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
) {
1574 aa
->array
= &arrayObj
->VertexAttrib
[VERT_ATTRIB_POS
];
1575 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1576 check_vbo(actx
, aa
->array
->BufferObj
);
1580 check_vbo(actx
, arrayObj
->ElementArrayBufferObj
);
1582 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1583 ASSERT(aa
- actx
->arrays
< 32);
1584 at
->func
= NULL
; /* terminate the list */
1585 aa
->offset
= -1; /* terminate the list */
1590 void _ae_map_vbos( struct gl_context
*ctx
)
1592 AEcontext
*actx
= AE_CONTEXT(ctx
);
1595 if (actx
->mapped_vbos
)
1599 _ae_update_state(ctx
);
1601 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1602 ctx
->Driver
.MapBufferRange(ctx
, 0,
1608 actx
->mapped_vbos
= GL_TRUE
;
1611 void _ae_unmap_vbos( struct gl_context
*ctx
)
1613 AEcontext
*actx
= AE_CONTEXT(ctx
);
1616 if (!actx
->mapped_vbos
)
1619 assert (!actx
->NewState
);
1621 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1622 ctx
->Driver
.UnmapBuffer(ctx
, actx
->vbo
[i
]);
1624 actx
->mapped_vbos
= GL_FALSE
;
1629 * Called via glArrayElement() and glDrawArrays().
1630 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1631 * for all enabled vertex arrays (for elt-th element).
1632 * Note: this may be called during display list construction.
1634 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1636 GET_CURRENT_CONTEXT(ctx
);
1637 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1640 const struct _glapi_table
* const disp
= GET_DISPATCH();
1643 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1644 * then we call PrimitiveRestartNV and return.
1646 if (ctx
->Array
.PrimitiveRestart
&& (elt
== ctx
->Array
.RestartIndex
)) {
1647 CALL_PrimitiveRestartNV((struct _glapi_table
*)disp
, ());
1651 if (actx
->NewState
) {
1652 assert(!actx
->mapped_vbos
);
1653 _ae_update_state( ctx
);
1656 /* Determine if we need to map/unmap VBOs */
1657 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1662 /* emit generic attribute elements */
1663 for (at
= actx
->attribs
; at
->func
; at
++) {
1665 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1666 + elt
* at
->array
->StrideB
;
1667 at
->func( at
->index
, src
);
1670 /* emit conventional arrays elements */
1671 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1673 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1674 + elt
* aa
->array
->StrideB
;
1675 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1676 ((const void *) src
) );
1680 _ae_unmap_vbos(ctx
);
1684 void _ae_invalidate_state( struct gl_context
*ctx
, GLuint new_state
)
1686 AEcontext
*actx
= AE_CONTEXT(ctx
);
1689 /* Only interested in this subset of mesa state. Need to prune
1690 * this down as both tnl/ and the drivers can raise statechanges
1691 * for arcane reasons in the middle of seemingly atomic operations
1692 * like DrawElements, over which we'd like to keep a known set of
1693 * arrays and vbo's mapped.
1695 * Luckily, neither the drivers nor tnl muck with the state that
1698 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1700 assert(!actx
->mapped_vbos
);
1701 actx
->NewState
|= new_state
;
1706 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1707 const GLvertexformat
*vfmt
)
1709 SET_ArrayElement(disp
, vfmt
->ArrayElement
);