/* $Id: interp.c,v 1.2 2000/10/27 15:21:40 mholst 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. */ #include "interp.h" #include "macros.h" #include "types.h" /* * Linear integer interpolation of Z (depth) values: * Iterpolate n integer values between z0 and z1 and put into zspan. * When finished, zspan[0] = z0, zspan[n-1] = z1, and the rest of * zspan[] is filled with interpolated values. * We have to be careful to avoid integer overflow! */ void gl_interpolate_z( GLint n, GLint z0, GLint z1, GLdepth zspan[] ) { GLint i, dz; switch (n) { case 1: zspan[0] = z0; return; case 2: zspan[0] = z0; zspan[1] = z1; return; case 3: zspan[0] = z0; zspan[1] = (z0 + z1) >> 1; zspan[2] = z1; return; default: z0 = z0 << 7; z1 = z1 << 7; dz = (z1-z0) / (n-1); for (i=0;i> 7; z0 += dz; } return; } } /* * Linear integer interpolation: * Iterpolate n integer values between y0 and y1 and put into yspan. * When finished, yspan[0] = y0, yspan[n-1] = y1, and the rest of * yspan[] is filled with interpolated values. */ void gl_interpolate_i( GLint n, GLint y0, GLint y1, GLint yspan[] ) { switch (n) { case 1: yspan[0] = y0; return; case 2: yspan[0] = y0; yspan[1] = y1; return; case 3: yspan[0] = y0; yspan[1] = (y0+y1) >> 1; yspan[2] = y1; return; default: if (y0==y1) { register GLint i; for (i=0;i