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 * Keith Whitwell <keith@tungstengraphics.com>
30 #include "api_arrayelt.h"
34 #include "glapioffsets.h"
37 typedef void (GLAPIENTRY
*array_func
)( const void * );
40 const struct gl_client_array
*array
;
44 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
47 const struct gl_client_array
*array
;
54 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
58 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
62 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
63 * in the range [0, 7]. Luckily these type tokens are sequentially
64 * numbered in gl.h, except for GL_DOUBLE.
66 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
68 static const int ColorFuncs
[2][8] = {
91 static const int VertexFuncs
[3][8] = {
124 static const int IndexFuncs
[8] = {
135 static const int NormalFuncs
[8] = {
146 /* Note: _gloffset_* for these may not be a compile-time constant. */
147 static int SecondaryColorFuncs
[8];
148 static int FogCoordFuncs
[8];
152 ** GL_NV_vertex_program
155 /* GL_BYTE attributes */
157 static void GLAPIENTRY
VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
159 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
162 static void GLAPIENTRY
VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
164 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
167 static void GLAPIENTRY
VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
169 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
172 static void GLAPIENTRY
VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
174 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
177 static void GLAPIENTRY
VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
179 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
181 BYTE_TO_FLOAT(v
[2])));
184 static void GLAPIENTRY
VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
186 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
189 static void GLAPIENTRY
VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
191 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
194 BYTE_TO_FLOAT(v
[3])));
197 static void GLAPIENTRY
VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
199 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
202 /* GL_UNSIGNED_BYTE attributes */
204 static void GLAPIENTRY
VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
206 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
209 static void GLAPIENTRY
VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
211 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
214 static void GLAPIENTRY
VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
216 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
217 UBYTE_TO_FLOAT(v
[1])));
220 static void GLAPIENTRY
VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
222 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
225 static void GLAPIENTRY
VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
227 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
228 UBYTE_TO_FLOAT(v
[1]),
229 UBYTE_TO_FLOAT(v
[2])));
231 static void GLAPIENTRY
VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
233 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
236 static void GLAPIENTRY
VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
238 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
239 UBYTE_TO_FLOAT(v
[1]),
240 UBYTE_TO_FLOAT(v
[2]),
241 UBYTE_TO_FLOAT(v
[3])));
244 static void GLAPIENTRY
VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
246 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
249 /* GL_SHORT attributes */
251 static void GLAPIENTRY
VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
253 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
256 static void GLAPIENTRY
VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
258 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
261 static void GLAPIENTRY
VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
263 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
264 SHORT_TO_FLOAT(v
[1])));
267 static void GLAPIENTRY
VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
269 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
272 static void GLAPIENTRY
VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
274 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
275 SHORT_TO_FLOAT(v
[1]),
276 SHORT_TO_FLOAT(v
[2])));
279 static void GLAPIENTRY
VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
281 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
284 static void GLAPIENTRY
VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
286 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
287 SHORT_TO_FLOAT(v
[1]),
288 SHORT_TO_FLOAT(v
[2]),
289 SHORT_TO_FLOAT(v
[3])));
292 static void GLAPIENTRY
VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
294 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
297 /* GL_UNSIGNED_SHORT attributes */
299 static void GLAPIENTRY
VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
301 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
304 static void GLAPIENTRY
VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
306 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
309 static void GLAPIENTRY
VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
311 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
312 USHORT_TO_FLOAT(v
[1])));
315 static void GLAPIENTRY
VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
317 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
320 static void GLAPIENTRY
VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
322 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
323 USHORT_TO_FLOAT(v
[1]),
324 USHORT_TO_FLOAT(v
[2])));
327 static void GLAPIENTRY
VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
329 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
332 static void GLAPIENTRY
VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
334 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
335 USHORT_TO_FLOAT(v
[1]),
336 USHORT_TO_FLOAT(v
[2]),
337 USHORT_TO_FLOAT(v
[3])));
340 static void GLAPIENTRY
VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
342 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
345 /* GL_INT attributes */
347 static void GLAPIENTRY
VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
349 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
352 static void GLAPIENTRY
VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
354 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
357 static void GLAPIENTRY
VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
359 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
360 INT_TO_FLOAT(v
[1])));
363 static void GLAPIENTRY
VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
365 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
368 static void GLAPIENTRY
VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
370 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
372 INT_TO_FLOAT(v
[2])));
375 static void GLAPIENTRY
VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
377 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
380 static void GLAPIENTRY
VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
382 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
385 INT_TO_FLOAT(v
[3])));
388 static void GLAPIENTRY
VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
390 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
393 /* GL_UNSIGNED_INT attributes */
395 static void GLAPIENTRY
VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
397 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
400 static void GLAPIENTRY
VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
402 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, v
[0]));
405 static void GLAPIENTRY
VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
407 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
408 UINT_TO_FLOAT(v
[1])));
411 static void GLAPIENTRY
VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
413 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, v
[0], v
[1]));
416 static void GLAPIENTRY
VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
418 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
420 UINT_TO_FLOAT(v
[2])));
423 static void GLAPIENTRY
VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
425 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
428 static void GLAPIENTRY
VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
430 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
433 UINT_TO_FLOAT(v
[3])));
436 static void GLAPIENTRY
VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
438 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
441 /* GL_FLOAT attributes */
443 static void GLAPIENTRY
VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
445 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
448 static void GLAPIENTRY
VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
450 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
453 static void GLAPIENTRY
VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
455 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
458 static void GLAPIENTRY
VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
460 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
463 /* GL_DOUBLE attributes */
465 static void GLAPIENTRY
VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
467 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
470 static void GLAPIENTRY
VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
472 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
475 static void GLAPIENTRY
VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
477 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
480 static void GLAPIENTRY
VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
482 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
487 * Array [size][type] of VertexAttrib functions
489 static attrib_func AttribFuncsNV
[2][4][8] = {
494 (attrib_func
) VertexAttrib1bvNV
,
495 (attrib_func
) VertexAttrib1ubvNV
,
496 (attrib_func
) VertexAttrib1svNV
,
497 (attrib_func
) VertexAttrib1usvNV
,
498 (attrib_func
) VertexAttrib1ivNV
,
499 (attrib_func
) VertexAttrib1uivNV
,
500 (attrib_func
) VertexAttrib1fvNV
,
501 (attrib_func
) VertexAttrib1dvNV
505 (attrib_func
) VertexAttrib2bvNV
,
506 (attrib_func
) VertexAttrib2ubvNV
,
507 (attrib_func
) VertexAttrib2svNV
,
508 (attrib_func
) VertexAttrib2usvNV
,
509 (attrib_func
) VertexAttrib2ivNV
,
510 (attrib_func
) VertexAttrib2uivNV
,
511 (attrib_func
) VertexAttrib2fvNV
,
512 (attrib_func
) VertexAttrib2dvNV
516 (attrib_func
) VertexAttrib3bvNV
,
517 (attrib_func
) VertexAttrib3ubvNV
,
518 (attrib_func
) VertexAttrib3svNV
,
519 (attrib_func
) VertexAttrib3usvNV
,
520 (attrib_func
) VertexAttrib3ivNV
,
521 (attrib_func
) VertexAttrib3uivNV
,
522 (attrib_func
) VertexAttrib3fvNV
,
523 (attrib_func
) VertexAttrib3dvNV
527 (attrib_func
) VertexAttrib4bvNV
,
528 (attrib_func
) VertexAttrib4ubvNV
,
529 (attrib_func
) VertexAttrib4svNV
,
530 (attrib_func
) VertexAttrib4usvNV
,
531 (attrib_func
) VertexAttrib4ivNV
,
532 (attrib_func
) VertexAttrib4uivNV
,
533 (attrib_func
) VertexAttrib4fvNV
,
534 (attrib_func
) VertexAttrib4dvNV
538 /* normalized (except for float/double) */
541 (attrib_func
) VertexAttrib1NbvNV
,
542 (attrib_func
) VertexAttrib1NubvNV
,
543 (attrib_func
) VertexAttrib1NsvNV
,
544 (attrib_func
) VertexAttrib1NusvNV
,
545 (attrib_func
) VertexAttrib1NivNV
,
546 (attrib_func
) VertexAttrib1NuivNV
,
547 (attrib_func
) VertexAttrib1fvNV
,
548 (attrib_func
) VertexAttrib1dvNV
552 (attrib_func
) VertexAttrib2NbvNV
,
553 (attrib_func
) VertexAttrib2NubvNV
,
554 (attrib_func
) VertexAttrib2NsvNV
,
555 (attrib_func
) VertexAttrib2NusvNV
,
556 (attrib_func
) VertexAttrib2NivNV
,
557 (attrib_func
) VertexAttrib2NuivNV
,
558 (attrib_func
) VertexAttrib2fvNV
,
559 (attrib_func
) VertexAttrib2dvNV
563 (attrib_func
) VertexAttrib3NbvNV
,
564 (attrib_func
) VertexAttrib3NubvNV
,
565 (attrib_func
) VertexAttrib3NsvNV
,
566 (attrib_func
) VertexAttrib3NusvNV
,
567 (attrib_func
) VertexAttrib3NivNV
,
568 (attrib_func
) VertexAttrib3NuivNV
,
569 (attrib_func
) VertexAttrib3fvNV
,
570 (attrib_func
) VertexAttrib3dvNV
574 (attrib_func
) VertexAttrib4NbvNV
,
575 (attrib_func
) VertexAttrib4NubvNV
,
576 (attrib_func
) VertexAttrib4NsvNV
,
577 (attrib_func
) VertexAttrib4NusvNV
,
578 (attrib_func
) VertexAttrib4NivNV
,
579 (attrib_func
) VertexAttrib4NuivNV
,
580 (attrib_func
) VertexAttrib4fvNV
,
581 (attrib_func
) VertexAttrib4dvNV
588 ** GL_ARB_vertex_program
591 /* GL_BYTE attributes */
593 static void GLAPIENTRY
VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
595 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
598 static void GLAPIENTRY
VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
600 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, v
[0]));
603 static void GLAPIENTRY
VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
605 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
608 static void GLAPIENTRY
VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
610 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, v
[0], v
[1]));
613 static void GLAPIENTRY
VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
615 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
617 BYTE_TO_FLOAT(v
[2])));
620 static void GLAPIENTRY
VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
622 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
625 static void GLAPIENTRY
VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
627 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
630 BYTE_TO_FLOAT(v
[3])));
633 static void GLAPIENTRY
VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
635 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
638 /* GL_UNSIGNED_BYTE attributes */
640 static void GLAPIENTRY
VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
642 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
645 static void GLAPIENTRY
VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
647 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, v
[0]));
650 static void GLAPIENTRY
VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
652 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
653 UBYTE_TO_FLOAT(v
[1])));
656 static void GLAPIENTRY
VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
658 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, v
[0], v
[1]));
661 static void GLAPIENTRY
VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
663 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
664 UBYTE_TO_FLOAT(v
[1]),
665 UBYTE_TO_FLOAT(v
[2])));
667 static void GLAPIENTRY
VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
669 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
672 static void GLAPIENTRY
VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
674 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
675 UBYTE_TO_FLOAT(v
[1]),
676 UBYTE_TO_FLOAT(v
[2]),
677 UBYTE_TO_FLOAT(v
[3])));
680 static void GLAPIENTRY
VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
682 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
685 /* GL_SHORT attributes */
687 static void GLAPIENTRY
VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
689 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
692 static void GLAPIENTRY
VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
694 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, v
[0]));
697 static void GLAPIENTRY
VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
699 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
700 SHORT_TO_FLOAT(v
[1])));
703 static void GLAPIENTRY
VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
705 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, v
[0], v
[1]));
708 static void GLAPIENTRY
VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
710 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
711 SHORT_TO_FLOAT(v
[1]),
712 SHORT_TO_FLOAT(v
[2])));
715 static void GLAPIENTRY
VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
717 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
720 static void GLAPIENTRY
VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
722 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
723 SHORT_TO_FLOAT(v
[1]),
724 SHORT_TO_FLOAT(v
[2]),
725 SHORT_TO_FLOAT(v
[3])));
728 static void GLAPIENTRY
VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
730 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
733 /* GL_UNSIGNED_SHORT attributes */
735 static void GLAPIENTRY
VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
737 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
740 static void GLAPIENTRY
VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
742 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, v
[0]));
745 static void GLAPIENTRY
VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
747 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
748 USHORT_TO_FLOAT(v
[1])));
751 static void GLAPIENTRY
VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
753 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, v
[0], v
[1]));
756 static void GLAPIENTRY
VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
758 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
759 USHORT_TO_FLOAT(v
[1]),
760 USHORT_TO_FLOAT(v
[2])));
763 static void GLAPIENTRY
VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
765 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
768 static void GLAPIENTRY
VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
770 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
771 USHORT_TO_FLOAT(v
[1]),
772 USHORT_TO_FLOAT(v
[2]),
773 USHORT_TO_FLOAT(v
[3])));
776 static void GLAPIENTRY
VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
778 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
781 /* GL_INT attributes */
783 static void GLAPIENTRY
VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
785 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
788 static void GLAPIENTRY
VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
790 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, v
[0]));
793 static void GLAPIENTRY
VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
795 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
796 INT_TO_FLOAT(v
[1])));
799 static void GLAPIENTRY
VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
801 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, v
[0], v
[1]));
804 static void GLAPIENTRY
VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
806 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
808 INT_TO_FLOAT(v
[2])));
811 static void GLAPIENTRY
VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
813 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
816 static void GLAPIENTRY
VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
818 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
821 INT_TO_FLOAT(v
[3])));
824 static void GLAPIENTRY
VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
826 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
829 /* GL_UNSIGNED_INT attributes */
831 static void GLAPIENTRY
VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
833 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
836 static void GLAPIENTRY
VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
838 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, v
[0]));
841 static void GLAPIENTRY
VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
843 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
844 UINT_TO_FLOAT(v
[1])));
847 static void GLAPIENTRY
VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
849 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, v
[0], v
[1]));
852 static void GLAPIENTRY
VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
854 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
856 UINT_TO_FLOAT(v
[2])));
859 static void GLAPIENTRY
VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
861 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
864 static void GLAPIENTRY
VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
866 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
869 UINT_TO_FLOAT(v
[3])));
872 static void GLAPIENTRY
VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
874 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
877 /* GL_FLOAT attributes */
879 static void GLAPIENTRY
VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
881 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
884 static void GLAPIENTRY
VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
886 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
889 static void GLAPIENTRY
VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
891 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
894 static void GLAPIENTRY
VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
896 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
899 /* GL_DOUBLE attributes */
901 static void GLAPIENTRY
VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
903 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
906 static void GLAPIENTRY
VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
908 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
911 static void GLAPIENTRY
VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
913 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
916 static void GLAPIENTRY
VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
918 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
923 * Array [size][type] of VertexAttrib functions
925 static attrib_func AttribFuncsARB
[2][4][8] = {
930 (attrib_func
) VertexAttrib1bvARB
,
931 (attrib_func
) VertexAttrib1ubvARB
,
932 (attrib_func
) VertexAttrib1svARB
,
933 (attrib_func
) VertexAttrib1usvARB
,
934 (attrib_func
) VertexAttrib1ivARB
,
935 (attrib_func
) VertexAttrib1uivARB
,
936 (attrib_func
) VertexAttrib1fvARB
,
937 (attrib_func
) VertexAttrib1dvARB
941 (attrib_func
) VertexAttrib2bvARB
,
942 (attrib_func
) VertexAttrib2ubvARB
,
943 (attrib_func
) VertexAttrib2svARB
,
944 (attrib_func
) VertexAttrib2usvARB
,
945 (attrib_func
) VertexAttrib2ivARB
,
946 (attrib_func
) VertexAttrib2uivARB
,
947 (attrib_func
) VertexAttrib2fvARB
,
948 (attrib_func
) VertexAttrib2dvARB
952 (attrib_func
) VertexAttrib3bvARB
,
953 (attrib_func
) VertexAttrib3ubvARB
,
954 (attrib_func
) VertexAttrib3svARB
,
955 (attrib_func
) VertexAttrib3usvARB
,
956 (attrib_func
) VertexAttrib3ivARB
,
957 (attrib_func
) VertexAttrib3uivARB
,
958 (attrib_func
) VertexAttrib3fvARB
,
959 (attrib_func
) VertexAttrib3dvARB
963 (attrib_func
) VertexAttrib4bvARB
,
964 (attrib_func
) VertexAttrib4ubvARB
,
965 (attrib_func
) VertexAttrib4svARB
,
966 (attrib_func
) VertexAttrib4usvARB
,
967 (attrib_func
) VertexAttrib4ivARB
,
968 (attrib_func
) VertexAttrib4uivARB
,
969 (attrib_func
) VertexAttrib4fvARB
,
970 (attrib_func
) VertexAttrib4dvARB
974 /* normalized (except for float/double) */
977 (attrib_func
) VertexAttrib1NbvARB
,
978 (attrib_func
) VertexAttrib1NubvARB
,
979 (attrib_func
) VertexAttrib1NsvARB
,
980 (attrib_func
) VertexAttrib1NusvARB
,
981 (attrib_func
) VertexAttrib1NivARB
,
982 (attrib_func
) VertexAttrib1NuivARB
,
983 (attrib_func
) VertexAttrib1fvARB
,
984 (attrib_func
) VertexAttrib1dvARB
988 (attrib_func
) VertexAttrib2NbvARB
,
989 (attrib_func
) VertexAttrib2NubvARB
,
990 (attrib_func
) VertexAttrib2NsvARB
,
991 (attrib_func
) VertexAttrib2NusvARB
,
992 (attrib_func
) VertexAttrib2NivARB
,
993 (attrib_func
) VertexAttrib2NuivARB
,
994 (attrib_func
) VertexAttrib2fvARB
,
995 (attrib_func
) VertexAttrib2dvARB
999 (attrib_func
) VertexAttrib3NbvARB
,
1000 (attrib_func
) VertexAttrib3NubvARB
,
1001 (attrib_func
) VertexAttrib3NsvARB
,
1002 (attrib_func
) VertexAttrib3NusvARB
,
1003 (attrib_func
) VertexAttrib3NivARB
,
1004 (attrib_func
) VertexAttrib3NuivARB
,
1005 (attrib_func
) VertexAttrib3fvARB
,
1006 (attrib_func
) VertexAttrib3dvARB
1010 (attrib_func
) VertexAttrib4NbvARB
,
1011 (attrib_func
) VertexAttrib4NubvARB
,
1012 (attrib_func
) VertexAttrib4NsvARB
,
1013 (attrib_func
) VertexAttrib4NusvARB
,
1014 (attrib_func
) VertexAttrib4NivARB
,
1015 (attrib_func
) VertexAttrib4NuivARB
,
1016 (attrib_func
) VertexAttrib4fvARB
,
1017 (attrib_func
) VertexAttrib4dvARB
1022 /**********************************************************************/
1025 GLboolean
_ae_create_context( GLcontext
*ctx
)
1027 if (ctx
->aelt_context
)
1030 /* These _gloffset_* values may not be compile-time constants */
1031 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1032 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1033 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1034 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1035 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1036 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1037 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1038 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1040 FogCoordFuncs
[0] = -1;
1041 FogCoordFuncs
[1] = -1;
1042 FogCoordFuncs
[2] = -1;
1043 FogCoordFuncs
[3] = -1;
1044 FogCoordFuncs
[4] = -1;
1045 FogCoordFuncs
[5] = -1;
1046 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1047 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1049 ctx
->aelt_context
= MALLOC( sizeof(AEcontext
) );
1050 if (!ctx
->aelt_context
)
1053 AE_CONTEXT(ctx
)->NewState
= ~0;
1058 void _ae_destroy_context( GLcontext
*ctx
)
1060 if ( AE_CONTEXT( ctx
) ) {
1061 FREE( ctx
->aelt_context
);
1062 ctx
->aelt_context
= NULL
;
1068 * Make a list of per-vertex functions to call for each glArrayElement call.
1069 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1071 * Note: this may be called during display list construction.
1073 static void _ae_update_state( GLcontext
*ctx
)
1075 AEcontext
*actx
= AE_CONTEXT(ctx
);
1076 AEarray
*aa
= actx
->arrays
;
1077 AEattrib
*at
= actx
->attribs
;
1080 /* conventional vertex arrays */
1081 if (ctx
->Array
.Index
.Enabled
) {
1082 aa
->array
= &ctx
->Array
.Index
;
1083 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1086 if (ctx
->Array
.EdgeFlag
.Enabled
) {
1087 aa
->array
= &ctx
->Array
.EdgeFlag
;
1088 aa
->offset
= _gloffset_EdgeFlagv
;
1091 if (ctx
->Array
.Normal
.Enabled
) {
1092 aa
->array
= &ctx
->Array
.Normal
;
1093 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1096 if (ctx
->Array
.Color
.Enabled
) {
1097 aa
->array
= &ctx
->Array
.Color
;
1098 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1101 if (ctx
->Array
.SecondaryColor
.Enabled
) {
1102 aa
->array
= &ctx
->Array
.SecondaryColor
;
1103 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1106 if (ctx
->Array
.FogCoord
.Enabled
) {
1107 aa
->array
= &ctx
->Array
.FogCoord
;
1108 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1111 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1112 struct gl_client_array
*attribArray
= &ctx
->Array
.TexCoord
[i
];
1113 if (attribArray
->Enabled
) {
1114 /* NOTE: we use generic glVertexAttribNV functions here.
1115 * If we ever remove GL_NV_vertex_program this will have to change.
1117 at
->array
= attribArray
;
1118 ASSERT(!at
->array
->Normalized
);
1119 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1121 [TYPE_IDX(at
->array
->Type
)];
1122 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1127 /* generic vertex attribute arrays */
1128 for (i
= 1; i
< VERT_ATTRIB_MAX
; i
++) { /* skip zero! */
1129 struct gl_client_array
*attribArray
= &ctx
->Array
.VertexAttrib
[i
];
1130 if (attribArray
->Enabled
) {
1131 at
->array
= attribArray
;
1132 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1133 * function pointer here (for float arrays) since the pointer may
1134 * change from one execution of _ae_loopback_array_elt() to
1135 * the next. Doing so caused UT to break.
1137 if (ctx
->VertexProgram
._Enabled
1138 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1139 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1141 [TYPE_IDX(at
->array
->Type
)];
1144 at
->func
= AttribFuncsARB
[at
->array
->Normalized
]
1146 [TYPE_IDX(at
->array
->Type
)];
1153 /* finally, vertex position */
1154 if (ctx
->Array
.VertexAttrib
[0].Enabled
) {
1155 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1156 * issued as the last (provoking) attribute).
1158 aa
->array
= &ctx
->Array
.VertexAttrib
[0];
1159 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1160 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1163 else if (ctx
->Array
.Vertex
.Enabled
) {
1164 aa
->array
= &ctx
->Array
.Vertex
;
1165 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1169 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1170 ASSERT(aa
- actx
->arrays
< 32);
1171 at
->func
= NULL
; /* terminate the list */
1172 aa
->offset
= -1; /* terminate the list */
1179 * Called via glArrayElement() and glDrawArrays().
1180 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1181 * for all enabled vertex arrays (for elt-th element).
1182 * Note: this may be called during display list construction.
1184 void GLAPIENTRY
_ae_loopback_array_elt( GLint elt
)
1186 GET_CURRENT_CONTEXT(ctx
);
1187 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1190 const struct _glapi_table
* const disp
= GET_DISPATCH();
1194 _ae_update_state( ctx
);
1196 /* generic attributes */
1197 for (at
= actx
->attribs
; at
->func
; at
++) {
1199 = ADD_POINTERS(at
->array
->BufferObj
->Data
, at
->array
->Ptr
)
1200 + elt
* at
->array
->StrideB
;
1201 at
->func( at
->index
, src
);
1204 /* conventional arrays */
1205 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1207 = ADD_POINTERS(aa
->array
->BufferObj
->Data
, aa
->array
->Ptr
)
1208 + elt
* aa
->array
->StrideB
;
1209 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1210 ((const void *) src
) );
1215 void _ae_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
1217 AE_CONTEXT(ctx
)->NewState
|= new_state
;