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