/* $Id: eval.c,v 1.2 1996/09/15 14:17:30 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 2.0 * Copyright (C) 1995-1996 Brian Paul * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * $Log: eval.c,v $ * Revision 1.2 1996/09/15 14:17:30 brianp * now use GLframebuffer and GLvisual * * Revision 1.1 1996/09/13 01:38:16 brianp * Initial revision * */ /* * eval.c was written by * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). * * My original implementation of evaluators was simplistic and didn't * compute surface normal vectors properly. Bernd and Volker applied * used more sophisticated methods to get better results. * * Thanks guys! */ #include #include #include #include "context.h" #include "draw.h" #include "eval.h" #include "dlist.h" #include "macros.h" #include "types.h" /* * Tensor product Bezier surfaces * * Again the Horner scheme is used to compute a point on a * TP Bezier surface. First a control polygon for a curve * on the surface in one parameter direction is computed, * then the point on the curve for the other parameter * direction is evaluated. * * To store the curve control polygon additional storage * for max(uorder,vorder) points is needed in the * control net cn. */ static void horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v, GLuint dim, GLuint uorder, GLuint vorder) { GLfloat *cp = cn + uorder*vorder*dim; GLuint i, uinc = vorder*dim; if(vorder > uorder) { if(uorder >= 2) { GLfloat s, poweru; GLuint j, k, bincoeff; /* Compute the control polygon for the surface-curve in u-direction */ for(j=0; j cn defines a curve in v */ horner_bezier_curve(cn, out, v, dim, vorder); } else /* vorder <= uorder */ { if(vorder > 1) { GLuint i; /* Compute the control polygon for the surface-curve in u-direction */ for(i=0; i cn defines a curve in u */ horner_bezier_curve(cn, out, u, dim, uorder); } }