api_arrayelt.c revision 03c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71eb
103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul/* $Id: api_arrayelt.c,v 1.6 2002/01/14 16:06:35 brianp Exp $ */
222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes/*
422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * Mesa 3-D graphics library
503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul * Version:  4.1
622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * Permission is hereby granted, free of charge, to any person obtaining a
1022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * copy of this software and associated documentation files (the "Software"),
1122144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * to deal in the Software without restriction, including without limitation
1222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * and/or sell copies of the Software, and to permit persons to whom the
1422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * Software is furnished to do so, subject to the following conditions:
1522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
1622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * The above copyright notice and this permission notice shall be included
1722144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * in all copies or substantial portions of the Software.
1822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes *
1922144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2122144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
2222144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
2322144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2422144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes */
2622144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
27fc00cbe8d1ac48faf345e41a13757a8a1e2e5ebeKeith Whitwell/* Author:
28fc00cbe8d1ac48faf345e41a13757a8a1e2e5ebeKeith Whitwell *    Keith Whitwell <keith_whitwell@yahoo.com>
29fc00cbe8d1ac48faf345e41a13757a8a1e2e5ebeKeith Whitwell */
30fc00cbe8d1ac48faf345e41a13757a8a1e2e5ebeKeith Whitwell
31cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "glheader.h"
324b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell#include "api_arrayelt.h"
33cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "context.h"
34fc00cbe8d1ac48faf345e41a13757a8a1e2e5ebeKeith Whitwell#include "glapi.h"
354b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell#include "mem.h"
36cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "macros.h"
37cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#include "mtypes.h"
38cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
39cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
401fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughestypedef void (*texarray_func)( GLenum, const void * );
411fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes
42cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwelltypedef struct {
43cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GLint unit;
44cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   struct gl_client_array *array;
451fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   texarray_func func;
464b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell} AEtexarray;
4722144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
481fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughestypedef void (*array_func)( const void * );
49cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
50cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwelltypedef struct {
51cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   struct gl_client_array *array;
521fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   array_func func;
534b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell} AEarray;
54cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
55cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwelltypedef struct {
564b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEtexarray texarrays[MAX_TEXTURE_UNITS+1];
574b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEarray arrays[32];
58cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GLuint NewState;
594b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell} AEcontext;
604b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
614b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
624b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell#define TYPE_IDX(t) ((t) & 0xf)
634b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
644b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellstatic void (*colorfuncs[2][8])( const void * ) = {
651fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   { (array_func)glColor3bv,
661fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor3ub,
671fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor3sv,
681fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor3usv,
691fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor3iv,
701fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor3uiv,
711fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor3fv,
721fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor3dv },
731fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes
741fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   { (array_func)glColor4bv,
751fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor4ub,
761fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor4sv,
771fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor4usv,
781fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor4iv,
791fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor4uiv,
801fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor4fv,
811fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glColor4dv }
82cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
83cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
844b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellstatic void (*vertexfuncs[3][8])( const void * ) = {
854b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   { 0,
864b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
871fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex2sv,
884b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
891fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex2iv,
904b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
911fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex2fv,
921fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex2dv },
934b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
944b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   { 0,
954b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
961fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex3sv,
974b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
981fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex3iv,
994b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1001fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex3fv,
1011fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex3dv },
1024b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
1034b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   { 0,
1044b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1051fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex4sv,
1064b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1071fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex4iv,
1084b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1091fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex4fv,
1101fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (array_func)glVertex4dv }
111cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
112cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
113cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
1144b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellstatic void (*multitexfuncs[4][8])( GLenum, const void * ) = {
1154b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   { 0,
1164b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1171fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord1svARB,
1184b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1191fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord1ivARB,
1204b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1211fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord1fvARB,
1221fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord1dvARB },
1234b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
1244b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   { 0,
1254b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1261fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord2svARB,
1274b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1281fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord2ivARB,
1294b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1301fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord2fvARB,
1311fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord2dvARB },
1324b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
1334b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   { 0,
1344b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1351fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord3svARB,
1364b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1371fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord3ivARB,
1384b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1391fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord3fvARB,
1401fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord3dvARB },
1414b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
1424b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   { 0,
1434b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1441fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord4svARB,
1454b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1461fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord4ivARB,
1474b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell     0,
1481fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord4fvARB,
1491fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes     (texarray_func)glMultiTexCoord4dvARB }
150cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
151cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
1524b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellstatic void (*indexfuncs[8])( const void * ) = {
1534b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   0,
1541fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glIndexubv,
1551fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glIndexsv,
1564b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   0,
1571fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glIndexiv,
1584b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   0,
1591fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glIndexfv,
1601fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glIndexdv
161cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
162cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
163cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
1644b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellstatic void (*normalfuncs[8])( const void * ) = {
1651fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glNormal3bv,
1664b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   0,
1671fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glNormal3sv,
1684b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   0,
1691fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glNormal3iv,
1704b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   0,
1711fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glNormal3fv,
1721fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   (array_func)glNormal3dv,
173cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell};
174cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
175cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
17603c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul/* Wrapper functions in case glSecondaryColor*EXT doesn't exist */
17703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3bvEXT(const GLbyte *c)
17803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
17903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3bvEXT(c);
18003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
18103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
18203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3ubvEXT(const GLubyte *c)
18303c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
18403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3ubvEXT(c);
18503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
18603c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
18703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3svEXT(const GLshort *c)
18803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
18903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3svEXT(c);
19003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
19103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
19203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3usvEXT(const GLushort *c)
19303c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
19403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3usvEXT(c);
19503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
19603c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
19703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3ivEXT(const GLint *c)
19803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
19903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3ivEXT(c);
20003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
20103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
20203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3uivEXT(const GLuint *c)
20303c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
20403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3uivEXT(c);
20503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
20603c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
20703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3fvEXT(const GLfloat *c)
20803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
20903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3fvEXT(c);
21003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
21103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
21203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void SecondaryColor3dvEXT(const GLdouble *c)
213cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
21403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->SecondaryColor3dvEXT(c);
21503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
216fc00cbe8d1ac48faf345e41a13757a8a1e2e5ebeKeith Whitwell
21703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void (*secondarycolorfuncs[8])( const void * ) = {
21803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3bvEXT,
21903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3ubvEXT,
22003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3svEXT,
22103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3usvEXT,
22203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3ivEXT,
22303c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3uivEXT,
22403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3fvEXT,
22503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) SecondaryColor3dvEXT,
22603c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul};
22703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
22803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
22903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul/* Again, wrapper functions in case glSecondaryColor*EXT doesn't exist */
23003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void FogCoordfvEXT(const GLfloat *f)
23103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
23203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->FogCoordfvEXT(f);
23303c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
23403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
23503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void FogCoorddvEXT(const GLdouble *f)
23603c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
23703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   _glapi_Dispatch->FogCoorddvEXT(f);
23803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul}
23903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
24003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paulstatic void (*fogcoordfuncs[8])( const void * ) = {
24103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   0,
24203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   0,
24303c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   0,
24403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   0,
24503c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   0,
24603c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   0,
24703c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) FogCoordfvEXT,
24803c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul   (array_func) FogCoorddvEXT
24903c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul};
25003c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
25103c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
25203c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul
25303c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian PaulGLboolean _ae_create_context( GLcontext *ctx )
25403c0c2e8aa5e5f1b430c4b3faa1f9ad92b1b71ebBrian Paul{
2554b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   ctx->aelt_context = MALLOC( sizeof(AEcontext) );
2561fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes   if (!ctx->aelt_context)
2574b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      return GL_FALSE;
2584b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
2594b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AE_CONTEXT(ctx)->NewState = ~0;
2604b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   return GL_TRUE;
2614b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell}
2624b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
2634b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
2644b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellvoid _ae_destroy_context( GLcontext *ctx )
2654b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell{
2664b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   if ( AE_CONTEXT( ctx ) ) {
2674b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      FREE( ctx->aelt_context );
2684b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      ctx->aelt_context = 0;
2694b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   }
270cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
271cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
2724b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
2734b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellstatic void _ae_update_state( GLcontext *ctx )
274cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
2754b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEcontext *actx = AE_CONTEXT(ctx);
2764b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEtexarray *ta = actx->texarrays;
2774b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEarray *aa = actx->arrays;
278cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   int i;
279cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
28022144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes   for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
281cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      if (ctx->Array.TexCoord[i].Enabled) {
282cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta->unit = i;
283cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta->array = &ctx->Array.TexCoord[i];
284cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta->func = multitexfuncs[ta->array->Size-1][TYPE_IDX(ta->array->Type)];
285cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell	 ta++;
286cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      }
287cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
288cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ta->func = 0;
289cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
290cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Color.Enabled) {
291cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Color;
292cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = colorfuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
293cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
294cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
295cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
296cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Normal.Enabled) {
297cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Normal;
298cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = normalfuncs[TYPE_IDX(aa->array->Type)];
299cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
300cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
301cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
302cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Index.Enabled) {
303cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Index;
304cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = indexfuncs[TYPE_IDX(aa->array->Type)];
305cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
306cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
307cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
308cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.EdgeFlag.Enabled) {
3094b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      aa->array = &ctx->Array.EdgeFlag;
3101fb0a43c16190f4d043b8a0918361bee76b37e5fGareth Hughes      aa->func = (array_func)glEdgeFlagv;
311cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
312cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
313cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
314cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.FogCoord.Enabled) {
3154b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      aa->array = &ctx->Array.FogCoord;
316cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = fogcoordfuncs[TYPE_IDX(aa->array->Type)];
317cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
318cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
319cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
320cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.SecondaryColor.Enabled) {
321cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.SecondaryColor;
322cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = secondarycolorfuncs[TYPE_IDX(aa->array->Type)];
323cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
324cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
325cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
326cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   /* Must be last
327cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell    */
328cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (ctx->Array.Vertex.Enabled) {
329cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->array = &ctx->Array.Vertex;
330cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa->func = vertexfuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
331cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      aa++;
332cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
333cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
334cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   aa->func = 0;
335cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   actx->NewState = 0;
336cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
337cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
338cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
3394b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellvoid _ae_loopback_array_elt( GLint elt )
340cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
341cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   GET_CURRENT_CONTEXT(ctx);
3424b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEcontext *actx = AE_CONTEXT(ctx);
3434b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEtexarray *ta;
3444b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AEarray *aa;
3454b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell
3464b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   if (actx->NewState)
3474b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      _ae_update_state( ctx );
348cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
349cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   for (ta = actx->texarrays ; ta->func ; ta++) {
3504b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      ta->func( ta->unit, (char *)ta->array->Ptr + elt * ta->array->StrideB );
351cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
352cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
3534b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   /* Must be last
3544b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell    */
355cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   for (aa = actx->arrays ; aa->func ; aa++) {
3564b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell      aa->func( (char *)aa->array->Ptr + elt * aa->array->StrideB );
357cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   }
358cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
359cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
360cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
361cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
3624b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwellvoid _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
363cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell{
3644b7d6f216bf768482e07e4d7feb8ca3e1be92d53Keith Whitwell   AE_CONTEXT(ctx)->NewState |= new_state;
365cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell}
366