home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / mesa-1.2.8 / src / interp.h < prev    next >
C/C++ Source or Header  |  1996-05-27  |  5KB  |  184 lines

  1. /* interp.h */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. $Id: interp.h,v 1.13 1996/02/12 19:07:53 brianp Exp $
  26.  
  27. $Log: interp.h,v $
  28.  * Revision 1.13  1996/02/12  19:07:53  brianp
  29.  * applied Bill's Feb 8 patches: change eye Z's to clip W's
  30.  *
  31.  * Revision 1.12  1996/01/22  15:38:11  brianp
  32.  * removed GL_INTERPOLATE_4FIXED, GL_INTERPOLATE_4UB, GL_INTERPOLATE_UB
  33.  *
  34.  * Revision 1.11  1995/12/30  17:16:52  brianp
  35.  * new gl_interp_texcoords function per Bill Triggs
  36.  *
  37.  * Revision 1.10  1995/12/30  00:52:50  brianp
  38.  * added gl_interpolate_4fixed function
  39.  * removed dead code
  40.  *
  41.  * Revision 1.9  1995/12/18  17:29:35  brianp
  42.  * use new GLdepth datatype
  43.  *
  44.  * Revision 1.8  1995/12/14  19:58:10  brianp
  45.  * added GL_INTERPOLATE_FIXED4 macro
  46.  *
  47.  * Revision 1.7  1995/12/12  21:46:28  brianp
  48.  * new GL_INTERPOLATE_Z macro
  49.  *
  50.  * Revision 1.6  1995/10/23  21:27:54  brianp
  51.  * new GLubyte interpolation using fixed point arithmetic
  52.  *
  53.  * Revision 1.5  1995/06/12  15:43:57  brianp
  54.  * separate GLint and GLubyte interpolation functions
  55.  *
  56.  * Revision 1.4  1995/06/02  13:59:01  brianp
  57.  * faster GL_INTERPOLATE() macro
  58.  *
  59.  * Revision 1.3  1995/05/22  20:59:34  brianp
  60.  * Release 1.2
  61.  *
  62.  * Revision 1.2  1995/03/04  19:25:29  brianp
  63.  * 1.1 beta revision
  64.  *
  65.  * Revision 1.1  1995/02/27  22:20:16  brianp
  66.  * Initial revision
  67.  *
  68.  */
  69.  
  70.  
  71. #ifndef INTERP_H
  72. #define INTERP_H
  73.  
  74.  
  75. /*
  76.  * Various integer interpolation functions and macros
  77.  */
  78.  
  79.  
  80.  
  81. extern void gl_interpolate_z( GLint n, GLint z0, GLint z1, GLdepth zspan[] );
  82.  
  83.  
  84. extern void gl_interpolate_i( GLint n, GLint y0, GLint y1, GLint yspan[] );
  85.  
  86.  
  87. extern void gl_interpolate_rgba( GLint n,
  88.                                  GLfixed r0, GLfixed r1, GLubyte rspan[],
  89.                                  GLfixed g0, GLfixed g1, GLubyte gspan[],
  90.                                  GLfixed b0, GLfixed b1, GLubyte bspan[],
  91.                                  GLfixed a0, GLfixed a1, GLubyte aspan[] );
  92.  
  93.  
  94. extern void gl_interp_texcoords( GLuint n, GLboolean homogeneous,
  95.                                  GLfloat clipw0, GLfloat clipw1,
  96.                                  GLfloat s0, GLfloat s1,
  97.                                  GLfloat t0, GLfloat t1,
  98.                                  GLfloat u0, GLfloat u1,
  99.                                  GLfloat v0, GLfloat v1,
  100.                                  GLfloat s[], GLfloat t[],
  101.                                  GLfloat u[], GLfloat v[],
  102.                                  GLfloat w[]);
  103.  
  104.  
  105.  
  106. #ifdef DEBUG
  107.  
  108. #define GL_INTERPOLATE_Z(N,Z0,Z1,ZSPAN)   gl_interpolate_z(N,Z0,Z1,ZSPAN)
  109.  
  110. #else
  111.  
  112. #define GL_INTERPOLATE_Z(N,Z0,Z1,ZSPAN)    \
  113. {                    \
  114.    GLint zz0, zz1, dzz, ii;        \
  115.    switch (N) {                \
  116.       case 1:                \
  117.      ZSPAN[0] = Z0;            \
  118.      break;                \
  119.       case 2:                \
  120.      ZSPAN[0] = Z0;            \
  121.      ZSPAN[1] = Z1;            \
  122.      break;                \
  123.       case 3:                \
  124.      ZSPAN[0] = Z0;            \
  125.      ZSPAN[1] = ((Z0)+(Z1)) >> 1;    \
  126.      ZSPAN[2] = Z1;            \
  127.      break;                \
  128.       default:                \
  129.          zz0 = (Z0) << 7;        \
  130.      zz1 = (Z1) << 7;        \
  131.      dzz = (zz1-zz0) / ((N)-1);    \
  132.      for (ii=0;ii<(N);ii++) {    \
  133.         ZSPAN[ii] = zz0 >> 7;    \
  134.         zz0 += dzz;            \
  135.      }                \
  136.    }                    \
  137. }
  138.  
  139.  
  140.  
  141. #endif  /*DEBUG*/
  142.  
  143.  
  144.  
  145.  
  146. /*
  147.  * Macro version of gl_interpolate_rgba()
  148.  */
  149. #define GL_INTERPOLATE_RGBA( N, R0,R1,R, G0,G1,G, B0,B1,B, A0,A1,A )    \
  150.     if ((N)<2) {                    \
  151.        R[0] = FixedToInt(R0);            \
  152.        G[0] = FixedToInt(G0);            \
  153.        B[0] = FixedToInt(B0);            \
  154.        A[0] = FixedToInt(A0);            \
  155.     }                        \
  156.     else if ((N)==2) {                \
  157.            R[0] = FixedToInt(R0);            \
  158.            R[1] = FixedToInt(R1);            \
  159.        G[0] = FixedToInt(G0);            \
  160.        G[1] = FixedToInt(G1);            \
  161.        B[0] = FixedToInt(B0);            \
  162.        B[1] = FixedToInt(B1);            \
  163.        A[0] = FixedToInt(A0);            \
  164.        A[1] = FixedToInt(A1);            \
  165.     }                        \
  166.     else {                        \
  167.        GLfixed r0, dr, g0, dg, b0, db, a0, da;    \
  168.        GLint ii, nn = (GLint) (N) - 1;        \
  169.        r0 = R0;   dr = (R1-r0) / nn;        \
  170.        g0 = G0;   dg = (G1-g0) / nn;        \
  171.        b0 = B0;   db = (B1-b0) / nn;        \
  172.        a0 = A0;   da = (A1-a0) / nn;        \
  173.        for (ii=0;ii<(N);ii++) {            \
  174.           R[ii] = FixedToInt(r0);    r0+=dr;        \
  175.           G[ii] = FixedToInt(g0);    g0+=dg;        \
  176.           B[ii] = FixedToInt(b0);    b0+=db;        \
  177.           A[ii] = FixedToInt(a0);    a0+=da;        \
  178.        }                        \
  179.     }
  180.  
  181.  
  182. #endif  /* INTERP_H */
  183.  
  184.