source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/src/softrender/sl_framebuffer.I @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.6 KB
Line 
1/*
2
3Homan Igehy
4
5Computer Graphics Laboratory
6Stanford University
7
8---------------------------------------------------------------------
9
10Copyright (1997) The Board of Trustees of the Leland Stanford Junior
11University. Except for commercial resale, lease, license or other
12commercial transactions, permission is hereby given to use, copy,
13modify this software for academic purposes only.  No part of this
14software or any derivatives thereof may be used in the production of
15computer models for resale or for use in a commercial
16product. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND
17CONCERNING THIS SOFTWARE.  No support is implied or provided.
18
19*/
20
21
22/*
23 * sl_framebuffer.I
24 *
25 */
26
27#ifndef SL_FRAMEBUFFER_I
28#define SL_FRAMEBUFFER_I
29
30#include "sl_val.H"
31#include "sl_framebuffer.H"
32#include "sl_hack.H"
33#include "sl_texture.H"
34#include "sl_texture.I"
35
36
37#include <iostream>
38#include <stdio.h>
39
40#ifdef SampleCalc_Dda
41#define get(i) (cur##i)
42#endif
43
44#ifdef SampleCalc_Ddx
45#define get(i) (cur##i + (ddx##i * curx))
46#endif
47
48
49static inline void
50BufferSample(
51#ifdef SampleCalc_Ddx
52             const Real curx,
53#endif
54             IN_FormalArgs(cur)
55#ifdef SampleCalc_Ddx
56             IN_FormalConstArgs(ddx)
57#endif
58             CA_FormalConstArgs(cur)
59#ifdef LevelOfDetail
60             Real numParX, Real numParY,
61#endif
62             FB_FormalArgs(* sample)
63             )
64{
65
66#ifdef ZBuffer
67  if (get(Z) > FB_Z(sample)) {
68    FB_Z(sample) = get(Z);
69#endif
70
71
72#ifdef Interpolate_Color
73    Real R = get(R);
74    Real G = get(G);
75    Real B = get(B);
76#endif
77
78#ifdef TextureCoord
79    Real inv_w = REAL_ONE / get(W);
80    Real S = get(U) * inv_w;
81    Real T = get(V) * inv_w;
82#endif
83
84
85#ifdef LevelOfDetail
86    Real D = ((numParX > numParY) ? numParX : numParY) * inv_w * inv_w;
87    G = D;
88#endif
89
90
91#ifdef PointSampleTexture
92    PointSample(curT, S, T, R, G, B);
93#endif
94
95#ifdef Interpolate_Color
96
97#ifndef Alpha
98
99    FB_R(sample) = FB_InterpToSample(R);
100    FB_G(sample) = FB_InterpToSample(G);
101    FB_B(sample) = FB_InterpToSample(B);
102
103#else
104
105#ifdef Constant_A
106    Real alpha = curA;
107#else
108    Real alpha = get(A);
109#endif
110
111
112    FB_R(sample) = red   + alpha * (FB_SampleToInterp(FB_R(sample)) - red  );
113    FB_G(sample) = green + alpha * (FB_SampleToInterp(FB_G(sample)) - green);
114    FB_B(sample) = blue  + alpha * (FB_SampleToInterp(FB_B(sample)) - blue );
115    FB_A(sample) = alpha + alpha * (FB_SampleToInterp(FB_R(sample)) - alpha);
116
117
118#endif /* Alpha */
119
120#endif /* Interpolate_Color */
121
122#ifdef Interpolate_Intensity
123    FB_I(sample) = FB_InterpToSample(get(I));
124#endif
125
126
127#ifdef Constant_PackedColor
128    FB_C(sample) = curC;
129#endif
130
131
132#ifdef ZBuffer
133  }
134#endif
135
136
137}
138
139
140
141
142#endif /* FRAMEBUFFER_I */
Note: See TracBrowser for help on using the repository browser.