Debian Codegraph @

debian/external_deps/fetk/sg/src/gl/interp.h

raw
1 /* $Id: interp.h,v 1.2 2000/10/27 15:21:40 mholst Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 2.0
6 * Copyright (C) 1995-1996 Brian Paul
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 #ifndef INTERP_H
24 #define INTERP_H
25
26
27 #include "types.h"
28
29
30 /*
31 * Various integer interpolation functions and macros
32 */
33
34
35
36 extern void gl_interpolate_z( GLint n, GLint z0, GLint z1, GLdepth zspan[] );
37
38
39 extern void gl_interpolate_i( GLint n, GLint y0, GLint y1, GLint yspan[] );
40
41
42 extern void gl_interpolate_rgba( GLint n,
43 GLfixed r0, GLfixed r1, GLubyte rspan[],
44 GLfixed g0, GLfixed g1, GLubyte gspan[],
45 GLfixed b0, GLfixed b1, GLubyte bspan[],
46 GLfixed a0, GLfixed a1, GLubyte aspan[] );
47
48
49
50 #ifdef DEBUG
51
52 #define GL_INTERPOLATE_Z(N,Z0,Z1,ZSPAN) gl_interpolate_z(N,Z0,Z1,ZSPAN)
53
54 #else
55
56 #define GL_INTERPOLATE_Z(N,Z0,Z1,ZSPAN) \
57 { \
58 GLint zz0, zz1, dzz, ii; \
59 switch (N) { \
60 case 1: \
61 ZSPAN[0] = Z0; \
62 break; \
63 case 2: \
64 ZSPAN[0] = Z0; \
65 ZSPAN[1] = Z1; \
66 break; \
67 case 3: \
68 ZSPAN[0] = Z0; \
69 ZSPAN[1] = ((Z0)+(Z1)) >> 1; \
70 ZSPAN[2] = Z1; \
71 break; \
72 default: \
73 zz0 = (Z0) << 7; \
74 zz1 = (Z1) << 7; \
75 dzz = (zz1-zz0) / ((N)-1); \
76 for (ii=0;ii<(N);ii++) { \
77 ZSPAN[ii] = zz0 >> 7; \
78 zz0 += dzz; \
79 } \
80 } \
81 }
82
83
84
85 #endif /*DEBUG*/
86
87
88
89
90 /*
91 * Macro version of gl_interpolate_rgba()
92 */
93 #define GL_INTERPOLATE_RGBA( N, R0,R1,R, G0,G1,G, B0,B1,B, A0,A1,A ) \
94 if ((N)<2) { \
95 R[0] = FixedToInt(R0); \
96 G[0] = FixedToInt(G0); \
97 B[0] = FixedToInt(B0); \
98 A[0] = FixedToInt(A0); \
99 } \
100 else if ((N)==2) { \
101 R[0] = FixedToInt(R0); \
102 R[1] = FixedToInt(R1); \
103 G[0] = FixedToInt(G0); \
104 G[1] = FixedToInt(G1); \
105 B[0] = FixedToInt(B0); \
106 B[1] = FixedToInt(B1); \
107 A[0] = FixedToInt(A0); \
108 A[1] = FixedToInt(A1); \
109 } \
110 else { \
111 GLfixed r0, dr, g0, dg, b0, db, a0, da; \
112 GLint ii, nn = (GLint) (N) - 1; \
113 r0 = R0; dr = (R1-r0) / nn; \
114 g0 = G0; dg = (G1-g0) / nn; \
115 b0 = B0; db = (B1-b0) / nn; \
116 a0 = A0; da = (A1-a0) / nn; \
117 for (ii=0;ii<(N);ii++) { \
118 R[ii] = FixedToInt(r0); r0+=dr; \
119 G[ii] = FixedToInt(g0); g0+=dg; \
120 B[ii] = FixedToInt(b0); b0+=db; \
121 A[ii] = FixedToInt(a0); a0+=da; \
122 } \
123 }
124
125
126 #endif /* INTERP_H */
127