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"
31 #include "bufferobj.h"
35 #include "main/dispatch.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];
57 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
59 GLboolean mapped_vbos
;
63 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
67 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
68 * in the range [0, 7]. Luckily these type tokens are sequentially
69 * numbered in gl.h, except for GL_DOUBLE.
71 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
77 static const int ColorFuncs
[2][8] = {
100 static const int VertexFuncs
[3][8] = {
133 static const int IndexFuncs
[8] = {
144 static const int NormalFuncs
[8] = {
155 /* Note: _gloffset_* for these may not be a compile-time constant. */
156 static int SecondaryColorFuncs
[8];
157 static int FogCoordFuncs
[8];
161 ** GL_NV_vertex_program
164 /* GL_BYTE attributes */
166 static void GLAPIENTRY
VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
168 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
171 static void GLAPIENTRY
VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
173 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
176 static void GLAPIENTRY
VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
178 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
181 static void GLAPIENTRY
VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
183 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
186 static void GLAPIENTRY
VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
188 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
190 BYTE_TO_FLOAT(v
[2])));
193 static void GLAPIENTRY
VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
195 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
198 static void GLAPIENTRY
VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
200 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
203 BYTE_TO_FLOAT(v
[3])));
206 static void GLAPIENTRY
VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
208 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
211 /* GL_UNSIGNED_BYTE attributes */
213 static void GLAPIENTRY
VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
215 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
218 static void GLAPIENTRY
VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
220 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
223 static void GLAPIENTRY
VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
225 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
226 UBYTE_TO_FLOAT(v
[1])));
229 static void GLAPIENTRY
VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
231 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
234 static void GLAPIENTRY
VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
236 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
237 UBYTE_TO_FLOAT(v
[1]),
238 UBYTE_TO_FLOAT(v
[2])));
240 static void GLAPIENTRY
VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
242 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
245 static void GLAPIENTRY
VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
247 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
248 UBYTE_TO_FLOAT(v
[1]),
249 UBYTE_TO_FLOAT(v
[2]),
250 UBYTE_TO_FLOAT(v
[3])));
253 static void GLAPIENTRY
VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
255 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
258 /* GL_SHORT attributes */
260 static void GLAPIENTRY
VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
262 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
265 static void GLAPIENTRY
VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
267 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
270 static void GLAPIENTRY
VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
272 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
273 SHORT_TO_FLOAT(v
[1])));
276 static void GLAPIENTRY
VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
278 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
281 static void GLAPIENTRY
VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
283 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
284 SHORT_TO_FLOAT(v
[1]),
285 SHORT_TO_FLOAT(v
[2])));
288 static void GLAPIENTRY
VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
290 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
293 static void GLAPIENTRY
VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
295 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
296 SHORT_TO_FLOAT(v
[1]),
297 SHORT_TO_FLOAT(v
[2]),
298 SHORT_TO_FLOAT(v
[3])));
301 static void GLAPIENTRY
VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
303 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
306 /* GL_UNSIGNED_SHORT attributes */
308 static void GLAPIENTRY
VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
310 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
313 static void GLAPIENTRY
VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
315 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
318 static void GLAPIENTRY
VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
320 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
321 USHORT_TO_FLOAT(v
[1])));
324 static void GLAPIENTRY
VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
326 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
329 static void GLAPIENTRY
VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
331 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
332 USHORT_TO_FLOAT(v
[1]),
333 USHORT_TO_FLOAT(v
[2])));
336 static void GLAPIENTRY
VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
338 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
341 static void GLAPIENTRY
VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
343 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
344 USHORT_TO_FLOAT(v
[1]),
345 USHORT_TO_FLOAT(v
[2]),
346 USHORT_TO_FLOAT(v
[3])));
349 static void GLAPIENTRY
VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
351 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
354 /* GL_INT attributes */
356 static void GLAPIENTRY
VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
358 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
361 static void GLAPIENTRY
VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
363 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
366 static void GLAPIENTRY
VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
368 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
369 INT_TO_FLOAT(v
[1])));
372 static void GLAPIENTRY
VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
374 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
377 static void GLAPIENTRY
VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
379 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
381 INT_TO_FLOAT(v
[2])));
384 static void GLAPIENTRY
VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
386 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
389 static void GLAPIENTRY
VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
391 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
394 INT_TO_FLOAT(v
[3])));
397 static void GLAPIENTRY
VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
399 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
402 /* GL_UNSIGNED_INT attributes */
404 static void GLAPIENTRY
VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
406 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
409 static void GLAPIENTRY
VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
411 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
414 static void GLAPIENTRY
VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
416 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
417 UINT_TO_FLOAT(v
[1])));
420 static void GLAPIENTRY
VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
422 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
425 static void GLAPIENTRY
VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
427 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
429 UINT_TO_FLOAT(v
[2])));
432 static void GLAPIENTRY
VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
434 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
437 static void GLAPIENTRY
VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
439 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
442 UINT_TO_FLOAT(v
[3])));
445 static void GLAPIENTRY
VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
447 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
450 /* GL_FLOAT attributes */
452 static void GLAPIENTRY
VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
454 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
457 static void GLAPIENTRY
VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
459 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
462 static void GLAPIENTRY
VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
464 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
467 static void GLAPIENTRY
VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
469 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
472 /* GL_DOUBLE attributes */
474 static void GLAPIENTRY
VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
476 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
479 static void GLAPIENTRY
VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
481 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
484 static void GLAPIENTRY
VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
486 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
489 static void GLAPIENTRY
VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
491 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
496 * Array [size][type] of VertexAttrib functions
498 static attrib_func AttribFuncsNV
[2][4][8] = {
503 (attrib_func
) VertexAttrib1bvNV
,
504 (attrib_func
) VertexAttrib1ubvNV
,
505 (attrib_func
) VertexAttrib1svNV
,
506 (attrib_func
) VertexAttrib1usvNV
,
507 (attrib_func
) VertexAttrib1ivNV
,
508 (attrib_func
) VertexAttrib1uivNV
,
509 (attrib_func
) VertexAttrib1fvNV
,
510 (attrib_func
) VertexAttrib1dvNV
514 (attrib_func
) VertexAttrib2bvNV
,
515 (attrib_func
) VertexAttrib2ubvNV
,
516 (attrib_func
) VertexAttrib2svNV
,
517 (attrib_func
) VertexAttrib2usvNV
,
518 (attrib_func
) VertexAttrib2ivNV
,
519 (attrib_func
) VertexAttrib2uivNV
,
520 (attrib_func
) VertexAttrib2fvNV
,
521 (attrib_func
) VertexAttrib2dvNV
525 (attrib_func
) VertexAttrib3bvNV
,
526 (attrib_func
) VertexAttrib3ubvNV
,
527 (attrib_func
) VertexAttrib3svNV
,
528 (attrib_func
) VertexAttrib3usvNV
,
529 (attrib_func
) VertexAttrib3ivNV
,
530 (attrib_func
) VertexAttrib3uivNV
,
531 (attrib_func
) VertexAttrib3fvNV
,
532 (attrib_func
) VertexAttrib3dvNV
536 (attrib_func
) VertexAttrib4bvNV
,
537 (attrib_func
) VertexAttrib4ubvNV
,
538 (attrib_func
) VertexAttrib4svNV
,
539 (attrib_func
) VertexAttrib4usvNV
,
540 (attrib_func
) VertexAttrib4ivNV
,
541 (attrib_func
) VertexAttrib4uivNV
,
542 (attrib_func
) VertexAttrib4fvNV
,
543 (attrib_func
) VertexAttrib4dvNV
547 /* normalized (except for float/double) */
550 (attrib_func
) VertexAttrib1NbvNV
,
551 (attrib_func
) VertexAttrib1NubvNV
,
552 (attrib_func
) VertexAttrib1NsvNV
,
553 (attrib_func
) VertexAttrib1NusvNV
,
554 (attrib_func
) VertexAttrib1NivNV
,
555 (attrib_func
) VertexAttrib1NuivNV
,
556 (attrib_func
) VertexAttrib1fvNV
,
557 (attrib_func
) VertexAttrib1dvNV
561 (attrib_func
) VertexAttrib2NbvNV
,
562 (attrib_func
) VertexAttrib2NubvNV
,
563 (attrib_func
) VertexAttrib2NsvNV
,
564 (attrib_func
) VertexAttrib2NusvNV
,
565 (attrib_func
) VertexAttrib2NivNV
,
566 (attrib_func
) VertexAttrib2NuivNV
,
567 (attrib_func
) VertexAttrib2fvNV
,
568 (attrib_func
) VertexAttrib2dvNV
572 (attrib_func
) VertexAttrib3NbvNV
,
573 (attrib_func
) VertexAttrib3NubvNV
,
574 (attrib_func
) VertexAttrib3NsvNV
,
575 (attrib_func
) VertexAttrib3NusvNV
,
576 (attrib_func
) VertexAttrib3NivNV
,
577 (attrib_func
) VertexAttrib3NuivNV
,
578 (attrib_func
) VertexAttrib3fvNV
,
579 (attrib_func
) VertexAttrib3dvNV
583 (attrib_func
) VertexAttrib4NbvNV
,
584 (attrib_func
) VertexAttrib4NubvNV
,
585 (attrib_func
) VertexAttrib4NsvNV
,
586 (attrib_func
) VertexAttrib4NusvNV
,
587 (attrib_func
) VertexAttrib4NivNV
,
588 (attrib_func
) VertexAttrib4NuivNV
,
589 (attrib_func
) VertexAttrib4fvNV
,
590 (attrib_func
) VertexAttrib4dvNV
597 ** GL_ARB_vertex_program
600 /* GL_BYTE attributes */
602 static void GLAPIENTRY
VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
604 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
607 static void GLAPIENTRY
VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
609 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
612 static void GLAPIENTRY
VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
614 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
617 static void GLAPIENTRY
VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
619 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
622 static void GLAPIENTRY
VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
624 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
626 BYTE_TO_FLOAT(v
[2])));
629 static void GLAPIENTRY
VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
631 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
634 static void GLAPIENTRY
VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
636 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
639 BYTE_TO_FLOAT(v
[3])));
642 static void GLAPIENTRY
VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
644 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
647 /* GL_UNSIGNED_BYTE attributes */
649 static void GLAPIENTRY
VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
651 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
654 static void GLAPIENTRY
VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
656 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
659 static void GLAPIENTRY
VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
661 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
662 UBYTE_TO_FLOAT(v
[1])));
665 static void GLAPIENTRY
VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
667 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
670 static void GLAPIENTRY
VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
672 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
673 UBYTE_TO_FLOAT(v
[1]),
674 UBYTE_TO_FLOAT(v
[2])));
676 static void GLAPIENTRY
VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
678 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
681 static void GLAPIENTRY
VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
683 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
684 UBYTE_TO_FLOAT(v
[1]),
685 UBYTE_TO_FLOAT(v
[2]),
686 UBYTE_TO_FLOAT(v
[3])));
689 static void GLAPIENTRY
VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
691 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
694 /* GL_SHORT attributes */
696 static void GLAPIENTRY
VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
698 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
701 static void GLAPIENTRY
VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
703 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
706 static void GLAPIENTRY
VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
708 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
709 SHORT_TO_FLOAT(v
[1])));
712 static void GLAPIENTRY
VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
714 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
717 static void GLAPIENTRY
VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
719 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
720 SHORT_TO_FLOAT(v
[1]),
721 SHORT_TO_FLOAT(v
[2])));
724 static void GLAPIENTRY
VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
726 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
729 static void GLAPIENTRY
VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
731 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
732 SHORT_TO_FLOAT(v
[1]),
733 SHORT_TO_FLOAT(v
[2]),
734 SHORT_TO_FLOAT(v
[3])));
737 static void GLAPIENTRY
VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
739 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
742 /* GL_UNSIGNED_SHORT attributes */
744 static void GLAPIENTRY
VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
746 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
749 static void GLAPIENTRY
VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
751 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
754 static void GLAPIENTRY
VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
756 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
757 USHORT_TO_FLOAT(v
[1])));
760 static void GLAPIENTRY
VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
762 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
765 static void GLAPIENTRY
VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
767 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
768 USHORT_TO_FLOAT(v
[1]),
769 USHORT_TO_FLOAT(v
[2])));
772 static void GLAPIENTRY
VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
774 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
777 static void GLAPIENTRY
VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
779 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
780 USHORT_TO_FLOAT(v
[1]),
781 USHORT_TO_FLOAT(v
[2]),
782 USHORT_TO_FLOAT(v
[3])));
785 static void GLAPIENTRY
VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
787 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
790 /* GL_INT attributes */
792 static void GLAPIENTRY
VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
794 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
797 static void GLAPIENTRY
VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
799 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
802 static void GLAPIENTRY
VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
804 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
805 INT_TO_FLOAT(v
[1])));
808 static void GLAPIENTRY
VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
810 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
813 static void GLAPIENTRY
VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
815 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
817 INT_TO_FLOAT(v
[2])));
820 static void GLAPIENTRY
VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
822 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
825 static void GLAPIENTRY
VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
827 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
830 INT_TO_FLOAT(v
[3])));
833 static void GLAPIENTRY
VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
835 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
838 /* GL_UNSIGNED_INT attributes */
840 static void GLAPIENTRY
VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
842 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
845 static void GLAPIENTRY
VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
847 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
850 static void GLAPIENTRY
VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
852 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
853 UINT_TO_FLOAT(v
[1])));
856 static void GLAPIENTRY
VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
858 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
861 static void GLAPIENTRY
VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
863 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
865 UINT_TO_FLOAT(v
[2])));
868 static void GLAPIENTRY
VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
870 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
873 static void GLAPIENTRY
VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
875 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
878 UINT_TO_FLOAT(v
[3])));
881 static void GLAPIENTRY
VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
883 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
886 /* GL_FLOAT attributes */
888 static void GLAPIENTRY
VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
890 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
893 static void GLAPIENTRY
VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
895 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
898 static void GLAPIENTRY
VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
900 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
903 static void GLAPIENTRY
VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
905 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
908 /* GL_DOUBLE attributes */
910 static void GLAPIENTRY
VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
912 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
915 static void GLAPIENTRY
VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
917 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
920 static void GLAPIENTRY
VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
922 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
925 static void GLAPIENTRY
VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
927 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
932 * Integer-valued attributes
935 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
937 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
941 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
943 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
947 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
949 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
953 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
955 CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
960 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
962 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
966 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
968 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
972 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
974 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
978 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
980 CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
986 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
988 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
992 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
994 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
998 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1000 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1004 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1006 CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
1011 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1013 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1017 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1019 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1023 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1025 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1029 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1031 CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
1037 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1039 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1043 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1045 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1049 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1051 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1055 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1057 CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
1062 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1064 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1068 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1070 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1074 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1076 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1080 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1082 CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2], v
[3]));
1089 * Array [size][type] of VertexAttrib functions
1091 static attrib_func AttribFuncsARB
[3][4][8] = {
1093 /* non-normalized */
1096 (attrib_func
) VertexAttrib1bvARB
,
1097 (attrib_func
) VertexAttrib1ubvARB
,
1098 (attrib_func
) VertexAttrib1svARB
,
1099 (attrib_func
) VertexAttrib1usvARB
,
1100 (attrib_func
) VertexAttrib1ivARB
,
1101 (attrib_func
) VertexAttrib1uivARB
,
1102 (attrib_func
) VertexAttrib1fvARB
,
1103 (attrib_func
) VertexAttrib1dvARB
1107 (attrib_func
) VertexAttrib2bvARB
,
1108 (attrib_func
) VertexAttrib2ubvARB
,
1109 (attrib_func
) VertexAttrib2svARB
,
1110 (attrib_func
) VertexAttrib2usvARB
,
1111 (attrib_func
) VertexAttrib2ivARB
,
1112 (attrib_func
) VertexAttrib2uivARB
,
1113 (attrib_func
) VertexAttrib2fvARB
,
1114 (attrib_func
) VertexAttrib2dvARB
1118 (attrib_func
) VertexAttrib3bvARB
,
1119 (attrib_func
) VertexAttrib3ubvARB
,
1120 (attrib_func
) VertexAttrib3svARB
,
1121 (attrib_func
) VertexAttrib3usvARB
,
1122 (attrib_func
) VertexAttrib3ivARB
,
1123 (attrib_func
) VertexAttrib3uivARB
,
1124 (attrib_func
) VertexAttrib3fvARB
,
1125 (attrib_func
) VertexAttrib3dvARB
1129 (attrib_func
) VertexAttrib4bvARB
,
1130 (attrib_func
) VertexAttrib4ubvARB
,
1131 (attrib_func
) VertexAttrib4svARB
,
1132 (attrib_func
) VertexAttrib4usvARB
,
1133 (attrib_func
) VertexAttrib4ivARB
,
1134 (attrib_func
) VertexAttrib4uivARB
,
1135 (attrib_func
) VertexAttrib4fvARB
,
1136 (attrib_func
) VertexAttrib4dvARB
1140 /* normalized (except for float/double) */
1143 (attrib_func
) VertexAttrib1NbvARB
,
1144 (attrib_func
) VertexAttrib1NubvARB
,
1145 (attrib_func
) VertexAttrib1NsvARB
,
1146 (attrib_func
) VertexAttrib1NusvARB
,
1147 (attrib_func
) VertexAttrib1NivARB
,
1148 (attrib_func
) VertexAttrib1NuivARB
,
1149 (attrib_func
) VertexAttrib1fvARB
,
1150 (attrib_func
) VertexAttrib1dvARB
1154 (attrib_func
) VertexAttrib2NbvARB
,
1155 (attrib_func
) VertexAttrib2NubvARB
,
1156 (attrib_func
) VertexAttrib2NsvARB
,
1157 (attrib_func
) VertexAttrib2NusvARB
,
1158 (attrib_func
) VertexAttrib2NivARB
,
1159 (attrib_func
) VertexAttrib2NuivARB
,
1160 (attrib_func
) VertexAttrib2fvARB
,
1161 (attrib_func
) VertexAttrib2dvARB
1165 (attrib_func
) VertexAttrib3NbvARB
,
1166 (attrib_func
) VertexAttrib3NubvARB
,
1167 (attrib_func
) VertexAttrib3NsvARB
,
1168 (attrib_func
) VertexAttrib3NusvARB
,
1169 (attrib_func
) VertexAttrib3NivARB
,
1170 (attrib_func
) VertexAttrib3NuivARB
,
1171 (attrib_func
) VertexAttrib3fvARB
,
1172 (attrib_func
) VertexAttrib3dvARB
1176 (attrib_func
) VertexAttrib4NbvARB
,
1177 (attrib_func
) VertexAttrib4NubvARB
,
1178 (attrib_func
) VertexAttrib4NsvARB
,
1179 (attrib_func
) VertexAttrib4NusvARB
,
1180 (attrib_func
) VertexAttrib4NivARB
,
1181 (attrib_func
) VertexAttrib4NuivARB
,
1182 (attrib_func
) VertexAttrib4fvARB
,
1183 (attrib_func
) VertexAttrib4dvARB
1188 /* integer-valued */
1191 (attrib_func
) VertexAttribI1bv
,
1192 (attrib_func
) VertexAttribI1ubv
,
1193 (attrib_func
) VertexAttribI1sv
,
1194 (attrib_func
) VertexAttribI1usv
,
1195 (attrib_func
) VertexAttribI1iv
,
1196 (attrib_func
) VertexAttribI1uiv
,
1197 NULL
, /* GL_FLOAT */
1198 NULL
/* GL_DOUBLE */
1202 (attrib_func
) VertexAttribI2bv
,
1203 (attrib_func
) VertexAttribI2ubv
,
1204 (attrib_func
) VertexAttribI2sv
,
1205 (attrib_func
) VertexAttribI2usv
,
1206 (attrib_func
) VertexAttribI2iv
,
1207 (attrib_func
) VertexAttribI2uiv
,
1208 NULL
, /* GL_FLOAT */
1209 NULL
/* GL_DOUBLE */
1213 (attrib_func
) VertexAttribI3bv
,
1214 (attrib_func
) VertexAttribI3ubv
,
1215 (attrib_func
) VertexAttribI3sv
,
1216 (attrib_func
) VertexAttribI3usv
,
1217 (attrib_func
) VertexAttribI3iv
,
1218 (attrib_func
) VertexAttribI3uiv
,
1219 NULL
, /* GL_FLOAT */
1220 NULL
/* GL_DOUBLE */
1224 (attrib_func
) VertexAttribI4bv
,
1225 (attrib_func
) VertexAttribI4ubv
,
1226 (attrib_func
) VertexAttribI4sv
,
1227 (attrib_func
) VertexAttribI4usv
,
1228 (attrib_func
) VertexAttribI4iv
,
1229 (attrib_func
) VertexAttribI4uiv
,
1230 NULL
, /* GL_FLOAT */
1231 NULL
/* GL_DOUBLE */
1236 /**********************************************************************/
1239 GLboolean
_ae_create_context( struct gl_context
*ctx
)
1241 if (ctx
->aelt_context
)
1244 /* These _gloffset_* values may not be compile-time constants */
1245 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1246 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1247 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1248 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1249 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1250 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1251 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1252 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1254 FogCoordFuncs
[0] = -1;
1255 FogCoordFuncs
[1] = -1;
1256 FogCoordFuncs
[2] = -1;
1257 FogCoordFuncs
[3] = -1;
1258 FogCoordFuncs
[4] = -1;
1259 FogCoordFuncs
[5] = -1;
1260 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1261 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1263 ctx
->aelt_context
= CALLOC( sizeof(AEcontext
) );
1264 if (!ctx
->aelt_context
)
1267 AE_CONTEXT(ctx
)->NewState
= ~0;
1272 void _ae_destroy_context( struct gl_context
*ctx
)
1274 if ( AE_CONTEXT( ctx
) ) {
1275 FREE( ctx
->aelt_context
);
1276 ctx
->aelt_context
= NULL
;
1280 static void check_vbo( AEcontext
*actx
,
1281 struct gl_buffer_object
*vbo
)
1283 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1285 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1286 if (actx
->vbo
[i
] == vbo
)
1288 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1289 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1295 * Make a list of per-vertex functions to call for each glArrayElement call.
1296 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1298 * Note: this may be called during display list construction.
1300 static void _ae_update_state( struct gl_context
*ctx
)
1302 AEcontext
*actx
= AE_CONTEXT(ctx
);
1303 AEarray
*aa
= actx
->arrays
;
1304 AEattrib
*at
= actx
->attribs
;
1306 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1310 /* conventional vertex arrays */
1311 if (arrayObj
->Index
.Enabled
) {
1312 aa
->array
= &arrayObj
->Index
;
1313 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1314 check_vbo(actx
, aa
->array
->BufferObj
);
1317 if (arrayObj
->EdgeFlag
.Enabled
) {
1318 aa
->array
= &arrayObj
->EdgeFlag
;
1319 aa
->offset
= _gloffset_EdgeFlagv
;
1320 check_vbo(actx
, aa
->array
->BufferObj
);
1323 if (arrayObj
->Normal
.Enabled
) {
1324 aa
->array
= &arrayObj
->Normal
;
1325 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1326 check_vbo(actx
, aa
->array
->BufferObj
);
1329 if (arrayObj
->Color
.Enabled
) {
1330 aa
->array
= &arrayObj
->Color
;
1331 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1332 check_vbo(actx
, aa
->array
->BufferObj
);
1335 if (arrayObj
->SecondaryColor
.Enabled
) {
1336 aa
->array
= &arrayObj
->SecondaryColor
;
1337 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1338 check_vbo(actx
, aa
->array
->BufferObj
);
1341 if (arrayObj
->FogCoord
.Enabled
) {
1342 aa
->array
= &arrayObj
->FogCoord
;
1343 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1344 check_vbo(actx
, aa
->array
->BufferObj
);
1347 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1348 struct gl_client_array
*attribArray
= &arrayObj
->TexCoord
[i
];
1349 if (attribArray
->Enabled
) {
1350 /* NOTE: we use generic glVertexAttribNV functions here.
1351 * If we ever remove GL_NV_vertex_program this will have to change.
1353 at
->array
= attribArray
;
1354 ASSERT(!at
->array
->Normalized
);
1355 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1357 [TYPE_IDX(at
->array
->Type
)];
1358 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1359 check_vbo(actx
, at
->array
->BufferObj
);
1364 /* generic vertex attribute arrays */
1365 for (i
= 1; i
< Elements(arrayObj
->VertexAttrib
); i
++) { /* skip zero! */
1366 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[i
];
1367 if (attribArray
->Enabled
) {
1368 at
->array
= attribArray
;
1369 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1370 * function pointer here (for float arrays) since the pointer may
1371 * change from one execution of _ae_ArrayElement() to
1372 * the next. Doing so caused UT to break.
1374 if (ctx
->VertexProgram
._Enabled
1375 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1376 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1378 [TYPE_IDX(at
->array
->Type
)];
1382 if (at
->array
->Integer
)
1384 else if (at
->array
->Normalized
)
1389 at
->func
= AttribFuncsARB
[intOrNorm
]
1391 [TYPE_IDX(at
->array
->Type
)];
1394 check_vbo(actx
, at
->array
->BufferObj
);
1399 /* finally, vertex position */
1400 if (arrayObj
->VertexAttrib
[0].Enabled
) {
1401 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1402 * issued as the last (provoking) attribute).
1404 aa
->array
= &arrayObj
->VertexAttrib
[0];
1405 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1406 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1407 check_vbo(actx
, aa
->array
->BufferObj
);
1410 else if (arrayObj
->Vertex
.Enabled
) {
1411 aa
->array
= &arrayObj
->Vertex
;
1412 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1413 check_vbo(actx
, aa
->array
->BufferObj
);
1417 check_vbo(actx
, ctx
->Array
.ElementArrayBufferObj
);
1419 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1420 ASSERT(aa
- actx
->arrays
< 32);
1421 at
->func
= NULL
; /* terminate the list */
1422 aa
->offset
= -1; /* terminate the list */
1427 void _ae_map_vbos( struct gl_context
*ctx
)
1429 AEcontext
*actx
= AE_CONTEXT(ctx
);
1432 if (actx
->mapped_vbos
)
1436 _ae_update_state(ctx
);
1438 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1439 ctx
->Driver
.MapBuffer(ctx
,
1440 GL_ARRAY_BUFFER_ARB
,
1441 GL_DYNAMIC_DRAW_ARB
,
1445 actx
->mapped_vbos
= GL_TRUE
;
1448 void _ae_unmap_vbos( struct gl_context
*ctx
)
1450 AEcontext
*actx
= AE_CONTEXT(ctx
);
1453 if (!actx
->mapped_vbos
)
1456 assert (!actx
->NewState
);
1458 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1459 ctx
->Driver
.UnmapBuffer(ctx
,
1460 GL_ARRAY_BUFFER_ARB
,
1463 actx
->mapped_vbos
= GL_FALSE
;
1468 * Called via glArrayElement() and glDrawArrays().
1469 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1470 * for all enabled vertex arrays (for elt-th element).
1471 * Note: this may be called during display list construction.
1473 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1475 GET_CURRENT_CONTEXT(ctx
);
1476 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1479 const struct _glapi_table
* const disp
= GET_DISPATCH();
1482 if (actx
->NewState
) {
1483 assert(!actx
->mapped_vbos
);
1484 _ae_update_state( ctx
);
1487 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1494 /* generic attributes */
1495 for (at
= actx
->attribs
; at
->func
; at
++) {
1497 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1498 + elt
* at
->array
->StrideB
;
1499 at
->func( at
->index
, src
);
1502 /* conventional arrays */
1503 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1505 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1506 + elt
* aa
->array
->StrideB
;
1507 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1508 ((const void *) src
) );
1512 _ae_unmap_vbos(ctx
);
1516 void _ae_invalidate_state( struct gl_context
*ctx
, GLuint new_state
)
1518 AEcontext
*actx
= AE_CONTEXT(ctx
);
1521 /* Only interested in this subset of mesa state. Need to prune
1522 * this down as both tnl/ and the drivers can raise statechanges
1523 * for arcane reasons in the middle of seemingly atomic operations
1524 * like DrawElements, over which we'd like to keep a known set of
1525 * arrays and vbo's mapped.
1527 * Luckily, neither the drivers nor tnl muck with the state that
1530 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1532 assert(!actx
->mapped_vbos
);
1533 actx
->NewState
|= new_state
;
1538 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1539 const GLvertexformat
*vfmt
)
1541 SET_ArrayElement(disp
, vfmt
->ArrayElement
);
1545 #endif /* FEATURE_arrayelt */