blob: e4bb99807eb67db1540e2c6b51baad5f4f3b850f [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 Romanick9bdfee32005-07-18 12:31:24 +0000148static const int SecondaryColorFuncs[8] = {
149 _gloffset_SecondaryColor3bvEXT,
150 _gloffset_SecondaryColor3ubvEXT,
151 _gloffset_SecondaryColor3svEXT,
152 _gloffset_SecondaryColor3usvEXT,
153 _gloffset_SecondaryColor3ivEXT,
154 _gloffset_SecondaryColor3uivEXT,
155 _gloffset_SecondaryColor3fvEXT,
156 _gloffset_SecondaryColor3dvEXT,
Brian Paul53ad0362004-02-09 00:24:48 +0000157};
158
Ian Romanick9bdfee32005-07-18 12:31:24 +0000159static const int FogCoordFuncs[8] = {
160 -1,
161 -1,
162 -1,
163 -1,
164 -1,
165 -1,
166 _gloffset_FogCoordfvEXT,
167 _gloffset_FogCoorddvEXT
Brian Paul53ad0362004-02-09 00:24:48 +0000168};
169
Brian Paul0d4393a2004-02-11 22:53:38 +0000170/**********************************************************************/
171
172/* GL_BYTE attributes */
173
Brian Paulb5b8d222004-11-27 20:07:08 +0000174static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000175{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000176 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000177}
178
Brian Paulb5b8d222004-11-27 20:07:08 +0000179static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000180{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000181 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000182}
183
Brian Paulb5b8d222004-11-27 20:07:08 +0000184static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000185{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000186 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000187}
188
Brian Paulb5b8d222004-11-27 20:07:08 +0000189static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000190{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000191 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000192}
193
Brian Paulb5b8d222004-11-27 20:07:08 +0000194static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000195{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000196 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
197 BYTE_TO_FLOAT(v[1]),
198 BYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000199}
200
Brian Paulb5b8d222004-11-27 20:07:08 +0000201static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000202{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000203 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000204}
205
Brian Paulb5b8d222004-11-27 20:07:08 +0000206static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000207{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000208 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
209 BYTE_TO_FLOAT(v[1]),
210 BYTE_TO_FLOAT(v[2]),
211 BYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000212}
213
Brian Paulb5b8d222004-11-27 20:07:08 +0000214static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000215{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000216 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000217}
218
219/* GL_UNSIGNED_BYTE attributes */
220
Brian Paulb5b8d222004-11-27 20:07:08 +0000221static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000222{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000223 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000224}
225
Brian Paulb5b8d222004-11-27 20:07:08 +0000226static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000227{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000228 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000229}
230
Brian Paulb5b8d222004-11-27 20:07:08 +0000231static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000232{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000233 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
234 UBYTE_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000235}
236
Brian Paulb5b8d222004-11-27 20:07:08 +0000237static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000238{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000239 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000240}
241
Brian Paulb5b8d222004-11-27 20:07:08 +0000242static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000243{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000244 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
245 UBYTE_TO_FLOAT(v[1]),
246 UBYTE_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000247}
Brian Paulb5b8d222004-11-27 20:07:08 +0000248static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000249{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000250 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000251}
252
Brian Paulb5b8d222004-11-27 20:07:08 +0000253static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000254{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000255 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
Brian Paul0d4393a2004-02-11 22:53:38 +0000256 UBYTE_TO_FLOAT(v[1]),
257 UBYTE_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000258 UBYTE_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000259}
260
Brian Paulb5b8d222004-11-27 20:07:08 +0000261static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000262{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000263 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000264}
265
266/* GL_SHORT attributes */
267
Brian Paulb5b8d222004-11-27 20:07:08 +0000268static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000269{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000270 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000271}
272
Brian Paulb5b8d222004-11-27 20:07:08 +0000273static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000274{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000275 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000276}
277
Brian Paulb5b8d222004-11-27 20:07:08 +0000278static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000279{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000280 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
281 SHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000282}
283
Brian Paulb5b8d222004-11-27 20:07:08 +0000284static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000285{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000286 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000287}
288
Brian Paulb5b8d222004-11-27 20:07:08 +0000289static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000290{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000291 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000292 SHORT_TO_FLOAT(v[1]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000293 SHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000294}
295
Brian Paulb5b8d222004-11-27 20:07:08 +0000296static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000297{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000298 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000299}
300
Brian Paulb5b8d222004-11-27 20:07:08 +0000301static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000302{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000303 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
Ian Romanickc1d455f2004-05-27 00:03:53 +0000304 SHORT_TO_FLOAT(v[1]),
305 SHORT_TO_FLOAT(v[2]),
Ian Romanick9bdfee32005-07-18 12:31:24 +0000306 SHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000307}
308
Brian Paulb5b8d222004-11-27 20:07:08 +0000309static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000310{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000311 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000312}
313
314/* GL_UNSIGNED_SHORT attributes */
315
Brian Paulb5b8d222004-11-27 20:07:08 +0000316static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000317{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000318 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000319}
320
Brian Paulb5b8d222004-11-27 20:07:08 +0000321static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000322{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000323 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000324}
325
Brian Paulb5b8d222004-11-27 20:07:08 +0000326static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000327{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000328 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
329 USHORT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000330}
331
Brian Paulb5b8d222004-11-27 20:07:08 +0000332static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000333{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000334 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000335}
336
Brian Paulb5b8d222004-11-27 20:07:08 +0000337static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000338{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000339 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
340 USHORT_TO_FLOAT(v[1]),
341 USHORT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000342}
343
Brian Paulb5b8d222004-11-27 20:07:08 +0000344static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000345{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000346 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000347}
348
Brian Paulb5b8d222004-11-27 20:07:08 +0000349static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000350{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000351 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
352 USHORT_TO_FLOAT(v[1]),
353 USHORT_TO_FLOAT(v[2]),
354 USHORT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000355}
356
Brian Paulb5b8d222004-11-27 20:07:08 +0000357static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000358{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000359 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000360}
361
362/* GL_INT attributes */
363
Brian Paulb5b8d222004-11-27 20:07:08 +0000364static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000365{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000366 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000367}
368
Brian Paulb5b8d222004-11-27 20:07:08 +0000369static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000370{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000371 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000372}
373
Brian Paulb5b8d222004-11-27 20:07:08 +0000374static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000375{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000376 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
377 INT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000378}
379
Brian Paulb5b8d222004-11-27 20:07:08 +0000380static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000381{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000382 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000383}
384
Brian Paulb5b8d222004-11-27 20:07:08 +0000385static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000386{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000387 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
388 INT_TO_FLOAT(v[1]),
389 INT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000390}
391
Brian Paulb5b8d222004-11-27 20:07:08 +0000392static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000393{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000394 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000395}
396
Brian Paulb5b8d222004-11-27 20:07:08 +0000397static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000398{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000399 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
400 INT_TO_FLOAT(v[1]),
401 INT_TO_FLOAT(v[2]),
402 INT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000403}
404
Brian Paulb5b8d222004-11-27 20:07:08 +0000405static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000406{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000407 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000408}
409
410/* GL_UNSIGNED_INT attributes */
411
Brian Paulb5b8d222004-11-27 20:07:08 +0000412static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000413{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000414 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000415}
416
Brian Paulb5b8d222004-11-27 20:07:08 +0000417static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000418{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000419 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000420}
421
Brian Paulb5b8d222004-11-27 20:07:08 +0000422static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000423{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000424 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
425 UINT_TO_FLOAT(v[1])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000426}
427
Brian Paulb5b8d222004-11-27 20:07:08 +0000428static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000429{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000430 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000431}
432
Brian Paulb5b8d222004-11-27 20:07:08 +0000433static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000434{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000435 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
436 UINT_TO_FLOAT(v[1]),
437 UINT_TO_FLOAT(v[2])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000438}
439
Brian Paulb5b8d222004-11-27 20:07:08 +0000440static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000441{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000442 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000443}
444
Brian Paulb5b8d222004-11-27 20:07:08 +0000445static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000446{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000447 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
448 UINT_TO_FLOAT(v[1]),
449 UINT_TO_FLOAT(v[2]),
450 UINT_TO_FLOAT(v[3])));
Brian Paul0d4393a2004-02-11 22:53:38 +0000451}
452
Brian Paulb5b8d222004-11-27 20:07:08 +0000453static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000454{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000455 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
Brian Paul0d4393a2004-02-11 22:53:38 +0000456}
457
458/* GL_FLOAT attributes */
459
Brian Paulb5b8d222004-11-27 20:07:08 +0000460static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000461{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000462 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000463}
464
Brian Paulb5b8d222004-11-27 20:07:08 +0000465static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000466{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000467 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000468}
469
Brian Paulb5b8d222004-11-27 20:07:08 +0000470static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000471{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000472 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000473}
474
Brian Paulb5b8d222004-11-27 20:07:08 +0000475static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000476{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000477 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000478}
479
480/* GL_DOUBLE attributes */
481
Brian Paulb5b8d222004-11-27 20:07:08 +0000482static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000483{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000484 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000485}
486
Brian Paulb5b8d222004-11-27 20:07:08 +0000487static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000488{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000489 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000490}
491
Brian Paulb5b8d222004-11-27 20:07:08 +0000492static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000493{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000494 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000495}
496
Brian Paulb5b8d222004-11-27 20:07:08 +0000497static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v)
Brian Paul0d4393a2004-02-11 22:53:38 +0000498{
Ian Romanick9bdfee32005-07-18 12:31:24 +0000499 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
Brian Paul0d4393a2004-02-11 22:53:38 +0000500}
501
502
503/*
504 * Array [size][type] of VertexAttrib functions
505 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000506static attrib_func AttribFuncsNV[2][4][8] = {
Brian Paul0d4393a2004-02-11 22:53:38 +0000507 {
508 /* non-normalized */
509 {
510 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000511 (attrib_func) VertexAttrib1bvNV,
512 (attrib_func) VertexAttrib1ubvNV,
513 (attrib_func) VertexAttrib1svNV,
514 (attrib_func) VertexAttrib1usvNV,
515 (attrib_func) VertexAttrib1ivNV,
516 (attrib_func) VertexAttrib1uivNV,
517 (attrib_func) VertexAttrib1fvNV,
518 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000519 },
520 {
521 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000522 (attrib_func) VertexAttrib2bvNV,
523 (attrib_func) VertexAttrib2ubvNV,
524 (attrib_func) VertexAttrib2svNV,
525 (attrib_func) VertexAttrib2usvNV,
526 (attrib_func) VertexAttrib2ivNV,
527 (attrib_func) VertexAttrib2uivNV,
528 (attrib_func) VertexAttrib2fvNV,
529 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000530 },
531 {
532 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000533 (attrib_func) VertexAttrib3bvNV,
534 (attrib_func) VertexAttrib3ubvNV,
535 (attrib_func) VertexAttrib3svNV,
536 (attrib_func) VertexAttrib3usvNV,
537 (attrib_func) VertexAttrib3ivNV,
538 (attrib_func) VertexAttrib3uivNV,
539 (attrib_func) VertexAttrib3fvNV,
540 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000541 },
542 {
543 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000544 (attrib_func) VertexAttrib4bvNV,
545 (attrib_func) VertexAttrib4ubvNV,
546 (attrib_func) VertexAttrib4svNV,
547 (attrib_func) VertexAttrib4usvNV,
548 (attrib_func) VertexAttrib4ivNV,
549 (attrib_func) VertexAttrib4uivNV,
550 (attrib_func) VertexAttrib4fvNV,
551 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000552 }
553 },
554 {
555 /* normalized (except for float/double) */
556 {
557 /* size 1 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000558 (attrib_func) VertexAttrib1NbvNV,
559 (attrib_func) VertexAttrib1NubvNV,
560 (attrib_func) VertexAttrib1NsvNV,
561 (attrib_func) VertexAttrib1NusvNV,
562 (attrib_func) VertexAttrib1NivNV,
563 (attrib_func) VertexAttrib1NuivNV,
564 (attrib_func) VertexAttrib1fvNV,
565 (attrib_func) VertexAttrib1dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000566 },
567 {
568 /* size 2 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000569 (attrib_func) VertexAttrib2NbvNV,
570 (attrib_func) VertexAttrib2NubvNV,
571 (attrib_func) VertexAttrib2NsvNV,
572 (attrib_func) VertexAttrib2NusvNV,
573 (attrib_func) VertexAttrib2NivNV,
574 (attrib_func) VertexAttrib2NuivNV,
575 (attrib_func) VertexAttrib2fvNV,
576 (attrib_func) VertexAttrib2dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000577 },
578 {
579 /* size 3 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000580 (attrib_func) VertexAttrib3NbvNV,
581 (attrib_func) VertexAttrib3NubvNV,
582 (attrib_func) VertexAttrib3NsvNV,
583 (attrib_func) VertexAttrib3NusvNV,
584 (attrib_func) VertexAttrib3NivNV,
585 (attrib_func) VertexAttrib3NuivNV,
586 (attrib_func) VertexAttrib3fvNV,
587 (attrib_func) VertexAttrib3dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000588 },
589 {
590 /* size 4 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000591 (attrib_func) VertexAttrib4NbvNV,
592 (attrib_func) VertexAttrib4NubvNV,
593 (attrib_func) VertexAttrib4NsvNV,
594 (attrib_func) VertexAttrib4NusvNV,
595 (attrib_func) VertexAttrib4NivNV,
596 (attrib_func) VertexAttrib4NuivNV,
597 (attrib_func) VertexAttrib4fvNV,
598 (attrib_func) VertexAttrib4dvNV
Brian Paul0d4393a2004-02-11 22:53:38 +0000599 }
600 }
601};
602
603/**********************************************************************/
604
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000605
606GLboolean _ae_create_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000607{
Keith Whitwellae0eaf92003-11-24 15:23:18 +0000608 if (ctx->aelt_context)
609 return GL_TRUE;
610
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000611 ctx->aelt_context = MALLOC( sizeof(AEcontext) );
Gareth Hughes1fb0a432001-12-28 06:28:10 +0000612 if (!ctx->aelt_context)
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000613 return GL_FALSE;
614
615 AE_CONTEXT(ctx)->NewState = ~0;
616 return GL_TRUE;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000617}
618
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000619
620void _ae_destroy_context( GLcontext *ctx )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000621{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000622 if ( AE_CONTEXT( ctx ) ) {
623 FREE( ctx->aelt_context );
Keith Whitwella0c85242005-02-11 09:34:05 +0000624 ctx->aelt_context = NULL;
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000625 }
626}
627
628
Brian Paul0d4393a2004-02-11 22:53:38 +0000629/**
630 * Make a list of per-vertex functions to call for each glArrayElement call.
Brian Paul1e3d8682004-02-24 02:49:43 +0000631 * These functions access the array data (i.e. glVertex, glColor, glNormal,
632 * etc).
633 * Note: this may be called during display list construction.
Brian Paul0d4393a2004-02-11 22:53:38 +0000634 */
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000635static void _ae_update_state( GLcontext *ctx )
636{
637 AEcontext *actx = AE_CONTEXT(ctx);
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000638 AEarray *aa = actx->arrays;
Brian Paul0d4393a2004-02-11 22:53:38 +0000639 AEattrib *at = actx->attribs;
Brian Pauldb07de02002-04-19 00:23:08 +0000640 GLuint i;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000641
Brian Paul1e3d8682004-02-24 02:49:43 +0000642 /* conventional vertex arrays */
643 if (ctx->Array.Index.Enabled) {
Keith Whitwellcab974c2000-12-26 05:09:27 +0000644 aa->array = &ctx->Array.Index;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000645 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
Keith Whitwellcab974c2000-12-26 05:09:27 +0000646 aa++;
647 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000648 if (ctx->Array.EdgeFlag.Enabled) {
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000649 aa->array = &ctx->Array.EdgeFlag;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000650 aa->offset = _gloffset_EdgeFlagv;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000651 aa++;
652 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000653 if (ctx->Array.Normal.Enabled) {
654 aa->array = &ctx->Array.Normal;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000655 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000656 aa++;
657 }
658 if (ctx->Array.Color.Enabled) {
659 aa->array = &ctx->Array.Color;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000660 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000661 aa++;
662 }
663 if (ctx->Array.SecondaryColor.Enabled) {
664 aa->array = &ctx->Array.SecondaryColor;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000665 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000666 aa++;
667 }
668 if (ctx->Array.FogCoord.Enabled) {
669 aa->array = &ctx->Array.FogCoord;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000670 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000671 aa++;
672 }
673 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
674 if (ctx->Array.TexCoord[i].Enabled) {
675 /* NOTE: we use generic glVertexAttrib functions here.
676 * If we ever de-alias conventional/generic vertex attribs this
677 * will have to change.
678 */
679 struct gl_client_array *attribArray = &ctx->Array.TexCoord[i];
680 at->array = attribArray;
Brian Paulb5b8d222004-11-27 20:07:08 +0000681 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul9d1ff8c2004-02-24 14:59:26 +0000682 at->index = VERT_ATTRIB_TEX0 + i;
Brian Paul1e3d8682004-02-24 02:49:43 +0000683 at++;
Brian Paul0d4393a2004-02-11 22:53:38 +0000684 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000685 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000686
Brian Paul1e3d8682004-02-24 02:49:43 +0000687 /* generic vertex attribute arrays */
688 for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */
689 if (ctx->Array.VertexAttrib[i].Enabled) {
690 struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i];
Brian Paul0d4393a2004-02-11 22:53:38 +0000691 at->array = attribArray;
692 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
693 * function pointer here (for float arrays) since the pointer may
694 * change from one execution of _ae_loopback_array_elt() to
695 * the next. Doing so caused UT to break.
696 */
Brian Paulb5b8d222004-11-27 20:07:08 +0000697 at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000698 at->index = i;
Brian Paul0d4393a2004-02-11 22:53:38 +0000699 at++;
700 }
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000701 }
Brian Paul1e3d8682004-02-24 02:49:43 +0000702
703 /* finally, vertex position */
704 if (ctx->Array.VertexAttrib[0].Enabled) {
705 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
706 * issued as the last (proviking) attribute).
707 */
708 aa->array = &ctx->Array.VertexAttrib[0];
709 assert(aa->array->Size >= 2); /* XXX fix someday? */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000710 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000711 aa++;
712 }
713 else if (ctx->Array.Vertex.Enabled) {
714 aa->array = &ctx->Array.Vertex;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000715 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
Brian Paul1e3d8682004-02-24 02:49:43 +0000716 aa++;
717 }
718
Brian Paul0d4393a2004-02-11 22:53:38 +0000719 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
720 ASSERT(aa - actx->arrays < 32);
721 at->func = NULL; /* terminate the list */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000722 aa->offset = -1; /* terminate the list */
Roland Scheideggerfaaf78a2004-02-11 01:06:03 +0000723
Keith Whitwellcab974c2000-12-26 05:09:27 +0000724 actx->NewState = 0;
725}
726
727
Brian Paul1e3d8682004-02-24 02:49:43 +0000728/**
729 * Called via glArrayElement() and glDrawArrays().
730 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
731 * for all enabled vertex arrays (for elt-th element).
732 * Note: this may be called during display list construction.
733 */
Karl Schultzd6745692003-12-04 20:23:44 +0000734void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000735{
736 GET_CURRENT_CONTEXT(ctx);
Brian Paul0d4393a2004-02-11 22:53:38 +0000737 const AEcontext *actx = AE_CONTEXT(ctx);
738 const AEarray *aa;
739 const AEattrib *at;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000740 const struct _glapi_table * const disp = GET_DISPATCH();
741
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000742
743 if (actx->NewState)
744 _ae_update_state( ctx );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000745
Brian Paul0d4393a2004-02-11 22:53:38 +0000746 /* generic attributes */
747 for (at = actx->attribs; at->func; at++) {
748 const GLubyte *src = at->array->BufferObj->Data
Karl Schultz6258b762005-05-05 21:08:07 +0000749 + (uintptr_t) at->array->Ptr
Brian Paul0d4393a2004-02-11 22:53:38 +0000750 + elt * at->array->StrideB;
751 at->func( at->index, src );
Brian Paul53ad0362004-02-09 00:24:48 +0000752 }
753
Brian Paul0d4393a2004-02-11 22:53:38 +0000754 /* conventional arrays */
Ian Romanick9bdfee32005-07-18 12:31:24 +0000755 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
Brian Paul0d4393a2004-02-11 22:53:38 +0000756 const GLubyte *src = aa->array->BufferObj->Data
Karl Schultz6258b762005-05-05 21:08:07 +0000757 + (uintptr_t) aa->array->Ptr
Brian Paul0d4393a2004-02-11 22:53:38 +0000758 + elt * aa->array->StrideB;
Ian Romanick9bdfee32005-07-18 12:31:24 +0000759 fprintf( stderr, "[%s,%u] aa->offset = %d\n", __func__, __LINE__,
760 aa->offset );
761 CALL_by_offset( disp, (array_func), aa->offset,
762 ((const void *) src) );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000763 }
Keith Whitwellcab974c2000-12-26 05:09:27 +0000764}
765
766
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000767void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
Keith Whitwellcab974c2000-12-26 05:09:27 +0000768{
Keith Whitwell4b7d6f22001-06-01 22:22:10 +0000769 AE_CONTEXT(ctx)->NewState |= new_state;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000770}