source: trunk/src/opengl/mesa/interp_tmp.h

Last change on this file was 3597, checked in by jeroen, 25 years ago

* empty log message *

File size: 4.4 KB
Line 
1/* $Id: interp_tmp.h,v 1.2 2000-05-23 20:34:51 jeroen Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 3.1
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27#define INTERP_UBYTE( out, t, a, b ) { \
28 GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a); \
29 GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b); \
30 GLfloat fo = LINTERP(t, fa, fb); \
31 FLOAT_COLOR_TO_UBYTE_COLOR(out, fo); \
32}
33
34#if 1
35
36#define INTERP_RGBA(nr, t, out, a, b) { \
37 int i; \
38 for (i = 0; i < nr; i++) { \
39 GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \
40 GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \
41 GLfloat fo = LINTERP(t, fa, fb); \
42 FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \
43 } \
44}
45#else
46
47#define INTERP_RGBA(nr, t, out, a, b) { \
48 int n; \
49 const GLuint ti = FloatToInt(t*256.0F); \
50 const GLubyte *Ib = (const GLubyte *)&a[0]; \
51 const GLubyte *Jb = (const GLubyte *)&b[0]; \
52 GLubyte *Ob = (GLubyte *)&out[0]; \
53 \
54 for (n = 0 ; n < nr ; n++) \
55 Ob[n] = (GLubyte) (Ib[n] + ((ti * (Jb[n] - Ib[n]))/256)); \
56}
57#endif
58
59static void NAME( struct vertex_buffer *VB,
60 GLuint dst, GLfloat t, GLuint in, GLuint out )
61{
62 (void) VB;
63 (void) dst;
64 (void) t;
65 (void) in;
66 (void) out;
67
68#if (IND & CLIP_RGBA0)
69 INTERP_RGBA( 4, t,
70 VB->Color[0]->data[dst],
71 VB->Color[0]->data[in],
72 VB->Color[0]->data[out] );
73#endif
74
75#if (IND & CLIP_RGBA1)
76 if (VB->ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
77 INTERP_RGBA( 4, t,
78 VB->Color[1]->data[dst],
79 VB->Color[1]->data[in],
80 VB->Color[1]->data[out] );
81 }
82
83 if (VB->ctx->TriangleCaps & DD_SEPERATE_SPECULAR)
84 {
85 INTERP_RGBA( 3, t,
86 VB->Spec[0][dst],
87 VB->Spec[0][in],
88 VB->Spec[0][out] );
89
90 if (VB->ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
91 INTERP_RGBA( 3, t,
92 VB->Spec[1][dst],
93 VB->Spec[1][in],
94 VB->Spec[1][out] );
95 }
96 }
97#endif
98
99#if (IND & CLIP_FOG_COORD)
100 {
101 GLubyte a = VB->Spec[0][in][3], b = VB->Spec[0][out][3];
102 INTERP_UBYTE( VB->Spec[0][dst][3], t, a, b );
103 }
104#endif
105
106
107#if (IND & CLIP_INDEX0)
108 VB->IndexPtr->data[dst] = (GLuint) (GLint)
109 LINTERP( t,
110 (GLfloat) VB->Index[0]->data[in],
111 (GLfloat) VB->Index[0]->data[out] );
112#endif
113
114#if (IND & CLIP_INDEX1)
115 VB->Index[1]->data[dst] = (GLuint) (GLint)
116 LINTERP( t,
117 (GLfloat) VB->Index[1]->data[in],
118 (GLfloat) VB->Index[1]->data[out] );
119#endif
120
121#if (IND & CLIP_TEX0)
122 INTERP_SZ( t,
123 VB->TexCoordPtr[0]->data,
124 dst, in, out,
125 VB->TexCoordPtr[0]->size );
126#endif
127
128#if (IND & CLIP_TEX1)
129 INTERP_SZ( t,
130 VB->TexCoordPtr[1]->data,
131 dst, in, out,
132 VB->TexCoordPtr[1]->size );
133#endif
134}
135
136
137#undef IND
138#undef NAME
Note: See TracBrowser for help on using the repository browser.