aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_M1.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_M1.cpp
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_M1.cpp1288
1 files changed, 644 insertions, 644 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_M1.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_M1.cpp
index 59a13b1..c7624bb 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_M1.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureLightMap2_M1.cpp
@@ -1,644 +1,644 @@
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
71namespace irr 71namespace irr
72{ 72{
73 73
74namespace video 74namespace video
75{ 75{
76 76
77class CTRTextureLightMap2_M1 : public IBurningShader 77class CTRTextureLightMap2_M1 : public IBurningShader
78{ 78{
79public: 79public:
80 80
81 //! constructor 81 //! constructor
82 CTRTextureLightMap2_M1(CBurningVideoDriver* driver); 82 CTRTextureLightMap2_M1(CBurningVideoDriver* driver);
83 83
84 //! draws an indexed triangle list 84 //! draws an indexed triangle list
85 virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); 85 virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c );
86 86
87 87
88private: 88private:
89 void scanline_bilinear2 (); 89 void scanline_bilinear2 ();
90 90
91 sScanLineData line; 91 sScanLineData line;
92 92
93}; 93};
94 94
95//! constructor 95//! constructor
96CTRTextureLightMap2_M1::CTRTextureLightMap2_M1(CBurningVideoDriver* driver) 96CTRTextureLightMap2_M1::CTRTextureLightMap2_M1(CBurningVideoDriver* driver)
97: IBurningShader(driver) 97: IBurningShader(driver)
98{ 98{
99 #ifdef _DEBUG 99 #ifdef _DEBUG
100 setDebugName("CTRTextureLightMap2_M1"); 100 setDebugName("CTRTextureLightMap2_M1");
101 #endif 101 #endif
102} 102}
103 103
104/*! 104/*!
105*/ 105*/
106REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 () 106REALINLINE void CTRTextureLightMap2_M1::scanline_bilinear2 ()
107{ 107{
108 tVideoSample *dst; 108 tVideoSample *dst;
109 fp24 *z; 109 fp24 *z;
110 110
111 s32 xStart; 111 s32 xStart;
112 s32 xEnd; 112 s32 xEnd;
113 s32 dx; 113 s32 dx;
114 s32 i; 114 s32 i;
115 115
116 116
117 // apply top-left fill-convention, left 117 // apply top-left fill-convention, left
118 xStart = core::ceil32( line.x[0] ); 118 xStart = core::ceil32( line.x[0] );
119 xEnd = core::ceil32( line.x[1] ) - 1; 119 xEnd = core::ceil32( line.x[1] ) - 1;
120 120
121 dx = xEnd - xStart; 121 dx = xEnd - xStart;
122 if ( dx < 0 ) 122 if ( dx < 0 )
123 return; 123 return;
124 124
125 // slopes 125 // slopes
126 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 126 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
127 127
128 // search z-buffer for first not occulled pixel 128 // search z-buffer for first not occulled pixel
129 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 129 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
130 130
131 // subTexel 131 // subTexel
132 const f32 subPixel = ( (f32) xStart ) - line.x[0]; 132 const f32 subPixel = ( (f32) xStart ) - line.x[0];
133 133
134#ifdef IPOL_W 134#ifdef IPOL_W
135 const f32 b = (line.w[1] - line.w[0]) * invDeltaX; 135 const f32 b = (line.w[1] - line.w[0]) * invDeltaX;
136 f32 a = line.w[0] + ( b * subPixel ); 136 f32 a = line.w[0] + ( b * subPixel );
137 137
138 i = 0; 138 i = 0;
139 139
140 while ( a <= z[i] ) 140 while ( a <= z[i] )
141 { 141 {
142 a += b; 142 a += b;
143 143
144 i += 1; 144 i += 1;
145 if ( i > dx ) 145 if ( i > dx )
146 return; 146 return;
147 147
148 } 148 }
149 149
150 // lazy setup rest of scanline 150 // lazy setup rest of scanline
151 151
152 line.w[0] = a; 152 line.w[0] = a;
153 line.w[1] = b; 153 line.w[1] = b;
154#else 154#else
155 const f32 b = (line.z[1] - line.z[0]) * invDeltaX; 155 const f32 b = (line.z[1] - line.z[0]) * invDeltaX;
156 f32 a = line.z[0] + ( b * subPixel ); 156 f32 a = line.z[0] + ( b * subPixel );
157 157
158 i = 0; 158 i = 0;
159 159
160 while ( a > z[i] ) 160 while ( a > z[i] )
161 { 161 {
162 a += b; 162 a += b;
163 163
164 i += 1; 164 i += 1;
165 if ( i > dx ) 165 if ( i > dx )
166 return; 166 return;
167 167
168 } 168 }
169 169
170 // lazy setup rest of scanline 170 // lazy setup rest of scanline
171 171
172 line.z[0] = a; 172 line.z[0] = a;
173 line.z[1] = b; 173 line.z[1] = b;
174#endif 174#endif
175 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 175 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
176 176
177 a = (f32) i + subPixel; 177 a = (f32) i + subPixel;
178 178
179 line.t[0][1] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 179 line.t[0][1] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
180 line.t[1][1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 180 line.t[1][1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
181 181
182 line.t[0][0] += line.t[0][1] * a; 182 line.t[0][0] += line.t[0][1] * a;
183 line.t[1][0] += line.t[1][1] * a; 183 line.t[1][0] += line.t[1][1] * a;
184 184
185 185
186#ifdef BURNINGVIDEO_RENDERER_FAST 186#ifdef BURNINGVIDEO_RENDERER_FAST
187 u32 dIndex = ( line.y & 3 ) << 2; 187 u32 dIndex = ( line.y & 3 ) << 2;
188 188
189 tFixPoint r0, g0, b0; 189 tFixPoint r0, g0, b0;
190 tFixPoint r1, g1, b1; 190 tFixPoint r1, g1, b1;
191 191
192#else 192#else
193 // 193 //
194 tFixPoint r0, g0, b0; 194 tFixPoint r0, g0, b0;
195 tFixPoint r1, g1, b1; 195 tFixPoint r1, g1, b1;
196#endif 196#endif
197 197
198 198
199 for ( ;i <= dx; i++ ) 199 for ( ;i <= dx; i++ )
200 { 200 {
201#ifdef IPOL_W 201#ifdef IPOL_W
202 if ( line.w[0] >= z[i] ) 202 if ( line.w[0] >= z[i] )
203 { 203 {
204 z[i] = line.w[0]; 204 z[i] = line.w[0];
205#else 205#else
206 if ( line.z[0] < z[i] ) 206 if ( line.z[0] < z[i] )
207 { 207 {
208 z[i] = line.z[0]; 208 z[i] = line.z[0];
209#endif 209#endif
210 210
211#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT 211#ifdef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
212 f32 inversew = fix_inverse32 ( line.w[0] ); 212 f32 inversew = fix_inverse32 ( line.w[0] );
213#else 213#else
214 f32 inversew = FIX_POINT_F32_MUL; 214 f32 inversew = FIX_POINT_F32_MUL;
215#endif 215#endif
216 216
217 217
218 218
219#ifdef BURNINGVIDEO_RENDERER_FAST 219#ifdef BURNINGVIDEO_RENDERER_FAST
220 220
221 const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ]; 221 const tFixPointu d = dithermask [ dIndex | ( i ) & 3 ];
222 222
223 getSample_texture ( r0, g0, b0, &IT[0], d + tofix ( line.t[0][0].x,inversew), d + tofix ( line.t[0][0].y,inversew) ); 223 getSample_texture ( r0, g0, b0, &IT[0], d + tofix ( line.t[0][0].x,inversew), d + tofix ( line.t[0][0].y,inversew) );
224 getSample_texture ( r1, g1, b1, &IT[1], d + tofix ( line.t[1][0].x,inversew), d + tofix ( line.t[1][0].y,inversew) ); 224 getSample_texture ( r1, g1, b1, &IT[1], d + tofix ( line.t[1][0].x,inversew), d + tofix ( line.t[1][0].y,inversew) );
225#else 225#else
226 getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) ); 226 getSample_texture ( r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,inversew), tofix ( line.t[0][0].y,inversew) );
227 getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) ); 227 getSample_texture ( r1, g1, b1, &IT[1], tofix ( line.t[1][0].x,inversew), tofix ( line.t[1][0].y,inversew) );
228 228
229#endif 229#endif
230 230
231 dst[i] = fix_to_color ( imulFix_tex1 ( r0, r1 ), 231 dst[i] = fix_to_color ( imulFix_tex1 ( r0, r1 ),
232 imulFix_tex1 ( g0, g1 ), 232 imulFix_tex1 ( g0, g1 ),
233 imulFix_tex1 ( b0, b1 ) 233 imulFix_tex1 ( b0, b1 )
234 ); 234 );
235 } 235 }
236 236
237#ifdef IPOL_W 237#ifdef IPOL_W
238 line.w[0] += line.w[1]; 238 line.w[0] += line.w[1];
239#else 239#else
240 line.z[0] += line.z[1]; 240 line.z[0] += line.z[1];
241#endif 241#endif
242 line.t[0][0] += line.t[0][1]; 242 line.t[0][0] += line.t[0][1];
243 line.t[1][0] += line.t[1][1]; 243 line.t[1][0] += line.t[1][1];
244 } 244 }
245 245
246} 246}
247 247
248 248
249 249
250void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) 250void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
251{ 251{
252 sScanConvertData scan; 252 sScanConvertData scan;
253 253
254 // sort on height, y 254 // sort on height, y
255 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 255 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
256 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); 256 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
257 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 257 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
258 258
259 const f32 ca = c->Pos.y - a->Pos.y; 259 const f32 ca = c->Pos.y - a->Pos.y;
260 const f32 ba = b->Pos.y - a->Pos.y; 260 const f32 ba = b->Pos.y - a->Pos.y;
261 const f32 cb = c->Pos.y - b->Pos.y; 261 const f32 cb = c->Pos.y - b->Pos.y;
262 // calculate delta y of the edges 262 // calculate delta y of the edges
263 scan.invDeltaY[0] = core::reciprocal( ca ); 263 scan.invDeltaY[0] = core::reciprocal( ca );
264 scan.invDeltaY[1] = core::reciprocal( ba ); 264 scan.invDeltaY[1] = core::reciprocal( ba );
265 scan.invDeltaY[2] = core::reciprocal( cb ); 265 scan.invDeltaY[2] = core::reciprocal( cb );
266 266
267 if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) 267 if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
268 return; 268 return;
269 269
270 // find if the major edge is left or right aligned 270 // find if the major edge is left or right aligned
271 f32 temp[4]; 271 f32 temp[4];
272 272
273 temp[0] = a->Pos.x - c->Pos.x; 273 temp[0] = a->Pos.x - c->Pos.x;
274 temp[1] = -ca; 274 temp[1] = -ca;
275 temp[2] = b->Pos.x - a->Pos.x; 275 temp[2] = b->Pos.x - a->Pos.x;
276 temp[3] = ba; 276 temp[3] = ba;
277 277
278 scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; 278 scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
279 scan.right = 1 - scan.left; 279 scan.right = 1 - scan.left;
280 280
281 // calculate slopes for the major edge 281 // calculate slopes for the major edge
282 scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; 282 scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0];
283 scan.x[0] = a->Pos.x; 283 scan.x[0] = a->Pos.x;
284 284
285#ifdef IPOL_Z 285#ifdef IPOL_Z
286 scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; 286 scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0];
287 scan.z[0] = a->Pos.z; 287 scan.z[0] = a->Pos.z;
288#endif 288#endif
289 289
290#ifdef IPOL_W 290#ifdef IPOL_W
291 scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; 291 scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0];
292 scan.w[0] = a->Pos.w; 292 scan.w[0] = a->Pos.w;
293#endif 293#endif
294 294
295#ifdef IPOL_C0 295#ifdef IPOL_C0
296 scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; 296 scan.slopeC[0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0];
297 scan.c[0] = a->Color[0]; 297 scan.c[0] = a->Color[0];
298#endif 298#endif
299 299
300#ifdef IPOL_T0 300#ifdef IPOL_T0
301 scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; 301 scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0];
302 scan.t[0][0] = a->Tex[0]; 302 scan.t[0][0] = a->Tex[0];
303#endif 303#endif
304 304
305#ifdef IPOL_T1 305#ifdef IPOL_T1
306 scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; 306 scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0];
307 scan.t[1][0] = a->Tex[1]; 307 scan.t[1][0] = a->Tex[1];
308#endif 308#endif
309 309
310 // top left fill convention y run 310 // top left fill convention y run
311 s32 yStart; 311 s32 yStart;
312 s32 yEnd; 312 s32 yEnd;
313 313
314#ifdef SUBTEXEL 314#ifdef SUBTEXEL
315 f32 subPixel; 315 f32 subPixel;
316#endif 316#endif
317 317
318 // rasterize upper sub-triangle 318 // rasterize upper sub-triangle
319 if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) 319 if ( F32_GREATER_0 ( scan.invDeltaY[1] ) )
320 { 320 {
321 // calculate slopes for top edge 321 // calculate slopes for top edge
322 scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; 322 scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1];
323 scan.x[1] = a->Pos.x; 323 scan.x[1] = a->Pos.x;
324 324
325#ifdef IPOL_Z 325#ifdef IPOL_Z
326 scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; 326 scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1];
327 scan.z[1] = a->Pos.z; 327 scan.z[1] = a->Pos.z;
328#endif 328#endif
329 329
330#ifdef IPOL_W 330#ifdef IPOL_W
331 scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; 331 scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1];
332 scan.w[1] = a->Pos.w; 332 scan.w[1] = a->Pos.w;
333#endif 333#endif
334 334
335#ifdef IPOL_C0 335#ifdef IPOL_C0
336 scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; 336 scan.slopeC[1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1];
337 scan.c[1] = a->Color[0]; 337 scan.c[1] = a->Color[0];
338#endif 338#endif
339 339
340#ifdef IPOL_T0 340#ifdef IPOL_T0
341 scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; 341 scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1];
342 scan.t[0][1] = a->Tex[0]; 342 scan.t[0][1] = a->Tex[0];
343#endif 343#endif
344 344
345#ifdef IPOL_T1 345#ifdef IPOL_T1
346 scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; 346 scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1];
347 scan.t[1][1] = a->Tex[1]; 347 scan.t[1][1] = a->Tex[1];
348#endif 348#endif
349 349
350 // apply top-left fill convention, top part 350 // apply top-left fill convention, top part
351 yStart = core::ceil32( a->Pos.y ); 351 yStart = core::ceil32( a->Pos.y );
352 yEnd = core::ceil32( b->Pos.y ) - 1; 352 yEnd = core::ceil32( b->Pos.y ) - 1;
353 353
354#ifdef SUBTEXEL 354#ifdef SUBTEXEL
355 subPixel = ( (f32) yStart ) - a->Pos.y; 355 subPixel = ( (f32) yStart ) - a->Pos.y;
356 356
357 // correct to pixel center 357 // correct to pixel center
358 scan.x[0] += scan.slopeX[0] * subPixel; 358 scan.x[0] += scan.slopeX[0] * subPixel;
359 scan.x[1] += scan.slopeX[1] * subPixel; 359 scan.x[1] += scan.slopeX[1] * subPixel;
360 360
361#ifdef IPOL_Z 361#ifdef IPOL_Z
362 scan.z[0] += scan.slopeZ[0] * subPixel; 362 scan.z[0] += scan.slopeZ[0] * subPixel;
363 scan.z[1] += scan.slopeZ[1] * subPixel; 363 scan.z[1] += scan.slopeZ[1] * subPixel;
364#endif 364#endif
365 365
366#ifdef IPOL_W 366#ifdef IPOL_W
367 scan.w[0] += scan.slopeW[0] * subPixel; 367 scan.w[0] += scan.slopeW[0] * subPixel;
368 scan.w[1] += scan.slopeW[1] * subPixel; 368 scan.w[1] += scan.slopeW[1] * subPixel;
369#endif 369#endif
370 370
371#ifdef IPOL_C0 371#ifdef IPOL_C0
372 scan.c[0] += scan.slopeC[0] * subPixel; 372 scan.c[0] += scan.slopeC[0] * subPixel;
373 scan.c[1] += scan.slopeC[1] * subPixel; 373 scan.c[1] += scan.slopeC[1] * subPixel;
374#endif 374#endif
375 375
376#ifdef IPOL_T0 376#ifdef IPOL_T0
377 scan.t[0][0] += scan.slopeT[0][0] * subPixel; 377 scan.t[0][0] += scan.slopeT[0][0] * subPixel;
378 scan.t[0][1] += scan.slopeT[0][1] * subPixel; 378 scan.t[0][1] += scan.slopeT[0][1] * subPixel;
379#endif 379#endif
380 380
381#ifdef IPOL_T1 381#ifdef IPOL_T1
382 scan.t[1][0] += scan.slopeT[1][0] * subPixel; 382 scan.t[1][0] += scan.slopeT[1][0] * subPixel;
383 scan.t[1][1] += scan.slopeT[1][1] * subPixel; 383 scan.t[1][1] += scan.slopeT[1][1] * subPixel;
384#endif 384#endif
385 385
386#endif 386#endif
387 387
388 // rasterize the edge scanlines 388 // rasterize the edge scanlines
389 for( line.y = yStart; line.y <= yEnd; ++line.y) 389 for( line.y = yStart; line.y <= yEnd; ++line.y)
390 { 390 {
391 line.x[scan.left] = scan.x[0]; 391 line.x[scan.left] = scan.x[0];
392 line.x[scan.right] = scan.x[1]; 392 line.x[scan.right] = scan.x[1];
393 393
394#ifdef IPOL_Z 394#ifdef IPOL_Z
395 line.z[scan.left] = scan.z[0]; 395 line.z[scan.left] = scan.z[0];
396 line.z[scan.right] = scan.z[1]; 396 line.z[scan.right] = scan.z[1];
397#endif 397#endif
398 398
399#ifdef IPOL_W 399#ifdef IPOL_W
400 line.w[scan.left] = scan.w[0]; 400 line.w[scan.left] = scan.w[0];
401 line.w[scan.right] = scan.w[1]; 401 line.w[scan.right] = scan.w[1];
402#endif 402#endif
403 403
404#ifdef IPOL_C0 404#ifdef IPOL_C0
405 line.c[scan.left] = scan.c[0]; 405 line.c[scan.left] = scan.c[0];
406 line.c[scan.right] = scan.c[1]; 406 line.c[scan.right] = scan.c[1];
407#endif 407#endif
408 408
409#ifdef IPOL_T0 409#ifdef IPOL_T0
410 line.t[0][scan.left] = scan.t[0][0]; 410 line.t[0][scan.left] = scan.t[0][0];
411 line.t[0][scan.right] = scan.t[0][1]; 411 line.t[0][scan.right] = scan.t[0][1];
412#endif 412#endif
413 413
414#ifdef IPOL_T1 414#ifdef IPOL_T1
415 line.t[1][scan.left] = scan.t[1][0]; 415 line.t[1][scan.left] = scan.t[1][0];
416 line.t[1][scan.right] = scan.t[1][1]; 416 line.t[1][scan.right] = scan.t[1][1];
417#endif 417#endif
418 418
419 // render a scanline 419 // render a scanline
420 scanline_bilinear2 (); 420 scanline_bilinear2 ();
421 421
422 scan.x[0] += scan.slopeX[0]; 422 scan.x[0] += scan.slopeX[0];
423 scan.x[1] += scan.slopeX[1]; 423 scan.x[1] += scan.slopeX[1];
424 424
425#ifdef IPOL_Z 425#ifdef IPOL_Z
426 scan.z[0] += scan.slopeZ[0]; 426 scan.z[0] += scan.slopeZ[0];
427 scan.z[1] += scan.slopeZ[1]; 427 scan.z[1] += scan.slopeZ[1];
428#endif 428#endif
429 429
430#ifdef IPOL_W 430#ifdef IPOL_W
431 scan.w[0] += scan.slopeW[0]; 431 scan.w[0] += scan.slopeW[0];
432 scan.w[1] += scan.slopeW[1]; 432 scan.w[1] += scan.slopeW[1];
433#endif 433#endif
434 434
435#ifdef IPOL_C0 435#ifdef IPOL_C0
436 scan.c[0] += scan.slopeC[0]; 436 scan.c[0] += scan.slopeC[0];
437 scan.c[1] += scan.slopeC[1]; 437 scan.c[1] += scan.slopeC[1];
438#endif 438#endif
439 439
440#ifdef IPOL_T0 440#ifdef IPOL_T0
441 scan.t[0][0] += scan.slopeT[0][0]; 441 scan.t[0][0] += scan.slopeT[0][0];
442 scan.t[0][1] += scan.slopeT[0][1]; 442 scan.t[0][1] += scan.slopeT[0][1];
443#endif 443#endif
444 444
445#ifdef IPOL_T1 445#ifdef IPOL_T1
446 scan.t[1][0] += scan.slopeT[1][0]; 446 scan.t[1][0] += scan.slopeT[1][0];
447 scan.t[1][1] += scan.slopeT[1][1]; 447 scan.t[1][1] += scan.slopeT[1][1];
448#endif 448#endif
449 449
450 } 450 }
451 } 451 }
452 452
453 // rasterize lower sub-triangle 453 // rasterize lower sub-triangle
454 //if ( (f32) 0.0 != scan.invDeltaY[2] ) 454 //if ( (f32) 0.0 != scan.invDeltaY[2] )
455 if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) 455 if ( F32_GREATER_0 ( scan.invDeltaY[2] ) )
456 { 456 {
457 // advance to middle point 457 // advance to middle point
458 if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) 458 if ( F32_GREATER_0 ( scan.invDeltaY[1] ) )
459 { 459 {
460 temp[0] = b->Pos.y - a->Pos.y; // dy 460 temp[0] = b->Pos.y - a->Pos.y; // dy
461 461
462 scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; 462 scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0];
463#ifdef IPOL_Z 463#ifdef IPOL_Z
464 scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; 464 scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0];
465#endif 465#endif
466#ifdef IPOL_W 466#ifdef IPOL_W
467 scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; 467 scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0];
468#endif 468#endif
469#ifdef IPOL_C0 469#ifdef IPOL_C0
470 scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0]; 470 scan.c[0] = a->Color[0] + scan.slopeC[0] * temp[0];
471#endif 471#endif
472#ifdef IPOL_T0 472#ifdef IPOL_T0
473 scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; 473 scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0];
474#endif 474#endif
475#ifdef IPOL_T1 475#ifdef IPOL_T1
476 scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; 476 scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0];
477#endif 477#endif
478 478
479 } 479 }
480 480
481 // calculate slopes for bottom edge 481 // calculate slopes for bottom edge
482 scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; 482 scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2];
483 scan.x[1] = b->Pos.x; 483 scan.x[1] = b->Pos.x;
484 484
485#ifdef IPOL_Z 485#ifdef IPOL_Z
486 scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; 486 scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2];
487 scan.z[1] = b->Pos.z; 487 scan.z[1] = b->Pos.z;
488#endif 488#endif
489 489
490#ifdef IPOL_W 490#ifdef IPOL_W
491 scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; 491 scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2];
492 scan.w[1] = b->Pos.w; 492 scan.w[1] = b->Pos.w;
493#endif 493#endif
494 494
495#ifdef IPOL_C0 495#ifdef IPOL_C0
496 scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; 496 scan.slopeC[1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2];
497 scan.c[1] = b->Color[0]; 497 scan.c[1] = b->Color[0];
498#endif 498#endif
499 499
500#ifdef IPOL_T0 500#ifdef IPOL_T0
501 scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; 501 scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2];
502 scan.t[0][1] = b->Tex[0]; 502 scan.t[0][1] = b->Tex[0];
503#endif 503#endif
504 504
505#ifdef IPOL_T1 505#ifdef IPOL_T1
506 scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; 506 scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2];
507 scan.t[1][1] = b->Tex[1]; 507 scan.t[1][1] = b->Tex[1];
508#endif 508#endif
509 509
510 // apply top-left fill convention, top part 510 // apply top-left fill convention, top part
511 yStart = core::ceil32( b->Pos.y ); 511 yStart = core::ceil32( b->Pos.y );
512 yEnd = core::ceil32( c->Pos.y ) - 1; 512 yEnd = core::ceil32( c->Pos.y ) - 1;
513 513
514#ifdef SUBTEXEL 514#ifdef SUBTEXEL
515 515
516 subPixel = ( (f32) yStart ) - b->Pos.y; 516 subPixel = ( (f32) yStart ) - b->Pos.y;
517 517
518 // correct to pixel center 518 // correct to pixel center
519 scan.x[0] += scan.slopeX[0] * subPixel; 519 scan.x[0] += scan.slopeX[0] * subPixel;
520 scan.x[1] += scan.slopeX[1] * subPixel; 520 scan.x[1] += scan.slopeX[1] * subPixel;
521 521
522#ifdef IPOL_Z 522#ifdef IPOL_Z
523 scan.z[0] += scan.slopeZ[0] * subPixel; 523 scan.z[0] += scan.slopeZ[0] * subPixel;
524 scan.z[1] += scan.slopeZ[1] * subPixel; 524 scan.z[1] += scan.slopeZ[1] * subPixel;
525#endif 525#endif
526 526
527#ifdef IPOL_W 527#ifdef IPOL_W
528 scan.w[0] += scan.slopeW[0] * subPixel; 528 scan.w[0] += scan.slopeW[0] * subPixel;
529 scan.w[1] += scan.slopeW[1] * subPixel; 529 scan.w[1] += scan.slopeW[1] * subPixel;
530#endif 530#endif
531 531
532#ifdef IPOL_C0 532#ifdef IPOL_C0
533 scan.c[0] += scan.slopeC[0] * subPixel; 533 scan.c[0] += scan.slopeC[0] * subPixel;
534 scan.c[1] += scan.slopeC[1] * subPixel; 534 scan.c[1] += scan.slopeC[1] * subPixel;
535#endif 535#endif
536 536
537#ifdef IPOL_T0 537#ifdef IPOL_T0
538 scan.t[0][0] += scan.slopeT[0][0] * subPixel; 538 scan.t[0][0] += scan.slopeT[0][0] * subPixel;
539 scan.t[0][1] += scan.slopeT[0][1] * subPixel; 539 scan.t[0][1] += scan.slopeT[0][1] * subPixel;
540#endif 540#endif
541 541
542#ifdef IPOL_T1 542#ifdef IPOL_T1
543 scan.t[1][0] += scan.slopeT[1][0] * subPixel; 543 scan.t[1][0] += scan.slopeT[1][0] * subPixel;
544 scan.t[1][1] += scan.slopeT[1][1] * subPixel; 544 scan.t[1][1] += scan.slopeT[1][1] * subPixel;
545#endif 545#endif
546 546
547#endif 547#endif
548 548
549 // rasterize the edge scanlines 549 // rasterize the edge scanlines
550 for( line.y = yStart; line.y <= yEnd; ++line.y) 550 for( line.y = yStart; line.y <= yEnd; ++line.y)
551 { 551 {
552 line.x[scan.left] = scan.x[0]; 552 line.x[scan.left] = scan.x[0];
553 line.x[scan.right] = scan.x[1]; 553 line.x[scan.right] = scan.x[1];
554 554
555#ifdef IPOL_Z 555#ifdef IPOL_Z
556 line.z[scan.left] = scan.z[0]; 556 line.z[scan.left] = scan.z[0];
557 line.z[scan.right] = scan.z[1]; 557 line.z[scan.right] = scan.z[1];
558#endif 558#endif
559 559
560#ifdef IPOL_W 560#ifdef IPOL_W
561 line.w[scan.left] = scan.w[0]; 561 line.w[scan.left] = scan.w[0];
562 line.w[scan.right] = scan.w[1]; 562 line.w[scan.right] = scan.w[1];
563#endif 563#endif
564 564
565#ifdef IPOL_C0 565#ifdef IPOL_C0
566 line.c[scan.left] = scan.c[0]; 566 line.c[scan.left] = scan.c[0];
567 line.c[scan.right] = scan.c[1]; 567 line.c[scan.right] = scan.c[1];
568#endif 568#endif
569 569
570#ifdef IPOL_T0 570#ifdef IPOL_T0
571 line.t[0][scan.left] = scan.t[0][0]; 571 line.t[0][scan.left] = scan.t[0][0];
572 line.t[0][scan.right] = scan.t[0][1]; 572 line.t[0][scan.right] = scan.t[0][1];
573#endif 573#endif
574 574
575#ifdef IPOL_T1 575#ifdef IPOL_T1
576 line.t[1][scan.left] = scan.t[1][0]; 576 line.t[1][scan.left] = scan.t[1][0];
577 line.t[1][scan.right] = scan.t[1][1]; 577 line.t[1][scan.right] = scan.t[1][1];
578#endif 578#endif
579 579
580 // render a scanline 580 // render a scanline
581 scanline_bilinear2 (); 581 scanline_bilinear2 ();
582 582
583 scan.x[0] += scan.slopeX[0]; 583 scan.x[0] += scan.slopeX[0];
584 scan.x[1] += scan.slopeX[1]; 584 scan.x[1] += scan.slopeX[1];
585 585
586#ifdef IPOL_Z 586#ifdef IPOL_Z
587 scan.z[0] += scan.slopeZ[0]; 587 scan.z[0] += scan.slopeZ[0];
588 scan.z[1] += scan.slopeZ[1]; 588 scan.z[1] += scan.slopeZ[1];
589#endif 589#endif
590 590
591#ifdef IPOL_W 591#ifdef IPOL_W
592 scan.w[0] += scan.slopeW[0]; 592 scan.w[0] += scan.slopeW[0];
593 scan.w[1] += scan.slopeW[1]; 593 scan.w[1] += scan.slopeW[1];
594#endif 594#endif
595 595
596#ifdef IPOL_C0 596#ifdef IPOL_C0
597 scan.c[0] += scan.slopeC[0]; 597 scan.c[0] += scan.slopeC[0];
598 scan.c[1] += scan.slopeC[1]; 598 scan.c[1] += scan.slopeC[1];
599#endif 599#endif
600 600
601#ifdef IPOL_T0 601#ifdef IPOL_T0
602 scan.t[0][0] += scan.slopeT[0][0]; 602 scan.t[0][0] += scan.slopeT[0][0];
603 scan.t[0][1] += scan.slopeT[0][1]; 603 scan.t[0][1] += scan.slopeT[0][1];
604#endif 604#endif
605 605
606#ifdef IPOL_T1 606#ifdef IPOL_T1
607 scan.t[1][0] += scan.slopeT[1][0]; 607 scan.t[1][0] += scan.slopeT[1][0];
608 scan.t[1][1] += scan.slopeT[1][1]; 608 scan.t[1][1] += scan.slopeT[1][1];
609#endif 609#endif
610 610
611 } 611 }
612 } 612 }
613 613
614} 614}
615 615
616 616
617} // end namespace video 617} // end namespace video
618} // end namespace irr 618} // end namespace irr
619 619
620#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 620#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
621 621
622namespace irr 622namespace irr
623{ 623{
624namespace video 624namespace video
625{ 625{
626 626
627 627
628 628
629//! creates a flat triangle renderer 629//! creates a flat triangle renderer
630IBurningShader* createTriangleRendererTextureLightMap2_M1(CBurningVideoDriver* driver) 630IBurningShader* createTriangleRendererTextureLightMap2_M1(CBurningVideoDriver* driver)
631{ 631{
632 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 632 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
633 return new CTRTextureLightMap2_M1(driver); 633 return new CTRTextureLightMap2_M1(driver);
634 #else 634 #else
635 return 0; 635 return 0;
636 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 636 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
637} 637}
638 638
639 639
640} // end namespace video 640} // end namespace video
641} // end namespace irr 641} // end namespace irr
642 642
643 643
644 644