diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CTRTextureGouraudAlpha.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CTRTextureGouraudAlpha.cpp | 1488 |
1 files changed, 744 insertions, 744 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureGouraudAlpha.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureGouraudAlpha.cpp index 62a7c9a..713e206 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureGouraudAlpha.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureGouraudAlpha.cpp | |||
@@ -1,744 +1,744 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #include "IrrCompileConfig.h" | 5 | #include "IrrCompileConfig.h" |
6 | #include "IBurningShader.h" | 6 | #include "IBurningShader.h" |
7 | 7 | ||
8 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 8 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ |
9 | 9 | ||
10 | // compile flag for this file | 10 | // compile flag for this file |
11 | #undef USE_ZBUFFER | 11 | #undef USE_ZBUFFER |
12 | #undef IPOL_Z | 12 | #undef IPOL_Z |
13 | #undef CMP_Z | 13 | #undef CMP_Z |
14 | #undef WRITE_Z | 14 | #undef WRITE_Z |
15 | 15 | ||
16 | #undef IPOL_W | 16 | #undef IPOL_W |
17 | #undef CMP_W | 17 | #undef CMP_W |
18 | #undef WRITE_W | 18 | #undef WRITE_W |
19 | 19 | ||
20 | #undef SUBTEXEL | 20 | #undef SUBTEXEL |
21 | #undef INVERSE_W | 21 | #undef INVERSE_W |
22 | 22 | ||
23 | #undef IPOL_C0 | 23 | #undef IPOL_C0 |
24 | #undef IPOL_T0 | 24 | #undef IPOL_T0 |
25 | #undef IPOL_T1 | 25 | #undef IPOL_T1 |
26 | 26 | ||
27 | // define render case | 27 | // define render case |
28 | #define SUBTEXEL | 28 | #define SUBTEXEL |
29 | #define INVERSE_W | 29 | #define INVERSE_W |
30 | 30 | ||
31 | #define USE_ZBUFFER | 31 | #define USE_ZBUFFER |
32 | #define IPOL_W | 32 | #define IPOL_W |
33 | #define CMP_W | 33 | #define CMP_W |
34 | #define WRITE_W | 34 | #define WRITE_W |
35 | 35 | ||
36 | #define IPOL_C0 | 36 | #define IPOL_C0 |
37 | #define IPOL_T0 | 37 | #define IPOL_T0 |
38 | //#define IPOL_T1 | 38 | //#define IPOL_T1 |
39 | 39 | ||
40 | // apply global override | 40 | // apply global override |
41 | #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT | 41 | #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT |
42 | #undef INVERSE_W | 42 | #undef INVERSE_W |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | #ifndef SOFTWARE_DRIVER_2_SUBTEXEL | 45 | #ifndef SOFTWARE_DRIVER_2_SUBTEXEL |
46 | #undef SUBTEXEL | 46 | #undef SUBTEXEL |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | 49 | #ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR |
50 | #undef IPOL_C0 | 50 | #undef IPOL_C0 |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) | 53 | #if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) |
54 | #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT | 54 | #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT |
55 | #undef IPOL_W | 55 | #undef IPOL_W |
56 | #endif | 56 | #endif |
57 | #define IPOL_Z | 57 | #define IPOL_Z |
58 | 58 | ||
59 | #ifdef CMP_W | 59 | #ifdef CMP_W |
60 | #undef CMP_W | 60 | #undef CMP_W |
61 | #define CMP_Z | 61 | #define CMP_Z |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | #ifdef WRITE_W | 64 | #ifdef WRITE_W |
65 | #undef WRITE_W | 65 | #undef WRITE_W |
66 | #define WRITE_Z | 66 | #define WRITE_Z |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | 71 | ||
72 | 72 | ||
73 | namespace irr | 73 | namespace irr |
74 | { | 74 | { |
75 | 75 | ||
76 | namespace video | 76 | namespace video |
77 | { | 77 | { |
78 | 78 | ||
79 | class CTRTextureGouraudAlpha2 : public IBurningShader | 79 | class CTRTextureGouraudAlpha2 : public IBurningShader |
80 | { | 80 | { |
81 | public: | 81 | public: |
82 | 82 | ||
83 | //! constructor | 83 | //! constructor |
84 | CTRTextureGouraudAlpha2(CBurningVideoDriver* driver); | 84 | CTRTextureGouraudAlpha2(CBurningVideoDriver* driver); |
85 | 85 | ||
86 | //! draws an indexed triangle list | 86 | //! draws an indexed triangle list |
87 | virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); | 87 | virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); |
88 | 88 | ||
89 | virtual void setParam ( u32 index, f32 value); | 89 | virtual void setParam ( u32 index, f32 value); |
90 | 90 | ||
91 | 91 | ||
92 | private: | 92 | private: |
93 | void scanline_bilinear (); | 93 | void scanline_bilinear (); |
94 | 94 | ||
95 | sScanConvertData scan; | 95 | sScanConvertData scan; |
96 | sScanLineData line; | 96 | sScanLineData line; |
97 | 97 | ||
98 | u32 AlphaRef; | 98 | u32 AlphaRef; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | //! constructor | 101 | //! constructor |
102 | CTRTextureGouraudAlpha2::CTRTextureGouraudAlpha2(CBurningVideoDriver* driver) | 102 | CTRTextureGouraudAlpha2::CTRTextureGouraudAlpha2(CBurningVideoDriver* driver) |
103 | : IBurningShader(driver) | 103 | : IBurningShader(driver) |
104 | { | 104 | { |
105 | #ifdef _DEBUG | 105 | #ifdef _DEBUG |
106 | setDebugName("CTRTextureGouraudAlpha2"); | 106 | setDebugName("CTRTextureGouraudAlpha2"); |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | AlphaRef = 0; | 109 | AlphaRef = 0; |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | /*! | 113 | /*! |
114 | */ | 114 | */ |
115 | void CTRTextureGouraudAlpha2::setParam ( u32 index, f32 value) | 115 | void CTRTextureGouraudAlpha2::setParam ( u32 index, f32 value) |
116 | { | 116 | { |
117 | #ifdef BURNINGVIDEO_RENDERER_FAST | 117 | #ifdef BURNINGVIDEO_RENDERER_FAST |
118 | AlphaRef = core::floor32 ( value * 256.f ); | 118 | AlphaRef = core::floor32 ( value * 256.f ); |
119 | #else | 119 | #else |
120 | AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); | 120 | AlphaRef = u32_to_fixPoint ( core::floor32 ( value * 256.f ) ); |
121 | #endif | 121 | #endif |
122 | } | 122 | } |
123 | 123 | ||
124 | /*! | 124 | /*! |
125 | */ | 125 | */ |
126 | void CTRTextureGouraudAlpha2::scanline_bilinear () | 126 | void CTRTextureGouraudAlpha2::scanline_bilinear () |
127 | { | 127 | { |
128 | tVideoSample *dst; | 128 | tVideoSample *dst; |
129 | 129 | ||
130 | #ifdef USE_ZBUFFER | 130 | #ifdef USE_ZBUFFER |
131 | fp24 *z; | 131 | fp24 *z; |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | s32 xStart; | 134 | s32 xStart; |
135 | s32 xEnd; | 135 | s32 xEnd; |
136 | s32 dx; | 136 | s32 dx; |
137 | 137 | ||
138 | 138 | ||
139 | #ifdef SUBTEXEL | 139 | #ifdef SUBTEXEL |
140 | f32 subPixel; | 140 | f32 subPixel; |
141 | #endif | 141 | #endif |
142 | 142 | ||
143 | #ifdef IPOL_Z | 143 | #ifdef IPOL_Z |
144 | f32 slopeZ; | 144 | f32 slopeZ; |
145 | #endif | 145 | #endif |
146 | #ifdef IPOL_W | 146 | #ifdef IPOL_W |
147 | fp24 slopeW; | 147 | fp24 slopeW; |
148 | #endif | 148 | #endif |
149 | #ifdef IPOL_C0 | 149 | #ifdef IPOL_C0 |
150 | sVec4 slopeC[MATERIAL_MAX_COLORS]; | 150 | sVec4 slopeC[MATERIAL_MAX_COLORS]; |
151 | #endif | 151 | #endif |
152 | #ifdef IPOL_T0 | 152 | #ifdef IPOL_T0 |
153 | sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; | 153 | sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | // apply top-left fill-convention, left | 156 | // apply top-left fill-convention, left |
157 | xStart = core::ceil32( line.x[0] ); | 157 | xStart = core::ceil32( line.x[0] ); |
158 | xEnd = core::ceil32( line.x[1] ) - 1; | 158 | xEnd = core::ceil32( line.x[1] ) - 1; |
159 | 159 | ||
160 | dx = xEnd - xStart; | 160 | dx = xEnd - xStart; |
161 | 161 | ||
162 | if ( dx < 0 ) | 162 | if ( dx < 0 ) |
163 | return; | 163 | return; |
164 | 164 | ||
165 | // slopes | 165 | // slopes |
166 | const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); | 166 | const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); |
167 | 167 | ||
168 | #ifdef IPOL_Z | 168 | #ifdef IPOL_Z |
169 | slopeZ = (line.z[1] - line.z[0]) * invDeltaX; | 169 | slopeZ = (line.z[1] - line.z[0]) * invDeltaX; |
170 | #endif | 170 | #endif |
171 | #ifdef IPOL_W | 171 | #ifdef IPOL_W |
172 | slopeW = (line.w[1] - line.w[0]) * invDeltaX; | 172 | slopeW = (line.w[1] - line.w[0]) * invDeltaX; |
173 | #endif | 173 | #endif |
174 | #ifdef IPOL_C0 | 174 | #ifdef IPOL_C0 |
175 | slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; | 175 | slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; |
176 | #endif | 176 | #endif |
177 | #ifdef IPOL_T0 | 177 | #ifdef IPOL_T0 |
178 | slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; | 178 | slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; |
179 | #endif | 179 | #endif |
180 | #ifdef IPOL_T1 | 180 | #ifdef IPOL_T1 |
181 | slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; | 181 | slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; |
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | #ifdef SUBTEXEL | 184 | #ifdef SUBTEXEL |
185 | subPixel = ( (f32) xStart ) - line.x[0]; | 185 | subPixel = ( (f32) xStart ) - line.x[0]; |
186 | #ifdef IPOL_Z | 186 | #ifdef IPOL_Z |
187 | line.z[0] += slopeZ * subPixel; | 187 | line.z[0] += slopeZ * subPixel; |
188 | #endif | 188 | #endif |
189 | #ifdef IPOL_W | 189 | #ifdef IPOL_W |
190 | line.w[0] += slopeW * subPixel; | 190 | line.w[0] += slopeW * subPixel; |
191 | #endif | 191 | #endif |
192 | #ifdef IPOL_C0 | 192 | #ifdef IPOL_C0 |
193 | line.c[0][0] += slopeC[0] * subPixel; | 193 | line.c[0][0] += slopeC[0] * subPixel; |
194 | #endif | 194 | #endif |
195 | #ifdef IPOL_T0 | 195 | #ifdef IPOL_T0 |
196 | line.t[0][0] += slopeT[0] * subPixel; | 196 | line.t[0][0] += slopeT[0] * subPixel; |
197 | #endif | 197 | #endif |
198 | #ifdef IPOL_T1 | 198 | #ifdef IPOL_T1 |
199 | line.t[1][0] += slopeT[1] * subPixel; | 199 | line.t[1][0] += slopeT[1] * subPixel; |
200 | #endif | 200 | #endif |
201 | #endif | 201 | #endif |
202 | 202 | ||
203 | dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; | 203 | dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; |
204 | 204 | ||
205 | #ifdef USE_ZBUFFER | 205 | #ifdef USE_ZBUFFER |
206 | z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; | 206 | z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; |
207 | #endif | 207 | #endif |
208 | 208 | ||
209 | 209 | ||
210 | #ifdef INVERSE_W | 210 | #ifdef INVERSE_W |
211 | f32 inversew; | 211 | f32 inversew; |
212 | #endif | 212 | #endif |
213 | 213 | ||
214 | #ifdef BURNINGVIDEO_RENDERER_FAST | 214 | #ifdef BURNINGVIDEO_RENDERER_FAST |
215 | u32 dIndex = ( line.y & 3 ) << 2; | 215 | u32 dIndex = ( line.y & 3 ) << 2; |
216 | 216 | ||
217 | #else | 217 | #else |
218 | tFixPoint a0; | 218 | tFixPoint a0; |
219 | tFixPoint r0, g0, b0; | 219 | tFixPoint r0, g0, b0; |
220 | #endif | 220 | #endif |
221 | 221 | ||
222 | #ifdef IPOL_C0 | 222 | #ifdef IPOL_C0 |
223 | tFixPoint r1, g1, b1; | 223 | tFixPoint r1, g1, b1; |
224 | tFixPoint r2, g2, b2; | 224 | tFixPoint r2, g2, b2; |
225 | #endif | 225 | #endif |
226 | 226 | ||
227 | for ( s32 i = 0; i <= dx; ++i ) | 227 | for ( s32 i = 0; i <= dx; ++i ) |
228 | { | 228 | { |
229 | #ifdef CMP_Z | 229 | #ifdef CMP_Z |
230 | if ( line.z[0] < z[i] ) | 230 | if ( line.z[0] < z[i] ) |
231 | #endif | 231 | #endif |
232 | #ifdef CMP_W | 232 | #ifdef CMP_W |
233 | if ( line.w[0] >= z[i] ) | 233 | if ( line.w[0] >= z[i] ) |
234 | #endif | 234 | #endif |
235 | 235 | ||
236 | { | 236 | { |
237 | 237 | ||
238 | #ifdef BURNINGVIDEO_RENDERER_FAST | 238 | #ifdef BURNINGVIDEO_RENDERER_FAST |
239 | 239 | ||
240 | const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; | 240 | const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; |
241 | 241 | ||
242 | #ifdef INVERSE_W | 242 | #ifdef INVERSE_W |
243 | 243 | ||
244 | inversew = fix_inverse32 ( line.w[0] ); | 244 | inversew = fix_inverse32 ( line.w[0] ); |
245 | 245 | ||
246 | u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew), | 246 | u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x,inversew), |
247 | d + tofix ( line.t[0][0].y,inversew) | 247 | d + tofix ( line.t[0][0].y,inversew) |
248 | ); | 248 | ); |
249 | 249 | ||
250 | #else | 250 | #else |
251 | 251 | ||
252 | u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x), | 252 | u32 argb = getTexel_plain ( &IT[0], d + tofix ( line.t[0][0].x), |
253 | d + tofix ( line.t[0][0].y) | 253 | d + tofix ( line.t[0][0].y) |
254 | ); | 254 | ); |
255 | 255 | ||
256 | #endif | 256 | #endif |
257 | 257 | ||
258 | const u32 alpha = ( argb >> 24 ); | 258 | const u32 alpha = ( argb >> 24 ); |
259 | if ( alpha > AlphaRef ) | 259 | if ( alpha > AlphaRef ) |
260 | { | 260 | { |
261 | #ifdef WRITE_Z | 261 | #ifdef WRITE_Z |
262 | z[i] = line.z[0]; | 262 | z[i] = line.z[0]; |
263 | #endif | 263 | #endif |
264 | #ifdef WRITE_W | 264 | #ifdef WRITE_W |
265 | z[i] = line.w[0]; | 265 | z[i] = line.w[0]; |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | dst[i] = PixelBlend32 ( dst[i], argb, alpha ); | 268 | dst[i] = PixelBlend32 ( dst[i], argb, alpha ); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | #else | 272 | #else |
273 | 273 | ||
274 | #ifdef INVERSE_W | 274 | #ifdef INVERSE_W |
275 | inversew = fix_inverse32 ( line.w[0] ); | 275 | inversew = fix_inverse32 ( line.w[0] ); |
276 | getSample_texture ( a0,r0,g0,b0, | 276 | getSample_texture ( a0,r0,g0,b0, |
277 | &IT[0], | 277 | &IT[0], |
278 | tofix ( line.t[0][0].x,inversew), | 278 | tofix ( line.t[0][0].x,inversew), |
279 | tofix ( line.t[0][0].y,inversew) | 279 | tofix ( line.t[0][0].y,inversew) |
280 | ); | 280 | ); |
281 | #else | 281 | #else |
282 | getSample_texture ( a0,r0,g0,b0, | 282 | getSample_texture ( a0,r0,g0,b0, |
283 | &IT[0], | 283 | &IT[0], |
284 | tofix ( line.t[0][0].x), | 284 | tofix ( line.t[0][0].x), |
285 | tofix ( line.t[0][0].y) | 285 | tofix ( line.t[0][0].y) |
286 | ); | 286 | ); |
287 | #endif | 287 | #endif |
288 | if ( (tFixPointu) a0 > AlphaRef ) | 288 | if ( (tFixPointu) a0 > AlphaRef ) |
289 | { | 289 | { |
290 | #ifdef WRITE_Z | 290 | #ifdef WRITE_Z |
291 | z[i] = line.z[0]; | 291 | z[i] = line.z[0]; |
292 | #endif | 292 | #endif |
293 | #ifdef WRITE_W | 293 | #ifdef WRITE_W |
294 | z[i] = line.w[0]; | 294 | z[i] = line.w[0]; |
295 | #endif | 295 | #endif |
296 | 296 | ||
297 | #ifdef INVERSE_W | 297 | #ifdef INVERSE_W |
298 | getSample_color ( r2, g2, b2, line.c[0][0], inversew ); | 298 | getSample_color ( r2, g2, b2, line.c[0][0], inversew ); |
299 | #else | 299 | #else |
300 | getSample_color ( r2, g2, b2, line.c[0][0] ); | 300 | getSample_color ( r2, g2, b2, line.c[0][0] ); |
301 | #endif | 301 | #endif |
302 | r0 = imulFix ( r0, r2 ); | 302 | r0 = imulFix ( r0, r2 ); |
303 | g0 = imulFix ( g0, g2 ); | 303 | g0 = imulFix ( g0, g2 ); |
304 | b0 = imulFix ( b0, b2 ); | 304 | b0 = imulFix ( b0, b2 ); |
305 | 305 | ||
306 | color_to_fix ( r1, g1, b1, dst[i] ); | 306 | color_to_fix ( r1, g1, b1, dst[i] ); |
307 | 307 | ||
308 | a0 >>= 8; | 308 | a0 >>= 8; |
309 | 309 | ||
310 | r2 = r1 + imulFix ( a0, r0 - r1 ); | 310 | r2 = r1 + imulFix ( a0, r0 - r1 ); |
311 | g2 = g1 + imulFix ( a0, g0 - g1 ); | 311 | g2 = g1 + imulFix ( a0, g0 - g1 ); |
312 | b2 = b1 + imulFix ( a0, b0 - b1 ); | 312 | b2 = b1 + imulFix ( a0, b0 - b1 ); |
313 | dst[i] = fix4_to_color ( a0, r2, g2, b2 ); | 313 | dst[i] = fix4_to_color ( a0, r2, g2, b2 ); |
314 | 314 | ||
315 | /* | 315 | /* |
316 | dst[i] = PixelBlend32 ( dst[i], | 316 | dst[i] = PixelBlend32 ( dst[i], |
317 | fix_to_color ( r0,g0, b0 ), | 317 | fix_to_color ( r0,g0, b0 ), |
318 | fixPointu_to_u32 ( a0 ) | 318 | fixPointu_to_u32 ( a0 ) |
319 | ); | 319 | ); |
320 | */ | 320 | */ |
321 | /* | 321 | /* |
322 | getSample_color ( r2, g2, b2, line.c[0][0], inversew * COLOR_MAX ); | 322 | getSample_color ( r2, g2, b2, line.c[0][0], inversew * COLOR_MAX ); |
323 | color_to_fix ( r1, g1, b1, dst[i] ); | 323 | color_to_fix ( r1, g1, b1, dst[i] ); |
324 | 324 | ||
325 | r2 = r0 + imulFix ( a0, r1 - r0 ); | 325 | r2 = r0 + imulFix ( a0, r1 - r0 ); |
326 | g2 = g0 + imulFix ( a0, g1 - g0 ); | 326 | g2 = g0 + imulFix ( a0, g1 - g0 ); |
327 | b2 = b0 + imulFix ( a0, b1 - b0 ); | 327 | b2 = b0 + imulFix ( a0, b1 - b0 ); |
328 | dst[i] = fix_to_color ( r2, g2, b2 ); | 328 | dst[i] = fix_to_color ( r2, g2, b2 ); |
329 | */ | 329 | */ |
330 | 330 | ||
331 | } | 331 | } |
332 | #endif | 332 | #endif |
333 | 333 | ||
334 | } | 334 | } |
335 | 335 | ||
336 | #ifdef IPOL_Z | 336 | #ifdef IPOL_Z |
337 | line.z[0] += slopeZ; | 337 | line.z[0] += slopeZ; |
338 | #endif | 338 | #endif |
339 | #ifdef IPOL_W | 339 | #ifdef IPOL_W |
340 | line.w[0] += slopeW; | 340 | line.w[0] += slopeW; |
341 | #endif | 341 | #endif |
342 | #ifdef IPOL_C0 | 342 | #ifdef IPOL_C0 |
343 | line.c[0][0] += slopeC[0]; | 343 | line.c[0][0] += slopeC[0]; |
344 | #endif | 344 | #endif |
345 | #ifdef IPOL_T0 | 345 | #ifdef IPOL_T0 |
346 | line.t[0][0] += slopeT[0]; | 346 | line.t[0][0] += slopeT[0]; |
347 | #endif | 347 | #endif |
348 | #ifdef IPOL_T1 | 348 | #ifdef IPOL_T1 |
349 | line.t[1][0] += slopeT[1]; | 349 | line.t[1][0] += slopeT[1]; |
350 | #endif | 350 | #endif |
351 | } | 351 | } |
352 | 352 | ||
353 | } | 353 | } |
354 | 354 | ||
355 | void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) | 355 | void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) |
356 | { | 356 | { |
357 | // sort on height, y | 357 | // sort on height, y |
358 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); | 358 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); |
359 | if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); | 359 | if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); |
360 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); | 360 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); |
361 | 361 | ||
362 | const f32 ca = c->Pos.y - a->Pos.y; | 362 | const f32 ca = c->Pos.y - a->Pos.y; |
363 | const f32 ba = b->Pos.y - a->Pos.y; | 363 | const f32 ba = b->Pos.y - a->Pos.y; |
364 | const f32 cb = c->Pos.y - b->Pos.y; | 364 | const f32 cb = c->Pos.y - b->Pos.y; |
365 | // calculate delta y of the edges | 365 | // calculate delta y of the edges |
366 | scan.invDeltaY[0] = core::reciprocal( ca ); | 366 | scan.invDeltaY[0] = core::reciprocal( ca ); |
367 | scan.invDeltaY[1] = core::reciprocal( ba ); | 367 | scan.invDeltaY[1] = core::reciprocal( ba ); |
368 | scan.invDeltaY[2] = core::reciprocal( cb ); | 368 | scan.invDeltaY[2] = core::reciprocal( cb ); |
369 | 369 | ||
370 | if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) | 370 | if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) |
371 | return; | 371 | return; |
372 | 372 | ||
373 | // find if the major edge is left or right aligned | 373 | // find if the major edge is left or right aligned |
374 | f32 temp[4]; | 374 | f32 temp[4]; |
375 | 375 | ||
376 | temp[0] = a->Pos.x - c->Pos.x; | 376 | temp[0] = a->Pos.x - c->Pos.x; |
377 | temp[1] = -ca; | 377 | temp[1] = -ca; |
378 | temp[2] = b->Pos.x - a->Pos.x; | 378 | temp[2] = b->Pos.x - a->Pos.x; |
379 | temp[3] = ba; | 379 | temp[3] = ba; |
380 | 380 | ||
381 | scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; | 381 | scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; |
382 | scan.right = 1 - scan.left; | 382 | scan.right = 1 - scan.left; |
383 | 383 | ||
384 | // calculate slopes for the major edge | 384 | // calculate slopes for the major edge |
385 | scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; | 385 | scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; |
386 | scan.x[0] = a->Pos.x; | 386 | scan.x[0] = a->Pos.x; |
387 | 387 | ||
388 | #ifdef IPOL_Z | 388 | #ifdef IPOL_Z |
389 | scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; | 389 | scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; |
390 | scan.z[0] = a->Pos.z; | 390 | scan.z[0] = a->Pos.z; |
391 | #endif | 391 | #endif |
392 | 392 | ||
393 | #ifdef IPOL_W | 393 | #ifdef IPOL_W |
394 | scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; | 394 | scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; |
395 | scan.w[0] = a->Pos.w; | 395 | scan.w[0] = a->Pos.w; |
396 | #endif | 396 | #endif |
397 | 397 | ||
398 | #ifdef IPOL_C0 | 398 | #ifdef IPOL_C0 |
399 | scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; | 399 | scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; |
400 | scan.c[0][0] = a->Color[0]; | 400 | scan.c[0][0] = a->Color[0]; |
401 | #endif | 401 | #endif |
402 | 402 | ||
403 | #ifdef IPOL_T0 | 403 | #ifdef IPOL_T0 |
404 | scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; | 404 | scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; |
405 | scan.t[0][0] = a->Tex[0]; | 405 | scan.t[0][0] = a->Tex[0]; |
406 | #endif | 406 | #endif |
407 | 407 | ||
408 | #ifdef IPOL_T1 | 408 | #ifdef IPOL_T1 |
409 | scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; | 409 | scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; |
410 | scan.t[1][0] = a->Tex[1]; | 410 | scan.t[1][0] = a->Tex[1]; |
411 | #endif | 411 | #endif |
412 | 412 | ||
413 | // top left fill convention y run | 413 | // top left fill convention y run |
414 | s32 yStart; | 414 | s32 yStart; |
415 | s32 yEnd; | 415 | s32 yEnd; |
416 | 416 | ||
417 | #ifdef SUBTEXEL | 417 | #ifdef SUBTEXEL |
418 | f32 subPixel; | 418 | f32 subPixel; |
419 | #endif | 419 | #endif |
420 | 420 | ||
421 | // rasterize upper sub-triangle | 421 | // rasterize upper sub-triangle |
422 | if ( (f32) 0.0 != scan.invDeltaY[1] ) | 422 | if ( (f32) 0.0 != scan.invDeltaY[1] ) |
423 | { | 423 | { |
424 | // calculate slopes for top edge | 424 | // calculate slopes for top edge |
425 | scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; | 425 | scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; |
426 | scan.x[1] = a->Pos.x; | 426 | scan.x[1] = a->Pos.x; |
427 | 427 | ||
428 | #ifdef IPOL_Z | 428 | #ifdef IPOL_Z |
429 | scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; | 429 | scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; |
430 | scan.z[1] = a->Pos.z; | 430 | scan.z[1] = a->Pos.z; |
431 | #endif | 431 | #endif |
432 | 432 | ||
433 | #ifdef IPOL_W | 433 | #ifdef IPOL_W |
434 | scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; | 434 | scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; |
435 | scan.w[1] = a->Pos.w; | 435 | scan.w[1] = a->Pos.w; |
436 | #endif | 436 | #endif |
437 | 437 | ||
438 | #ifdef IPOL_C0 | 438 | #ifdef IPOL_C0 |
439 | scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; | 439 | scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; |
440 | scan.c[0][1] = a->Color[0]; | 440 | scan.c[0][1] = a->Color[0]; |
441 | #endif | 441 | #endif |
442 | 442 | ||
443 | #ifdef IPOL_T0 | 443 | #ifdef IPOL_T0 |
444 | scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; | 444 | scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; |
445 | scan.t[0][1] = a->Tex[0]; | 445 | scan.t[0][1] = a->Tex[0]; |
446 | #endif | 446 | #endif |
447 | 447 | ||
448 | #ifdef IPOL_T1 | 448 | #ifdef IPOL_T1 |
449 | scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; | 449 | scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; |
450 | scan.t[1][1] = a->Tex[1]; | 450 | scan.t[1][1] = a->Tex[1]; |
451 | #endif | 451 | #endif |
452 | 452 | ||
453 | // apply top-left fill convention, top part | 453 | // apply top-left fill convention, top part |
454 | yStart = core::ceil32( a->Pos.y ); | 454 | yStart = core::ceil32( a->Pos.y ); |
455 | yEnd = core::ceil32( b->Pos.y ) - 1; | 455 | yEnd = core::ceil32( b->Pos.y ) - 1; |
456 | 456 | ||
457 | #ifdef SUBTEXEL | 457 | #ifdef SUBTEXEL |
458 | subPixel = ( (f32) yStart ) - a->Pos.y; | 458 | subPixel = ( (f32) yStart ) - a->Pos.y; |
459 | 459 | ||
460 | // correct to pixel center | 460 | // correct to pixel center |
461 | scan.x[0] += scan.slopeX[0] * subPixel; | 461 | scan.x[0] += scan.slopeX[0] * subPixel; |
462 | scan.x[1] += scan.slopeX[1] * subPixel; | 462 | scan.x[1] += scan.slopeX[1] * subPixel; |
463 | 463 | ||
464 | #ifdef IPOL_Z | 464 | #ifdef IPOL_Z |
465 | scan.z[0] += scan.slopeZ[0] * subPixel; | 465 | scan.z[0] += scan.slopeZ[0] * subPixel; |
466 | scan.z[1] += scan.slopeZ[1] * subPixel; | 466 | scan.z[1] += scan.slopeZ[1] * subPixel; |
467 | #endif | 467 | #endif |
468 | 468 | ||
469 | #ifdef IPOL_W | 469 | #ifdef IPOL_W |
470 | scan.w[0] += scan.slopeW[0] * subPixel; | 470 | scan.w[0] += scan.slopeW[0] * subPixel; |
471 | scan.w[1] += scan.slopeW[1] * subPixel; | 471 | scan.w[1] += scan.slopeW[1] * subPixel; |
472 | #endif | 472 | #endif |
473 | 473 | ||
474 | #ifdef IPOL_C0 | 474 | #ifdef IPOL_C0 |
475 | scan.c[0][0] += scan.slopeC[0][0] * subPixel; | 475 | scan.c[0][0] += scan.slopeC[0][0] * subPixel; |
476 | scan.c[0][1] += scan.slopeC[0][1] * subPixel; | 476 | scan.c[0][1] += scan.slopeC[0][1] * subPixel; |
477 | #endif | 477 | #endif |
478 | 478 | ||
479 | #ifdef IPOL_T0 | 479 | #ifdef IPOL_T0 |
480 | scan.t[0][0] += scan.slopeT[0][0] * subPixel; | 480 | scan.t[0][0] += scan.slopeT[0][0] * subPixel; |
481 | scan.t[0][1] += scan.slopeT[0][1] * subPixel; | 481 | scan.t[0][1] += scan.slopeT[0][1] * subPixel; |
482 | #endif | 482 | #endif |
483 | 483 | ||
484 | #ifdef IPOL_T1 | 484 | #ifdef IPOL_T1 |
485 | scan.t[1][0] += scan.slopeT[1][0] * subPixel; | 485 | scan.t[1][0] += scan.slopeT[1][0] * subPixel; |
486 | scan.t[1][1] += scan.slopeT[1][1] * subPixel; | 486 | scan.t[1][1] += scan.slopeT[1][1] * subPixel; |
487 | #endif | 487 | #endif |
488 | 488 | ||
489 | #endif | 489 | #endif |
490 | 490 | ||
491 | // rasterize the edge scanlines | 491 | // rasterize the edge scanlines |
492 | for( line.y = yStart; line.y <= yEnd; ++line.y) | 492 | for( line.y = yStart; line.y <= yEnd; ++line.y) |
493 | { | 493 | { |
494 | line.x[scan.left] = scan.x[0]; | 494 | line.x[scan.left] = scan.x[0]; |
495 | line.x[scan.right] = scan.x[1]; | 495 | line.x[scan.right] = scan.x[1]; |
496 | 496 | ||
497 | #ifdef IPOL_Z | 497 | #ifdef IPOL_Z |
498 | line.z[scan.left] = scan.z[0]; | 498 | line.z[scan.left] = scan.z[0]; |
499 | line.z[scan.right] = scan.z[1]; | 499 | line.z[scan.right] = scan.z[1]; |
500 | #endif | 500 | #endif |
501 | 501 | ||
502 | #ifdef IPOL_W | 502 | #ifdef IPOL_W |
503 | line.w[scan.left] = scan.w[0]; | 503 | line.w[scan.left] = scan.w[0]; |
504 | line.w[scan.right] = scan.w[1]; | 504 | line.w[scan.right] = scan.w[1]; |
505 | #endif | 505 | #endif |
506 | 506 | ||
507 | #ifdef IPOL_C0 | 507 | #ifdef IPOL_C0 |
508 | line.c[0][scan.left] = scan.c[0][0]; | 508 | line.c[0][scan.left] = scan.c[0][0]; |
509 | line.c[0][scan.right] = scan.c[0][1]; | 509 | line.c[0][scan.right] = scan.c[0][1]; |
510 | #endif | 510 | #endif |
511 | 511 | ||
512 | #ifdef IPOL_T0 | 512 | #ifdef IPOL_T0 |
513 | line.t[0][scan.left] = scan.t[0][0]; | 513 | line.t[0][scan.left] = scan.t[0][0]; |
514 | line.t[0][scan.right] = scan.t[0][1]; | 514 | line.t[0][scan.right] = scan.t[0][1]; |
515 | #endif | 515 | #endif |
516 | 516 | ||
517 | #ifdef IPOL_T1 | 517 | #ifdef IPOL_T1 |
518 | line.t[1][scan.left] = scan.t[1][0]; | 518 | line.t[1][scan.left] = scan.t[1][0]; |
519 | line.t[1][scan.right] = scan.t[1][1]; | 519 | line.t[1][scan.right] = scan.t[1][1]; |
520 | #endif | 520 | #endif |
521 | 521 | ||
522 | // render a scanline | 522 | // render a scanline |
523 | scanline_bilinear ( ); | 523 | scanline_bilinear ( ); |
524 | 524 | ||
525 | scan.x[0] += scan.slopeX[0]; | 525 | scan.x[0] += scan.slopeX[0]; |
526 | scan.x[1] += scan.slopeX[1]; | 526 | scan.x[1] += scan.slopeX[1]; |
527 | 527 | ||
528 | #ifdef IPOL_Z | 528 | #ifdef IPOL_Z |
529 | scan.z[0] += scan.slopeZ[0]; | 529 | scan.z[0] += scan.slopeZ[0]; |
530 | scan.z[1] += scan.slopeZ[1]; | 530 | scan.z[1] += scan.slopeZ[1]; |
531 | #endif | 531 | #endif |
532 | 532 | ||
533 | #ifdef IPOL_W | 533 | #ifdef IPOL_W |
534 | scan.w[0] += scan.slopeW[0]; | 534 | scan.w[0] += scan.slopeW[0]; |
535 | scan.w[1] += scan.slopeW[1]; | 535 | scan.w[1] += scan.slopeW[1]; |
536 | #endif | 536 | #endif |
537 | 537 | ||
538 | #ifdef IPOL_C0 | 538 | #ifdef IPOL_C0 |
539 | scan.c[0][0] += scan.slopeC[0][0]; | 539 | scan.c[0][0] += scan.slopeC[0][0]; |
540 | scan.c[0][1] += scan.slopeC[0][1]; | 540 | scan.c[0][1] += scan.slopeC[0][1]; |
541 | #endif | 541 | #endif |
542 | 542 | ||
543 | #ifdef IPOL_T0 | 543 | #ifdef IPOL_T0 |
544 | scan.t[0][0] += scan.slopeT[0][0]; | 544 | scan.t[0][0] += scan.slopeT[0][0]; |
545 | scan.t[0][1] += scan.slopeT[0][1]; | 545 | scan.t[0][1] += scan.slopeT[0][1]; |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | #ifdef IPOL_T1 | 548 | #ifdef IPOL_T1 |
549 | scan.t[1][0] += scan.slopeT[1][0]; | 549 | scan.t[1][0] += scan.slopeT[1][0]; |
550 | scan.t[1][1] += scan.slopeT[1][1]; | 550 | scan.t[1][1] += scan.slopeT[1][1]; |
551 | #endif | 551 | #endif |
552 | 552 | ||
553 | } | 553 | } |
554 | } | 554 | } |
555 | 555 | ||
556 | // rasterize lower sub-triangle | 556 | // rasterize lower sub-triangle |
557 | if ( (f32) 0.0 != scan.invDeltaY[2] ) | 557 | if ( (f32) 0.0 != scan.invDeltaY[2] ) |
558 | { | 558 | { |
559 | // advance to middle point | 559 | // advance to middle point |
560 | if( (f32) 0.0 != scan.invDeltaY[1] ) | 560 | if( (f32) 0.0 != scan.invDeltaY[1] ) |
561 | { | 561 | { |
562 | temp[0] = b->Pos.y - a->Pos.y; // dy | 562 | temp[0] = b->Pos.y - a->Pos.y; // dy |
563 | 563 | ||
564 | scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; | 564 | scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; |
565 | #ifdef IPOL_Z | 565 | #ifdef IPOL_Z |
566 | scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; | 566 | scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; |
567 | #endif | 567 | #endif |
568 | #ifdef IPOL_W | 568 | #ifdef IPOL_W |
569 | scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; | 569 | scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; |
570 | #endif | 570 | #endif |
571 | #ifdef IPOL_C0 | 571 | #ifdef IPOL_C0 |
572 | scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; | 572 | scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; |
573 | #endif | 573 | #endif |
574 | #ifdef IPOL_T0 | 574 | #ifdef IPOL_T0 |
575 | scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; | 575 | scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; |
576 | #endif | 576 | #endif |
577 | #ifdef IPOL_T1 | 577 | #ifdef IPOL_T1 |
578 | scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; | 578 | scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; |
579 | #endif | 579 | #endif |
580 | 580 | ||
581 | } | 581 | } |
582 | 582 | ||
583 | // calculate slopes for bottom edge | 583 | // calculate slopes for bottom edge |
584 | scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; | 584 | scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; |
585 | scan.x[1] = b->Pos.x; | 585 | scan.x[1] = b->Pos.x; |
586 | 586 | ||
587 | #ifdef IPOL_Z | 587 | #ifdef IPOL_Z |
588 | scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; | 588 | scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; |
589 | scan.z[1] = b->Pos.z; | 589 | scan.z[1] = b->Pos.z; |
590 | #endif | 590 | #endif |
591 | 591 | ||
592 | #ifdef IPOL_W | 592 | #ifdef IPOL_W |
593 | scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; | 593 | scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; |
594 | scan.w[1] = b->Pos.w; | 594 | scan.w[1] = b->Pos.w; |
595 | #endif | 595 | #endif |
596 | 596 | ||
597 | #ifdef IPOL_C0 | 597 | #ifdef IPOL_C0 |
598 | scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; | 598 | scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; |
599 | scan.c[0][1] = b->Color[0]; | 599 | scan.c[0][1] = b->Color[0]; |
600 | #endif | 600 | #endif |
601 | 601 | ||
602 | #ifdef IPOL_T0 | 602 | #ifdef IPOL_T0 |
603 | scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; | 603 | scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; |
604 | scan.t[0][1] = b->Tex[0]; | 604 | scan.t[0][1] = b->Tex[0]; |
605 | #endif | 605 | #endif |
606 | 606 | ||
607 | #ifdef IPOL_T1 | 607 | #ifdef IPOL_T1 |
608 | scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; | 608 | scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; |
609 | scan.t[1][1] = b->Tex[1]; | 609 | scan.t[1][1] = b->Tex[1]; |
610 | #endif | 610 | #endif |
611 | 611 | ||
612 | // apply top-left fill convention, top part | 612 | // apply top-left fill convention, top part |
613 | yStart = core::ceil32( b->Pos.y ); | 613 | yStart = core::ceil32( b->Pos.y ); |
614 | yEnd = core::ceil32( c->Pos.y ) - 1; | 614 | yEnd = core::ceil32( c->Pos.y ) - 1; |
615 | 615 | ||
616 | #ifdef SUBTEXEL | 616 | #ifdef SUBTEXEL |
617 | 617 | ||
618 | subPixel = ( (f32) yStart ) - b->Pos.y; | 618 | subPixel = ( (f32) yStart ) - b->Pos.y; |
619 | 619 | ||
620 | // correct to pixel center | 620 | // correct to pixel center |
621 | scan.x[0] += scan.slopeX[0] * subPixel; | 621 | scan.x[0] += scan.slopeX[0] * subPixel; |
622 | scan.x[1] += scan.slopeX[1] * subPixel; | 622 | scan.x[1] += scan.slopeX[1] * subPixel; |
623 | 623 | ||
624 | #ifdef IPOL_Z | 624 | #ifdef IPOL_Z |
625 | scan.z[0] += scan.slopeZ[0] * subPixel; | 625 | scan.z[0] += scan.slopeZ[0] * subPixel; |
626 | scan.z[1] += scan.slopeZ[1] * subPixel; | 626 | scan.z[1] += scan.slopeZ[1] * subPixel; |
627 | #endif | 627 | #endif |
628 | 628 | ||
629 | #ifdef IPOL_W | 629 | #ifdef IPOL_W |
630 | scan.w[0] += scan.slopeW[0] * subPixel; | 630 | scan.w[0] += scan.slopeW[0] * subPixel; |
631 | scan.w[1] += scan.slopeW[1] * subPixel; | 631 | scan.w[1] += scan.slopeW[1] * subPixel; |
632 | #endif | 632 | #endif |
633 | 633 | ||
634 | #ifdef IPOL_C0 | 634 | #ifdef IPOL_C0 |
635 | scan.c[0][0] += scan.slopeC[0][0] * subPixel; | 635 | scan.c[0][0] += scan.slopeC[0][0] * subPixel; |
636 | scan.c[0][1] += scan.slopeC[0][1] * subPixel; | 636 | scan.c[0][1] += scan.slopeC[0][1] * subPixel; |
637 | #endif | 637 | #endif |
638 | 638 | ||
639 | #ifdef IPOL_T0 | 639 | #ifdef IPOL_T0 |
640 | scan.t[0][0] += scan.slopeT[0][0] * subPixel; | 640 | scan.t[0][0] += scan.slopeT[0][0] * subPixel; |
641 | scan.t[0][1] += scan.slopeT[0][1] * subPixel; | 641 | scan.t[0][1] += scan.slopeT[0][1] * subPixel; |
642 | #endif | 642 | #endif |
643 | 643 | ||
644 | #ifdef IPOL_T1 | 644 | #ifdef IPOL_T1 |
645 | scan.t[1][0] += scan.slopeT[1][0] * subPixel; | 645 | scan.t[1][0] += scan.slopeT[1][0] * subPixel; |
646 | scan.t[1][1] += scan.slopeT[1][1] * subPixel; | 646 | scan.t[1][1] += scan.slopeT[1][1] * subPixel; |
647 | #endif | 647 | #endif |
648 | 648 | ||
649 | #endif | 649 | #endif |
650 | 650 | ||
651 | // rasterize the edge scanlines | 651 | // rasterize the edge scanlines |
652 | for( line.y = yStart; line.y <= yEnd; ++line.y) | 652 | for( line.y = yStart; line.y <= yEnd; ++line.y) |
653 | { | 653 | { |
654 | line.x[scan.left] = scan.x[0]; | 654 | line.x[scan.left] = scan.x[0]; |
655 | line.x[scan.right] = scan.x[1]; | 655 | line.x[scan.right] = scan.x[1]; |
656 | 656 | ||
657 | #ifdef IPOL_Z | 657 | #ifdef IPOL_Z |
658 | line.z[scan.left] = scan.z[0]; | 658 | line.z[scan.left] = scan.z[0]; |
659 | line.z[scan.right] = scan.z[1]; | 659 | line.z[scan.right] = scan.z[1]; |
660 | #endif | 660 | #endif |
661 | 661 | ||
662 | #ifdef IPOL_W | 662 | #ifdef IPOL_W |
663 | line.w[scan.left] = scan.w[0]; | 663 | line.w[scan.left] = scan.w[0]; |
664 | line.w[scan.right] = scan.w[1]; | 664 | line.w[scan.right] = scan.w[1]; |
665 | #endif | 665 | #endif |
666 | 666 | ||
667 | #ifdef IPOL_C0 | 667 | #ifdef IPOL_C0 |
668 | line.c[0][scan.left] = scan.c[0][0]; | 668 | line.c[0][scan.left] = scan.c[0][0]; |
669 | line.c[0][scan.right] = scan.c[0][1]; | 669 | line.c[0][scan.right] = scan.c[0][1]; |
670 | #endif | 670 | #endif |
671 | 671 | ||
672 | #ifdef IPOL_T0 | 672 | #ifdef IPOL_T0 |
673 | line.t[0][scan.left] = scan.t[0][0]; | 673 | line.t[0][scan.left] = scan.t[0][0]; |
674 | line.t[0][scan.right] = scan.t[0][1]; | 674 | line.t[0][scan.right] = scan.t[0][1]; |
675 | #endif | 675 | #endif |
676 | 676 | ||
677 | #ifdef IPOL_T1 | 677 | #ifdef IPOL_T1 |
678 | line.t[1][scan.left] = scan.t[1][0]; | 678 | line.t[1][scan.left] = scan.t[1][0]; |
679 | line.t[1][scan.right] = scan.t[1][1]; | 679 | line.t[1][scan.right] = scan.t[1][1]; |
680 | #endif | 680 | #endif |
681 | 681 | ||
682 | // render a scanline | 682 | // render a scanline |
683 | scanline_bilinear ( ); | 683 | scanline_bilinear ( ); |
684 | 684 | ||
685 | scan.x[0] += scan.slopeX[0]; | 685 | scan.x[0] += scan.slopeX[0]; |
686 | scan.x[1] += scan.slopeX[1]; | 686 | scan.x[1] += scan.slopeX[1]; |
687 | 687 | ||
688 | #ifdef IPOL_Z | 688 | #ifdef IPOL_Z |
689 | scan.z[0] += scan.slopeZ[0]; | 689 | scan.z[0] += scan.slopeZ[0]; |
690 | scan.z[1] += scan.slopeZ[1]; | 690 | scan.z[1] += scan.slopeZ[1]; |
691 | #endif | 691 | #endif |
692 | 692 | ||
693 | #ifdef IPOL_W | 693 | #ifdef IPOL_W |
694 | scan.w[0] += scan.slopeW[0]; | 694 | scan.w[0] += scan.slopeW[0]; |
695 | scan.w[1] += scan.slopeW[1]; | 695 | scan.w[1] += scan.slopeW[1]; |
696 | #endif | 696 | #endif |
697 | 697 | ||
698 | #ifdef IPOL_C0 | 698 | #ifdef IPOL_C0 |
699 | scan.c[0][0] += scan.slopeC[0][0]; | 699 | scan.c[0][0] += scan.slopeC[0][0]; |
700 | scan.c[0][1] += scan.slopeC[0][1]; | 700 | scan.c[0][1] += scan.slopeC[0][1]; |
701 | #endif | 701 | #endif |
702 | 702 | ||
703 | #ifdef IPOL_T0 | 703 | #ifdef IPOL_T0 |
704 | scan.t[0][0] += scan.slopeT[0][0]; | 704 | scan.t[0][0] += scan.slopeT[0][0]; |
705 | scan.t[0][1] += scan.slopeT[0][1]; | 705 | scan.t[0][1] += scan.slopeT[0][1]; |
706 | #endif | 706 | #endif |
707 | 707 | ||
708 | #ifdef IPOL_T1 | 708 | #ifdef IPOL_T1 |
709 | scan.t[1][0] += scan.slopeT[1][0]; | 709 | scan.t[1][0] += scan.slopeT[1][0]; |
710 | scan.t[1][1] += scan.slopeT[1][1]; | 710 | scan.t[1][1] += scan.slopeT[1][1]; |
711 | #endif | 711 | #endif |
712 | 712 | ||
713 | } | 713 | } |
714 | } | 714 | } |
715 | 715 | ||
716 | } | 716 | } |
717 | 717 | ||
718 | 718 | ||
719 | } // end namespace video | 719 | } // end namespace video |
720 | } // end namespace irr | 720 | } // end namespace irr |
721 | 721 | ||
722 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 722 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ |
723 | 723 | ||
724 | namespace irr | 724 | namespace irr |
725 | { | 725 | { |
726 | namespace video | 726 | namespace video |
727 | { | 727 | { |
728 | 728 | ||
729 | 729 | ||
730 | //! creates a flat triangle renderer | 730 | //! creates a flat triangle renderer |
731 | IBurningShader* createTRTextureGouraudAlpha(CBurningVideoDriver* driver) | 731 | IBurningShader* createTRTextureGouraudAlpha(CBurningVideoDriver* driver) |
732 | { | 732 | { |
733 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 733 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ |
734 | return new CTRTextureGouraudAlpha2(driver); | 734 | return new CTRTextureGouraudAlpha2(driver); |
735 | #else | 735 | #else |
736 | return 0; | 736 | return 0; |
737 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 737 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ |
738 | } | 738 | } |
739 | 739 | ||
740 | 740 | ||
741 | } // end namespace video | 741 | } // end namespace video |
742 | } // end namespace irr | 742 | } // end namespace irr |
743 | 743 | ||
744 | 744 | ||