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 "glapi/glapioffsets.h"
36 #include "glapi/dispatch.h"
38 typedef void (GLAPIENTRY
*array_func
)( const void * );
41 const struct gl_client_array
*array
;
45 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
48 const struct gl_client_array
*array
;
55 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
58 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
60 GLboolean mapped_vbos
;
64 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
68 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
69 * in the range [0, 7]. Luckily these type tokens are sequentially
70 * numbered in gl.h, except for GL_DOUBLE.
72 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
78 static const int ColorFuncs
[2][8] = {
101 static const int VertexFuncs
[3][8] = {
134 static const int IndexFuncs
[8] = {
145 static const int NormalFuncs
[8] = {
156 /* Note: _gloffset_* for these may not be a compile-time constant. */
157 static int SecondaryColorFuncs
[8];
158 static int FogCoordFuncs
[8];
162 ** GL_NV_vertex_program
165 /* GL_BYTE attributes */
167 static void GLAPIENTRY
VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
169 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
172 static void GLAPIENTRY
VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
174 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
177 static void GLAPIENTRY
VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
179 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
182 static void GLAPIENTRY
VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
184 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
187 static void GLAPIENTRY
VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
189 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
191 BYTE_TO_FLOAT(v
[2])));
194 static void GLAPIENTRY
VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
196 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
199 static void GLAPIENTRY
VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
201 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
204 BYTE_TO_FLOAT(v
[3])));
207 static void GLAPIENTRY
VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
209 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
212 /* GL_UNSIGNED_BYTE attributes */
214 static void GLAPIENTRY
VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
216 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
219 static void GLAPIENTRY
VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
221 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
224 static void GLAPIENTRY
VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
226 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
227 UBYTE_TO_FLOAT(v
[1])));
230 static void GLAPIENTRY
VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
232 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
235 static void GLAPIENTRY
VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
237 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
238 UBYTE_TO_FLOAT(v
[1]),
239 UBYTE_TO_FLOAT(v
[2])));
241 static void GLAPIENTRY
VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
243 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
246 static void GLAPIENTRY
VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
248 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
249 UBYTE_TO_FLOAT(v
[1]),
250 UBYTE_TO_FLOAT(v
[2]),
251 UBYTE_TO_FLOAT(v
[3])));
254 static void GLAPIENTRY
VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
256 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
259 /* GL_SHORT attributes */
261 static void GLAPIENTRY
VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
263 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
266 static void GLAPIENTRY
VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
268 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
271 static void GLAPIENTRY
VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
273 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
274 SHORT_TO_FLOAT(v
[1])));
277 static void GLAPIENTRY
VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
279 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
282 static void GLAPIENTRY
VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
284 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
285 SHORT_TO_FLOAT(v
[1]),
286 SHORT_TO_FLOAT(v
[2])));
289 static void GLAPIENTRY
VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
291 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
294 static void GLAPIENTRY
VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
296 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
297 SHORT_TO_FLOAT(v
[1]),
298 SHORT_TO_FLOAT(v
[2]),
299 SHORT_TO_FLOAT(v
[3])));
302 static void GLAPIENTRY
VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
304 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
307 /* GL_UNSIGNED_SHORT attributes */
309 static void GLAPIENTRY
VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
311 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
314 static void GLAPIENTRY
VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
316 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
319 static void GLAPIENTRY
VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
321 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
322 USHORT_TO_FLOAT(v
[1])));
325 static void GLAPIENTRY
VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
327 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
330 static void GLAPIENTRY
VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
332 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
333 USHORT_TO_FLOAT(v
[1]),
334 USHORT_TO_FLOAT(v
[2])));
337 static void GLAPIENTRY
VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
339 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
342 static void GLAPIENTRY
VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
344 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
345 USHORT_TO_FLOAT(v
[1]),
346 USHORT_TO_FLOAT(v
[2]),
347 USHORT_TO_FLOAT(v
[3])));
350 static void GLAPIENTRY
VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
352 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
355 /* GL_INT attributes */
357 static void GLAPIENTRY
VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
359 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
362 static void GLAPIENTRY
VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
364 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
367 static void GLAPIENTRY
VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
369 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
370 INT_TO_FLOAT(v
[1])));
373 static void GLAPIENTRY
VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
375 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
378 static void GLAPIENTRY
VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
380 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
382 INT_TO_FLOAT(v
[2])));
385 static void GLAPIENTRY
VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
387 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
390 static void GLAPIENTRY
VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
392 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
395 INT_TO_FLOAT(v
[3])));
398 static void GLAPIENTRY
VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
400 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
403 /* GL_UNSIGNED_INT attributes */
405 static void GLAPIENTRY
VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
407 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
410 static void GLAPIENTRY
VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
412 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
415 static void GLAPIENTRY
VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
417 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
418 UINT_TO_FLOAT(v
[1])));
421 static void GLAPIENTRY
VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
423 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
426 static void GLAPIENTRY
VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
428 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
430 UINT_TO_FLOAT(v
[2])));
433 static void GLAPIENTRY
VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
435 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
438 static void GLAPIENTRY
VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
440 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
443 UINT_TO_FLOAT(v
[3])));
446 static void GLAPIENTRY
VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
448 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
451 /* GL_FLOAT attributes */
453 static void GLAPIENTRY
VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
455 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
458 static void GLAPIENTRY
VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
460 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
463 static void GLAPIENTRY
VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
465 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
468 static void GLAPIENTRY
VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
470 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
473 /* GL_DOUBLE attributes */
475 static void GLAPIENTRY
VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
477 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
480 static void GLAPIENTRY
VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
482 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
485 static void GLAPIENTRY
VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
487 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
490 static void GLAPIENTRY
VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
492 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
497 * Array [size][type] of VertexAttrib functions
499 static attrib_func AttribFuncsNV
[2][4][8] = {
504 (attrib_func
) VertexAttrib1bvNV
,
505 (attrib_func
) VertexAttrib1ubvNV
,
506 (attrib_func
) VertexAttrib1svNV
,
507 (attrib_func
) VertexAttrib1usvNV
,
508 (attrib_func
) VertexAttrib1ivNV
,
509 (attrib_func
) VertexAttrib1uivNV
,
510 (attrib_func
) VertexAttrib1fvNV
,
511 (attrib_func
) VertexAttrib1dvNV
515 (attrib_func
) VertexAttrib2bvNV
,
516 (attrib_func
) VertexAttrib2ubvNV
,
517 (attrib_func
) VertexAttrib2svNV
,
518 (attrib_func
) VertexAttrib2usvNV
,
519 (attrib_func
) VertexAttrib2ivNV
,
520 (attrib_func
) VertexAttrib2uivNV
,
521 (attrib_func
) VertexAttrib2fvNV
,
522 (attrib_func
) VertexAttrib2dvNV
526 (attrib_func
) VertexAttrib3bvNV
,
527 (attrib_func
) VertexAttrib3ubvNV
,
528 (attrib_func
) VertexAttrib3svNV
,
529 (attrib_func
) VertexAttrib3usvNV
,
530 (attrib_func
) VertexAttrib3ivNV
,
531 (attrib_func
) VertexAttrib3uivNV
,
532 (attrib_func
) VertexAttrib3fvNV
,
533 (attrib_func
) VertexAttrib3dvNV
537 (attrib_func
) VertexAttrib4bvNV
,
538 (attrib_func
) VertexAttrib4ubvNV
,
539 (attrib_func
) VertexAttrib4svNV
,
540 (attrib_func
) VertexAttrib4usvNV
,
541 (attrib_func
) VertexAttrib4ivNV
,
542 (attrib_func
) VertexAttrib4uivNV
,
543 (attrib_func
) VertexAttrib4fvNV
,
544 (attrib_func
) VertexAttrib4dvNV
548 /* normalized (except for float/double) */
551 (attrib_func
) VertexAttrib1NbvNV
,
552 (attrib_func
) VertexAttrib1NubvNV
,
553 (attrib_func
) VertexAttrib1NsvNV
,
554 (attrib_func
) VertexAttrib1NusvNV
,
555 (attrib_func
) VertexAttrib1NivNV
,
556 (attrib_func
) VertexAttrib1NuivNV
,
557 (attrib_func
) VertexAttrib1fvNV
,
558 (attrib_func
) VertexAttrib1dvNV
562 (attrib_func
) VertexAttrib2NbvNV
,
563 (attrib_func
) VertexAttrib2NubvNV
,
564 (attrib_func
) VertexAttrib2NsvNV
,
565 (attrib_func
) VertexAttrib2NusvNV
,
566 (attrib_func
) VertexAttrib2NivNV
,
567 (attrib_func
) VertexAttrib2NuivNV
,
568 (attrib_func
) VertexAttrib2fvNV
,
569 (attrib_func
) VertexAttrib2dvNV
573 (attrib_func
) VertexAttrib3NbvNV
,
574 (attrib_func
) VertexAttrib3NubvNV
,
575 (attrib_func
) VertexAttrib3NsvNV
,
576 (attrib_func
) VertexAttrib3NusvNV
,
577 (attrib_func
) VertexAttrib3NivNV
,
578 (attrib_func
) VertexAttrib3NuivNV
,
579 (attrib_func
) VertexAttrib3fvNV
,
580 (attrib_func
) VertexAttrib3dvNV
584 (attrib_func
) VertexAttrib4NbvNV
,
585 (attrib_func
) VertexAttrib4NubvNV
,
586 (attrib_func
) VertexAttrib4NsvNV
,
587 (attrib_func
) VertexAttrib4NusvNV
,
588 (attrib_func
) VertexAttrib4NivNV
,
589 (attrib_func
) VertexAttrib4NuivNV
,
590 (attrib_func
) VertexAttrib4fvNV
,
591 (attrib_func
) VertexAttrib4dvNV
598 ** GL_ARB_vertex_program
601 /* GL_BYTE attributes */
603 static void GLAPIENTRY
VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
605 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
608 static void GLAPIENTRY
VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
610 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
613 static void GLAPIENTRY
VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
615 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
618 static void GLAPIENTRY
VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
620 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
623 static void GLAPIENTRY
VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
625 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
627 BYTE_TO_FLOAT(v
[2])));
630 static void GLAPIENTRY
VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
632 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
635 static void GLAPIENTRY
VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
637 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
640 BYTE_TO_FLOAT(v
[3])));
643 static void GLAPIENTRY
VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
645 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
648 /* GL_UNSIGNED_BYTE attributes */
650 static void GLAPIENTRY
VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
652 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
655 static void GLAPIENTRY
VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
657 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
660 static void GLAPIENTRY
VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
662 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
663 UBYTE_TO_FLOAT(v
[1])));
666 static void GLAPIENTRY
VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
668 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
671 static void GLAPIENTRY
VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
673 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
674 UBYTE_TO_FLOAT(v
[1]),
675 UBYTE_TO_FLOAT(v
[2])));
677 static void GLAPIENTRY
VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
679 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
682 static void GLAPIENTRY
VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
684 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
685 UBYTE_TO_FLOAT(v
[1]),
686 UBYTE_TO_FLOAT(v
[2]),
687 UBYTE_TO_FLOAT(v
[3])));
690 static void GLAPIENTRY
VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
692 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
695 /* GL_SHORT attributes */
697 static void GLAPIENTRY
VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
699 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
702 static void GLAPIENTRY
VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
704 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
707 static void GLAPIENTRY
VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
709 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
710 SHORT_TO_FLOAT(v
[1])));
713 static void GLAPIENTRY
VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
715 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
718 static void GLAPIENTRY
VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
720 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
721 SHORT_TO_FLOAT(v
[1]),
722 SHORT_TO_FLOAT(v
[2])));
725 static void GLAPIENTRY
VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
727 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
730 static void GLAPIENTRY
VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
732 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
733 SHORT_TO_FLOAT(v
[1]),
734 SHORT_TO_FLOAT(v
[2]),
735 SHORT_TO_FLOAT(v
[3])));
738 static void GLAPIENTRY
VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
740 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
743 /* GL_UNSIGNED_SHORT attributes */
745 static void GLAPIENTRY
VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
747 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
750 static void GLAPIENTRY
VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
752 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
755 static void GLAPIENTRY
VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
757 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
758 USHORT_TO_FLOAT(v
[1])));
761 static void GLAPIENTRY
VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
763 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
766 static void GLAPIENTRY
VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
768 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
769 USHORT_TO_FLOAT(v
[1]),
770 USHORT_TO_FLOAT(v
[2])));
773 static void GLAPIENTRY
VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
775 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
778 static void GLAPIENTRY
VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
780 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
781 USHORT_TO_FLOAT(v
[1]),
782 USHORT_TO_FLOAT(v
[2]),
783 USHORT_TO_FLOAT(v
[3])));
786 static void GLAPIENTRY
VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
788 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
791 /* GL_INT attributes */
793 static void GLAPIENTRY
VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
795 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
798 static void GLAPIENTRY
VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
800 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
803 static void GLAPIENTRY
VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
805 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
806 INT_TO_FLOAT(v
[1])));
809 static void GLAPIENTRY
VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
811 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
814 static void GLAPIENTRY
VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
816 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
818 INT_TO_FLOAT(v
[2])));
821 static void GLAPIENTRY
VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
823 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
826 static void GLAPIENTRY
VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
828 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
831 INT_TO_FLOAT(v
[3])));
834 static void GLAPIENTRY
VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
836 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
839 /* GL_UNSIGNED_INT attributes */
841 static void GLAPIENTRY
VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
843 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
846 static void GLAPIENTRY
VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
848 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
851 static void GLAPIENTRY
VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
853 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
854 UINT_TO_FLOAT(v
[1])));
857 static void GLAPIENTRY
VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
859 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
862 static void GLAPIENTRY
VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
864 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
866 UINT_TO_FLOAT(v
[2])));
869 static void GLAPIENTRY
VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
871 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
874 static void GLAPIENTRY
VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
876 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
879 UINT_TO_FLOAT(v
[3])));
882 static void GLAPIENTRY
VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
884 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
887 /* GL_FLOAT attributes */
889 static void GLAPIENTRY
VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
891 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
894 static void GLAPIENTRY
VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
896 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
899 static void GLAPIENTRY
VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
901 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
904 static void GLAPIENTRY
VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
906 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
909 /* GL_DOUBLE attributes */
911 static void GLAPIENTRY
VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
913 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
916 static void GLAPIENTRY
VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
918 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
921 static void GLAPIENTRY
VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
923 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
926 static void GLAPIENTRY
VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
928 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
933 * Array [size][type] of VertexAttrib functions
935 static attrib_func AttribFuncsARB
[2][4][8] = {
940 (attrib_func
) VertexAttrib1bvARB
,
941 (attrib_func
) VertexAttrib1ubvARB
,
942 (attrib_func
) VertexAttrib1svARB
,
943 (attrib_func
) VertexAttrib1usvARB
,
944 (attrib_func
) VertexAttrib1ivARB
,
945 (attrib_func
) VertexAttrib1uivARB
,
946 (attrib_func
) VertexAttrib1fvARB
,
947 (attrib_func
) VertexAttrib1dvARB
951 (attrib_func
) VertexAttrib2bvARB
,
952 (attrib_func
) VertexAttrib2ubvARB
,
953 (attrib_func
) VertexAttrib2svARB
,
954 (attrib_func
) VertexAttrib2usvARB
,
955 (attrib_func
) VertexAttrib2ivARB
,
956 (attrib_func
) VertexAttrib2uivARB
,
957 (attrib_func
) VertexAttrib2fvARB
,
958 (attrib_func
) VertexAttrib2dvARB
962 (attrib_func
) VertexAttrib3bvARB
,
963 (attrib_func
) VertexAttrib3ubvARB
,
964 (attrib_func
) VertexAttrib3svARB
,
965 (attrib_func
) VertexAttrib3usvARB
,
966 (attrib_func
) VertexAttrib3ivARB
,
967 (attrib_func
) VertexAttrib3uivARB
,
968 (attrib_func
) VertexAttrib3fvARB
,
969 (attrib_func
) VertexAttrib3dvARB
973 (attrib_func
) VertexAttrib4bvARB
,
974 (attrib_func
) VertexAttrib4ubvARB
,
975 (attrib_func
) VertexAttrib4svARB
,
976 (attrib_func
) VertexAttrib4usvARB
,
977 (attrib_func
) VertexAttrib4ivARB
,
978 (attrib_func
) VertexAttrib4uivARB
,
979 (attrib_func
) VertexAttrib4fvARB
,
980 (attrib_func
) VertexAttrib4dvARB
984 /* normalized (except for float/double) */
987 (attrib_func
) VertexAttrib1NbvARB
,
988 (attrib_func
) VertexAttrib1NubvARB
,
989 (attrib_func
) VertexAttrib1NsvARB
,
990 (attrib_func
) VertexAttrib1NusvARB
,
991 (attrib_func
) VertexAttrib1NivARB
,
992 (attrib_func
) VertexAttrib1NuivARB
,
993 (attrib_func
) VertexAttrib1fvARB
,
994 (attrib_func
) VertexAttrib1dvARB
998 (attrib_func
) VertexAttrib2NbvARB
,
999 (attrib_func
) VertexAttrib2NubvARB
,
1000 (attrib_func
) VertexAttrib2NsvARB
,
1001 (attrib_func
) VertexAttrib2NusvARB
,
1002 (attrib_func
) VertexAttrib2NivARB
,
1003 (attrib_func
) VertexAttrib2NuivARB
,
1004 (attrib_func
) VertexAttrib2fvARB
,
1005 (attrib_func
) VertexAttrib2dvARB
1009 (attrib_func
) VertexAttrib3NbvARB
,
1010 (attrib_func
) VertexAttrib3NubvARB
,
1011 (attrib_func
) VertexAttrib3NsvARB
,
1012 (attrib_func
) VertexAttrib3NusvARB
,
1013 (attrib_func
) VertexAttrib3NivARB
,
1014 (attrib_func
) VertexAttrib3NuivARB
,
1015 (attrib_func
) VertexAttrib3fvARB
,
1016 (attrib_func
) VertexAttrib3dvARB
1020 (attrib_func
) VertexAttrib4NbvARB
,
1021 (attrib_func
) VertexAttrib4NubvARB
,
1022 (attrib_func
) VertexAttrib4NsvARB
,
1023 (attrib_func
) VertexAttrib4NusvARB
,
1024 (attrib_func
) VertexAttrib4NivARB
,
1025 (attrib_func
) VertexAttrib4NuivARB
,
1026 (attrib_func
) VertexAttrib4fvARB
,
1027 (attrib_func
) VertexAttrib4dvARB
1032 /**********************************************************************/
1035 GLboolean
_ae_create_context( GLcontext
*ctx
)
1037 if (ctx
->aelt_context
)
1040 /* These _gloffset_* values may not be compile-time constants */
1041 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1042 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1043 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1044 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1045 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1046 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1047 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1048 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1050 FogCoordFuncs
[0] = -1;
1051 FogCoordFuncs
[1] = -1;
1052 FogCoordFuncs
[2] = -1;
1053 FogCoordFuncs
[3] = -1;
1054 FogCoordFuncs
[4] = -1;
1055 FogCoordFuncs
[5] = -1;
1056 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1057 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1059 ctx
->aelt_context
= CALLOC( sizeof(AEcontext
) );
1060 if (!ctx
->aelt_context
)
1063 AE_CONTEXT(ctx
)->NewState
= ~0;
1068 void _ae_destroy_context( GLcontext
*ctx
)
1070 if ( AE_CONTEXT( ctx
) ) {
1071 FREE( ctx
->aelt_context
);
1072 ctx
->aelt_context
= NULL
;
1076 static void check_vbo( AEcontext
*actx
,
1077 struct gl_buffer_object
*vbo
)
1079 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1081 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1082 if (actx
->vbo
[i
] == vbo
)
1084 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1085 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1091 * Make a list of per-vertex functions to call for each glArrayElement call.
1092 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1094 * Note: this may be called during display list construction.
1096 static void _ae_update_state( GLcontext
*ctx
)
1098 AEcontext
*actx
= AE_CONTEXT(ctx
);
1099 AEarray
*aa
= actx
->arrays
;
1100 AEattrib
*at
= actx
->attribs
;
1102 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1106 /* conventional vertex arrays */
1107 if (arrayObj
->Index
.Enabled
) {
1108 aa
->array
= &arrayObj
->Index
;
1109 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1110 check_vbo(actx
, aa
->array
->BufferObj
);
1113 if (arrayObj
->EdgeFlag
.Enabled
) {
1114 aa
->array
= &arrayObj
->EdgeFlag
;
1115 aa
->offset
= _gloffset_EdgeFlagv
;
1116 check_vbo(actx
, aa
->array
->BufferObj
);
1119 if (arrayObj
->Normal
.Enabled
) {
1120 aa
->array
= &arrayObj
->Normal
;
1121 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1122 check_vbo(actx
, aa
->array
->BufferObj
);
1125 if (arrayObj
->Color
.Enabled
) {
1126 aa
->array
= &arrayObj
->Color
;
1127 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1128 check_vbo(actx
, aa
->array
->BufferObj
);
1131 if (arrayObj
->SecondaryColor
.Enabled
) {
1132 aa
->array
= &arrayObj
->SecondaryColor
;
1133 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1134 check_vbo(actx
, aa
->array
->BufferObj
);
1137 if (arrayObj
->FogCoord
.Enabled
) {
1138 aa
->array
= &arrayObj
->FogCoord
;
1139 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1140 check_vbo(actx
, aa
->array
->BufferObj
);
1143 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1144 struct gl_client_array
*attribArray
= &arrayObj
->TexCoord
[i
];
1145 if (attribArray
->Enabled
) {
1146 /* NOTE: we use generic glVertexAttribNV functions here.
1147 * If we ever remove GL_NV_vertex_program this will have to change.
1149 at
->array
= attribArray
;
1150 ASSERT(!at
->array
->Normalized
);
1151 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1153 [TYPE_IDX(at
->array
->Type
)];
1154 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1155 check_vbo(actx
, at
->array
->BufferObj
);
1160 /* generic vertex attribute arrays */
1161 for (i
= 1; i
< Elements(arrayObj
->VertexAttrib
); i
++) { /* skip zero! */
1162 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[i
];
1163 if (attribArray
->Enabled
) {
1164 at
->array
= attribArray
;
1165 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1166 * function pointer here (for float arrays) since the pointer may
1167 * change from one execution of _ae_ArrayElement() to
1168 * the next. Doing so caused UT to break.
1170 if (ctx
->VertexProgram
._Enabled
1171 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1172 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1174 [TYPE_IDX(at
->array
->Type
)];
1177 at
->func
= AttribFuncsARB
[at
->array
->Normalized
]
1179 [TYPE_IDX(at
->array
->Type
)];
1182 check_vbo(actx
, at
->array
->BufferObj
);
1187 /* finally, vertex position */
1188 if (arrayObj
->VertexAttrib
[0].Enabled
) {
1189 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1190 * issued as the last (provoking) attribute).
1192 aa
->array
= &arrayObj
->VertexAttrib
[0];
1193 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1194 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1195 check_vbo(actx
, aa
->array
->BufferObj
);
1198 else if (arrayObj
->Vertex
.Enabled
) {
1199 aa
->array
= &arrayObj
->Vertex
;
1200 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1201 check_vbo(actx
, aa
->array
->BufferObj
);
1205 check_vbo(actx
, ctx
->Array
.ElementArrayBufferObj
);
1207 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1208 ASSERT(aa
- actx
->arrays
< 32);
1209 at
->func
= NULL
; /* terminate the list */
1210 aa
->offset
= -1; /* terminate the list */
1215 void _ae_map_vbos( GLcontext
*ctx
)
1217 AEcontext
*actx
= AE_CONTEXT(ctx
);
1220 if (actx
->mapped_vbos
)
1224 _ae_update_state(ctx
);
1226 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1227 ctx
->Driver
.MapBuffer(ctx
,
1228 GL_ARRAY_BUFFER_ARB
,
1229 GL_DYNAMIC_DRAW_ARB
,
1233 actx
->mapped_vbos
= GL_TRUE
;
1236 void _ae_unmap_vbos( GLcontext
*ctx
)
1238 AEcontext
*actx
= AE_CONTEXT(ctx
);
1241 if (!actx
->mapped_vbos
)
1244 assert (!actx
->NewState
);
1246 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1247 ctx
->Driver
.UnmapBuffer(ctx
,
1248 GL_ARRAY_BUFFER_ARB
,
1251 actx
->mapped_vbos
= GL_FALSE
;
1256 * Called via glArrayElement() and glDrawArrays().
1257 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1258 * for all enabled vertex arrays (for elt-th element).
1259 * Note: this may be called during display list construction.
1261 void GLAPIENTRY
_ae_ArrayElement( GLint elt
)
1263 GET_CURRENT_CONTEXT(ctx
);
1264 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1267 const struct _glapi_table
* const disp
= GET_DISPATCH();
1270 if (actx
->NewState
) {
1271 assert(!actx
->mapped_vbos
);
1272 _ae_update_state( ctx
);
1275 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1282 /* generic attributes */
1283 for (at
= actx
->attribs
; at
->func
; at
++) {
1285 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1286 + elt
* at
->array
->StrideB
;
1287 at
->func( at
->index
, src
);
1290 /* conventional arrays */
1291 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1293 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1294 + elt
* aa
->array
->StrideB
;
1295 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1296 ((const void *) src
) );
1300 _ae_unmap_vbos(ctx
);
1304 void _ae_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
1306 AEcontext
*actx
= AE_CONTEXT(ctx
);
1309 /* Only interested in this subset of mesa state. Need to prune
1310 * this down as both tnl/ and the drivers can raise statechanges
1311 * for arcane reasons in the middle of seemingly atomic operations
1312 * like DrawElements, over which we'd like to keep a known set of
1313 * arrays and vbo's mapped.
1315 * Luckily, neither the drivers nor tnl muck with the state that
1318 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1320 assert(!actx
->mapped_vbos
);
1321 actx
->NewState
|= new_state
;
1326 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1327 const GLvertexformat
*vfmt
)
1329 SET_ArrayElement(disp
, vfmt
->ArrayElement
);
1333 #endif /* FEATURE_arrayelt */