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 * Array [size][type] of VertexAttrib functions
934 static attrib_func AttribFuncsARB
[2][4][8] = {
939 (attrib_func
) VertexAttrib1bvARB
,
940 (attrib_func
) VertexAttrib1ubvARB
,
941 (attrib_func
) VertexAttrib1svARB
,
942 (attrib_func
) VertexAttrib1usvARB
,
943 (attrib_func
) VertexAttrib1ivARB
,
944 (attrib_func
) VertexAttrib1uivARB
,
945 (attrib_func
) VertexAttrib1fvARB
,
946 (attrib_func
) VertexAttrib1dvARB
950 (attrib_func
) VertexAttrib2bvARB
,
951 (attrib_func
) VertexAttrib2ubvARB
,
952 (attrib_func
) VertexAttrib2svARB
,
953 (attrib_func
) VertexAttrib2usvARB
,
954 (attrib_func
) VertexAttrib2ivARB
,
955 (attrib_func
) VertexAttrib2uivARB
,
956 (attrib_func
) VertexAttrib2fvARB
,
957 (attrib_func
) VertexAttrib2dvARB
961 (attrib_func
) VertexAttrib3bvARB
,
962 (attrib_func
) VertexAttrib3ubvARB
,
963 (attrib_func
) VertexAttrib3svARB
,
964 (attrib_func
) VertexAttrib3usvARB
,
965 (attrib_func
) VertexAttrib3ivARB
,
966 (attrib_func
) VertexAttrib3uivARB
,
967 (attrib_func
) VertexAttrib3fvARB
,
968 (attrib_func
) VertexAttrib3dvARB
972 (attrib_func
) VertexAttrib4bvARB
,
973 (attrib_func
) VertexAttrib4ubvARB
,
974 (attrib_func
) VertexAttrib4svARB
,
975 (attrib_func
) VertexAttrib4usvARB
,
976 (attrib_func
) VertexAttrib4ivARB
,
977 (attrib_func
) VertexAttrib4uivARB
,
978 (attrib_func
) VertexAttrib4fvARB
,
979 (attrib_func
) VertexAttrib4dvARB
983 /* normalized (except for float/double) */
986 (attrib_func
) VertexAttrib1NbvARB
,
987 (attrib_func
) VertexAttrib1NubvARB
,
988 (attrib_func
) VertexAttrib1NsvARB
,
989 (attrib_func
) VertexAttrib1NusvARB
,
990 (attrib_func
) VertexAttrib1NivARB
,
991 (attrib_func
) VertexAttrib1NuivARB
,
992 (attrib_func
) VertexAttrib1fvARB
,
993 (attrib_func
) VertexAttrib1dvARB
997 (attrib_func
) VertexAttrib2NbvARB
,
998 (attrib_func
) VertexAttrib2NubvARB
,
999 (attrib_func
) VertexAttrib2NsvARB
,
1000 (attrib_func
) VertexAttrib2NusvARB
,
1001 (attrib_func
) VertexAttrib2NivARB
,
1002 (attrib_func
) VertexAttrib2NuivARB
,
1003 (attrib_func
) VertexAttrib2fvARB
,
1004 (attrib_func
) VertexAttrib2dvARB
1008 (attrib_func
) VertexAttrib3NbvARB
,
1009 (attrib_func
) VertexAttrib3NubvARB
,
1010 (attrib_func
) VertexAttrib3NsvARB
,
1011 (attrib_func
) VertexAttrib3NusvARB
,
1012 (attrib_func
) VertexAttrib3NivARB
,
1013 (attrib_func
) VertexAttrib3NuivARB
,
1014 (attrib_func
) VertexAttrib3fvARB
,
1015 (attrib_func
) VertexAttrib3dvARB
1019 (attrib_func
) VertexAttrib4NbvARB
,
1020 (attrib_func
) VertexAttrib4NubvARB
,
1021 (attrib_func
) VertexAttrib4NsvARB
,
1022 (attrib_func
) VertexAttrib4NusvARB
,
1023 (attrib_func
) VertexAttrib4NivARB
,
1024 (attrib_func
) VertexAttrib4NuivARB
,
1025 (attrib_func
) VertexAttrib4fvARB
,
1026 (attrib_func
) VertexAttrib4dvARB
1031 /**********************************************************************/
1034 GLboolean
_ae_create_context( GLcontext
*ctx
)
1036 if (ctx
->aelt_context
)
1039 /* These _gloffset_* values may not be compile-time constants */
1040 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1041 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1042 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1043 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1044 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1045 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1046 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1047 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1049 FogCoordFuncs
[0] = -1;
1050 FogCoordFuncs
[1] = -1;
1051 FogCoordFuncs
[2] = -1;
1052 FogCoordFuncs
[3] = -1;
1053 FogCoordFuncs
[4] = -1;
1054 FogCoordFuncs
[5] = -1;
1055 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1056 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1058 ctx
->aelt_context
= CALLOC( sizeof(AEcontext
) );
1059 if (!ctx
->aelt_context
)
1062 AE_CONTEXT(ctx
)->NewState
= ~0;
1067 void _ae_destroy_context( GLcontext
*ctx
)
1069 if ( AE_CONTEXT( ctx
) ) {
1070 FREE( ctx
->aelt_context
);
1071 ctx
->aelt_context
= NULL
;
1075 static void check_vbo( AEcontext
*actx
,
1076 struct gl_buffer_object
*vbo
)
1078 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1080 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1081 if (actx
->vbo
[i
] == vbo
)
1083 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1084 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1090 * Make a list of per-vertex functions to call for each glArrayElement call.
1091 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1093 * Note: this may be called during display list construction.
1095 static void _ae_update_state( GLcontext
*ctx
)
1097 AEcontext
*actx
= AE_CONTEXT(ctx
);
1098 AEarray
*aa
= actx
->arrays
;
1099 AEattrib
*at
= actx
->attribs
;
1101 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1105 /* conventional vertex arrays */
1106 if (arrayObj
->Index
.Enabled
) {
1107 aa
->array
= &arrayObj
->Index
;
1108 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1109 check_vbo(actx
, aa
->array
->BufferObj
);
1112 if (arrayObj
->EdgeFlag
.Enabled
) {
1113 aa
->array
= &arrayObj
->EdgeFlag
;
1114 aa
->offset
= _gloffset_EdgeFlagv
;
1115 check_vbo(actx
, aa
->array
->BufferObj
);
1118 if (arrayObj
->Normal
.Enabled
) {
1119 aa
->array
= &arrayObj
->Normal
;
1120 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1121 check_vbo(actx
, aa
->array
->BufferObj
);
1124 if (arrayObj
->Color
.Enabled
) {
1125 aa
->array
= &arrayObj
->Color
;
1126 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1127 check_vbo(actx
, aa
->array
->BufferObj
);
1130 if (arrayObj
->SecondaryColor
.Enabled
) {
1131 aa
->array
= &arrayObj
->SecondaryColor
;
1132 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1133 check_vbo(actx
, aa
->array
->BufferObj
);
1136 if (arrayObj
->FogCoord
.Enabled
) {
1137 aa
->array
= &arrayObj
->FogCoord
;
1138 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1139 check_vbo(actx
, aa
->array
->BufferObj
);
1142 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1143 struct gl_client_array
*attribArray
= &arrayObj
->TexCoord
[i
];
1144 if (attribArray
->Enabled
) {
1145 /* NOTE: we use generic glVertexAttribNV functions here.
1146 * If we ever remove GL_NV_vertex_program this will have to change.
1148 at
->array
= attribArray
;
1149 ASSERT(!at
->array
->Normalized
);
1150 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1152 [TYPE_IDX(at
->array
->Type
)];
1153 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1154 check_vbo(actx
, at
->array
->BufferObj
);
1159 /* generic vertex attribute arrays */
1160 for (i
= 1; i
< Elements(arrayObj
->VertexAttrib
); i
++) { /* skip zero! */
1161 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[i
];
1162 if (attribArray
->Enabled
) {
1163 at
->array
= attribArray
;
1164 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1165 * function pointer here (for float arrays) since the pointer may
1166 * change from one execution of _ae_ArrayElement() to
1167 * the next. Doing so caused UT to break.
1169 if (ctx
->VertexProgram
._Enabled
1170 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1171 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1173 [TYPE_IDX(at
->array
->Type
)];
1176 at
->func
= AttribFuncsARB
[at
->array
->Normalized
]
1178 [TYPE_IDX(at
->array
->Type
)];
1181 check_vbo(actx
, at
->array
->BufferObj
);
1186 /* finally, vertex position */
1187 if (arrayObj
->VertexAttrib
[0].Enabled
) {
1188 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1189 * issued as the last (provoking) attribute).
1191 aa
->array
= &arrayObj
->VertexAttrib
[0];
1192 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1193 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1194 check_vbo(actx
, aa
->array
->BufferObj
);
1197 else if (arrayObj
->Vertex
.Enabled
) {
1198 aa
->array
= &arrayObj
->Vertex
;
1199 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1200 check_vbo(actx
, aa
->array
->BufferObj
);
1204 check_vbo(actx
, ctx
->Array
.ElementArrayBufferObj
);
1206 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1207 ASSERT(aa
- actx
->arrays
< 32);
1208 at
->func
= NULL
; /* terminate the list */
1209 aa
->offset
= -1; /* terminate the list */
1214 void _ae_map_vbos( GLcontext
*ctx
)
1216 AEcontext
*actx
= AE_CONTEXT(ctx
);
1219 if (actx
->mapped_vbos
)
1223 _ae_update_state(ctx
);
1225 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1226 ctx
->Driver
.MapBuffer(ctx
,
1227 GL_ARRAY_BUFFER_ARB
,
1228 GL_DYNAMIC_DRAW_ARB
,
1232 actx
->mapped_vbos
= GL_TRUE
;
1235 void _ae_unmap_vbos( GLcontext
*ctx
)
1237 AEcontext
*actx
= AE_CONTEXT(ctx
);
1240 if (!actx
->mapped_vbos
)
1243 assert (!actx
->NewState
);
1245 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1246 ctx
->Driver
.UnmapBuffer(ctx
,
1247 GL_ARRAY_BUFFER_ARB
,
1250 actx
->mapped_vbos
= GL_FALSE
;
1255 * Called via glArrayElement() and glDrawArrays().
1256 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1257 * for all enabled vertex arrays (for elt-th element).
1258 * Note: this may be called during display list construction.
1260 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1262 GET_CURRENT_CONTEXT(ctx
);
1263 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1266 const struct _glapi_table
* const disp
= GET_DISPATCH();
1269 if (actx
->NewState
) {
1270 assert(!actx
->mapped_vbos
);
1271 _ae_update_state( ctx
);
1274 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1281 /* generic attributes */
1282 for (at
= actx
->attribs
; at
->func
; at
++) {
1284 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1285 + elt
* at
->array
->StrideB
;
1286 at
->func( at
->index
, src
);
1289 /* conventional arrays */
1290 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1292 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1293 + elt
* aa
->array
->StrideB
;
1294 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1295 ((const void *) src
) );
1299 _ae_unmap_vbos(ctx
);
1303 void _ae_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
1305 AEcontext
*actx
= AE_CONTEXT(ctx
);
1308 /* Only interested in this subset of mesa state. Need to prune
1309 * this down as both tnl/ and the drivers can raise statechanges
1310 * for arcane reasons in the middle of seemingly atomic operations
1311 * like DrawElements, over which we'd like to keep a known set of
1312 * arrays and vbo's mapped.
1314 * Luckily, neither the drivers nor tnl muck with the state that
1317 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1319 assert(!actx
->mapped_vbos
);
1320 actx
->NewState
|= new_state
;
1325 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1326 const GLvertexformat
*vfmt
)
1328 SET_ArrayElement(disp
, vfmt
->ArrayElement
);
1332 #endif /* FEATURE_arrayelt */