2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 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"
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)
61 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
62 * in the range [0, 7]. Luckily these type tokens are sequentially
63 * numbered in gl.h, except for GL_DOUBLE.
65 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
67 static void GLAPIENTRY
Color3bv(const GLbyte
*v
)
72 static void GLAPIENTRY
Color3ubv(const GLubyte
*v
)
74 GL_CALL(Color3ubv
)(v
);
77 static void GLAPIENTRY
Color3sv(const GLshort
*v
)
82 static void GLAPIENTRY
Color3usv(const GLushort
*v
)
84 GL_CALL(Color3usv
)(v
);
87 static void GLAPIENTRY
Color3iv(const GLint
*v
)
92 static void GLAPIENTRY
Color3uiv(const GLuint
*v
)
94 GL_CALL(Color3uiv
)(v
);
97 static void GLAPIENTRY
Color3fv(const GLfloat
*v
)
102 static void GLAPIENTRY
Color3dv(const GLdouble
*v
)
104 GL_CALL(Color3dv
)(v
);
107 static void GLAPIENTRY
Color4bv(const GLbyte
*v
)
109 GL_CALL(Color4bv
)(v
);
112 static void GLAPIENTRY
Color4ubv(const GLubyte
*v
)
114 GL_CALL(Color4ubv
)(v
);
117 static void GLAPIENTRY
Color4sv(const GLshort
*v
)
119 GL_CALL(Color4sv
)(v
);
122 static void GLAPIENTRY
Color4usv(const GLushort
*v
)
124 GL_CALL(Color4usv
)(v
);
127 static void GLAPIENTRY
Color4iv(const GLint
*v
)
129 GL_CALL(Color4iv
)(v
);
132 static void GLAPIENTRY
Color4uiv(const GLuint
*v
)
134 GL_CALL(Color4uiv
)(v
);
137 static void GLAPIENTRY
Color4fv(const GLfloat
*v
)
139 GL_CALL(Color4fv
)(v
);
142 static void GLAPIENTRY
Color4dv(const GLdouble
*v
)
144 GL_CALL(Color4dv
)(v
);
147 static const array_func ColorFuncs
[2][8] = {
149 (array_func
) Color3bv
,
150 (array_func
) Color3ubv
,
151 (array_func
) Color3sv
,
152 (array_func
) Color3usv
,
153 (array_func
) Color3iv
,
154 (array_func
) Color3uiv
,
155 (array_func
) Color3fv
,
156 (array_func
) Color3dv
,
159 (array_func
) Color4bv
,
160 (array_func
) Color4ubv
,
161 (array_func
) Color4sv
,
162 (array_func
) Color4usv
,
163 (array_func
) Color4iv
,
164 (array_func
) Color4uiv
,
165 (array_func
) Color4fv
,
166 (array_func
) Color4dv
,
170 static void GLAPIENTRY
Vertex2sv(const GLshort
*v
)
172 GL_CALL(Vertex2sv
)(v
);
175 static void GLAPIENTRY
Vertex2iv(const GLint
*v
)
177 GL_CALL(Vertex2iv
)(v
);
180 static void GLAPIENTRY
Vertex2fv(const GLfloat
*v
)
182 GL_CALL(Vertex2fv
)(v
);
185 static void GLAPIENTRY
Vertex2dv(const GLdouble
*v
)
187 GL_CALL(Vertex2dv
)(v
);
190 static void GLAPIENTRY
Vertex3sv(const GLshort
*v
)
192 GL_CALL(Vertex3sv
)(v
);
195 static void GLAPIENTRY
Vertex3iv(const GLint
*v
)
197 GL_CALL(Vertex3iv
)(v
);
200 static void GLAPIENTRY
Vertex3fv(const GLfloat
*v
)
202 GL_CALL(Vertex3fv
)(v
);
205 static void GLAPIENTRY
Vertex3dv(const GLdouble
*v
)
207 GL_CALL(Vertex3dv
)(v
);
210 static void GLAPIENTRY
Vertex4sv(const GLshort
*v
)
212 GL_CALL(Vertex4sv
)(v
);
215 static void GLAPIENTRY
Vertex4iv(const GLint
*v
)
217 GL_CALL(Vertex4iv
)(v
);
220 static void GLAPIENTRY
Vertex4fv(const GLfloat
*v
)
222 GL_CALL(Vertex4fv
)(v
);
225 static void GLAPIENTRY
Vertex4dv(const GLdouble
*v
)
227 GL_CALL(Vertex4dv
)(v
);
230 static const array_func VertexFuncs
[3][8] = {
234 (array_func
) Vertex2sv
,
236 (array_func
) Vertex2iv
,
238 (array_func
) Vertex2fv
,
239 (array_func
) Vertex2dv
,
244 (array_func
) Vertex3sv
,
246 (array_func
) Vertex3iv
,
248 (array_func
) Vertex3fv
,
249 (array_func
) Vertex3dv
,
254 (array_func
) Vertex4sv
,
256 (array_func
) Vertex4iv
,
258 (array_func
) Vertex4fv
,
259 (array_func
) Vertex4dv
,
263 static void GLAPIENTRY
Indexubv(const GLubyte
*c
)
265 GL_CALL(Indexubv
)(c
);
268 static void GLAPIENTRY
Indexsv(const GLshort
*c
)
273 static void GLAPIENTRY
Indexiv(const GLint
*c
)
278 static void GLAPIENTRY
Indexfv(const GLfloat
*c
)
283 static void GLAPIENTRY
Indexdv(const GLdouble
*c
)
288 static const array_func IndexFuncs
[8] = {
290 (array_func
) Indexubv
,
291 (array_func
) Indexsv
,
293 (array_func
) Indexiv
,
295 (array_func
) Indexfv
,
296 (array_func
) Indexdv
,
299 static void GLAPIENTRY
Normal3bv(const GLbyte
*v
)
301 GL_CALL(Normal3bv
)(v
);
304 static void GLAPIENTRY
Normal3sv(const GLshort
*v
)
306 GL_CALL(Normal3sv
)(v
);
309 static void GLAPIENTRY
Normal3iv(const GLint
*v
)
311 GL_CALL(Normal3iv
)(v
);
314 static void GLAPIENTRY
Normal3fv(const GLfloat
*v
)
316 GL_CALL(Normal3fv
)(v
);
319 static void GLAPIENTRY
Normal3dv(const GLdouble
*v
)
321 GL_CALL(Normal3dv
)(v
);
324 static const array_func NormalFuncs
[8] = {
325 (array_func
) Normal3bv
,
327 (array_func
) Normal3sv
,
329 (array_func
) Normal3iv
,
331 (array_func
) Normal3fv
,
332 (array_func
) Normal3dv
,
335 /* Wrapper functions in case glSecondaryColor*EXT doesn't exist */
336 static void GLAPIENTRY
SecondaryColor3bvEXT(const GLbyte
*c
)
338 GL_CALL(SecondaryColor3bvEXT
)(c
);
341 static void GLAPIENTRY
SecondaryColor3ubvEXT(const GLubyte
*c
)
343 GL_CALL(SecondaryColor3ubvEXT
)(c
);
346 static void GLAPIENTRY
SecondaryColor3svEXT(const GLshort
*c
)
348 GL_CALL(SecondaryColor3svEXT
)(c
);
351 static void GLAPIENTRY
SecondaryColor3usvEXT(const GLushort
*c
)
353 GL_CALL(SecondaryColor3usvEXT
)(c
);
356 static void GLAPIENTRY
SecondaryColor3ivEXT(const GLint
*c
)
358 GL_CALL(SecondaryColor3ivEXT
)(c
);
361 static void GLAPIENTRY
SecondaryColor3uivEXT(const GLuint
*c
)
363 GL_CALL(SecondaryColor3uivEXT
)(c
);
366 static void GLAPIENTRY
SecondaryColor3fvEXT(const GLfloat
*c
)
368 GL_CALL(SecondaryColor3fvEXT
)(c
);
371 static void GLAPIENTRY
SecondaryColor3dvEXT(const GLdouble
*c
)
373 GL_CALL(SecondaryColor3dvEXT
)(c
);
376 static const array_func SecondaryColorFuncs
[8] = {
377 (array_func
) SecondaryColor3bvEXT
,
378 (array_func
) SecondaryColor3ubvEXT
,
379 (array_func
) SecondaryColor3svEXT
,
380 (array_func
) SecondaryColor3usvEXT
,
381 (array_func
) SecondaryColor3ivEXT
,
382 (array_func
) SecondaryColor3uivEXT
,
383 (array_func
) SecondaryColor3fvEXT
,
384 (array_func
) SecondaryColor3dvEXT
,
388 /* Again, wrapper functions in case glSecondaryColor*EXT doesn't exist */
389 static void GLAPIENTRY
FogCoordfvEXT(const GLfloat
*f
)
391 GL_CALL(FogCoordfvEXT
)(f
);
394 static void GLAPIENTRY
FogCoorddvEXT(const GLdouble
*f
)
396 GL_CALL(FogCoorddvEXT
)(f
);
399 static const array_func FogCoordFuncs
[8] = {
406 (array_func
) FogCoordfvEXT
,
407 (array_func
) FogCoorddvEXT
410 /**********************************************************************/
412 /* GL_BYTE attributes */
414 static void GLAPIENTRY
VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
416 GL_CALL(VertexAttrib1fNV
)(index
, BYTE_TO_FLOAT(v
[0]));
419 static void GLAPIENTRY
VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
421 GL_CALL(VertexAttrib1fNV
)(index
, v
[0]);
424 static void GLAPIENTRY
VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
426 GL_CALL(VertexAttrib2fNV
)(index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1]));
429 static void GLAPIENTRY
VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
431 GL_CALL(VertexAttrib2fNV
)(index
, v
[0], v
[1]);
434 static void GLAPIENTRY
VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
436 GL_CALL(VertexAttrib3fNV
)(index
, BYTE_TO_FLOAT(v
[0]),
438 BYTE_TO_FLOAT(v
[2]));
441 static void GLAPIENTRY
VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
443 GL_CALL(VertexAttrib3fNV
)(index
, v
[0], v
[1], v
[2]);
446 static void GLAPIENTRY
VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
448 GL_CALL(VertexAttrib4fNV
)(index
, BYTE_TO_FLOAT(v
[0]),
451 BYTE_TO_FLOAT(v
[3]));
454 static void GLAPIENTRY
VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
456 GL_CALL(VertexAttrib4fNV
)(index
, v
[0], v
[1], v
[2], v
[3]);
459 /* GL_UNSIGNED_BYTE attributes */
461 static void GLAPIENTRY
VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
463 GL_CALL(VertexAttrib1fNV
)(index
, UBYTE_TO_FLOAT(v
[0]));
466 static void GLAPIENTRY
VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
468 GL_CALL(VertexAttrib1fNV
)(index
, v
[0]);
471 static void GLAPIENTRY
VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
473 GL_CALL(VertexAttrib2fNV
)(index
, UBYTE_TO_FLOAT(v
[0]),
474 UBYTE_TO_FLOAT(v
[1]));
477 static void GLAPIENTRY
VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
479 GL_CALL(VertexAttrib2fNV
)(index
, v
[0], v
[1]);
482 static void GLAPIENTRY
VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
484 GL_CALL(VertexAttrib3fNV
)(index
, UBYTE_TO_FLOAT(v
[0]),
485 UBYTE_TO_FLOAT(v
[1]),
486 UBYTE_TO_FLOAT(v
[2]));
488 static void GLAPIENTRY
VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
490 GL_CALL(VertexAttrib3fNV
)(index
, v
[0], v
[1], v
[2]);
493 static void GLAPIENTRY
VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
495 GL_CALL(VertexAttrib4fNV
)(index
, UBYTE_TO_FLOAT(v
[0]),
496 UBYTE_TO_FLOAT(v
[1]),
497 UBYTE_TO_FLOAT(v
[2]),
498 UBYTE_TO_FLOAT(v
[3]));
501 static void GLAPIENTRY
VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
503 GL_CALL(VertexAttrib4fNV
)(index
, v
[0], v
[1], v
[2], v
[3]);
506 /* GL_SHORT attributes */
508 static void GLAPIENTRY
VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
510 GL_CALL(VertexAttrib1fNV
)(index
, SHORT_TO_FLOAT(v
[0]));
513 static void GLAPIENTRY
VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
515 GL_CALL(VertexAttrib1fNV
)(index
, v
[0]);
518 static void GLAPIENTRY
VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
520 GL_CALL(VertexAttrib2fNV
)(index
, SHORT_TO_FLOAT(v
[0]),
521 SHORT_TO_FLOAT(v
[1]));
524 static void GLAPIENTRY
VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
526 GL_CALL(VertexAttrib2fNV
)(index
, v
[0], v
[1]);
529 static void GLAPIENTRY
VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
531 GL_CALL(VertexAttrib3fNV
)(index
, SHORT_TO_FLOAT(v
[0]),
532 SHORT_TO_FLOAT(v
[1]),
533 SHORT_TO_FLOAT(v
[2]));
536 static void GLAPIENTRY
VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
538 GL_CALL(VertexAttrib3fNV
)(index
, v
[0], v
[1], v
[2]);
541 static void GLAPIENTRY
VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
543 GL_CALL(VertexAttrib4fNV
)(index
, SHORT_TO_FLOAT(v
[0]),
544 SHORT_TO_FLOAT(v
[1]),
545 SHORT_TO_FLOAT(v
[2]),
546 SHORT_TO_FLOAT(v
[3]));
549 static void GLAPIENTRY
VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
551 GL_CALL(VertexAttrib4fNV
)(index
, v
[0], v
[1], v
[2], v
[3]);
554 /* GL_UNSIGNED_SHORT attributes */
556 static void GLAPIENTRY
VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
558 GL_CALL(VertexAttrib1fNV
)(index
, USHORT_TO_FLOAT(v
[0]));
561 static void GLAPIENTRY
VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
563 GL_CALL(VertexAttrib1fNV
)(index
, v
[0]);
566 static void GLAPIENTRY
VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
568 GL_CALL(VertexAttrib2fNV
)(index
, USHORT_TO_FLOAT(v
[0]),
569 USHORT_TO_FLOAT(v
[1]));
572 static void GLAPIENTRY
VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
574 GL_CALL(VertexAttrib2fNV
)(index
, v
[0], v
[1]);
577 static void GLAPIENTRY
VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
579 GL_CALL(VertexAttrib3fNV
)(index
, USHORT_TO_FLOAT(v
[0]),
580 USHORT_TO_FLOAT(v
[1]),
581 USHORT_TO_FLOAT(v
[2]));
584 static void GLAPIENTRY
VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
586 GL_CALL(VertexAttrib3fNV
)(index
, v
[0], v
[1], v
[2]);
589 static void GLAPIENTRY
VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
591 GL_CALL(VertexAttrib4fNV
)(index
, USHORT_TO_FLOAT(v
[0]),
592 USHORT_TO_FLOAT(v
[1]),
593 USHORT_TO_FLOAT(v
[2]),
594 USHORT_TO_FLOAT(v
[3]));
597 static void GLAPIENTRY
VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
599 GL_CALL(VertexAttrib4fNV
)(index
, v
[0], v
[1], v
[2], v
[3]);
602 /* GL_INT attributes */
604 static void GLAPIENTRY
VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
606 GL_CALL(VertexAttrib1fNV
)(index
, INT_TO_FLOAT(v
[0]));
609 static void GLAPIENTRY
VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
611 GL_CALL(VertexAttrib1fNV
)(index
, v
[0]);
614 static void GLAPIENTRY
VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
616 GL_CALL(VertexAttrib2fNV
)(index
, INT_TO_FLOAT(v
[0]),
620 static void GLAPIENTRY
VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
622 GL_CALL(VertexAttrib2fNV
)(index
, v
[0], v
[1]);
625 static void GLAPIENTRY
VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
627 GL_CALL(VertexAttrib3fNV
)(index
, INT_TO_FLOAT(v
[0]),
632 static void GLAPIENTRY
VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
634 GL_CALL(VertexAttrib3fNV
)(index
, v
[0], v
[1], v
[2]);
637 static void GLAPIENTRY
VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
639 GL_CALL(VertexAttrib4fNV
)(index
, INT_TO_FLOAT(v
[0]),
645 static void GLAPIENTRY
VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
647 GL_CALL(VertexAttrib4fNV
)(index
, v
[0], v
[1], v
[2], v
[3]);
650 /* GL_UNSIGNED_INT attributes */
652 static void GLAPIENTRY
VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
654 GL_CALL(VertexAttrib1fNV
)(index
, UINT_TO_FLOAT(v
[0]));
657 static void GLAPIENTRY
VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
659 GL_CALL(VertexAttrib1fNV
)(index
, v
[0]);
662 static void GLAPIENTRY
VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
664 GL_CALL(VertexAttrib2fNV
)(index
, UINT_TO_FLOAT(v
[0]),
665 UINT_TO_FLOAT(v
[1]));
668 static void GLAPIENTRY
VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
670 GL_CALL(VertexAttrib2fNV
)(index
, v
[0], v
[1]);
673 static void GLAPIENTRY
VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
675 GL_CALL(VertexAttrib3fNV
)(index
, UINT_TO_FLOAT(v
[0]),
677 UINT_TO_FLOAT(v
[2]));
680 static void GLAPIENTRY
VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
682 GL_CALL(VertexAttrib3fNV
)(index
, v
[0], v
[1], v
[2]);
685 static void GLAPIENTRY
VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
687 GL_CALL(VertexAttrib4fNV
)(index
, UINT_TO_FLOAT(v
[0]),
690 UINT_TO_FLOAT(v
[3]));
693 static void GLAPIENTRY
VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
695 GL_CALL(VertexAttrib4fNV
)(index
, v
[0], v
[1], v
[2], v
[3]);
698 /* GL_FLOAT attributes */
700 static void GLAPIENTRY
VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
702 GL_CALL(VertexAttrib1fvNV
)(index
, v
);
705 static void GLAPIENTRY
VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
707 GL_CALL(VertexAttrib2fvNV
)(index
, v
);
710 static void GLAPIENTRY
VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
712 GL_CALL(VertexAttrib3fvNV
)(index
, v
);
715 static void GLAPIENTRY
VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
717 GL_CALL(VertexAttrib4fvNV
)(index
, v
);
720 /* GL_DOUBLE attributes */
722 static void GLAPIENTRY
VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
724 GL_CALL(VertexAttrib1dvNV
)(index
, v
);
727 static void GLAPIENTRY
VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
729 GL_CALL(VertexAttrib2dvNV
)(index
, v
);
732 static void GLAPIENTRY
VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
734 GL_CALL(VertexAttrib3dvNV
)(index
, v
);
737 static void GLAPIENTRY
VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
739 GL_CALL(VertexAttrib4dvNV
)(index
, v
);
744 * Array [size][type] of VertexAttrib functions
746 static attrib_func AttribFuncsNV
[2][4][8] = {
751 (attrib_func
) VertexAttrib1bvNV
,
752 (attrib_func
) VertexAttrib1ubvNV
,
753 (attrib_func
) VertexAttrib1svNV
,
754 (attrib_func
) VertexAttrib1usvNV
,
755 (attrib_func
) VertexAttrib1ivNV
,
756 (attrib_func
) VertexAttrib1uivNV
,
757 (attrib_func
) VertexAttrib1fvNV
,
758 (attrib_func
) VertexAttrib1dvNV
762 (attrib_func
) VertexAttrib2bvNV
,
763 (attrib_func
) VertexAttrib2ubvNV
,
764 (attrib_func
) VertexAttrib2svNV
,
765 (attrib_func
) VertexAttrib2usvNV
,
766 (attrib_func
) VertexAttrib2ivNV
,
767 (attrib_func
) VertexAttrib2uivNV
,
768 (attrib_func
) VertexAttrib2fvNV
,
769 (attrib_func
) VertexAttrib2dvNV
773 (attrib_func
) VertexAttrib3bvNV
,
774 (attrib_func
) VertexAttrib3ubvNV
,
775 (attrib_func
) VertexAttrib3svNV
,
776 (attrib_func
) VertexAttrib3usvNV
,
777 (attrib_func
) VertexAttrib3ivNV
,
778 (attrib_func
) VertexAttrib3uivNV
,
779 (attrib_func
) VertexAttrib3fvNV
,
780 (attrib_func
) VertexAttrib3dvNV
784 (attrib_func
) VertexAttrib4bvNV
,
785 (attrib_func
) VertexAttrib4ubvNV
,
786 (attrib_func
) VertexAttrib4svNV
,
787 (attrib_func
) VertexAttrib4usvNV
,
788 (attrib_func
) VertexAttrib4ivNV
,
789 (attrib_func
) VertexAttrib4uivNV
,
790 (attrib_func
) VertexAttrib4fvNV
,
791 (attrib_func
) VertexAttrib4dvNV
795 /* normalized (except for float/double) */
798 (attrib_func
) VertexAttrib1NbvNV
,
799 (attrib_func
) VertexAttrib1NubvNV
,
800 (attrib_func
) VertexAttrib1NsvNV
,
801 (attrib_func
) VertexAttrib1NusvNV
,
802 (attrib_func
) VertexAttrib1NivNV
,
803 (attrib_func
) VertexAttrib1NuivNV
,
804 (attrib_func
) VertexAttrib1fvNV
,
805 (attrib_func
) VertexAttrib1dvNV
809 (attrib_func
) VertexAttrib2NbvNV
,
810 (attrib_func
) VertexAttrib2NubvNV
,
811 (attrib_func
) VertexAttrib2NsvNV
,
812 (attrib_func
) VertexAttrib2NusvNV
,
813 (attrib_func
) VertexAttrib2NivNV
,
814 (attrib_func
) VertexAttrib2NuivNV
,
815 (attrib_func
) VertexAttrib2fvNV
,
816 (attrib_func
) VertexAttrib2dvNV
820 (attrib_func
) VertexAttrib3NbvNV
,
821 (attrib_func
) VertexAttrib3NubvNV
,
822 (attrib_func
) VertexAttrib3NsvNV
,
823 (attrib_func
) VertexAttrib3NusvNV
,
824 (attrib_func
) VertexAttrib3NivNV
,
825 (attrib_func
) VertexAttrib3NuivNV
,
826 (attrib_func
) VertexAttrib3fvNV
,
827 (attrib_func
) VertexAttrib3dvNV
831 (attrib_func
) VertexAttrib4NbvNV
,
832 (attrib_func
) VertexAttrib4NubvNV
,
833 (attrib_func
) VertexAttrib4NsvNV
,
834 (attrib_func
) VertexAttrib4NusvNV
,
835 (attrib_func
) VertexAttrib4NivNV
,
836 (attrib_func
) VertexAttrib4NuivNV
,
837 (attrib_func
) VertexAttrib4fvNV
,
838 (attrib_func
) VertexAttrib4dvNV
843 static void GLAPIENTRY
EdgeFlagv(const GLboolean
*flag
)
845 GL_CALL(EdgeFlagv
)(flag
);
848 /**********************************************************************/
851 GLboolean
_ae_create_context( GLcontext
*ctx
)
853 if (ctx
->aelt_context
)
856 ctx
->aelt_context
= MALLOC( sizeof(AEcontext
) );
857 if (!ctx
->aelt_context
)
860 AE_CONTEXT(ctx
)->NewState
= ~0;
865 void _ae_destroy_context( GLcontext
*ctx
)
867 if ( AE_CONTEXT( ctx
) ) {
868 FREE( ctx
->aelt_context
);
869 ctx
->aelt_context
= NULL
;
875 * Make a list of per-vertex functions to call for each glArrayElement call.
876 * These functions access the array data (i.e. glVertex, glColor, glNormal,
878 * Note: this may be called during display list construction.
880 static void _ae_update_state( GLcontext
*ctx
)
882 AEcontext
*actx
= AE_CONTEXT(ctx
);
883 AEarray
*aa
= actx
->arrays
;
884 AEattrib
*at
= actx
->attribs
;
887 /* conventional vertex arrays */
888 if (ctx
->Array
.Index
.Enabled
) {
889 aa
->array
= &ctx
->Array
.Index
;
890 aa
->func
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
893 if (ctx
->Array
.EdgeFlag
.Enabled
) {
894 aa
->array
= &ctx
->Array
.EdgeFlag
;
895 aa
->func
= (array_func
) EdgeFlagv
;
898 if (ctx
->Array
.Normal
.Enabled
) {
899 aa
->array
= &ctx
->Array
.Normal
;
900 aa
->func
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
903 if (ctx
->Array
.Color
.Enabled
) {
904 aa
->array
= &ctx
->Array
.Color
;
905 aa
->func
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
908 if (ctx
->Array
.SecondaryColor
.Enabled
) {
909 aa
->array
= &ctx
->Array
.SecondaryColor
;
910 aa
->func
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
913 if (ctx
->Array
.FogCoord
.Enabled
) {
914 aa
->array
= &ctx
->Array
.FogCoord
;
915 aa
->func
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
918 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
919 if (ctx
->Array
.TexCoord
[i
].Enabled
) {
920 /* NOTE: we use generic glVertexAttrib functions here.
921 * If we ever de-alias conventional/generic vertex attribs this
922 * will have to change.
924 struct gl_client_array
*attribArray
= &ctx
->Array
.TexCoord
[i
];
925 at
->array
= attribArray
;
926 at
->func
= AttribFuncsNV
[at
->array
->Normalized
][at
->array
->Size
-1][TYPE_IDX(at
->array
->Type
)];
927 at
->index
= VERT_ATTRIB_TEX0
+ i
;
932 /* generic vertex attribute arrays */
933 for (i
= 1; i
< VERT_ATTRIB_MAX
; i
++) { /* skip zero! */
934 if (ctx
->Array
.VertexAttrib
[i
].Enabled
) {
935 struct gl_client_array
*attribArray
= &ctx
->Array
.VertexAttrib
[i
];
936 at
->array
= attribArray
;
937 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
938 * function pointer here (for float arrays) since the pointer may
939 * change from one execution of _ae_loopback_array_elt() to
940 * the next. Doing so caused UT to break.
942 at
->func
= AttribFuncsNV
[at
->array
->Normalized
][at
->array
->Size
-1][TYPE_IDX(at
->array
->Type
)];
948 /* finally, vertex position */
949 if (ctx
->Array
.VertexAttrib
[0].Enabled
) {
950 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
951 * issued as the last (proviking) attribute).
953 aa
->array
= &ctx
->Array
.VertexAttrib
[0];
954 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
955 aa
->func
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
958 else if (ctx
->Array
.Vertex
.Enabled
) {
959 aa
->array
= &ctx
->Array
.Vertex
;
960 aa
->func
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
964 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
965 ASSERT(aa
- actx
->arrays
< 32);
966 at
->func
= NULL
; /* terminate the list */
967 aa
->func
= NULL
; /* terminate the list */
974 * Called via glArrayElement() and glDrawArrays().
975 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
976 * for all enabled vertex arrays (for elt-th element).
977 * Note: this may be called during display list construction.
979 void GLAPIENTRY
_ae_loopback_array_elt( GLint elt
)
981 GET_CURRENT_CONTEXT(ctx
);
982 const AEcontext
*actx
= AE_CONTEXT(ctx
);
987 _ae_update_state( ctx
);
989 /* generic attributes */
990 for (at
= actx
->attribs
; at
->func
; at
++) {
991 const GLubyte
*src
= at
->array
->BufferObj
->Data
992 + (uintptr_t) at
->array
->Ptr
993 + elt
* at
->array
->StrideB
;
994 at
->func( at
->index
, src
);
997 /* conventional arrays */
998 for (aa
= actx
->arrays
; aa
->func
; aa
++) {
999 const GLubyte
*src
= aa
->array
->BufferObj
->Data
1000 + (uintptr_t) aa
->array
->Ptr
1001 + elt
* aa
->array
->StrideB
;
1007 void _ae_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
1009 AE_CONTEXT(ctx
)->NewState
|= new_state
;