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