blob: e905f164025fe2347dd81d6692d25b9d6a7be6c8 [file] [log] [blame]
Gareth Hughes22144ab2001-03-12 00:48:37 +00001/*
2 * Mesa 3-D graphics library
Brian Paul024b5892005-11-25 17:07:10 +00003 * Version: 6.5
Gareth Hughes22144ab2001-03-12 00:48:37 +00004 *
Brian Pauleec33cc2006-03-17 04:13:29 +00005 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
Gareth Hughes22144ab2001-03-12 00:48:37 +00006 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
Keith Whitwellfc00cbe2001-12-20 15:30:45 +000025/* Author:
Brian Paul05a4b372002-10-29 20:28:36 +000026 * Keith Whitwell <keith@tungstengraphics.com>
Keith Whitwellfc00cbe2001-12-20 15:30:45 +000027 */
28
Keith Whitwellcab974c2000-12-26 05:09:27 +000029#include "glheader.h"
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000030#include "api_arrayelt.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000031#include "context.h"
Brian Paul3c634522002-10-24 23:57:19 +000032#include "imports.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000033#include "macros.h"
Ian Romanick9bdfee32005-07-18 12:31:24 +000034#include "glapioffsets.h"
35#include "dispatch.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000036
Karl Schultzb72902e2004-01-28 22:24:12 +000037typedef void (GLAPIENTRY *array_func)( const void * );
Keith Whitwellcab974c2000-12-26 05:09:27 +000038
39typedef struct {
Brian Paul0d4393a2004-02-11 22:53:38 +000040 const struct gl_client_array *array;
Ian Romanick9bdfee32005-07-18 12:31:24 +000041 int offset;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000042} AEarray;
Keith Whitwellcab974c2000-12-26 05:09:27 +000043
Brian Paul0d4393a2004-02-11 22:53:38 +000044typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
45
Keith Whitwellcab974c2000-12-26 05:09:27 +000046typedef struct {
Brian Paul0d4393a2004-02-11 22:53:38 +000047 const struct gl_client_array *array;
48 attrib_func func;
49 GLuint index;
50} AEattrib;
51
52typedef struct {
Brian Paul53ad0362004-02-09 00:24:48 +000053 AEarray arrays[32];
Brian Paul0d4393a2004-02-11 22:53:38 +000054 AEattrib attribs[VERT_ATTRIB_MAX + 1];
Keith Whitwellcab974c2000-12-26 05:09:27 +000055 GLuint NewState;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000056} AEcontext;
Keith Whitwellcab974c2000-12-26 05:09:27 +000057
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000058#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
Brian Paul0d4393a2004-02-11 22:53:38 +000059
Ian Romanick9bdfee32005-07-18 12:31:24 +000060
Brian Paul0d4393a2004-02-11 22:53:38 +000061/*
62 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
63 * in the range [0, 7]. Luckily these type tokens are sequentially
Brian Paulf2f33502004-04-23 17:58:06 +000064 * numbered in gl.h, except for GL_DOUBLE.
Brian Paul0d4393a2004-02-11 22:53:38 +000065 */
Brian Paulf2f33502004-04-23 17:58:06 +000066#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
Keith Whitwellcab974c2000-12-26 05:09:27 +000067
Ian Romanick9bdfee32005-07-18 12:31:24 +000068static const int ColorFuncs[2][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000069 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000070 _gloffset_Color3bv,
71 _gloffset_Color3ubv,
72 _gloffset_Color3sv,
73 _gloffset_Color3usv,
74 _gloffset_Color3iv,
75 _gloffset_Color3uiv,
76 _gloffset_Color3fv,
77 _gloffset_Color3dv,
Adam Jackson94987be2004-10-24 02:05:40 +000078 },
79 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000080 _gloffset_Color4bv,
81 _gloffset_Color4ubv,
82 _gloffset_Color4sv,
83 _gloffset_Color4usv,
84 _gloffset_Color4iv,
85 _gloffset_Color4uiv,
86 _gloffset_Color4fv,
87 _gloffset_Color4dv,
Adam Jackson94987be2004-10-24 02:05:40 +000088 },
Brian Paul53ad0362004-02-09 00:24:48 +000089};
90
Ian Romanick9bdfee32005-07-18 12:31:24 +000091static const int VertexFuncs[3][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000092 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000093 -1,
94 -1,
95 _gloffset_Vertex2sv,
96 -1,
97 _gloffset_Vertex2iv,
98 -1,
99 _gloffset_Vertex2fv,
100 _gloffset_Vertex2dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000101 },
102 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000103 -1,
104 -1,
105 _gloffset_Vertex3sv,
106 -1,
107 _gloffset_Vertex3iv,
108 -1,
109 _gloffset_Vertex3fv,
110 _gloffset_Vertex3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000111 },
112 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000113 -1,
114 -1,
115 _gloffset_Vertex4sv,
116 -1,
117 _gloffset_Vertex4iv,
118 -1,
119 _gloffset_Vertex4fv,
120 _gloffset_Vertex4dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000121 },
Brian Paul53ad0362004-02-09 00:24:48 +0000122};
123
Ian Romanick9bdfee32005-07-18 12:31:24 +0000124static const int IndexFuncs[8] = {
125 -1,
126 _gloffset_Indexubv,
127 _gloffset_Indexsv,
128 -1,
129 _gloffset_Indexiv,
130 -1,
131 _gloffset_Indexfv,
132 _gloffset_Indexdv,
Keith Whitwellcab974c2000-12-26 05:09:27 +0000133};
134
Ian Romanick9bdfee32005-07-18 12:31:24 +0000135static const int NormalFuncs[8] = {
136 _gloffset_Normal3bv,
137 -1,
138 _gloffset_Normal3sv,
139 -1,
140 _gloffset_Normal3iv,
141 -1,
142 _gloffset_Normal3fv,
143 _gloffset_Normal3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000144};
Brian Paul53ad0362004-02-09 00:24:48 +0000145
Brian Paul0f1d98c2006-03-17 04:10:03 +0000146/* Note: _gloffset_* for these may not be a compile-time constant. */
Ian Romanick126c89e2005-08-05 18:13:37 +0000147static int SecondaryColorFuncs[8];
Brian Paul0f1d98c2006-03-17 04:10:03 +0000148static int FogCoordFuncs[8];
Brian Paul53ad0362004-02-09 00:24:48 +0000149
Brian Paul0d4393a2004-02-11 22:53:38 +0000150/**********************************************************************/
151
152/* GL_BYTE attributes */
153
Brian Paulb5b8d222004-11-27 20:07:08 +0000154static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000155{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000156 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000157}
158
Brian Paulb5b8d222004-11-27 20:07:08 +0000159static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000160{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000161 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000162}
163
Brian Paulb5b8d222004-11-27 20:07:08 +0000164static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000165{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000166 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000167}
168
Brian Paulb5b8d222004-11-27 20:07:08 +0000169static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000170{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000171 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000172}
173
Brian Paulb5b8d222004-11-27 20:07:08 +0000174static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000175{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000176 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
177 BYTE_TO_FLOAT(v[1]),
178 BYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000179}
180
Brian Paulb5b8d222004-11-27 20:07:08 +0000181static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000182{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000183 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000184}
185
Brian Paulb5b8d222004-11-27 20:07:08 +0000186static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000187{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000188 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
189 BYTE_TO_FLOAT(v[1]),
190 BYTE_TO_FLOAT(v[2]),
191 BYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000192}
193
Brian Paulb5b8d222004-11-27 20:07:08 +0000194static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000195{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000196 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000197}
198
199/* GL_UNSIGNED_BYTE attributes */
200
Brian Paulb5b8d222004-11-27 20:07:08 +0000201static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000202{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000203 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000204}
205
Brian Paulb5b8d222004-11-27 20:07:08 +0000206static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000207{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000208 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000209}
210
Brian Paulb5b8d222004-11-27 20:07:08 +0000211static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000212{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000213 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
214 UBYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000215}
216
Brian Paulb5b8d222004-11-27 20:07:08 +0000217static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000218{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000219 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000220}
221
Brian Paulb5b8d222004-11-27 20:07:08 +0000222static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000223{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000224 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
225 UBYTE_TO_FLOAT(v[1]),
226 UBYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000227}
Brian Paulb5b8d222004-11-27 20:07:08 +0000228static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000229{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000230 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000231}
232
Brian Paulb5b8d222004-11-27 20:07:08 +0000233static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000234{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000235 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
Brian Paul0d4393a2004-02-11 22:53:38 +0000236 UBYTE_TO_FLOAT(v[1]),
237 UBYTE_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000238 UBYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000239}
240
Brian Paulb5b8d222004-11-27 20:07:08 +0000241static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000242{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000243 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000244}
245
246/* GL_SHORT attributes */
247
Brian Paulb5b8d222004-11-27 20:07:08 +0000248static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000249{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000250 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000251}
252
Brian Paulb5b8d222004-11-27 20:07:08 +0000253static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000254{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000255 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000256}
257
Brian Paulb5b8d222004-11-27 20:07:08 +0000258static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000259{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000260 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
261 SHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000262}
263
Brian Paulb5b8d222004-11-27 20:07:08 +0000264static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000265{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000266 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000267}
268
Brian Paulb5b8d222004-11-27 20:07:08 +0000269static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000270{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000271 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000272 SHORT_TO_FLOAT(v[1]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000273 SHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000274}
275
Brian Paulb5b8d222004-11-27 20:07:08 +0000276static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000277{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000278 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000279}
280
Brian Paulb5b8d222004-11-27 20:07:08 +0000281static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000282{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000283 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000284 SHORT_TO_FLOAT(v[1]),
285 SHORT_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000286 SHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000287}
288
Brian Paulb5b8d222004-11-27 20:07:08 +0000289static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000290{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000291 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000292}
293
294/* GL_UNSIGNED_SHORT attributes */
295
Brian Paulb5b8d222004-11-27 20:07:08 +0000296static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000297{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000298 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000299}
300
Brian Paulb5b8d222004-11-27 20:07:08 +0000301static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000302{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000303 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000304}
305
Brian Paulb5b8d222004-11-27 20:07:08 +0000306static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000307{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000308 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
309 USHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000310}
311
Brian Paulb5b8d222004-11-27 20:07:08 +0000312static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000313{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000314 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000315}
316
Brian Paulb5b8d222004-11-27 20:07:08 +0000317static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000318{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000319 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
320 USHORT_TO_FLOAT(v[1]),
321 USHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000322}
323
Brian Paulb5b8d222004-11-27 20:07:08 +0000324static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000325{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000326 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000327}
328
Brian Paulb5b8d222004-11-27 20:07:08 +0000329static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000330{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000331 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
332 USHORT_TO_FLOAT(v[1]),
333 USHORT_TO_FLOAT(v[2]),
334 USHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000335}
336
Brian Paulb5b8d222004-11-27 20:07:08 +0000337static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000338{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000339 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000340}
341
342/* GL_INT attributes */
343
Brian Paulb5b8d222004-11-27 20:07:08 +0000344static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000345{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000346 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000347}
348
Brian Paulb5b8d222004-11-27 20:07:08 +0000349static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000350{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000351 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000352}
353
Brian Paulb5b8d222004-11-27 20:07:08 +0000354static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000355{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000356 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
357 INT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000358}
359
Brian Paulb5b8d222004-11-27 20:07:08 +0000360static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000361{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000362 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000363}
364
Brian Paulb5b8d222004-11-27 20:07:08 +0000365static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000366{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000367 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
368 INT_TO_FLOAT(v[1]),
369 INT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000370}
371
Brian Paulb5b8d222004-11-27 20:07:08 +0000372static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000373{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000374 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000375}
376
Brian Paulb5b8d222004-11-27 20:07:08 +0000377static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000378{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000379 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
380 INT_TO_FLOAT(v[1]),
381 INT_TO_FLOAT(v[2]),
382 INT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000383}
384
Brian Paulb5b8d222004-11-27 20:07:08 +0000385static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000386{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000387 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000388}
389
390/* GL_UNSIGNED_INT attributes */
391
Brian Paulb5b8d222004-11-27 20:07:08 +0000392static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000393{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000394 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000395}
396
Brian Paulb5b8d222004-11-27 20:07:08 +0000397static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000398{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000399 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000400}
401
Brian Paulb5b8d222004-11-27 20:07:08 +0000402static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000403{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000404 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
405 UINT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000406}
407
Brian Paulb5b8d222004-11-27 20:07:08 +0000408static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000409{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000410 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000411}
412
Brian Paulb5b8d222004-11-27 20:07:08 +0000413static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000414{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000415 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
416 UINT_TO_FLOAT(v[1]),
417 UINT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000418}
419
Brian Paulb5b8d222004-11-27 20:07:08 +0000420static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000421{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000422 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000423}
424
Brian Paulb5b8d222004-11-27 20:07:08 +0000425static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000426{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000427 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
428 UINT_TO_FLOAT(v[1]),
429 UINT_TO_FLOAT(v[2]),
430 UINT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000431}
432
Brian Paulb5b8d222004-11-27 20:07:08 +0000433static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000434{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000435 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000436}
437
438/* GL_FLOAT attributes */
439
Brian Paulb5b8d222004-11-27 20:07:08 +0000440static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000441{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000442 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000443}
444
Brian Paulb5b8d222004-11-27 20:07:08 +0000445static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000446{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000447 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000448}
449
Brian Paulb5b8d222004-11-27 20:07:08 +0000450static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000451{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000452 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000453}
454
Brian Paulb5b8d222004-11-27 20:07:08 +0000455static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000456{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000457 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000458}
459
460/* GL_DOUBLE attributes */
461
Brian Paulb5b8d222004-11-27 20:07:08 +0000462static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000463{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000464 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000465}
466
Brian Paulb5b8d222004-11-27 20:07:08 +0000467static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000468{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000469 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000470}
471
Brian Paulb5b8d222004-11-27 20:07:08 +0000472static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000473{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000474 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000475}
476
Brian Paulb5b8d222004-11-27 20:07:08 +0000477static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000478{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000479 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000480}
481
482
483/*
484 * Array [size][type] of VertexAttrib functions
485 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000486static attrib_func AttribFuncsNV[2][4][8] = {
Brian Paul0d4393a2004-02-11 22:53:38 +0000487 {
488 /* non-normalized */
489 {
490 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000491 (attrib_func) VertexAttrib1bvNV,
492 (attrib_func) VertexAttrib1ubvNV,
493 (attrib_func) VertexAttrib1svNV,
494 (attrib_func) VertexAttrib1usvNV,
495 (attrib_func) VertexAttrib1ivNV,
496 (attrib_func) VertexAttrib1uivNV,
497 (attrib_func) VertexAttrib1fvNV,
498 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000499 },
500 {
501 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000502 (attrib_func) VertexAttrib2bvNV,
503 (attrib_func) VertexAttrib2ubvNV,
504 (attrib_func) VertexAttrib2svNV,
505 (attrib_func) VertexAttrib2usvNV,
506 (attrib_func) VertexAttrib2ivNV,
507 (attrib_func) VertexAttrib2uivNV,
508 (attrib_func) VertexAttrib2fvNV,
509 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000510 },
511 {
512 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000513 (attrib_func) VertexAttrib3bvNV,
514 (attrib_func) VertexAttrib3ubvNV,
515 (attrib_func) VertexAttrib3svNV,
516 (attrib_func) VertexAttrib3usvNV,
517 (attrib_func) VertexAttrib3ivNV,
518 (attrib_func) VertexAttrib3uivNV,
519 (attrib_func) VertexAttrib3fvNV,
520 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000521 },
522 {
523 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000524 (attrib_func) VertexAttrib4bvNV,
525 (attrib_func) VertexAttrib4ubvNV,
526 (attrib_func) VertexAttrib4svNV,
527 (attrib_func) VertexAttrib4usvNV,
528 (attrib_func) VertexAttrib4ivNV,
529 (attrib_func) VertexAttrib4uivNV,
530 (attrib_func) VertexAttrib4fvNV,
531 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000532 }
533 },
534 {
535 /* normalized (except for float/double) */
536 {
537 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000538 (attrib_func) VertexAttrib1NbvNV,
539 (attrib_func) VertexAttrib1NubvNV,
540 (attrib_func) VertexAttrib1NsvNV,
541 (attrib_func) VertexAttrib1NusvNV,
542 (attrib_func) VertexAttrib1NivNV,
543 (attrib_func) VertexAttrib1NuivNV,
544 (attrib_func) VertexAttrib1fvNV,
545 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000546 },
547 {
548 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000549 (attrib_func) VertexAttrib2NbvNV,
550 (attrib_func) VertexAttrib2NubvNV,
551 (attrib_func) VertexAttrib2NsvNV,
552 (attrib_func) VertexAttrib2NusvNV,
553 (attrib_func) VertexAttrib2NivNV,
554 (attrib_func) VertexAttrib2NuivNV,
555 (attrib_func) VertexAttrib2fvNV,
556 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000557 },
558 {
559 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000560 (attrib_func) VertexAttrib3NbvNV,
561 (attrib_func) VertexAttrib3NubvNV,
562 (attrib_func) VertexAttrib3NsvNV,
563 (attrib_func) VertexAttrib3NusvNV,
564 (attrib_func) VertexAttrib3NivNV,
565 (attrib_func) VertexAttrib3NuivNV,
566 (attrib_func) VertexAttrib3fvNV,
567 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000568 },
569 {
570 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000571 (attrib_func) VertexAttrib4NbvNV,
572 (attrib_func) VertexAttrib4NubvNV,
573 (attrib_func) VertexAttrib4NsvNV,
574 (attrib_func) VertexAttrib4NusvNV,
575 (attrib_func) VertexAttrib4NivNV,
576 (attrib_func) VertexAttrib4NuivNV,
577 (attrib_func) VertexAttrib4fvNV,
578 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000579 }
580 }
581};
582
583/**********************************************************************/
584
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000585
586GLboolean _ae_create_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000587{
Keith Whitwellae0eaf92003-11-24 15:23:18 +0000588 if (ctx->aelt_context)
589 return GL_TRUE;
590
Brian Paul0f1d98c2006-03-17 04:10:03 +0000591 /* These _gloffset_* values may not be compile-time constants */
Ian Romanick126c89e2005-08-05 18:13:37 +0000592 SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT;
593 SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT;
594 SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT;
595 SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT;
596 SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT;
597 SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT;
598 SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
599 SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT;
600
Brian Pauleec33cc2006-03-17 04:13:29 +0000601 FogCoordFuncs[0] = -1;
602 FogCoordFuncs[1] = -1;
603 FogCoordFuncs[2] = -1;
604 FogCoordFuncs[3] = -1;
605 FogCoordFuncs[4] = -1;
606 FogCoordFuncs[5] = -1;
Ian Romanick126c89e2005-08-05 18:13:37 +0000607 FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
608 FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
Ian Romanick126c89e2005-08-05 18:13:37 +0000609
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000610 ctx->aelt_context = MALLOC( sizeof(AEcontext) );
Gareth Hughes1fb0a432001-12-28 06:28:10 +0000611 if (!ctx->aelt_context)
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000612 return GL_FALSE;
613
614 AE_CONTEXT(ctx)->NewState = ~0;
615 return GL_TRUE;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000616}
617
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000618
619void _ae_destroy_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000620{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000621 if ( AE_CONTEXT( ctx ) ) {
622 FREE( ctx->aelt_context );
Keith Whitwella0c85242005-02-11 09:34:05 +0000623 ctx->aelt_context = NULL;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000624 }
625}
626
627
Brian Paul0d4393a2004-02-11 22:53:38 +0000628/**
629 * Make a list of per-vertex functions to call for each glArrayElement call.
Brian Paul1e3d8682004-02-24 02:49:43 +0000630 * These functions access the array data (i.e. glVertex, glColor, glNormal,
631 * etc).
632 * Note: this may be called during display list construction.
Brian Paul0d4393a2004-02-11 22:53:38 +0000633 */
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000634static void _ae_update_state( GLcontext *ctx )
635{
636 AEcontext *actx = AE_CONTEXT(ctx);
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000637 AEarray *aa = actx->arrays;
Brian Paul0d4393a2004-02-11 22:53:38 +0000638 AEattrib *at = actx->attribs;
Brian Pauldb07de02002-04-19 00:23:08 +0000639 GLuint i;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000640
Brian Paul1e3d8682004-02-24 02:49:43 +0000641 /* conventional vertex arrays */
642 if (ctx->Array.Index.Enabled) {
Keith Whitwellcab974c2000-12-26 05:09:27 +0000643 aa->array = &ctx->Array.Index;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000644 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
Keith Whitwellcab974c2000-12-26 05:09:27 +0000645 aa++;
646 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000647 if (ctx->Array.EdgeFlag.Enabled) {
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000648 aa->array = &ctx->Array.EdgeFlag;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000649 aa->offset = _gloffset_EdgeFlagv;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000650 aa++;
651 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000652 if (ctx->Array.Normal.Enabled) {
653 aa->array = &ctx->Array.Normal;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000654 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000655 aa++;
656 }
657 if (ctx->Array.Color.Enabled) {
658 aa->array = &ctx->Array.Color;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000659 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000660 aa++;
661 }
662 if (ctx->Array.SecondaryColor.Enabled) {
663 aa->array = &ctx->Array.SecondaryColor;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000664 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000665 aa++;
666 }
667 if (ctx->Array.FogCoord.Enabled) {
668 aa->array = &ctx->Array.FogCoord;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000669 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000670 aa++;
671 }
672 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
Adam Jackson823c5812006-03-30 19:23:38 +0000673 if (ctx->Array.TexCoord[i].Enabled) {
Brian Paul1e3d8682004-02-24 02:49:43 +0000674 /* NOTE: we use generic glVertexAttrib functions here.
675 * If we ever de-alias conventional/generic vertex attribs this
676 * will have to change.
677 */
678 struct gl_client_array *attribArray = &ctx->Array.TexCoord[i];
679 at->array = attribArray;
Brian Paulb5b8d222004-11-27 20:07:08 +0000680 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul9d1ff8c2004-02-24 14:59:26 +0000681 at->index = VERT_ATTRIB_TEX0 + i;
Brian Paul1e3d8682004-02-24 02:49:43 +0000682 at++;
Brian Paul0d4393a2004-02-11 22:53:38 +0000683 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000684 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000685
Brian Paul1e3d8682004-02-24 02:49:43 +0000686 /* generic vertex attribute arrays */
687 for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */
Adam Jackson823c5812006-03-30 19:23:38 +0000688 if (ctx->Array.VertexAttrib[i].Enabled) {
Brian Paul1e3d8682004-02-24 02:49:43 +0000689 struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i];
Brian Paul0d4393a2004-02-11 22:53:38 +0000690 at->array = attribArray;
691 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
692 * function pointer here (for float arrays) since the pointer may
693 * change from one execution of _ae_loopback_array_elt() to
694 * the next. Doing so caused UT to break.
695 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000696 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000697 at->index = i;
Brian Paul0d4393a2004-02-11 22:53:38 +0000698 at++;
699 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000700 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000701
702 /* finally, vertex position */
703 if (ctx->Array.VertexAttrib[0].Enabled) {
704 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
705 * issued as the last (proviking) attribute).
706 */
707 aa->array = &ctx->Array.VertexAttrib[0];
708 assert(aa->array->Size >= 2); /* XXX fix someday? */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000709 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000710 aa++;
711 }
712 else if (ctx->Array.Vertex.Enabled) {
713 aa->array = &ctx->Array.Vertex;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000714 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000715 aa++;
716 }
717
Brian Paul0d4393a2004-02-11 22:53:38 +0000718 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
719 ASSERT(aa - actx->arrays < 32);
720 at->func = NULL; /* terminate the list */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000721 aa->offset = -1; /* terminate the list */
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000722
Keith Whitwellcab974c2000-12-26 05:09:27 +0000723 actx->NewState = 0;
724}
725
726
Brian Paul1e3d8682004-02-24 02:49:43 +0000727/**
728 * Called via glArrayElement() and glDrawArrays().
729 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
730 * for all enabled vertex arrays (for elt-th element).
731 * Note: this may be called during display list construction.
732 */
Karl Schultzd6745692003-12-04 20:23:44 +0000733void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000734{
735 GET_CURRENT_CONTEXT(ctx);
Brian Paul0d4393a2004-02-11 22:53:38 +0000736 const AEcontext *actx = AE_CONTEXT(ctx);
737 const AEarray *aa;
738 const AEattrib *at;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000739 const struct _glapi_table * const disp = GET_DISPATCH();
740
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000741
742 if (actx->NewState)
743 _ae_update_state( ctx );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000744
Brian Paul0d4393a2004-02-11 22:53:38 +0000745 /* generic attributes */
746 for (at = actx->attribs; at->func; at++) {
Brian Paul024b5892005-11-25 17:07:10 +0000747 const GLubyte *src
748 = ADD_POINTERS(at->array->BufferObj->Data, at->array->Ptr)
749 + elt * at->array->StrideB;
Brian Paul0d4393a2004-02-11 22:53:38 +0000750 at->func( at->index, src );
Brian Paul53ad0362004-02-09 00:24:48 +0000751 }
752
Brian Paul0d4393a2004-02-11 22:53:38 +0000753 /* conventional arrays */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000754 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
Brian Paul024b5892005-11-25 17:07:10 +0000755 const GLubyte *src
756 = ADD_POINTERS(aa->array->BufferObj->Data, aa->array->Ptr)
757 + elt * aa->array->StrideB;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000758 CALL_by_offset( disp, (array_func), aa->offset,
759 ((const void *) src) );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000760 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000761}
762
763
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000764void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000765{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000766 AE_CONTEXT(ctx)->NewState |= new_state;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000767}