1fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell/* 2fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Mesa 3-D graphics library 3fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Version: 6.1 4fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 5fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. 6fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 7fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 8fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * copy of this software and associated documentation files (the "Software"), 9fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * to deal in the Software without restriction, including without limitation 10fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * and/or sell copies of the Software, and to permit persons to whom the 12fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Software is furnished to do so, subject to the following conditions: 13fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 14fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * The above copyright notice and this permission notice shall be included 15fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * in all copies or substantial portions of the Software. 16fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 17fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * 24fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Authors: 25fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell * Keith Whitwell <keith@tungstengraphics.com> 26fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell */ 27fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 28c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/glheader.h" 29c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/context.h" 30c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/macros.h" 31fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell#include "math/m_eval.h" 322cf44390d1e819f23e1d7ceb3199276c9148c647Chia-I Wu#include "main/dispatch.h" 33fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell#include "vbo_exec.h" 34fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 35fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 36fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwellstatic void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) 37fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 3854b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul assert(attr < Elements(exec->eval.map1)); 39fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map1[attr].map = NULL; 40fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 41fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 42fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwellstatic void clear_active_eval2( struct vbo_exec_context *exec, GLuint attr ) 43fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 4454b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul assert(attr < Elements(exec->eval.map2)); 45fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map2[attr].map = NULL; 46fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 47fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 48fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwellstatic void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint dim, 49fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_1d_map *map ) 50fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 5154b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul assert(attr < Elements(exec->eval.map1)); 52fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (!exec->eval.map1[attr].map) { 53fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map1[attr].map = map; 54fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map1[attr].sz = dim; 55fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 56fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 57fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 58fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwellstatic void set_active_eval2( struct vbo_exec_context *exec, GLuint attr, GLuint dim, 59fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_2d_map *map ) 60fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 6154b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul assert(attr < Elements(exec->eval.map2)); 62fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (!exec->eval.map2[attr].map) { 63fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map2[attr].map = map; 64fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map2[attr].sz = dim; 65fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 66fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 67fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 68fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwellvoid vbo_exec_eval_update( struct vbo_exec_context *exec ) 69fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 70f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context *ctx = exec->ctx; 71fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint attr; 72fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 73fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell /* Vertex program maps have priority over conventional attribs */ 74fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 75fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell for (attr = 0; attr < VBO_ATTRIB_FIRST_MATERIAL; attr++) { 76fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell clear_active_eval1( exec, attr ); 77fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell clear_active_eval2( exec, attr ); 78fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 79fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 80fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map1Color4) 81fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map1Color4 ); 82fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 83fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map2Color4) 84fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map2Color4 ); 85fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 86fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map1TextureCoord4) 87fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_TEX0, 4, &ctx->EvalMap.Map1Texture4 ); 88fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map1TextureCoord3) 89fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_TEX0, 3, &ctx->EvalMap.Map1Texture3 ); 90fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map1TextureCoord2) 91fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_TEX0, 2, &ctx->EvalMap.Map1Texture2 ); 92fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map1TextureCoord1) 93fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_TEX0, 1, &ctx->EvalMap.Map1Texture1 ); 94fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 95fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map2TextureCoord4) 96fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_TEX0, 4, &ctx->EvalMap.Map2Texture4 ); 97fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map2TextureCoord3) 98fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_TEX0, 3, &ctx->EvalMap.Map2Texture3 ); 99fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map2TextureCoord2) 100fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_TEX0, 2, &ctx->EvalMap.Map2Texture2 ); 101fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map2TextureCoord1) 102fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_TEX0, 1, &ctx->EvalMap.Map2Texture1 ); 103fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 104fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map1Normal) 105fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map1Normal ); 106fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 107fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map2Normal) 108fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map2Normal ); 109fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 110fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map1Vertex4) 111fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_POS, 4, &ctx->EvalMap.Map1Vertex4 ); 112fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map1Vertex3) 113fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval1( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map1Vertex3 ); 114fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 115fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (ctx->Eval.Map2Vertex4) 116fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_POS, 4, &ctx->EvalMap.Map2Vertex4 ); 117fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else if (ctx->Eval.Map2Vertex3) 118fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell set_active_eval2( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 ); 119fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 12054b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul /* _NEW_PROGRAM */ 12154b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul if (ctx->VertexProgram._Enabled) { 12254b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul /* These are the 16 evaluators which GL_NV_vertex_program defines. 12354b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul * They alias and override the conventional vertex attributs. 12454b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul */ 12554b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul for (attr = 0; attr < 16; attr++) { 12654b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul /* _NEW_EVAL */ 12754b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul assert(attr < Elements(ctx->Eval.Map1Attrib)); 12854b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul if (ctx->Eval.Map1Attrib[attr]) 12954b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul set_active_eval1( exec, attr, 4, &ctx->EvalMap.Map1Attrib[attr] ); 13054b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul 13154b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul assert(attr < Elements(ctx->Eval.Map2Attrib)); 13254b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul if (ctx->Eval.Map2Attrib[attr]) 13354b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul set_active_eval2( exec, attr, 4, &ctx->EvalMap.Map2Attrib[attr] ); 13454b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul } 13554b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul } 13654b0ed8360019fc6e0234c2c3413be40fe4d3b59Brian Paul 137fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.recalculate_maps = 0; 138fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 139fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 140fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 141fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 142fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwellvoid vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u) 143fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 144fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint attr; 145fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 146ae55d5322c9cff61f61e8df04bb0846332cc85ceBrian for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) { 147fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_1d_map *map = exec->eval.map1[attr].map; 148fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (map) { 149fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat uu = (u - map->u1) * map->du; 150fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat data[4]; 151fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 152fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ASSIGN_4V(data, 0, 0, 0, 1); 153fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 154fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _math_horner_bezier_curve(map->Points, data, uu, 155fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map1[attr].sz, 156fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell map->Order); 157fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 158fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell COPY_SZ_4V( exec->vtx.attrptr[attr], 159fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.attrsz[attr], 160fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell data ); 161fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 162fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 163fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 164fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell /** Vertex -- EvalCoord1f is a noop if this map not enabled: 165fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell **/ 166fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->eval.map1[0].map) { 167fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_1d_map *map = exec->eval.map1[0].map; 168fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat uu = (u - map->u1) * map->du; 169fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat vertex[4]; 170fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 171fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ASSIGN_4V(vertex, 0, 0, 0, 1); 172fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 173fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _math_horner_bezier_curve(map->Points, vertex, uu, 174fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map1[0].sz, 175fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell map->Order); 176fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 177fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->eval.map1[0].sz == 4) 178fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell CALL_Vertex4fv(GET_DISPATCH(), ( vertex )); 179fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else 180fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell CALL_Vertex3fv(GET_DISPATCH(), ( vertex )); 181fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 182fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 183fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 184fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 185fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 186fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwellvoid vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, 187fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat u, GLfloat v ) 188fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell{ 189fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLuint attr; 190fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 191ae55d5322c9cff61f61e8df04bb0846332cc85ceBrian for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) { 192fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_2d_map *map = exec->eval.map2[attr].map; 193fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (map) { 194fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat uu = (u - map->u1) * map->du; 195fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat vv = (v - map->v1) * map->dv; 196fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat data[4]; 197fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 198fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ASSIGN_4V(data, 0, 0, 0, 1); 199fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 200fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _math_horner_bezier_surf(map->Points, 201fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell data, 202fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell uu, vv, 203fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map2[attr].sz, 204fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell map->Uorder, map->Vorder); 205fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 206fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell COPY_SZ_4V( exec->vtx.attrptr[attr], 207fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.attrsz[attr], 208fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell data ); 209fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 210fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 211fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 212fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell /** Vertex -- EvalCoord2f is a noop if this map not enabled: 213fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell **/ 214fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->eval.map2[0].map) { 215fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell struct gl_2d_map *map = exec->eval.map2[0].map; 216fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat uu = (u - map->u1) * map->du; 217fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat vv = (v - map->v1) * map->dv; 218fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat vertex[4]; 219fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 220fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell ASSIGN_4V(vertex, 0, 0, 0, 1); 221fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 222fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->ctx->Eval.AutoNormal) { 223fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat normal[4]; 224fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell GLfloat du[4], dv[4]; 225fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 226fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, 227fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map2[0].sz, 228fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell map->Uorder, map->Vorder); 229fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 230fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->eval.map2[0].sz == 4) { 231fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell du[0] = du[0]*vertex[3] - du[3]*vertex[0]; 232fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell du[1] = du[1]*vertex[3] - du[3]*vertex[1]; 233fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell du[2] = du[2]*vertex[3] - du[3]*vertex[2]; 234fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 235fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell dv[0] = dv[0]*vertex[3] - dv[3]*vertex[0]; 236fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell dv[1] = dv[1]*vertex[3] - dv[3]*vertex[1]; 237fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell dv[2] = dv[2]*vertex[3] - dv[3]*vertex[2]; 238fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 239fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 240fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 241fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell CROSS3(normal, du, dv); 242fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell NORMALIZE_3FV(normal); 243fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell normal[3] = 1.0; 244fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 245fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL], 246fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->vtx.attrsz[VBO_ATTRIB_NORMAL], 247fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell normal ); 248fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 249fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 250fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else { 251fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell _math_horner_bezier_surf(map->Points, vertex, uu, vv, 252fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell exec->eval.map2[0].sz, 253fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell map->Uorder, map->Vorder); 254fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 255fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 256fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell if (exec->vtx.attrsz[0] == 4) 257fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell CALL_Vertex4fv(GET_DISPATCH(), ( vertex )); 258fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell else 259fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell CALL_Vertex3fv(GET_DISPATCH(), ( vertex )); 260fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell } 261fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell} 262fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 263fd12b37dbada6f945a94b93ecf332d0b6a8eef06Keith Whitwell 264