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 )
74 static const int ColorFuncs
[2][8] = {
97 static const int VertexFuncs
[3][8] = {
130 static const int IndexFuncs
[8] = {
141 static const int NormalFuncs
[8] = {
152 /* Note: _gloffset_* for these may not be a compile-time constant. */
153 static int SecondaryColorFuncs
[8];
154 static int FogCoordFuncs
[8];
158 ** GL_NV_vertex_program
161 /* GL_BYTE attributes */
163 static void GLAPIENTRY
VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
165 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
168 static void GLAPIENTRY
VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
170 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
173 static void GLAPIENTRY
VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
175 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
178 static void GLAPIENTRY
VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
180 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
183 static void GLAPIENTRY
VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
185 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
187 BYTE_TO_FLOAT(v
[2])));
190 static void GLAPIENTRY
VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
192 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
195 static void GLAPIENTRY
VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
197 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
200 BYTE_TO_FLOAT(v
[3])));
203 static void GLAPIENTRY
VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
205 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
208 /* GL_UNSIGNED_BYTE attributes */
210 static void GLAPIENTRY
VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
212 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
215 static void GLAPIENTRY
VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
217 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
220 static void GLAPIENTRY
VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
222 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
223 UBYTE_TO_FLOAT(v
[1])));
226 static void GLAPIENTRY
VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
228 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
231 static void GLAPIENTRY
VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
233 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
234 UBYTE_TO_FLOAT(v
[1]),
235 UBYTE_TO_FLOAT(v
[2])));
237 static void GLAPIENTRY
VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
239 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
242 static void GLAPIENTRY
VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
244 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
245 UBYTE_TO_FLOAT(v
[1]),
246 UBYTE_TO_FLOAT(v
[2]),
247 UBYTE_TO_FLOAT(v
[3])));
250 static void GLAPIENTRY
VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
252 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
255 /* GL_SHORT attributes */
257 static void GLAPIENTRY
VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
259 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
262 static void GLAPIENTRY
VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
264 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
267 static void GLAPIENTRY
VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
269 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
270 SHORT_TO_FLOAT(v
[1])));
273 static void GLAPIENTRY
VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
275 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
278 static void GLAPIENTRY
VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
280 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
281 SHORT_TO_FLOAT(v
[1]),
282 SHORT_TO_FLOAT(v
[2])));
285 static void GLAPIENTRY
VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
287 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
290 static void GLAPIENTRY
VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
292 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
293 SHORT_TO_FLOAT(v
[1]),
294 SHORT_TO_FLOAT(v
[2]),
295 SHORT_TO_FLOAT(v
[3])));
298 static void GLAPIENTRY
VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
300 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
303 /* GL_UNSIGNED_SHORT attributes */
305 static void GLAPIENTRY
VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
307 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
310 static void GLAPIENTRY
VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
312 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
315 static void GLAPIENTRY
VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
317 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
318 USHORT_TO_FLOAT(v
[1])));
321 static void GLAPIENTRY
VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
323 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
326 static void GLAPIENTRY
VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
328 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
329 USHORT_TO_FLOAT(v
[1]),
330 USHORT_TO_FLOAT(v
[2])));
333 static void GLAPIENTRY
VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
335 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
338 static void GLAPIENTRY
VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
340 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
341 USHORT_TO_FLOAT(v
[1]),
342 USHORT_TO_FLOAT(v
[2]),
343 USHORT_TO_FLOAT(v
[3])));
346 static void GLAPIENTRY
VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
348 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
351 /* GL_INT attributes */
353 static void GLAPIENTRY
VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
355 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
358 static void GLAPIENTRY
VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
360 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
363 static void GLAPIENTRY
VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
365 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
366 INT_TO_FLOAT(v
[1])));
369 static void GLAPIENTRY
VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
371 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
374 static void GLAPIENTRY
VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
376 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
378 INT_TO_FLOAT(v
[2])));
381 static void GLAPIENTRY
VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
383 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
386 static void GLAPIENTRY
VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
388 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
391 INT_TO_FLOAT(v
[3])));
394 static void GLAPIENTRY
VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
396 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
399 /* GL_UNSIGNED_INT attributes */
401 static void GLAPIENTRY
VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
403 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
406 static void GLAPIENTRY
VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
408 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
411 static void GLAPIENTRY
VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
413 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
414 UINT_TO_FLOAT(v
[1])));
417 static void GLAPIENTRY
VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
419 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
422 static void GLAPIENTRY
VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
424 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
426 UINT_TO_FLOAT(v
[2])));
429 static void GLAPIENTRY
VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
431 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
434 static void GLAPIENTRY
VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
436 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
439 UINT_TO_FLOAT(v
[3])));
442 static void GLAPIENTRY
VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
444 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
447 /* GL_FLOAT attributes */
449 static void GLAPIENTRY
VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
451 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
454 static void GLAPIENTRY
VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
456 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
459 static void GLAPIENTRY
VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
461 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
464 static void GLAPIENTRY
VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
466 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
469 /* GL_DOUBLE attributes */
471 static void GLAPIENTRY
VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
473 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
476 static void GLAPIENTRY
VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
478 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
481 static void GLAPIENTRY
VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
483 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
486 static void GLAPIENTRY
VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
488 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
493 * Array [size][type] of VertexAttrib functions
495 static attrib_func AttribFuncsNV
[2][4][8] = {
500 (attrib_func
) VertexAttrib1bvNV
,
501 (attrib_func
) VertexAttrib1ubvNV
,
502 (attrib_func
) VertexAttrib1svNV
,
503 (attrib_func
) VertexAttrib1usvNV
,
504 (attrib_func
) VertexAttrib1ivNV
,
505 (attrib_func
) VertexAttrib1uivNV
,
506 (attrib_func
) VertexAttrib1fvNV
,
507 (attrib_func
) VertexAttrib1dvNV
511 (attrib_func
) VertexAttrib2bvNV
,
512 (attrib_func
) VertexAttrib2ubvNV
,
513 (attrib_func
) VertexAttrib2svNV
,
514 (attrib_func
) VertexAttrib2usvNV
,
515 (attrib_func
) VertexAttrib2ivNV
,
516 (attrib_func
) VertexAttrib2uivNV
,
517 (attrib_func
) VertexAttrib2fvNV
,
518 (attrib_func
) VertexAttrib2dvNV
522 (attrib_func
) VertexAttrib3bvNV
,
523 (attrib_func
) VertexAttrib3ubvNV
,
524 (attrib_func
) VertexAttrib3svNV
,
525 (attrib_func
) VertexAttrib3usvNV
,
526 (attrib_func
) VertexAttrib3ivNV
,
527 (attrib_func
) VertexAttrib3uivNV
,
528 (attrib_func
) VertexAttrib3fvNV
,
529 (attrib_func
) VertexAttrib3dvNV
533 (attrib_func
) VertexAttrib4bvNV
,
534 (attrib_func
) VertexAttrib4ubvNV
,
535 (attrib_func
) VertexAttrib4svNV
,
536 (attrib_func
) VertexAttrib4usvNV
,
537 (attrib_func
) VertexAttrib4ivNV
,
538 (attrib_func
) VertexAttrib4uivNV
,
539 (attrib_func
) VertexAttrib4fvNV
,
540 (attrib_func
) VertexAttrib4dvNV
544 /* normalized (except for float/double) */
547 (attrib_func
) VertexAttrib1NbvNV
,
548 (attrib_func
) VertexAttrib1NubvNV
,
549 (attrib_func
) VertexAttrib1NsvNV
,
550 (attrib_func
) VertexAttrib1NusvNV
,
551 (attrib_func
) VertexAttrib1NivNV
,
552 (attrib_func
) VertexAttrib1NuivNV
,
553 (attrib_func
) VertexAttrib1fvNV
,
554 (attrib_func
) VertexAttrib1dvNV
558 (attrib_func
) VertexAttrib2NbvNV
,
559 (attrib_func
) VertexAttrib2NubvNV
,
560 (attrib_func
) VertexAttrib2NsvNV
,
561 (attrib_func
) VertexAttrib2NusvNV
,
562 (attrib_func
) VertexAttrib2NivNV
,
563 (attrib_func
) VertexAttrib2NuivNV
,
564 (attrib_func
) VertexAttrib2fvNV
,
565 (attrib_func
) VertexAttrib2dvNV
569 (attrib_func
) VertexAttrib3NbvNV
,
570 (attrib_func
) VertexAttrib3NubvNV
,
571 (attrib_func
) VertexAttrib3NsvNV
,
572 (attrib_func
) VertexAttrib3NusvNV
,
573 (attrib_func
) VertexAttrib3NivNV
,
574 (attrib_func
) VertexAttrib3NuivNV
,
575 (attrib_func
) VertexAttrib3fvNV
,
576 (attrib_func
) VertexAttrib3dvNV
580 (attrib_func
) VertexAttrib4NbvNV
,
581 (attrib_func
) VertexAttrib4NubvNV
,
582 (attrib_func
) VertexAttrib4NsvNV
,
583 (attrib_func
) VertexAttrib4NusvNV
,
584 (attrib_func
) VertexAttrib4NivNV
,
585 (attrib_func
) VertexAttrib4NuivNV
,
586 (attrib_func
) VertexAttrib4fvNV
,
587 (attrib_func
) VertexAttrib4dvNV
594 ** GL_ARB_vertex_program
597 /* GL_BYTE attributes */
599 static void GLAPIENTRY
VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
601 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
604 static void GLAPIENTRY
VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
606 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
609 static void GLAPIENTRY
VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
611 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
614 static void GLAPIENTRY
VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
616 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
619 static void GLAPIENTRY
VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
621 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
623 BYTE_TO_FLOAT(v
[2])));
626 static void GLAPIENTRY
VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
628 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
631 static void GLAPIENTRY
VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
633 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
636 BYTE_TO_FLOAT(v
[3])));
639 static void GLAPIENTRY
VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
641 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
644 /* GL_UNSIGNED_BYTE attributes */
646 static void GLAPIENTRY
VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
648 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
651 static void GLAPIENTRY
VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
653 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
656 static void GLAPIENTRY
VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
658 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
659 UBYTE_TO_FLOAT(v
[1])));
662 static void GLAPIENTRY
VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
664 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
667 static void GLAPIENTRY
VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
669 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
670 UBYTE_TO_FLOAT(v
[1]),
671 UBYTE_TO_FLOAT(v
[2])));
673 static void GLAPIENTRY
VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
675 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
678 static void GLAPIENTRY
VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
680 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
681 UBYTE_TO_FLOAT(v
[1]),
682 UBYTE_TO_FLOAT(v
[2]),
683 UBYTE_TO_FLOAT(v
[3])));
686 static void GLAPIENTRY
VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
688 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
691 /* GL_SHORT attributes */
693 static void GLAPIENTRY
VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
695 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
698 static void GLAPIENTRY
VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
700 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
703 static void GLAPIENTRY
VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
705 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
706 SHORT_TO_FLOAT(v
[1])));
709 static void GLAPIENTRY
VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
711 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
714 static void GLAPIENTRY
VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
716 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
717 SHORT_TO_FLOAT(v
[1]),
718 SHORT_TO_FLOAT(v
[2])));
721 static void GLAPIENTRY
VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
723 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
726 static void GLAPIENTRY
VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
728 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
729 SHORT_TO_FLOAT(v
[1]),
730 SHORT_TO_FLOAT(v
[2]),
731 SHORT_TO_FLOAT(v
[3])));
734 static void GLAPIENTRY
VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
736 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
739 /* GL_UNSIGNED_SHORT attributes */
741 static void GLAPIENTRY
VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
743 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
746 static void GLAPIENTRY
VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
748 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
751 static void GLAPIENTRY
VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
753 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
754 USHORT_TO_FLOAT(v
[1])));
757 static void GLAPIENTRY
VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
759 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
762 static void GLAPIENTRY
VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
764 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
765 USHORT_TO_FLOAT(v
[1]),
766 USHORT_TO_FLOAT(v
[2])));
769 static void GLAPIENTRY
VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
771 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
774 static void GLAPIENTRY
VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
776 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
777 USHORT_TO_FLOAT(v
[1]),
778 USHORT_TO_FLOAT(v
[2]),
779 USHORT_TO_FLOAT(v
[3])));
782 static void GLAPIENTRY
VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
784 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
787 /* GL_INT attributes */
789 static void GLAPIENTRY
VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
791 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
794 static void GLAPIENTRY
VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
796 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
799 static void GLAPIENTRY
VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
801 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
802 INT_TO_FLOAT(v
[1])));
805 static void GLAPIENTRY
VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
807 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
810 static void GLAPIENTRY
VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
812 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
814 INT_TO_FLOAT(v
[2])));
817 static void GLAPIENTRY
VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
819 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
822 static void GLAPIENTRY
VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
824 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
827 INT_TO_FLOAT(v
[3])));
830 static void GLAPIENTRY
VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
832 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
835 /* GL_UNSIGNED_INT attributes */
837 static void GLAPIENTRY
VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
839 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
842 static void GLAPIENTRY
VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
844 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
847 static void GLAPIENTRY
VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
849 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
850 UINT_TO_FLOAT(v
[1])));
853 static void GLAPIENTRY
VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
855 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
858 static void GLAPIENTRY
VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
860 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
862 UINT_TO_FLOAT(v
[2])));
865 static void GLAPIENTRY
VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
867 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
870 static void GLAPIENTRY
VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
872 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
875 UINT_TO_FLOAT(v
[3])));
878 static void GLAPIENTRY
VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
880 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
883 /* GL_FLOAT attributes */
885 static void GLAPIENTRY
VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
887 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
890 static void GLAPIENTRY
VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
892 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
895 static void GLAPIENTRY
VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
897 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
900 static void GLAPIENTRY
VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
902 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
905 /* GL_DOUBLE attributes */
907 static void GLAPIENTRY
VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
909 CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index
, v
));
912 static void GLAPIENTRY
VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
914 CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index
, v
));
917 static void GLAPIENTRY
VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
919 CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index
, v
));
922 static void GLAPIENTRY
VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
924 CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index
, v
));
929 * Array [size][type] of VertexAttrib functions
931 static attrib_func AttribFuncsARB
[2][4][8] = {
936 (attrib_func
) VertexAttrib1bvARB
,
937 (attrib_func
) VertexAttrib1ubvARB
,
938 (attrib_func
) VertexAttrib1svARB
,
939 (attrib_func
) VertexAttrib1usvARB
,
940 (attrib_func
) VertexAttrib1ivARB
,
941 (attrib_func
) VertexAttrib1uivARB
,
942 (attrib_func
) VertexAttrib1fvARB
,
943 (attrib_func
) VertexAttrib1dvARB
947 (attrib_func
) VertexAttrib2bvARB
,
948 (attrib_func
) VertexAttrib2ubvARB
,
949 (attrib_func
) VertexAttrib2svARB
,
950 (attrib_func
) VertexAttrib2usvARB
,
951 (attrib_func
) VertexAttrib2ivARB
,
952 (attrib_func
) VertexAttrib2uivARB
,
953 (attrib_func
) VertexAttrib2fvARB
,
954 (attrib_func
) VertexAttrib2dvARB
958 (attrib_func
) VertexAttrib3bvARB
,
959 (attrib_func
) VertexAttrib3ubvARB
,
960 (attrib_func
) VertexAttrib3svARB
,
961 (attrib_func
) VertexAttrib3usvARB
,
962 (attrib_func
) VertexAttrib3ivARB
,
963 (attrib_func
) VertexAttrib3uivARB
,
964 (attrib_func
) VertexAttrib3fvARB
,
965 (attrib_func
) VertexAttrib3dvARB
969 (attrib_func
) VertexAttrib4bvARB
,
970 (attrib_func
) VertexAttrib4ubvARB
,
971 (attrib_func
) VertexAttrib4svARB
,
972 (attrib_func
) VertexAttrib4usvARB
,
973 (attrib_func
) VertexAttrib4ivARB
,
974 (attrib_func
) VertexAttrib4uivARB
,
975 (attrib_func
) VertexAttrib4fvARB
,
976 (attrib_func
) VertexAttrib4dvARB
980 /* normalized (except for float/double) */
983 (attrib_func
) VertexAttrib1NbvARB
,
984 (attrib_func
) VertexAttrib1NubvARB
,
985 (attrib_func
) VertexAttrib1NsvARB
,
986 (attrib_func
) VertexAttrib1NusvARB
,
987 (attrib_func
) VertexAttrib1NivARB
,
988 (attrib_func
) VertexAttrib1NuivARB
,
989 (attrib_func
) VertexAttrib1fvARB
,
990 (attrib_func
) VertexAttrib1dvARB
994 (attrib_func
) VertexAttrib2NbvARB
,
995 (attrib_func
) VertexAttrib2NubvARB
,
996 (attrib_func
) VertexAttrib2NsvARB
,
997 (attrib_func
) VertexAttrib2NusvARB
,
998 (attrib_func
) VertexAttrib2NivARB
,
999 (attrib_func
) VertexAttrib2NuivARB
,
1000 (attrib_func
) VertexAttrib2fvARB
,
1001 (attrib_func
) VertexAttrib2dvARB
1005 (attrib_func
) VertexAttrib3NbvARB
,
1006 (attrib_func
) VertexAttrib3NubvARB
,
1007 (attrib_func
) VertexAttrib3NsvARB
,
1008 (attrib_func
) VertexAttrib3NusvARB
,
1009 (attrib_func
) VertexAttrib3NivARB
,
1010 (attrib_func
) VertexAttrib3NuivARB
,
1011 (attrib_func
) VertexAttrib3fvARB
,
1012 (attrib_func
) VertexAttrib3dvARB
1016 (attrib_func
) VertexAttrib4NbvARB
,
1017 (attrib_func
) VertexAttrib4NubvARB
,
1018 (attrib_func
) VertexAttrib4NsvARB
,
1019 (attrib_func
) VertexAttrib4NusvARB
,
1020 (attrib_func
) VertexAttrib4NivARB
,
1021 (attrib_func
) VertexAttrib4NuivARB
,
1022 (attrib_func
) VertexAttrib4fvARB
,
1023 (attrib_func
) VertexAttrib4dvARB
1028 /**********************************************************************/
1031 GLboolean
_ae_create_context( GLcontext
*ctx
)
1033 if (ctx
->aelt_context
)
1036 /* These _gloffset_* values may not be compile-time constants */
1037 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bvEXT
;
1038 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubvEXT
;
1039 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3svEXT
;
1040 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usvEXT
;
1041 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3ivEXT
;
1042 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uivEXT
;
1043 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1044 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dvEXT
;
1046 FogCoordFuncs
[0] = -1;
1047 FogCoordFuncs
[1] = -1;
1048 FogCoordFuncs
[2] = -1;
1049 FogCoordFuncs
[3] = -1;
1050 FogCoordFuncs
[4] = -1;
1051 FogCoordFuncs
[5] = -1;
1052 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1053 FogCoordFuncs
[7] = _gloffset_FogCoorddvEXT
;
1055 ctx
->aelt_context
= CALLOC( sizeof(AEcontext
) );
1056 if (!ctx
->aelt_context
)
1059 AE_CONTEXT(ctx
)->NewState
= ~0;
1064 void _ae_destroy_context( GLcontext
*ctx
)
1066 if ( AE_CONTEXT( ctx
) ) {
1067 FREE( ctx
->aelt_context
);
1068 ctx
->aelt_context
= NULL
;
1072 static void check_vbo( AEcontext
*actx
,
1073 struct gl_buffer_object
*vbo
)
1075 if (_mesa_is_bufferobj(vbo
) && !_mesa_bufferobj_mapped(vbo
)) {
1077 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1078 if (actx
->vbo
[i
] == vbo
)
1080 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1081 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1087 * Make a list of per-vertex functions to call for each glArrayElement call.
1088 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1090 * Note: this may be called during display list construction.
1092 static void _ae_update_state( GLcontext
*ctx
)
1094 AEcontext
*actx
= AE_CONTEXT(ctx
);
1095 AEarray
*aa
= actx
->arrays
;
1096 AEattrib
*at
= actx
->attribs
;
1098 struct gl_array_object
*arrayObj
= ctx
->Array
.ArrayObj
;
1102 /* conventional vertex arrays */
1103 if (arrayObj
->Index
.Enabled
) {
1104 aa
->array
= &arrayObj
->Index
;
1105 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1106 check_vbo(actx
, aa
->array
->BufferObj
);
1109 if (arrayObj
->EdgeFlag
.Enabled
) {
1110 aa
->array
= &arrayObj
->EdgeFlag
;
1111 aa
->offset
= _gloffset_EdgeFlagv
;
1112 check_vbo(actx
, aa
->array
->BufferObj
);
1115 if (arrayObj
->Normal
.Enabled
) {
1116 aa
->array
= &arrayObj
->Normal
;
1117 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1118 check_vbo(actx
, aa
->array
->BufferObj
);
1121 if (arrayObj
->Color
.Enabled
) {
1122 aa
->array
= &arrayObj
->Color
;
1123 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1124 check_vbo(actx
, aa
->array
->BufferObj
);
1127 if (arrayObj
->SecondaryColor
.Enabled
) {
1128 aa
->array
= &arrayObj
->SecondaryColor
;
1129 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1130 check_vbo(actx
, aa
->array
->BufferObj
);
1133 if (arrayObj
->FogCoord
.Enabled
) {
1134 aa
->array
= &arrayObj
->FogCoord
;
1135 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1136 check_vbo(actx
, aa
->array
->BufferObj
);
1139 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1140 struct gl_client_array
*attribArray
= &arrayObj
->TexCoord
[i
];
1141 if (attribArray
->Enabled
) {
1142 /* NOTE: we use generic glVertexAttribNV functions here.
1143 * If we ever remove GL_NV_vertex_program this will have to change.
1145 at
->array
= attribArray
;
1146 ASSERT(!at
->array
->Normalized
);
1147 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1149 [TYPE_IDX(at
->array
->Type
)];
1150 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1151 check_vbo(actx
, at
->array
->BufferObj
);
1156 /* generic vertex attribute arrays */
1157 for (i
= 1; i
< Elements(arrayObj
->VertexAttrib
); i
++) { /* skip zero! */
1158 struct gl_client_array
*attribArray
= &arrayObj
->VertexAttrib
[i
];
1159 if (attribArray
->Enabled
) {
1160 at
->array
= attribArray
;
1161 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1162 * function pointer here (for float arrays) since the pointer may
1163 * change from one execution of _ae_loopback_array_elt() to
1164 * the next. Doing so caused UT to break.
1166 if (ctx
->VertexProgram
._Enabled
1167 && ctx
->VertexProgram
.Current
->IsNVProgram
) {
1168 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1170 [TYPE_IDX(at
->array
->Type
)];
1173 at
->func
= AttribFuncsARB
[at
->array
->Normalized
]
1175 [TYPE_IDX(at
->array
->Type
)];
1178 check_vbo(actx
, at
->array
->BufferObj
);
1183 /* finally, vertex position */
1184 if (arrayObj
->VertexAttrib
[0].Enabled
) {
1185 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1186 * issued as the last (provoking) attribute).
1188 aa
->array
= &arrayObj
->VertexAttrib
[0];
1189 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1190 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1191 check_vbo(actx
, aa
->array
->BufferObj
);
1194 else if (arrayObj
->Vertex
.Enabled
) {
1195 aa
->array
= &arrayObj
->Vertex
;
1196 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1197 check_vbo(actx
, aa
->array
->BufferObj
);
1201 check_vbo(actx
, ctx
->Array
.ElementArrayBufferObj
);
1203 ASSERT(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1204 ASSERT(aa
- actx
->arrays
< 32);
1205 at
->func
= NULL
; /* terminate the list */
1206 aa
->offset
= -1; /* terminate the list */
1211 void _ae_map_vbos( GLcontext
*ctx
)
1213 AEcontext
*actx
= AE_CONTEXT(ctx
);
1216 if (actx
->mapped_vbos
)
1220 _ae_update_state(ctx
);
1222 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1223 ctx
->Driver
.MapBuffer(ctx
,
1224 GL_ARRAY_BUFFER_ARB
,
1225 GL_DYNAMIC_DRAW_ARB
,
1229 actx
->mapped_vbos
= GL_TRUE
;
1232 void _ae_unmap_vbos( GLcontext
*ctx
)
1234 AEcontext
*actx
= AE_CONTEXT(ctx
);
1237 if (!actx
->mapped_vbos
)
1240 assert (!actx
->NewState
);
1242 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1243 ctx
->Driver
.UnmapBuffer(ctx
,
1244 GL_ARRAY_BUFFER_ARB
,
1247 actx
->mapped_vbos
= GL_FALSE
;
1252 * Called via glArrayElement() and glDrawArrays().
1253 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1254 * for all enabled vertex arrays (for elt-th element).
1255 * Note: this may be called during display list construction.
1257 void GLAPIENTRY
_ae_loopback_array_elt( GLint elt
)
1259 GET_CURRENT_CONTEXT(ctx
);
1260 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1263 const struct _glapi_table
* const disp
= GET_DISPATCH();
1266 if (actx
->NewState
) {
1267 assert(!actx
->mapped_vbos
);
1268 _ae_update_state( ctx
);
1271 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1278 /* generic attributes */
1279 for (at
= actx
->attribs
; at
->func
; at
++) {
1281 = ADD_POINTERS(at
->array
->BufferObj
->Pointer
, at
->array
->Ptr
)
1282 + elt
* at
->array
->StrideB
;
1283 at
->func( at
->index
, src
);
1286 /* conventional arrays */
1287 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1289 = ADD_POINTERS(aa
->array
->BufferObj
->Pointer
, aa
->array
->Ptr
)
1290 + elt
* aa
->array
->StrideB
;
1291 CALL_by_offset( disp
, (array_func
), aa
->offset
,
1292 ((const void *) src
) );
1296 _ae_unmap_vbos(ctx
);
1300 void _ae_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
1302 AEcontext
*actx
= AE_CONTEXT(ctx
);
1305 /* Only interested in this subset of mesa state. Need to prune
1306 * this down as both tnl/ and the drivers can raise statechanges
1307 * for arcane reasons in the middle of seemingly atomic operations
1308 * like DrawElements, over which we'd like to keep a known set of
1309 * arrays and vbo's mapped.
1311 * Luckily, neither the drivers nor tnl muck with the state that
1314 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1316 assert(!actx
->mapped_vbos
);
1317 actx
->NewState
|= new_state
;