blob: 41adc1d1d29fe769c58b6d7ff124f4270cdf4819 [file] [log] [blame]
Gareth Hughes22144ab2001-03-12 00:48:37 +00001/*
2 * Mesa 3-D graphics library
Brian Paulb5b8d222004-11-27 20:07:08 +00003 * Version: 6.3
Gareth Hughes22144ab2001-03-12 00:48:37 +00004 *
Brian Paul0d4393a2004-02-11 22:53:38 +00005 * Copyright (C) 1999-2004 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"
Keith Whitwellfc00cbe2001-12-20 15:30:45 +000032#include "glapi.h"
Brian Paul3c634522002-10-24 23:57:19 +000033#include "imports.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000034#include "macros.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000035#include "mtypes.h"
Ian Romanick9bdfee32005-07-18 12:31:24 +000036#include "glapioffsets.h"
37#include "dispatch.h"
Keith Whitwellcab974c2000-12-26 05:09:27 +000038
Karl Schultzb72902e2004-01-28 22:24:12 +000039typedef void (GLAPIENTRY *array_func)( const void * );
Keith Whitwellcab974c2000-12-26 05:09:27 +000040
41typedef struct {
Brian Paul0d4393a2004-02-11 22:53:38 +000042 const struct gl_client_array *array;
Ian Romanick9bdfee32005-07-18 12:31:24 +000043 int offset;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000044} AEarray;
Keith Whitwellcab974c2000-12-26 05:09:27 +000045
Brian Paul0d4393a2004-02-11 22:53:38 +000046typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
47
Keith Whitwellcab974c2000-12-26 05:09:27 +000048typedef struct {
Brian Paul0d4393a2004-02-11 22:53:38 +000049 const struct gl_client_array *array;
50 attrib_func func;
51 GLuint index;
52} AEattrib;
53
54typedef struct {
Brian Paul53ad0362004-02-09 00:24:48 +000055 AEarray arrays[32];
Brian Paul0d4393a2004-02-11 22:53:38 +000056 AEattrib attribs[VERT_ATTRIB_MAX + 1];
Keith Whitwellcab974c2000-12-26 05:09:27 +000057 GLuint NewState;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000058} AEcontext;
Keith Whitwellcab974c2000-12-26 05:09:27 +000059
Keith Whitwell4b7d6f22001-06-01 22:22:10 +000060#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
Brian Paul0d4393a2004-02-11 22:53:38 +000061
Ian Romanick9bdfee32005-07-18 12:31:24 +000062
Brian Paul0d4393a2004-02-11 22:53:38 +000063/*
64 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
65 * in the range [0, 7]. Luckily these type tokens are sequentially
Brian Paulf2f33502004-04-23 17:58:06 +000066 * numbered in gl.h, except for GL_DOUBLE.
Brian Paul0d4393a2004-02-11 22:53:38 +000067 */
Brian Paulf2f33502004-04-23 17:58:06 +000068#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
Keith Whitwellcab974c2000-12-26 05:09:27 +000069
Ian Romanick9bdfee32005-07-18 12:31:24 +000070static const int ColorFuncs[2][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000071 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000072 _gloffset_Color3bv,
73 _gloffset_Color3ubv,
74 _gloffset_Color3sv,
75 _gloffset_Color3usv,
76 _gloffset_Color3iv,
77 _gloffset_Color3uiv,
78 _gloffset_Color3fv,
79 _gloffset_Color3dv,
Adam Jackson94987be2004-10-24 02:05:40 +000080 },
81 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000082 _gloffset_Color4bv,
83 _gloffset_Color4ubv,
84 _gloffset_Color4sv,
85 _gloffset_Color4usv,
86 _gloffset_Color4iv,
87 _gloffset_Color4uiv,
88 _gloffset_Color4fv,
89 _gloffset_Color4dv,
Adam Jackson94987be2004-10-24 02:05:40 +000090 },
Brian Paul53ad0362004-02-09 00:24:48 +000091};
92
Ian Romanick9bdfee32005-07-18 12:31:24 +000093static const int VertexFuncs[3][8] = {
Adam Jackson94987be2004-10-24 02:05:40 +000094 {
Ian Romanick9bdfee32005-07-18 12:31:24 +000095 -1,
96 -1,
97 _gloffset_Vertex2sv,
98 -1,
99 _gloffset_Vertex2iv,
100 -1,
101 _gloffset_Vertex2fv,
102 _gloffset_Vertex2dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000103 },
104 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000105 -1,
106 -1,
107 _gloffset_Vertex3sv,
108 -1,
109 _gloffset_Vertex3iv,
110 -1,
111 _gloffset_Vertex3fv,
112 _gloffset_Vertex3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000113 },
114 {
Ian Romanick9bdfee32005-07-18 12:31:24 +0000115 -1,
116 -1,
117 _gloffset_Vertex4sv,
118 -1,
119 _gloffset_Vertex4iv,
120 -1,
121 _gloffset_Vertex4fv,
122 _gloffset_Vertex4dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000123 },
Brian Paul53ad0362004-02-09 00:24:48 +0000124};
125
Ian Romanick9bdfee32005-07-18 12:31:24 +0000126static const int IndexFuncs[8] = {
127 -1,
128 _gloffset_Indexubv,
129 _gloffset_Indexsv,
130 -1,
131 _gloffset_Indexiv,
132 -1,
133 _gloffset_Indexfv,
134 _gloffset_Indexdv,
Keith Whitwellcab974c2000-12-26 05:09:27 +0000135};
136
Ian Romanick9bdfee32005-07-18 12:31:24 +0000137static const int NormalFuncs[8] = {
138 _gloffset_Normal3bv,
139 -1,
140 _gloffset_Normal3sv,
141 -1,
142 _gloffset_Normal3iv,
143 -1,
144 _gloffset_Normal3fv,
145 _gloffset_Normal3dv,
Adam Jackson94987be2004-10-24 02:05:40 +0000146};
Brian Paul53ad0362004-02-09 00:24:48 +0000147
Ian Romanick126c89e2005-08-05 18:13:37 +0000148#if defined(IN_DRI_DRIVER)
149static int SecondaryColorFuncs[8];
150static int FogCoordFuncs[8] = {
151 -1,
152 -1,
153 -1,
154 -1,
155 -1,
156 -1,
157 0,
158 0,
159};
160#else
Ian Romanick9bdfee32005-07-18 12:31:24 +0000161static const int SecondaryColorFuncs[8] = {
162 _gloffset_SecondaryColor3bvEXT,
163 _gloffset_SecondaryColor3ubvEXT,
164 _gloffset_SecondaryColor3svEXT,
165 _gloffset_SecondaryColor3usvEXT,
166 _gloffset_SecondaryColor3ivEXT,
167 _gloffset_SecondaryColor3uivEXT,
168 _gloffset_SecondaryColor3fvEXT,
169 _gloffset_SecondaryColor3dvEXT,
Brian Paul53ad0362004-02-09 00:24:48 +0000170};
171
Ian Romanick9bdfee32005-07-18 12:31:24 +0000172static const int FogCoordFuncs[8] = {
173 -1,
174 -1,
175 -1,
176 -1,
177 -1,
178 -1,
179 _gloffset_FogCoordfvEXT,
180 _gloffset_FogCoorddvEXT
Brian Paul53ad0362004-02-09 00:24:48 +0000181};
Ian Romanick126c89e2005-08-05 18:13:37 +0000182#endif
Brian Paul53ad0362004-02-09 00:24:48 +0000183
Brian Paul0d4393a2004-02-11 22:53:38 +0000184/**********************************************************************/
185
186/* GL_BYTE attributes */
187
Brian Paulb5b8d222004-11-27 20:07:08 +0000188static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000189{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000190 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000191}
192
Brian Paulb5b8d222004-11-27 20:07:08 +0000193static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000194{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000195 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000196}
197
Brian Paulb5b8d222004-11-27 20:07:08 +0000198static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000199{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000200 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000201}
202
Brian Paulb5b8d222004-11-27 20:07:08 +0000203static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000204{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000205 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000206}
207
Brian Paulb5b8d222004-11-27 20:07:08 +0000208static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000209{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000210 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
211 BYTE_TO_FLOAT(v[1]),
212 BYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000213}
214
Brian Paulb5b8d222004-11-27 20:07:08 +0000215static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000216{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000217 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000218}
219
Brian Paulb5b8d222004-11-27 20:07:08 +0000220static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000221{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000222 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
223 BYTE_TO_FLOAT(v[1]),
224 BYTE_TO_FLOAT(v[2]),
225 BYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000226}
227
Brian Paulb5b8d222004-11-27 20:07:08 +0000228static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000229{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000230 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000231}
232
233/* GL_UNSIGNED_BYTE attributes */
234
Brian Paulb5b8d222004-11-27 20:07:08 +0000235static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000236{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000237 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000238}
239
Brian Paulb5b8d222004-11-27 20:07:08 +0000240static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000241{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000242 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000243}
244
Brian Paulb5b8d222004-11-27 20:07:08 +0000245static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000246{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000247 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
248 UBYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000249}
250
Brian Paulb5b8d222004-11-27 20:07:08 +0000251static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000252{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000253 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000254}
255
Brian Paulb5b8d222004-11-27 20:07:08 +0000256static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000257{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000258 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
259 UBYTE_TO_FLOAT(v[1]),
260 UBYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000261}
Brian Paulb5b8d222004-11-27 20:07:08 +0000262static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000263{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000264 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000265}
266
Brian Paulb5b8d222004-11-27 20:07:08 +0000267static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000268{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000269 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
Brian Paul0d4393a2004-02-11 22:53:38 +0000270 UBYTE_TO_FLOAT(v[1]),
271 UBYTE_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000272 UBYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000273}
274
Brian Paulb5b8d222004-11-27 20:07:08 +0000275static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000276{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000277 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000278}
279
280/* GL_SHORT attributes */
281
Brian Paulb5b8d222004-11-27 20:07:08 +0000282static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000283{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000284 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000285}
286
Brian Paulb5b8d222004-11-27 20:07:08 +0000287static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000288{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000289 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000290}
291
Brian Paulb5b8d222004-11-27 20:07:08 +0000292static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000293{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000294 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
295 SHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000296}
297
Brian Paulb5b8d222004-11-27 20:07:08 +0000298static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000299{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000300 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000301}
302
Brian Paulb5b8d222004-11-27 20:07:08 +0000303static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000304{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000305 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000306 SHORT_TO_FLOAT(v[1]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000307 SHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000308}
309
Brian Paulb5b8d222004-11-27 20:07:08 +0000310static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000311{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000312 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000313}
314
Brian Paulb5b8d222004-11-27 20:07:08 +0000315static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000316{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000317 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000318 SHORT_TO_FLOAT(v[1]),
319 SHORT_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000320 SHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000321}
322
Brian Paulb5b8d222004-11-27 20:07:08 +0000323static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000324{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000325 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000326}
327
328/* GL_UNSIGNED_SHORT attributes */
329
Brian Paulb5b8d222004-11-27 20:07:08 +0000330static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000331{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000332 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000333}
334
Brian Paulb5b8d222004-11-27 20:07:08 +0000335static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000336{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000337 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000338}
339
Brian Paulb5b8d222004-11-27 20:07:08 +0000340static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000341{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000342 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
343 USHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000344}
345
Brian Paulb5b8d222004-11-27 20:07:08 +0000346static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000347{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000348 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000349}
350
Brian Paulb5b8d222004-11-27 20:07:08 +0000351static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000352{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000353 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
354 USHORT_TO_FLOAT(v[1]),
355 USHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000356}
357
Brian Paulb5b8d222004-11-27 20:07:08 +0000358static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000359{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000360 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000361}
362
Brian Paulb5b8d222004-11-27 20:07:08 +0000363static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000364{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000365 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
366 USHORT_TO_FLOAT(v[1]),
367 USHORT_TO_FLOAT(v[2]),
368 USHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000369}
370
Brian Paulb5b8d222004-11-27 20:07:08 +0000371static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000372{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000373 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000374}
375
376/* GL_INT attributes */
377
Brian Paulb5b8d222004-11-27 20:07:08 +0000378static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000379{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000380 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000381}
382
Brian Paulb5b8d222004-11-27 20:07:08 +0000383static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000384{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000385 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000386}
387
Brian Paulb5b8d222004-11-27 20:07:08 +0000388static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000389{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000390 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
391 INT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000392}
393
Brian Paulb5b8d222004-11-27 20:07:08 +0000394static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000395{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000396 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000397}
398
Brian Paulb5b8d222004-11-27 20:07:08 +0000399static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000400{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000401 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
402 INT_TO_FLOAT(v[1]),
403 INT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000404}
405
Brian Paulb5b8d222004-11-27 20:07:08 +0000406static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000407{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000408 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000409}
410
Brian Paulb5b8d222004-11-27 20:07:08 +0000411static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000412{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000413 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
414 INT_TO_FLOAT(v[1]),
415 INT_TO_FLOAT(v[2]),
416 INT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000417}
418
Brian Paulb5b8d222004-11-27 20:07:08 +0000419static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000420{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000421 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000422}
423
424/* GL_UNSIGNED_INT attributes */
425
Brian Paulb5b8d222004-11-27 20:07:08 +0000426static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000427{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000428 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000429}
430
Brian Paulb5b8d222004-11-27 20:07:08 +0000431static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000432{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000433 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000434}
435
Brian Paulb5b8d222004-11-27 20:07:08 +0000436static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000437{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000438 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
439 UINT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000440}
441
Brian Paulb5b8d222004-11-27 20:07:08 +0000442static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000443{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000444 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000445}
446
Brian Paulb5b8d222004-11-27 20:07:08 +0000447static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000448{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000449 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
450 UINT_TO_FLOAT(v[1]),
451 UINT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000452}
453
Brian Paulb5b8d222004-11-27 20:07:08 +0000454static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000455{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000456 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000457}
458
Brian Paulb5b8d222004-11-27 20:07:08 +0000459static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000460{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000461 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
462 UINT_TO_FLOAT(v[1]),
463 UINT_TO_FLOAT(v[2]),
464 UINT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000465}
466
Brian Paulb5b8d222004-11-27 20:07:08 +0000467static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000468{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000469 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000470}
471
472/* GL_FLOAT attributes */
473
Brian Paulb5b8d222004-11-27 20:07:08 +0000474static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000475{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000476 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000477}
478
Brian Paulb5b8d222004-11-27 20:07:08 +0000479static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000480{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000481 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000482}
483
Brian Paulb5b8d222004-11-27 20:07:08 +0000484static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000485{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000486 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000487}
488
Brian Paulb5b8d222004-11-27 20:07:08 +0000489static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000490{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000491 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000492}
493
494/* GL_DOUBLE attributes */
495
Brian Paulb5b8d222004-11-27 20:07:08 +0000496static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000497{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000498 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000499}
500
Brian Paulb5b8d222004-11-27 20:07:08 +0000501static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000502{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000503 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000504}
505
Brian Paulb5b8d222004-11-27 20:07:08 +0000506static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000507{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000508 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000509}
510
Brian Paulb5b8d222004-11-27 20:07:08 +0000511static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000512{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000513 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000514}
515
516
517/*
518 * Array [size][type] of VertexAttrib functions
519 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000520static attrib_func AttribFuncsNV[2][4][8] = {
Brian Paul0d4393a2004-02-11 22:53:38 +0000521 {
522 /* non-normalized */
523 {
524 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000525 (attrib_func) VertexAttrib1bvNV,
526 (attrib_func) VertexAttrib1ubvNV,
527 (attrib_func) VertexAttrib1svNV,
528 (attrib_func) VertexAttrib1usvNV,
529 (attrib_func) VertexAttrib1ivNV,
530 (attrib_func) VertexAttrib1uivNV,
531 (attrib_func) VertexAttrib1fvNV,
532 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000533 },
534 {
535 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000536 (attrib_func) VertexAttrib2bvNV,
537 (attrib_func) VertexAttrib2ubvNV,
538 (attrib_func) VertexAttrib2svNV,
539 (attrib_func) VertexAttrib2usvNV,
540 (attrib_func) VertexAttrib2ivNV,
541 (attrib_func) VertexAttrib2uivNV,
542 (attrib_func) VertexAttrib2fvNV,
543 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000544 },
545 {
546 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000547 (attrib_func) VertexAttrib3bvNV,
548 (attrib_func) VertexAttrib3ubvNV,
549 (attrib_func) VertexAttrib3svNV,
550 (attrib_func) VertexAttrib3usvNV,
551 (attrib_func) VertexAttrib3ivNV,
552 (attrib_func) VertexAttrib3uivNV,
553 (attrib_func) VertexAttrib3fvNV,
554 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000555 },
556 {
557 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000558 (attrib_func) VertexAttrib4bvNV,
559 (attrib_func) VertexAttrib4ubvNV,
560 (attrib_func) VertexAttrib4svNV,
561 (attrib_func) VertexAttrib4usvNV,
562 (attrib_func) VertexAttrib4ivNV,
563 (attrib_func) VertexAttrib4uivNV,
564 (attrib_func) VertexAttrib4fvNV,
565 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000566 }
567 },
568 {
569 /* normalized (except for float/double) */
570 {
571 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000572 (attrib_func) VertexAttrib1NbvNV,
573 (attrib_func) VertexAttrib1NubvNV,
574 (attrib_func) VertexAttrib1NsvNV,
575 (attrib_func) VertexAttrib1NusvNV,
576 (attrib_func) VertexAttrib1NivNV,
577 (attrib_func) VertexAttrib1NuivNV,
578 (attrib_func) VertexAttrib1fvNV,
579 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000580 },
581 {
582 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000583 (attrib_func) VertexAttrib2NbvNV,
584 (attrib_func) VertexAttrib2NubvNV,
585 (attrib_func) VertexAttrib2NsvNV,
586 (attrib_func) VertexAttrib2NusvNV,
587 (attrib_func) VertexAttrib2NivNV,
588 (attrib_func) VertexAttrib2NuivNV,
589 (attrib_func) VertexAttrib2fvNV,
590 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000591 },
592 {
593 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000594 (attrib_func) VertexAttrib3NbvNV,
595 (attrib_func) VertexAttrib3NubvNV,
596 (attrib_func) VertexAttrib3NsvNV,
597 (attrib_func) VertexAttrib3NusvNV,
598 (attrib_func) VertexAttrib3NivNV,
599 (attrib_func) VertexAttrib3NuivNV,
600 (attrib_func) VertexAttrib3fvNV,
601 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000602 },
603 {
604 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000605 (attrib_func) VertexAttrib4NbvNV,
606 (attrib_func) VertexAttrib4NubvNV,
607 (attrib_func) VertexAttrib4NsvNV,
608 (attrib_func) VertexAttrib4NusvNV,
609 (attrib_func) VertexAttrib4NivNV,
610 (attrib_func) VertexAttrib4NuivNV,
611 (attrib_func) VertexAttrib4fvNV,
612 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000613 }
614 }
615};
616
617/**********************************************************************/
618
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000619
620GLboolean _ae_create_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000621{
Keith Whitwellae0eaf92003-11-24 15:23:18 +0000622 if (ctx->aelt_context)
623 return GL_TRUE;
624
Ian Romanick126c89e2005-08-05 18:13:37 +0000625#if defined(IN_DRI_DRIVER)
626 SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT;
627 SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT;
628 SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT;
629 SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT;
630 SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT;
631 SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT;
632 SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
633 SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT;
634
635 FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
636 FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
637#endif
638
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000639 ctx->aelt_context = MALLOC( sizeof(AEcontext) );
Gareth Hughes1fb0a432001-12-28 06:28:10 +0000640 if (!ctx->aelt_context)
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000641 return GL_FALSE;
642
643 AE_CONTEXT(ctx)->NewState = ~0;
644 return GL_TRUE;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000645}
646
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000647
648void _ae_destroy_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000649{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000650 if ( AE_CONTEXT( ctx ) ) {
651 FREE( ctx->aelt_context );
Keith Whitwella0c85242005-02-11 09:34:05 +0000652 ctx->aelt_context = NULL;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000653 }
654}
655
656
Brian Paul0d4393a2004-02-11 22:53:38 +0000657/**
658 * Make a list of per-vertex functions to call for each glArrayElement call.
Brian Paul1e3d8682004-02-24 02:49:43 +0000659 * These functions access the array data (i.e. glVertex, glColor, glNormal,
660 * etc).
661 * Note: this may be called during display list construction.
Brian Paul0d4393a2004-02-11 22:53:38 +0000662 */
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000663static void _ae_update_state( GLcontext *ctx )
664{
665 AEcontext *actx = AE_CONTEXT(ctx);
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000666 AEarray *aa = actx->arrays;
Brian Paul0d4393a2004-02-11 22:53:38 +0000667 AEattrib *at = actx->attribs;
Brian Pauldb07de02002-04-19 00:23:08 +0000668 GLuint i;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000669
Brian Paul1e3d8682004-02-24 02:49:43 +0000670 /* conventional vertex arrays */
671 if (ctx->Array.Index.Enabled) {
Keith Whitwellcab974c2000-12-26 05:09:27 +0000672 aa->array = &ctx->Array.Index;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000673 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
Keith Whitwellcab974c2000-12-26 05:09:27 +0000674 aa++;
675 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000676 if (ctx->Array.EdgeFlag.Enabled) {
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000677 aa->array = &ctx->Array.EdgeFlag;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000678 aa->offset = _gloffset_EdgeFlagv;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000679 aa++;
680 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000681 if (ctx->Array.Normal.Enabled) {
682 aa->array = &ctx->Array.Normal;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000683 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000684 aa++;
685 }
686 if (ctx->Array.Color.Enabled) {
687 aa->array = &ctx->Array.Color;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000688 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000689 aa++;
690 }
691 if (ctx->Array.SecondaryColor.Enabled) {
692 aa->array = &ctx->Array.SecondaryColor;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000693 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000694 aa++;
695 }
696 if (ctx->Array.FogCoord.Enabled) {
697 aa->array = &ctx->Array.FogCoord;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000698 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000699 aa++;
700 }
701 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
702 if (ctx->Array.TexCoord[i].Enabled) {
703 /* NOTE: we use generic glVertexAttrib functions here.
704 * If we ever de-alias conventional/generic vertex attribs this
705 * will have to change.
706 */
707 struct gl_client_array *attribArray = &ctx->Array.TexCoord[i];
708 at->array = attribArray;
Brian Paulb5b8d222004-11-27 20:07:08 +0000709 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul9d1ff8c2004-02-24 14:59:26 +0000710 at->index = VERT_ATTRIB_TEX0 + i;
Brian Paul1e3d8682004-02-24 02:49:43 +0000711 at++;
Brian Paul0d4393a2004-02-11 22:53:38 +0000712 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000713 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000714
Brian Paul1e3d8682004-02-24 02:49:43 +0000715 /* generic vertex attribute arrays */
716 for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */
717 if (ctx->Array.VertexAttrib[i].Enabled) {
718 struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i];
Brian Paul0d4393a2004-02-11 22:53:38 +0000719 at->array = attribArray;
720 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
721 * function pointer here (for float arrays) since the pointer may
722 * change from one execution of _ae_loopback_array_elt() to
723 * the next. Doing so caused UT to break.
724 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000725 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000726 at->index = i;
Brian Paul0d4393a2004-02-11 22:53:38 +0000727 at++;
728 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000729 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000730
731 /* finally, vertex position */
732 if (ctx->Array.VertexAttrib[0].Enabled) {
733 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
734 * issued as the last (proviking) attribute).
735 */
736 aa->array = &ctx->Array.VertexAttrib[0];
737 assert(aa->array->Size >= 2); /* XXX fix someday? */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000738 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000739 aa++;
740 }
741 else if (ctx->Array.Vertex.Enabled) {
742 aa->array = &ctx->Array.Vertex;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000743 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000744 aa++;
745 }
746
Brian Paul0d4393a2004-02-11 22:53:38 +0000747 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
748 ASSERT(aa - actx->arrays < 32);
749 at->func = NULL; /* terminate the list */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000750 aa->offset = -1; /* terminate the list */
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000751
Keith Whitwellcab974c2000-12-26 05:09:27 +0000752 actx->NewState = 0;
753}
754
755
Brian Paul1e3d8682004-02-24 02:49:43 +0000756/**
757 * Called via glArrayElement() and glDrawArrays().
758 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
759 * for all enabled vertex arrays (for elt-th element).
760 * Note: this may be called during display list construction.
761 */
Karl Schultzd6745692003-12-04 20:23:44 +0000762void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000763{
764 GET_CURRENT_CONTEXT(ctx);
Brian Paul0d4393a2004-02-11 22:53:38 +0000765 const AEcontext *actx = AE_CONTEXT(ctx);
766 const AEarray *aa;
767 const AEattrib *at;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000768 const struct _glapi_table * const disp = GET_DISPATCH();
769
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000770
771 if (actx->NewState)
772 _ae_update_state( ctx );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000773
Brian Paul0d4393a2004-02-11 22:53:38 +0000774 /* generic attributes */
775 for (at = actx->attribs; at->func; at++) {
776 const GLubyte *src = at->array->BufferObj->Data
Karl Schultz6258b762005-05-05 21:08:07 +0000777 + (uintptr_t) at->array->Ptr
Brian Paul0d4393a2004-02-11 22:53:38 +0000778 + elt * at->array->StrideB;
779 at->func( at->index, src );
Brian Paul53ad0362004-02-09 00:24:48 +0000780 }
781
Brian Paul0d4393a2004-02-11 22:53:38 +0000782 /* conventional arrays */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000783 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
Brian Paul0d4393a2004-02-11 22:53:38 +0000784 const GLubyte *src = aa->array->BufferObj->Data
Karl Schultz6258b762005-05-05 21:08:07 +0000785 + (uintptr_t) aa->array->Ptr
Brian Paul0d4393a2004-02-11 22:53:38 +0000786 + elt * aa->array->StrideB;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000787 CALL_by_offset( disp, (array_func), aa->offset,
788 ((const void *) src) );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000789 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000790}
791
792
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000793void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000794{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000795 AE_CONTEXT(ctx)->NewState |= new_state;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000796}