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