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