aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureBlend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CTRTextureBlend.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CTRTextureBlend.cpp4770
1 files changed, 2385 insertions, 2385 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureBlend.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureBlend.cpp
index 82372e8..b189e54 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureBlend.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureBlend.cpp
@@ -1,2385 +1,2385 @@
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 CTRTextureBlend : public IBurningShader 79class CTRTextureBlend : public IBurningShader
80{ 80{
81public: 81public:
82 82
83 //! constructor 83 //! constructor
84 CTRTextureBlend(CBurningVideoDriver* driver); 84 CTRTextureBlend(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 virtual void setZCompareFunc ( u32 func); 89 virtual void setZCompareFunc ( u32 func);
90 virtual void setParam ( u32 index, f32 value); 90 virtual void setParam ( u32 index, f32 value);
91 91
92 92
93private: 93private:
94 // fragment shader 94 // fragment shader
95 typedef void (CTRTextureBlend::*tFragmentShader) (); 95 typedef void (CTRTextureBlend::*tFragmentShader) ();
96 void fragment_dst_color_zero (); 96 void fragment_dst_color_zero ();
97 void fragment_dst_color_one (); 97 void fragment_dst_color_one ();
98 void fragment_dst_color_src_alpha (); 98 void fragment_dst_color_src_alpha ();
99 void fragment_dst_color_one_minus_dst_alpha (); 99 void fragment_dst_color_one_minus_dst_alpha ();
100 void fragment_zero_one_minus_scr_color (); 100 void fragment_zero_one_minus_scr_color ();
101 void fragment_src_color_src_alpha (); 101 void fragment_src_color_src_alpha ();
102 void fragment_one_one_minus_src_alpha (); 102 void fragment_one_one_minus_src_alpha ();
103 void fragment_one_minus_dst_alpha_one(); 103 void fragment_one_minus_dst_alpha_one();
104 void fragment_src_alpha_one(); 104 void fragment_src_alpha_one();
105 105
106 tFragmentShader fragmentShader; 106 tFragmentShader fragmentShader;
107 sScanConvertData scan; 107 sScanConvertData scan;
108 sScanLineData line; 108 sScanLineData line;
109 109
110 u32 ZCompare; 110 u32 ZCompare;
111}; 111};
112 112
113//! constructor 113//! constructor
114CTRTextureBlend::CTRTextureBlend(CBurningVideoDriver* driver) 114CTRTextureBlend::CTRTextureBlend(CBurningVideoDriver* driver)
115: IBurningShader(driver) 115: IBurningShader(driver)
116{ 116{
117 #ifdef _DEBUG 117 #ifdef _DEBUG
118 setDebugName("CTRTextureBlend"); 118 setDebugName("CTRTextureBlend");
119 #endif 119 #endif
120 120
121 ZCompare = 1; 121 ZCompare = 1;
122} 122}
123 123
124/*! 124/*!
125*/ 125*/
126void CTRTextureBlend::setZCompareFunc ( u32 func) 126void CTRTextureBlend::setZCompareFunc ( u32 func)
127{ 127{
128 ZCompare = func; 128 ZCompare = func;
129} 129}
130 130
131/*! 131/*!
132*/ 132*/
133void CTRTextureBlend::setParam ( u32 index, f32 value) 133void CTRTextureBlend::setParam ( u32 index, f32 value)
134{ 134{
135 u8 showname = 0; 135 u8 showname = 0;
136 136
137 E_BLEND_FACTOR srcFact,dstFact; 137 E_BLEND_FACTOR srcFact,dstFact;
138 E_MODULATE_FUNC modulate; 138 E_MODULATE_FUNC modulate;
139 u32 alphaSrc; 139 u32 alphaSrc;
140 unpack_textureBlendFunc ( srcFact, dstFact, modulate, alphaSrc, value ); 140 unpack_textureBlendFunc ( srcFact, dstFact, modulate, alphaSrc, value );
141 141
142 fragmentShader = 0; 142 fragmentShader = 0;
143 143
144 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ZERO ) 144 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ZERO )
145 { 145 {
146 fragmentShader = &CTRTextureBlend::fragment_dst_color_zero; 146 fragmentShader = &CTRTextureBlend::fragment_dst_color_zero;
147 } 147 }
148 else 148 else
149 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ONE ) 149 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ONE )
150 { 150 {
151 fragmentShader = &CTRTextureBlend::fragment_dst_color_one; 151 fragmentShader = &CTRTextureBlend::fragment_dst_color_one;
152 } 152 }
153 else 153 else
154 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_SRC_ALPHA) 154 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_SRC_ALPHA)
155 { 155 {
156 fragmentShader = &CTRTextureBlend::fragment_dst_color_src_alpha; 156 fragmentShader = &CTRTextureBlend::fragment_dst_color_src_alpha;
157 } 157 }
158 else 158 else
159 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ONE_MINUS_DST_ALPHA) 159 if ( srcFact == EBF_DST_COLOR && dstFact == EBF_ONE_MINUS_DST_ALPHA)
160 { 160 {
161 fragmentShader = &CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha; 161 fragmentShader = &CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha;
162 } 162 }
163 else 163 else
164 if ( srcFact == EBF_ZERO && dstFact == EBF_ONE_MINUS_SRC_COLOR ) 164 if ( srcFact == EBF_ZERO && dstFact == EBF_ONE_MINUS_SRC_COLOR )
165 { 165 {
166 fragmentShader = &CTRTextureBlend::fragment_zero_one_minus_scr_color; 166 fragmentShader = &CTRTextureBlend::fragment_zero_one_minus_scr_color;
167 } 167 }
168 else 168 else
169 if ( srcFact == EBF_ONE && dstFact == EBF_ONE_MINUS_SRC_ALPHA) 169 if ( srcFact == EBF_ONE && dstFact == EBF_ONE_MINUS_SRC_ALPHA)
170 { 170 {
171 fragmentShader = &CTRTextureBlend::fragment_one_one_minus_src_alpha; 171 fragmentShader = &CTRTextureBlend::fragment_one_one_minus_src_alpha;
172 } 172 }
173 else 173 else
174 if ( srcFact == EBF_ONE_MINUS_DST_ALPHA && dstFact == EBF_ONE ) 174 if ( srcFact == EBF_ONE_MINUS_DST_ALPHA && dstFact == EBF_ONE )
175 { 175 {
176 fragmentShader = &CTRTextureBlend::fragment_one_minus_dst_alpha_one; 176 fragmentShader = &CTRTextureBlend::fragment_one_minus_dst_alpha_one;
177 } 177 }
178 else 178 else
179 if ( srcFact == EBF_SRC_ALPHA && dstFact == EBF_ONE ) 179 if ( srcFact == EBF_SRC_ALPHA && dstFact == EBF_ONE )
180 { 180 {
181 fragmentShader = &CTRTextureBlend::fragment_src_alpha_one; 181 fragmentShader = &CTRTextureBlend::fragment_src_alpha_one;
182 } 182 }
183 else 183 else
184 if ( srcFact == EBF_SRC_COLOR && dstFact == EBF_SRC_ALPHA ) 184 if ( srcFact == EBF_SRC_COLOR && dstFact == EBF_SRC_ALPHA )
185 { 185 {
186 fragmentShader = &CTRTextureBlend::fragment_src_color_src_alpha; 186 fragmentShader = &CTRTextureBlend::fragment_src_color_src_alpha;
187 } 187 }
188 else 188 else
189 { 189 {
190 showname = 1; 190 showname = 1;
191 fragmentShader = &CTRTextureBlend::fragment_dst_color_zero; 191 fragmentShader = &CTRTextureBlend::fragment_dst_color_zero;
192 } 192 }
193 193
194 static const c8 *n[] = 194 static const c8 *n[] =
195 { 195 {
196 "gl_zero", 196 "gl_zero",
197 "gl_one", 197 "gl_one",
198 "gl_dst_color", 198 "gl_dst_color",
199 "gl_one_minus_dst_color", 199 "gl_one_minus_dst_color",
200 "gl_src_color", 200 "gl_src_color",
201 "gl_one_minus_src_color", 201 "gl_one_minus_src_color",
202 "gl_src_alpha", 202 "gl_src_alpha",
203 "gl_one_minus_src_alpha", 203 "gl_one_minus_src_alpha",
204 "gl_dst_alpha", 204 "gl_dst_alpha",
205 "gl_one_minus_dst_alpha", 205 "gl_one_minus_dst_alpha",
206 "gl_src_alpha_saturate" 206 "gl_src_alpha_saturate"
207 }; 207 };
208 208
209 static E_BLEND_FACTOR lsrcFact = EBF_ZERO; 209 static E_BLEND_FACTOR lsrcFact = EBF_ZERO;
210 static E_BLEND_FACTOR ldstFact = EBF_ZERO; 210 static E_BLEND_FACTOR ldstFact = EBF_ZERO;
211 211
212 if ( showname && ( lsrcFact != srcFact || ldstFact != dstFact ) ) 212 if ( showname && ( lsrcFact != srcFact || ldstFact != dstFact ) )
213 { 213 {
214 char buf[128]; 214 char buf[128];
215 snprintf ( buf, 128, "missing shader: %s %s",n[srcFact], n[dstFact] ); 215 snprintf ( buf, 128, "missing shader: %s %s",n[srcFact], n[dstFact] );
216 os::Printer::log( buf, ELL_INFORMATION ); 216 os::Printer::log( buf, ELL_INFORMATION );
217 217
218 lsrcFact = srcFact; 218 lsrcFact = srcFact;
219 ldstFact = dstFact; 219 ldstFact = dstFact;
220 } 220 }
221 221
222} 222}
223 223
224 224
225/*! 225/*!
226*/ 226*/
227void CTRTextureBlend::fragment_dst_color_src_alpha () 227void CTRTextureBlend::fragment_dst_color_src_alpha ()
228{ 228{
229 tVideoSample *dst; 229 tVideoSample *dst;
230 230
231#ifdef USE_ZBUFFER 231#ifdef USE_ZBUFFER
232 fp24 *z; 232 fp24 *z;
233#endif 233#endif
234 234
235 s32 xStart; 235 s32 xStart;
236 s32 xEnd; 236 s32 xEnd;
237 s32 dx; 237 s32 dx;
238 238
239 239
240#ifdef SUBTEXEL 240#ifdef SUBTEXEL
241 f32 subPixel; 241 f32 subPixel;
242#endif 242#endif
243 243
244#ifdef IPOL_Z 244#ifdef IPOL_Z
245 f32 slopeZ; 245 f32 slopeZ;
246#endif 246#endif
247#ifdef IPOL_W 247#ifdef IPOL_W
248 fp24 slopeW; 248 fp24 slopeW;
249#endif 249#endif
250#ifdef IPOL_C0 250#ifdef IPOL_C0
251 sVec4 slopeC[MATERIAL_MAX_COLORS]; 251 sVec4 slopeC[MATERIAL_MAX_COLORS];
252#endif 252#endif
253#ifdef IPOL_T0 253#ifdef IPOL_T0
254 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 254 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
255#endif 255#endif
256 256
257 // apply top-left fill-convention, left 257 // apply top-left fill-convention, left
258 xStart = core::ceil32( line.x[0] ); 258 xStart = core::ceil32( line.x[0] );
259 xEnd = core::ceil32( line.x[1] ) - 1; 259 xEnd = core::ceil32( line.x[1] ) - 1;
260 260
261 dx = xEnd - xStart; 261 dx = xEnd - xStart;
262 262
263 if ( dx < 0 ) 263 if ( dx < 0 )
264 return; 264 return;
265 265
266 // slopes 266 // slopes
267 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 267 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
268 268
269#ifdef IPOL_Z 269#ifdef IPOL_Z
270 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 270 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
271#endif 271#endif
272#ifdef IPOL_W 272#ifdef IPOL_W
273 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 273 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
274#endif 274#endif
275#ifdef IPOL_C0 275#ifdef IPOL_C0
276 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 276 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
277#endif 277#endif
278#ifdef IPOL_T0 278#ifdef IPOL_T0
279 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 279 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
280#endif 280#endif
281#ifdef IPOL_T1 281#ifdef IPOL_T1
282 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 282 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
283#endif 283#endif
284 284
285#ifdef SUBTEXEL 285#ifdef SUBTEXEL
286 subPixel = ( (f32) xStart ) - line.x[0]; 286 subPixel = ( (f32) xStart ) - line.x[0];
287#ifdef IPOL_Z 287#ifdef IPOL_Z
288 line.z[0] += slopeZ * subPixel; 288 line.z[0] += slopeZ * subPixel;
289#endif 289#endif
290#ifdef IPOL_W 290#ifdef IPOL_W
291 line.w[0] += slopeW * subPixel; 291 line.w[0] += slopeW * subPixel;
292#endif 292#endif
293#ifdef IPOL_C0 293#ifdef IPOL_C0
294 line.c[0][0] += slopeC[0] * subPixel; 294 line.c[0][0] += slopeC[0] * subPixel;
295#endif 295#endif
296#ifdef IPOL_T0 296#ifdef IPOL_T0
297 line.t[0][0] += slopeT[0] * subPixel; 297 line.t[0][0] += slopeT[0] * subPixel;
298#endif 298#endif
299#ifdef IPOL_T1 299#ifdef IPOL_T1
300 line.t[1][0] += slopeT[1] * subPixel; 300 line.t[1][0] += slopeT[1] * subPixel;
301#endif 301#endif
302#endif 302#endif
303 303
304 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 304 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
305 305
306#ifdef USE_ZBUFFER 306#ifdef USE_ZBUFFER
307 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 307 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
308#endif 308#endif
309 309
310 310
311 f32 iw = FIX_POINT_F32_MUL; 311 f32 iw = FIX_POINT_F32_MUL;
312 312
313 tFixPoint a0, r0, g0, b0; 313 tFixPoint a0, r0, g0, b0;
314 tFixPoint r1, g1, b1; 314 tFixPoint r1, g1, b1;
315 315
316 s32 i; 316 s32 i;
317 317
318 switch ( ZCompare ) 318 switch ( ZCompare )
319 { 319 {
320 case 1: 320 case 1:
321 for ( i = 0; i <= dx; ++i ) 321 for ( i = 0; i <= dx; ++i )
322 { 322 {
323#ifdef CMP_W 323#ifdef CMP_W
324 if ( line.w[0] >= z[i] ) 324 if ( line.w[0] >= z[i] )
325#endif 325#endif
326 326
327 { 327 {
328 328
329#ifdef WRITE_W 329#ifdef WRITE_W
330 z[i] = line.w[0]; 330 z[i] = line.w[0];
331#endif 331#endif
332 332
333#ifdef INVERSE_W 333#ifdef INVERSE_W
334 iw = fix_inverse32 ( line.w[0] ); 334 iw = fix_inverse32 ( line.w[0] );
335#endif 335#endif
336 336
337 getSample_texture ( a0,r0,g0,b0, 337 getSample_texture ( a0,r0,g0,b0,
338 &IT[0], 338 &IT[0],
339 tofix ( line.t[0][0].x,iw), 339 tofix ( line.t[0][0].x,iw),
340 tofix ( line.t[0][0].y,iw) 340 tofix ( line.t[0][0].y,iw)
341 ); 341 );
342 342
343 color_to_fix ( r1, g1, b1, dst[i] ); 343 color_to_fix ( r1, g1, b1, dst[i] );
344 344
345 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), 345 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ),
346 clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), 346 clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ),
347 clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) 347 clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) )
348 ); 348 );
349 } 349 }
350 350
351#ifdef IPOL_W 351#ifdef IPOL_W
352 line.w[0] += slopeW; 352 line.w[0] += slopeW;
353#endif 353#endif
354#ifdef IPOL_T0 354#ifdef IPOL_T0
355 line.t[0][0] += slopeT[0]; 355 line.t[0][0] += slopeT[0];
356#endif 356#endif
357#ifdef IPOL_C0 357#ifdef IPOL_C0
358 line.c[0][0] += slopeC[0]; 358 line.c[0][0] += slopeC[0];
359#endif 359#endif
360 } 360 }
361 break; 361 break;
362 362
363 case 2: 363 case 2:
364 for ( i = 0; i <= dx; ++i ) 364 for ( i = 0; i <= dx; ++i )
365 { 365 {
366#ifdef CMP_W 366#ifdef CMP_W
367 if ( line.w[0] == z[i] ) 367 if ( line.w[0] == z[i] )
368#endif 368#endif
369 369
370 { 370 {
371 371
372#ifdef WRITE_W 372#ifdef WRITE_W
373 z[i] = line.w[0]; 373 z[i] = line.w[0];
374#endif 374#endif
375 375
376#ifdef INVERSE_W 376#ifdef INVERSE_W
377 iw = fix_inverse32 ( line.w[0] ); 377 iw = fix_inverse32 ( line.w[0] );
378#endif 378#endif
379 379
380 getSample_texture ( a0,r0,g0,b0, 380 getSample_texture ( a0,r0,g0,b0,
381 &IT[0], 381 &IT[0],
382 tofix ( line.t[0][0].x,iw), 382 tofix ( line.t[0][0].x,iw),
383 tofix ( line.t[0][0].y,iw) 383 tofix ( line.t[0][0].y,iw)
384 ); 384 );
385 385
386 color_to_fix ( r1, g1, b1, dst[i] ); 386 color_to_fix ( r1, g1, b1, dst[i] );
387 387
388 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), 388 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ),
389 clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), 389 clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ),
390 clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) 390 clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) )
391 ); 391 );
392 392
393 } 393 }
394 394
395#ifdef IPOL_W 395#ifdef IPOL_W
396 line.w[0] += slopeW; 396 line.w[0] += slopeW;
397#endif 397#endif
398#ifdef IPOL_T0 398#ifdef IPOL_T0
399 line.t[0][0] += slopeT[0]; 399 line.t[0][0] += slopeT[0];
400#endif 400#endif
401#ifdef IPOL_C0 401#ifdef IPOL_C0
402 line.c[0][0] += slopeC[0]; 402 line.c[0][0] += slopeC[0];
403#endif 403#endif
404 }break; 404 }break;
405 } // zcompare 405 } // zcompare
406 406
407} 407}
408 408
409/*! 409/*!
410*/ 410*/
411void CTRTextureBlend::fragment_src_color_src_alpha () 411void CTRTextureBlend::fragment_src_color_src_alpha ()
412{ 412{
413 tVideoSample *dst; 413 tVideoSample *dst;
414 414
415#ifdef USE_ZBUFFER 415#ifdef USE_ZBUFFER
416 fp24 *z; 416 fp24 *z;
417#endif 417#endif
418 418
419 s32 xStart; 419 s32 xStart;
420 s32 xEnd; 420 s32 xEnd;
421 s32 dx; 421 s32 dx;
422 422
423 423
424#ifdef SUBTEXEL 424#ifdef SUBTEXEL
425 f32 subPixel; 425 f32 subPixel;
426#endif 426#endif
427 427
428#ifdef IPOL_Z 428#ifdef IPOL_Z
429 f32 slopeZ; 429 f32 slopeZ;
430#endif 430#endif
431#ifdef IPOL_W 431#ifdef IPOL_W
432 fp24 slopeW; 432 fp24 slopeW;
433#endif 433#endif
434#ifdef IPOL_C0 434#ifdef IPOL_C0
435 sVec4 slopeC[MATERIAL_MAX_COLORS]; 435 sVec4 slopeC[MATERIAL_MAX_COLORS];
436#endif 436#endif
437#ifdef IPOL_T0 437#ifdef IPOL_T0
438 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 438 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
439#endif 439#endif
440 440
441 // apply top-left fill-convention, left 441 // apply top-left fill-convention, left
442 xStart = core::ceil32( line.x[0] ); 442 xStart = core::ceil32( line.x[0] );
443 xEnd = core::ceil32( line.x[1] ) - 1; 443 xEnd = core::ceil32( line.x[1] ) - 1;
444 444
445 dx = xEnd - xStart; 445 dx = xEnd - xStart;
446 446
447 if ( dx < 0 ) 447 if ( dx < 0 )
448 return; 448 return;
449 449
450 // slopes 450 // slopes
451 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 451 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
452 452
453#ifdef IPOL_Z 453#ifdef IPOL_Z
454 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 454 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
455#endif 455#endif
456#ifdef IPOL_W 456#ifdef IPOL_W
457 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 457 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
458#endif 458#endif
459#ifdef IPOL_C0 459#ifdef IPOL_C0
460 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 460 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
461#endif 461#endif
462#ifdef IPOL_T0 462#ifdef IPOL_T0
463 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 463 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
464#endif 464#endif
465#ifdef IPOL_T1 465#ifdef IPOL_T1
466 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 466 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
467#endif 467#endif
468 468
469#ifdef SUBTEXEL 469#ifdef SUBTEXEL
470 subPixel = ( (f32) xStart ) - line.x[0]; 470 subPixel = ( (f32) xStart ) - line.x[0];
471#ifdef IPOL_Z 471#ifdef IPOL_Z
472 line.z[0] += slopeZ * subPixel; 472 line.z[0] += slopeZ * subPixel;
473#endif 473#endif
474#ifdef IPOL_W 474#ifdef IPOL_W
475 line.w[0] += slopeW * subPixel; 475 line.w[0] += slopeW * subPixel;
476#endif 476#endif
477#ifdef IPOL_C0 477#ifdef IPOL_C0
478 line.c[0][0] += slopeC[0] * subPixel; 478 line.c[0][0] += slopeC[0] * subPixel;
479#endif 479#endif
480#ifdef IPOL_T0 480#ifdef IPOL_T0
481 line.t[0][0] += slopeT[0] * subPixel; 481 line.t[0][0] += slopeT[0] * subPixel;
482#endif 482#endif
483#ifdef IPOL_T1 483#ifdef IPOL_T1
484 line.t[1][0] += slopeT[1] * subPixel; 484 line.t[1][0] += slopeT[1] * subPixel;
485#endif 485#endif
486#endif 486#endif
487 487
488 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 488 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
489 489
490#ifdef USE_ZBUFFER 490#ifdef USE_ZBUFFER
491 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 491 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
492#endif 492#endif
493 493
494 494
495 f32 iw = FIX_POINT_F32_MUL; 495 f32 iw = FIX_POINT_F32_MUL;
496 496
497 tFixPoint a0, r0, g0, b0; 497 tFixPoint a0, r0, g0, b0;
498 tFixPoint r1, g1, b1; 498 tFixPoint r1, g1, b1;
499 499
500 s32 i; 500 s32 i;
501 501
502 switch ( ZCompare ) 502 switch ( ZCompare )
503 { 503 {
504 case 1: 504 case 1:
505 for ( i = 0; i <= dx; ++i ) 505 for ( i = 0; i <= dx; ++i )
506 { 506 {
507#ifdef CMP_W 507#ifdef CMP_W
508 if ( line.w[0] >= z[i] ) 508 if ( line.w[0] >= z[i] )
509#endif 509#endif
510 510
511 { 511 {
512 512
513#ifdef WRITE_W 513#ifdef WRITE_W
514 z[i] = line.w[0]; 514 z[i] = line.w[0];
515#endif 515#endif
516 516
517#ifdef INVERSE_W 517#ifdef INVERSE_W
518 iw = fix_inverse32 ( line.w[0] ); 518 iw = fix_inverse32 ( line.w[0] );
519#endif 519#endif
520 520
521 getSample_texture ( a0, r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,iw), tofix ( line.t[0][0].y,iw) ); 521 getSample_texture ( a0, r0, g0, b0, &IT[0], tofix ( line.t[0][0].x,iw), tofix ( line.t[0][0].y,iw) );
522 color_to_fix ( r1, g1, b1, dst[i] ); 522 color_to_fix ( r1, g1, b1, dst[i] );
523 523
524// u32 check = imulFix_tex1( r0, r1 ); 524// u32 check = imulFix_tex1( r0, r1 );
525 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1( r0, r1 ) + imulFix_tex1( r1, a0 ) ), 525 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1( r0, r1 ) + imulFix_tex1( r1, a0 ) ),
526 clampfix_maxcolor ( imulFix_tex1( g0, g1 ) + imulFix_tex1( g1, a0 ) ), 526 clampfix_maxcolor ( imulFix_tex1( g0, g1 ) + imulFix_tex1( g1, a0 ) ),
527 clampfix_maxcolor ( imulFix_tex1( b0, b1 ) + imulFix_tex1( b1, a0 ) ) 527 clampfix_maxcolor ( imulFix_tex1( b0, b1 ) + imulFix_tex1( b1, a0 ) )
528 ); 528 );
529 } 529 }
530 530
531#ifdef IPOL_W 531#ifdef IPOL_W
532 line.w[0] += slopeW; 532 line.w[0] += slopeW;
533#endif 533#endif
534#ifdef IPOL_T0 534#ifdef IPOL_T0
535 line.t[0][0] += slopeT[0]; 535 line.t[0][0] += slopeT[0];
536#endif 536#endif
537#ifdef IPOL_C0 537#ifdef IPOL_C0
538 line.c[0][0] += slopeC[0]; 538 line.c[0][0] += slopeC[0];
539#endif 539#endif
540 } 540 }
541 break; 541 break;
542 542
543 case 2: 543 case 2:
544 for ( i = 0; i <= dx; ++i ) 544 for ( i = 0; i <= dx; ++i )
545 { 545 {
546#ifdef CMP_W 546#ifdef CMP_W
547 if ( line.w[0] == z[i] ) 547 if ( line.w[0] == z[i] )
548#endif 548#endif
549 549
550 { 550 {
551 551
552#ifdef WRITE_W 552#ifdef WRITE_W
553 z[i] = line.w[0]; 553 z[i] = line.w[0];
554#endif 554#endif
555 555
556#ifdef INVERSE_W 556#ifdef INVERSE_W
557 iw = fix_inverse32 ( line.w[0] ); 557 iw = fix_inverse32 ( line.w[0] );
558#endif 558#endif
559 559
560 getSample_texture ( a0,r0,g0,b0, 560 getSample_texture ( a0,r0,g0,b0,
561 &IT[0], 561 &IT[0],
562 tofix ( line.t[0][0].x,iw), 562 tofix ( line.t[0][0].x,iw),
563 tofix ( line.t[0][0].y,iw) 563 tofix ( line.t[0][0].y,iw)
564 ); 564 );
565 565
566 color_to_fix ( r1, g1, b1, dst[i] ); 566 color_to_fix ( r1, g1, b1, dst[i] );
567 567
568 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ), 568 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex2 ( r0, r1 ) ),
569 clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ), 569 clampfix_maxcolor ( imulFix_tex2 ( g0, g1 ) ),
570 clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) ) 570 clampfix_maxcolor ( imulFix_tex2 ( b0, b1 ) )
571 ); 571 );
572 572
573 } 573 }
574 574
575#ifdef IPOL_W 575#ifdef IPOL_W
576 line.w[0] += slopeW; 576 line.w[0] += slopeW;
577#endif 577#endif
578#ifdef IPOL_T0 578#ifdef IPOL_T0
579 line.t[0][0] += slopeT[0]; 579 line.t[0][0] += slopeT[0];
580#endif 580#endif
581#ifdef IPOL_C0 581#ifdef IPOL_C0
582 line.c[0][0] += slopeC[0]; 582 line.c[0][0] += slopeC[0];
583#endif 583#endif
584 }break; 584 }break;
585 } // zcompare 585 } // zcompare
586 586
587} 587}
588 588
589/*! 589/*!
590*/ 590*/
591void CTRTextureBlend::fragment_one_one_minus_src_alpha() 591void CTRTextureBlend::fragment_one_one_minus_src_alpha()
592{ 592{
593 tVideoSample *dst; 593 tVideoSample *dst;
594 594
595#ifdef USE_ZBUFFER 595#ifdef USE_ZBUFFER
596 fp24 *z; 596 fp24 *z;
597#endif 597#endif
598 598
599 s32 xStart; 599 s32 xStart;
600 s32 xEnd; 600 s32 xEnd;
601 s32 dx; 601 s32 dx;
602 602
603 603
604#ifdef SUBTEXEL 604#ifdef SUBTEXEL
605 f32 subPixel; 605 f32 subPixel;
606#endif 606#endif
607 607
608#ifdef IPOL_Z 608#ifdef IPOL_Z
609 f32 slopeZ; 609 f32 slopeZ;
610#endif 610#endif
611#ifdef IPOL_W 611#ifdef IPOL_W
612 fp24 slopeW; 612 fp24 slopeW;
613#endif 613#endif
614#ifdef IPOL_C0 614#ifdef IPOL_C0
615 sVec4 slopeC[MATERIAL_MAX_COLORS]; 615 sVec4 slopeC[MATERIAL_MAX_COLORS];
616#endif 616#endif
617#ifdef IPOL_T0 617#ifdef IPOL_T0
618 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 618 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
619#endif 619#endif
620 620
621 // apply top-left fill-convention, left 621 // apply top-left fill-convention, left
622 xStart = core::ceil32( line.x[0] ); 622 xStart = core::ceil32( line.x[0] );
623 xEnd = core::ceil32( line.x[1] ) - 1; 623 xEnd = core::ceil32( line.x[1] ) - 1;
624 624
625 dx = xEnd - xStart; 625 dx = xEnd - xStart;
626 626
627 if ( dx < 0 ) 627 if ( dx < 0 )
628 return; 628 return;
629 629
630 // slopes 630 // slopes
631 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 631 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
632 632
633#ifdef IPOL_Z 633#ifdef IPOL_Z
634 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 634 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
635#endif 635#endif
636#ifdef IPOL_W 636#ifdef IPOL_W
637 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 637 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
638#endif 638#endif
639#ifdef IPOL_C0 639#ifdef IPOL_C0
640 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 640 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
641#endif 641#endif
642#ifdef IPOL_T0 642#ifdef IPOL_T0
643 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 643 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
644#endif 644#endif
645#ifdef IPOL_T1 645#ifdef IPOL_T1
646 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 646 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
647#endif 647#endif
648 648
649#ifdef SUBTEXEL 649#ifdef SUBTEXEL
650 subPixel = ( (f32) xStart ) - line.x[0]; 650 subPixel = ( (f32) xStart ) - line.x[0];
651#ifdef IPOL_Z 651#ifdef IPOL_Z
652 line.z[0] += slopeZ * subPixel; 652 line.z[0] += slopeZ * subPixel;
653#endif 653#endif
654#ifdef IPOL_W 654#ifdef IPOL_W
655 line.w[0] += slopeW * subPixel; 655 line.w[0] += slopeW * subPixel;
656#endif 656#endif
657#ifdef IPOL_C0 657#ifdef IPOL_C0
658 line.c[0][0] += slopeC[0] * subPixel; 658 line.c[0][0] += slopeC[0] * subPixel;
659#endif 659#endif
660#ifdef IPOL_T0 660#ifdef IPOL_T0
661 line.t[0][0] += slopeT[0] * subPixel; 661 line.t[0][0] += slopeT[0] * subPixel;
662#endif 662#endif
663#ifdef IPOL_T1 663#ifdef IPOL_T1
664 line.t[1][0] += slopeT[1] * subPixel; 664 line.t[1][0] += slopeT[1] * subPixel;
665#endif 665#endif
666#endif 666#endif
667 667
668 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 668 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
669 669
670#ifdef USE_ZBUFFER 670#ifdef USE_ZBUFFER
671 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 671 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
672#endif 672#endif
673 673
674 674
675 f32 iw = FIX_POINT_F32_MUL; 675 f32 iw = FIX_POINT_F32_MUL;
676 676
677 tFixPoint a0,r0, g0, b0; 677 tFixPoint a0,r0, g0, b0;
678 tFixPoint r1, g1, b1; 678 tFixPoint r1, g1, b1;
679 tFixPoint r2, g2, b2; 679 tFixPoint r2, g2, b2;
680 680
681 s32 i; 681 s32 i;
682 682
683 switch ( ZCompare ) 683 switch ( ZCompare )
684 { 684 {
685 case 1: 685 case 1:
686 for ( i = 0; i <= dx; ++i ) 686 for ( i = 0; i <= dx; ++i )
687 { 687 {
688#ifdef CMP_W 688#ifdef CMP_W
689 if ( line.w[0] >= z[i] ) 689 if ( line.w[0] >= z[i] )
690#endif 690#endif
691 691
692 { 692 {
693 693
694#ifdef WRITE_W 694#ifdef WRITE_W
695 z[i] = line.w[0]; 695 z[i] = line.w[0];
696#endif 696#endif
697 697
698#ifdef INVERSE_W 698#ifdef INVERSE_W
699 iw = fix_inverse32 ( line.w[0] ); 699 iw = fix_inverse32 ( line.w[0] );
700#endif 700#endif
701 701
702 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 702 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
703 a0 = FIX_POINT_ONE - a0; 703 a0 = FIX_POINT_ONE - a0;
704 704
705 color_to_fix1 ( r1, g1, b1, dst[i] ); 705 color_to_fix1 ( r1, g1, b1, dst[i] );
706#ifdef IPOL_C0 706#ifdef IPOL_C0
707 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 707 getSample_color ( r2, g2, b2, line.c[0][0],iw );
708 708
709 dst[i] = fix_to_color ( imulFix ( r0 + imulFix ( r1, a0 ), r2 ), 709 dst[i] = fix_to_color ( imulFix ( r0 + imulFix ( r1, a0 ), r2 ),
710 imulFix ( g0 + imulFix ( g1, a0 ), g2 ), 710 imulFix ( g0 + imulFix ( g1, a0 ), g2 ),
711 imulFix ( b0 + imulFix ( b1, a0 ), b2 ) 711 imulFix ( b0 + imulFix ( b1, a0 ), b2 )
712 ); 712 );
713#else 713#else
714 dst[i] = fix_to_color ( r0 + imulFix ( r1, a0 ), 714 dst[i] = fix_to_color ( r0 + imulFix ( r1, a0 ),
715 g0 + imulFix ( g1, a0 ), 715 g0 + imulFix ( g1, a0 ),
716 b0 + imulFix ( b1, a0 ) 716 b0 + imulFix ( b1, a0 )
717 ); 717 );
718 718
719#endif 719#endif
720 720
721 } 721 }
722 722
723#ifdef IPOL_W 723#ifdef IPOL_W
724 line.w[0] += slopeW; 724 line.w[0] += slopeW;
725#endif 725#endif
726#ifdef IPOL_T0 726#ifdef IPOL_T0
727 line.t[0][0] += slopeT[0]; 727 line.t[0][0] += slopeT[0];
728#endif 728#endif
729#ifdef IPOL_C0 729#ifdef IPOL_C0
730 line.c[0][0] += slopeC[0]; 730 line.c[0][0] += slopeC[0];
731#endif 731#endif
732 } 732 }
733 break; 733 break;
734 734
735 case 2: 735 case 2:
736 for ( i = 0; i <= dx; ++i ) 736 for ( i = 0; i <= dx; ++i )
737 { 737 {
738#ifdef CMP_W 738#ifdef CMP_W
739 if ( line.w[0] == z[i] ) 739 if ( line.w[0] == z[i] )
740#endif 740#endif
741 741
742 { 742 {
743 743
744#ifdef WRITE_W 744#ifdef WRITE_W
745 z[i] = line.w[0]; 745 z[i] = line.w[0];
746#endif 746#endif
747 747
748#ifdef INVERSE_W 748#ifdef INVERSE_W
749 iw = fix_inverse32 ( line.w[0] ); 749 iw = fix_inverse32 ( line.w[0] );
750#endif 750#endif
751 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 751 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
752 a0 = FIX_POINT_ONE - a0; 752 a0 = FIX_POINT_ONE - a0;
753 753
754 color_to_fix1 ( r1, g1, b1, dst[i] ); 754 color_to_fix1 ( r1, g1, b1, dst[i] );
755#ifdef IPOL_C0 755#ifdef IPOL_C0
756 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 756 getSample_color ( r2, g2, b2, line.c[0][0],iw );
757 757
758 dst[i] = fix_to_color ( imulFix ( r0 + imulFix ( r1, a0 ), r2 ), 758 dst[i] = fix_to_color ( imulFix ( r0 + imulFix ( r1, a0 ), r2 ),
759 imulFix ( g0 + imulFix ( g1, a0 ), g2 ), 759 imulFix ( g0 + imulFix ( g1, a0 ), g2 ),
760 imulFix ( b0 + imulFix ( b1, a0 ), b2 ) 760 imulFix ( b0 + imulFix ( b1, a0 ), b2 )
761 ); 761 );
762#else 762#else
763 dst[i] = fix_to_color ( r0 + imulFix ( r1, a0 ), 763 dst[i] = fix_to_color ( r0 + imulFix ( r1, a0 ),
764 g0 + imulFix ( g1, a0 ), 764 g0 + imulFix ( g1, a0 ),
765 b0 + imulFix ( b1, a0 ) 765 b0 + imulFix ( b1, a0 )
766 ); 766 );
767 767
768#endif 768#endif
769 769
770 } 770 }
771 771
772#ifdef IPOL_W 772#ifdef IPOL_W
773 line.w[0] += slopeW; 773 line.w[0] += slopeW;
774#endif 774#endif
775#ifdef IPOL_T0 775#ifdef IPOL_T0
776 line.t[0][0] += slopeT[0]; 776 line.t[0][0] += slopeT[0];
777#endif 777#endif
778#ifdef IPOL_C0 778#ifdef IPOL_C0
779 line.c[0][0] += slopeC[0]; 779 line.c[0][0] += slopeC[0];
780#endif 780#endif
781 }break; 781 }break;
782 } // zcompare 782 } // zcompare
783 783
784} 784}
785 785
786/*! 786/*!
787*/ 787*/
788void CTRTextureBlend::fragment_one_minus_dst_alpha_one () 788void CTRTextureBlend::fragment_one_minus_dst_alpha_one ()
789{ 789{
790 tVideoSample *dst; 790 tVideoSample *dst;
791 791
792#ifdef USE_ZBUFFER 792#ifdef USE_ZBUFFER
793 fp24 *z; 793 fp24 *z;
794#endif 794#endif
795 795
796 s32 xStart; 796 s32 xStart;
797 s32 xEnd; 797 s32 xEnd;
798 s32 dx; 798 s32 dx;
799 799
800 800
801#ifdef SUBTEXEL 801#ifdef SUBTEXEL
802 f32 subPixel; 802 f32 subPixel;
803#endif 803#endif
804 804
805#ifdef IPOL_Z 805#ifdef IPOL_Z
806 f32 slopeZ; 806 f32 slopeZ;
807#endif 807#endif
808#ifdef IPOL_W 808#ifdef IPOL_W
809 fp24 slopeW; 809 fp24 slopeW;
810#endif 810#endif
811#ifdef IPOL_C0 811#ifdef IPOL_C0
812 sVec4 slopeC[MATERIAL_MAX_COLORS]; 812 sVec4 slopeC[MATERIAL_MAX_COLORS];
813#endif 813#endif
814#ifdef IPOL_T0 814#ifdef IPOL_T0
815 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 815 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
816#endif 816#endif
817 817
818 // apply top-left fill-convention, left 818 // apply top-left fill-convention, left
819 xStart = core::ceil32( line.x[0] ); 819 xStart = core::ceil32( line.x[0] );
820 xEnd = core::ceil32( line.x[1] ) - 1; 820 xEnd = core::ceil32( line.x[1] ) - 1;
821 821
822 dx = xEnd - xStart; 822 dx = xEnd - xStart;
823 823
824 if ( dx < 0 ) 824 if ( dx < 0 )
825 return; 825 return;
826 826
827 // slopes 827 // slopes
828 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 828 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
829 829
830#ifdef IPOL_Z 830#ifdef IPOL_Z
831 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 831 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
832#endif 832#endif
833#ifdef IPOL_W 833#ifdef IPOL_W
834 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 834 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
835#endif 835#endif
836#ifdef IPOL_C0 836#ifdef IPOL_C0
837 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 837 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
838#endif 838#endif
839#ifdef IPOL_T0 839#ifdef IPOL_T0
840 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 840 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
841#endif 841#endif
842#ifdef IPOL_T1 842#ifdef IPOL_T1
843 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 843 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
844#endif 844#endif
845 845
846#ifdef SUBTEXEL 846#ifdef SUBTEXEL
847 subPixel = ( (f32) xStart ) - line.x[0]; 847 subPixel = ( (f32) xStart ) - line.x[0];
848#ifdef IPOL_Z 848#ifdef IPOL_Z
849 line.z[0] += slopeZ * subPixel; 849 line.z[0] += slopeZ * subPixel;
850#endif 850#endif
851#ifdef IPOL_W 851#ifdef IPOL_W
852 line.w[0] += slopeW * subPixel; 852 line.w[0] += slopeW * subPixel;
853#endif 853#endif
854#ifdef IPOL_C0 854#ifdef IPOL_C0
855 line.c[0][0] += slopeC[0] * subPixel; 855 line.c[0][0] += slopeC[0] * subPixel;
856#endif 856#endif
857#ifdef IPOL_T0 857#ifdef IPOL_T0
858 line.t[0][0] += slopeT[0] * subPixel; 858 line.t[0][0] += slopeT[0] * subPixel;
859#endif 859#endif
860#ifdef IPOL_T1 860#ifdef IPOL_T1
861 line.t[1][0] += slopeT[1] * subPixel; 861 line.t[1][0] += slopeT[1] * subPixel;
862#endif 862#endif
863#endif 863#endif
864 864
865 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 865 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
866 866
867#ifdef USE_ZBUFFER 867#ifdef USE_ZBUFFER
868 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 868 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
869#endif 869#endif
870 870
871 871
872 f32 iw = FIX_POINT_F32_MUL; 872 f32 iw = FIX_POINT_F32_MUL;
873 873
874 tFixPoint r0, g0, b0; 874 tFixPoint r0, g0, b0;
875 tFixPoint a1, r1, g1, b1; 875 tFixPoint a1, r1, g1, b1;
876 tFixPoint r2, g2, b2; 876 tFixPoint r2, g2, b2;
877 877
878 s32 i; 878 s32 i;
879 879
880 switch ( ZCompare ) 880 switch ( ZCompare )
881 { 881 {
882 case 1: 882 case 1:
883 for ( i = 0; i <= dx; ++i ) 883 for ( i = 0; i <= dx; ++i )
884 { 884 {
885#ifdef CMP_W 885#ifdef CMP_W
886 if ( line.w[0] >= z[i] ) 886 if ( line.w[0] >= z[i] )
887#endif 887#endif
888 888
889 { 889 {
890 890
891#ifdef WRITE_W 891#ifdef WRITE_W
892 z[i] = line.w[0]; 892 z[i] = line.w[0];
893#endif 893#endif
894 894
895#ifdef INVERSE_W 895#ifdef INVERSE_W
896 iw = fix_inverse32 ( line.w[0] ); 896 iw = fix_inverse32 ( line.w[0] );
897#endif 897#endif
898 898
899 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 899 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
900 color_to_fix1 ( a1, r1, g1, b1, dst[i] ); 900 color_to_fix1 ( a1, r1, g1, b1, dst[i] );
901#ifdef IPOL_C0 901#ifdef IPOL_C0
902 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 902 getSample_color ( r2, g2, b2, line.c[0][0],iw );
903 903
904 a1 = FIX_POINT_ONE - a1; 904 a1 = FIX_POINT_ONE - a1;
905 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ), 905 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ),
906 imulFix ( imulFix ( g0, a1 ) + g1, g2 ), 906 imulFix ( imulFix ( g0, a1 ) + g1, g2 ),
907 imulFix ( imulFix ( b0, a1 ) + b1, b2 ) 907 imulFix ( imulFix ( b0, a1 ) + b1, b2 )
908 ); 908 );
909#else 909#else
910 dst[i] = fix_to_color ( imulFix ( r0, a1) + r0, 910 dst[i] = fix_to_color ( imulFix ( r0, a1) + r0,
911 imulFix ( g0, a1) + g0, 911 imulFix ( g0, a1) + g0,
912 imulFix ( b0, a1) + b0 912 imulFix ( b0, a1) + b0
913 ); 913 );
914 914
915#endif 915#endif
916 916
917 } 917 }
918 918
919#ifdef IPOL_W 919#ifdef IPOL_W
920 line.w[0] += slopeW; 920 line.w[0] += slopeW;
921#endif 921#endif
922#ifdef IPOL_T0 922#ifdef IPOL_T0
923 line.t[0][0] += slopeT[0]; 923 line.t[0][0] += slopeT[0];
924#endif 924#endif
925#ifdef IPOL_C0 925#ifdef IPOL_C0
926 line.c[0][0] += slopeC[0]; 926 line.c[0][0] += slopeC[0];
927#endif 927#endif
928 } 928 }
929 break; 929 break;
930 930
931 case 2: 931 case 2:
932 for ( i = 0; i <= dx; ++i ) 932 for ( i = 0; i <= dx; ++i )
933 { 933 {
934#ifdef CMP_W 934#ifdef CMP_W
935 if ( line.w[0] == z[i] ) 935 if ( line.w[0] == z[i] )
936#endif 936#endif
937 937
938 { 938 {
939 939
940#ifdef WRITE_W 940#ifdef WRITE_W
941 z[i] = line.w[0]; 941 z[i] = line.w[0];
942#endif 942#endif
943 943
944#ifdef INVERSE_W 944#ifdef INVERSE_W
945 iw = fix_inverse32 ( line.w[0] ); 945 iw = fix_inverse32 ( line.w[0] );
946#endif 946#endif
947 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 947 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
948 color_to_fix1 ( a1, r1, g1, b1, dst[i] ); 948 color_to_fix1 ( a1, r1, g1, b1, dst[i] );
949 949
950#ifdef IPOL_C0 950#ifdef IPOL_C0
951 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 951 getSample_color ( r2, g2, b2, line.c[0][0],iw );
952 952
953 a1 = FIX_POINT_ONE - a1; 953 a1 = FIX_POINT_ONE - a1;
954 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ), 954 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, a1 ) + r1, r2 ),
955 imulFix ( imulFix ( g0, a1 ) + g1, g2 ), 955 imulFix ( imulFix ( g0, a1 ) + g1, g2 ),
956 imulFix ( imulFix ( b0, a1 ) + b1, b2 ) 956 imulFix ( imulFix ( b0, a1 ) + b1, b2 )
957 ); 957 );
958#else 958#else
959 dst[i] = fix_to_color ( imulFix ( r0, a1) + r0, 959 dst[i] = fix_to_color ( imulFix ( r0, a1) + r0,
960 imulFix ( g0, a1) + g0, 960 imulFix ( g0, a1) + g0,
961 imulFix ( b0, a1) + b0 961 imulFix ( b0, a1) + b0
962 ); 962 );
963 963
964#endif 964#endif
965 965
966 } 966 }
967 967
968#ifdef IPOL_W 968#ifdef IPOL_W
969 line.w[0] += slopeW; 969 line.w[0] += slopeW;
970#endif 970#endif
971#ifdef IPOL_T0 971#ifdef IPOL_T0
972 line.t[0][0] += slopeT[0]; 972 line.t[0][0] += slopeT[0];
973#endif 973#endif
974#ifdef IPOL_C0 974#ifdef IPOL_C0
975 line.c[0][0] += slopeC[0]; 975 line.c[0][0] += slopeC[0];
976#endif 976#endif
977 }break; 977 }break;
978 } // zcompare 978 } // zcompare
979 979
980} 980}
981 981
982/*! 982/*!
983*/ 983*/
984void CTRTextureBlend::fragment_src_alpha_one () 984void CTRTextureBlend::fragment_src_alpha_one ()
985{ 985{
986 tVideoSample *dst; 986 tVideoSample *dst;
987 987
988#ifdef USE_ZBUFFER 988#ifdef USE_ZBUFFER
989 fp24 *z; 989 fp24 *z;
990#endif 990#endif
991 991
992 s32 xStart; 992 s32 xStart;
993 s32 xEnd; 993 s32 xEnd;
994 s32 dx; 994 s32 dx;
995 995
996 996
997#ifdef SUBTEXEL 997#ifdef SUBTEXEL
998 f32 subPixel; 998 f32 subPixel;
999#endif 999#endif
1000 1000
1001#ifdef IPOL_Z 1001#ifdef IPOL_Z
1002 f32 slopeZ; 1002 f32 slopeZ;
1003#endif 1003#endif
1004#ifdef IPOL_W 1004#ifdef IPOL_W
1005 fp24 slopeW; 1005 fp24 slopeW;
1006#endif 1006#endif
1007#ifdef IPOL_C0 1007#ifdef IPOL_C0
1008 sVec4 slopeC[MATERIAL_MAX_COLORS]; 1008 sVec4 slopeC[MATERIAL_MAX_COLORS];
1009#endif 1009#endif
1010#ifdef IPOL_T0 1010#ifdef IPOL_T0
1011 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 1011 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
1012#endif 1012#endif
1013 1013
1014 // apply top-left fill-convention, left 1014 // apply top-left fill-convention, left
1015 xStart = core::ceil32( line.x[0] ); 1015 xStart = core::ceil32( line.x[0] );
1016 xEnd = core::ceil32( line.x[1] ) - 1; 1016 xEnd = core::ceil32( line.x[1] ) - 1;
1017 1017
1018 dx = xEnd - xStart; 1018 dx = xEnd - xStart;
1019 1019
1020 if ( dx < 0 ) 1020 if ( dx < 0 )
1021 return; 1021 return;
1022 1022
1023 // slopes 1023 // slopes
1024 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 1024 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
1025 1025
1026#ifdef IPOL_Z 1026#ifdef IPOL_Z
1027 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 1027 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
1028#endif 1028#endif
1029#ifdef IPOL_W 1029#ifdef IPOL_W
1030 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 1030 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
1031#endif 1031#endif
1032#ifdef IPOL_C0 1032#ifdef IPOL_C0
1033 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 1033 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
1034#endif 1034#endif
1035#ifdef IPOL_T0 1035#ifdef IPOL_T0
1036 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 1036 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
1037#endif 1037#endif
1038#ifdef IPOL_T1 1038#ifdef IPOL_T1
1039 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 1039 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
1040#endif 1040#endif
1041 1041
1042#ifdef SUBTEXEL 1042#ifdef SUBTEXEL
1043 subPixel = ( (f32) xStart ) - line.x[0]; 1043 subPixel = ( (f32) xStart ) - line.x[0];
1044#ifdef IPOL_Z 1044#ifdef IPOL_Z
1045 line.z[0] += slopeZ * subPixel; 1045 line.z[0] += slopeZ * subPixel;
1046#endif 1046#endif
1047#ifdef IPOL_W 1047#ifdef IPOL_W
1048 line.w[0] += slopeW * subPixel; 1048 line.w[0] += slopeW * subPixel;
1049#endif 1049#endif
1050#ifdef IPOL_C0 1050#ifdef IPOL_C0
1051 line.c[0][0] += slopeC[0] * subPixel; 1051 line.c[0][0] += slopeC[0] * subPixel;
1052#endif 1052#endif
1053#ifdef IPOL_T0 1053#ifdef IPOL_T0
1054 line.t[0][0] += slopeT[0] * subPixel; 1054 line.t[0][0] += slopeT[0] * subPixel;
1055#endif 1055#endif
1056#ifdef IPOL_T1 1056#ifdef IPOL_T1
1057 line.t[1][0] += slopeT[1] * subPixel; 1057 line.t[1][0] += slopeT[1] * subPixel;
1058#endif 1058#endif
1059#endif 1059#endif
1060 1060
1061 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1061 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1062 1062
1063#ifdef USE_ZBUFFER 1063#ifdef USE_ZBUFFER
1064 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1064 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1065#endif 1065#endif
1066 1066
1067 1067
1068 f32 iw = FIX_POINT_F32_MUL; 1068 f32 iw = FIX_POINT_F32_MUL;
1069 1069
1070 tFixPoint a0, r0, g0, b0; 1070 tFixPoint a0, r0, g0, b0;
1071 tFixPoint r1, g1, b1; 1071 tFixPoint r1, g1, b1;
1072 tFixPoint r2, g2, b2; 1072 tFixPoint r2, g2, b2;
1073 1073
1074 s32 i; 1074 s32 i;
1075 1075
1076 switch ( ZCompare ) 1076 switch ( ZCompare )
1077 { 1077 {
1078 case 1: 1078 case 1:
1079 for ( i = 0; i <= dx; ++i ) 1079 for ( i = 0; i <= dx; ++i )
1080 { 1080 {
1081#ifdef CMP_W 1081#ifdef CMP_W
1082 if ( line.w[0] >= z[i] ) 1082 if ( line.w[0] >= z[i] )
1083#endif 1083#endif
1084 1084
1085 { 1085 {
1086 1086
1087 1087
1088#ifdef INVERSE_W 1088#ifdef INVERSE_W
1089 iw = fix_inverse32 ( line.w[0] ); 1089 iw = fix_inverse32 ( line.w[0] );
1090#endif 1090#endif
1091 1091
1092 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1092 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1093 if ( a0 > 0 ) 1093 if ( a0 > 0 )
1094 { 1094 {
1095 a0 >>= 8; 1095 a0 >>= 8;
1096 1096
1097 color_to_fix ( r1, g1, b1, dst[i] ); 1097 color_to_fix ( r1, g1, b1, dst[i] );
1098 1098
1099#ifdef IPOL_C0 1099#ifdef IPOL_C0
1100 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1100 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1101 1101
1102 dst[i] = fix4_to_color ( a0, 1102 dst[i] = fix4_to_color ( a0,
1103 clampfix_maxcolor ( imulFix (r0,a0 ) + r1), 1103 clampfix_maxcolor ( imulFix (r0,a0 ) + r1),
1104 clampfix_maxcolor ( imulFix (g0,a0 ) + g1), 1104 clampfix_maxcolor ( imulFix (g0,a0 ) + g1),
1105 clampfix_maxcolor ( imulFix (b0,a0 ) + b1) 1105 clampfix_maxcolor ( imulFix (b0,a0 ) + b1)
1106 ); 1106 );
1107 1107
1108/* 1108/*
1109 a0 >>= 8; 1109 a0 >>= 8;
1110 dst[i] = fix4_to_color ( a0, 1110 dst[i] = fix4_to_color ( a0,
1111 imulFix ( imulFix ( r0, a0 ) + r1, r2 ), 1111 imulFix ( imulFix ( r0, a0 ) + r1, r2 ),
1112 imulFix ( imulFix ( g0, a0 ) + g1, g2 ), 1112 imulFix ( imulFix ( g0, a0 ) + g1, g2 ),
1113 imulFix ( imulFix ( b0, a0 ) + b1, b2 ) 1113 imulFix ( imulFix ( b0, a0 ) + b1, b2 )
1114 ); 1114 );
1115*/ 1115*/
1116#else 1116#else
1117 dst[i] = fix4_to_color ( a0, 1117 dst[i] = fix4_to_color ( a0,
1118 clampfix_maxcolor ( imulFix (r0,a0 ) + r1 ), 1118 clampfix_maxcolor ( imulFix (r0,a0 ) + r1 ),
1119 clampfix_maxcolor ( imulFix (g0,a0 ) + g1 ), 1119 clampfix_maxcolor ( imulFix (g0,a0 ) + g1 ),
1120 clampfix_maxcolor ( imulFix (b0,a0 ) + b1 ) 1120 clampfix_maxcolor ( imulFix (b0,a0 ) + b1 )
1121 ); 1121 );
1122 1122
1123#endif 1123#endif
1124 1124
1125#ifdef WRITE_W 1125#ifdef WRITE_W
1126 //z[i] = line.w[0]; 1126 //z[i] = line.w[0];
1127#endif 1127#endif
1128 } 1128 }
1129 1129
1130 } 1130 }
1131 1131
1132#ifdef IPOL_W 1132#ifdef IPOL_W
1133 line.w[0] += slopeW; 1133 line.w[0] += slopeW;
1134#endif 1134#endif
1135#ifdef IPOL_T0 1135#ifdef IPOL_T0
1136 line.t[0][0] += slopeT[0]; 1136 line.t[0][0] += slopeT[0];
1137#endif 1137#endif
1138#ifdef IPOL_C0 1138#ifdef IPOL_C0
1139 line.c[0][0] += slopeC[0]; 1139 line.c[0][0] += slopeC[0];
1140#endif 1140#endif
1141 } 1141 }
1142 break; 1142 break;
1143 1143
1144 case 2: 1144 case 2:
1145 for ( i = 0; i <= dx; ++i ) 1145 for ( i = 0; i <= dx; ++i )
1146 { 1146 {
1147#ifdef CMP_W 1147#ifdef CMP_W
1148 if ( line.w[0] == z[i] ) 1148 if ( line.w[0] == z[i] )
1149#endif 1149#endif
1150 { 1150 {
1151 1151
1152#ifdef INVERSE_W 1152#ifdef INVERSE_W
1153 iw = fix_inverse32 ( line.w[0] ); 1153 iw = fix_inverse32 ( line.w[0] );
1154#endif 1154#endif
1155 1155
1156 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1156 getSample_texture ( a0, r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1157 if ( a0 > 0 ) 1157 if ( a0 > 0 )
1158 { 1158 {
1159 a0 >>= 8; 1159 a0 >>= 8;
1160 1160
1161 color_to_fix ( r1, g1, b1, dst[i] ); 1161 color_to_fix ( r1, g1, b1, dst[i] );
1162 1162
1163#ifdef IPOL_C0 1163#ifdef IPOL_C0
1164 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1164 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1165 1165
1166 dst[i] = fix4_to_color ( a0, 1166 dst[i] = fix4_to_color ( a0,
1167 clampfix_maxcolor ( imulFix ( imulFix (r0,a0 ) + r1, r2 ) ), 1167 clampfix_maxcolor ( imulFix ( imulFix (r0,a0 ) + r1, r2 ) ),
1168 clampfix_maxcolor ( imulFix ( imulFix (g0,a0 ) + g1, g2 ) ), 1168 clampfix_maxcolor ( imulFix ( imulFix (g0,a0 ) + g1, g2 ) ),
1169 clampfix_maxcolor ( imulFix ( imulFix (b0,a0 ) + b1, b2 ) ) 1169 clampfix_maxcolor ( imulFix ( imulFix (b0,a0 ) + b1, b2 ) )
1170 ); 1170 );
1171 1171
1172/* 1172/*
1173 a0 >>= 8; 1173 a0 >>= 8;
1174 dst[i] = fix4_to_color ( a0, 1174 dst[i] = fix4_to_color ( a0,
1175 imulFix ( imulFix ( r0, a0 ) + r1, r2 ), 1175 imulFix ( imulFix ( r0, a0 ) + r1, r2 ),
1176 imulFix ( imulFix ( g0, a0 ) + g1, g2 ), 1176 imulFix ( imulFix ( g0, a0 ) + g1, g2 ),
1177 imulFix ( imulFix ( b0, a0 ) + b1, b2 ) 1177 imulFix ( imulFix ( b0, a0 ) + b1, b2 )
1178 ); 1178 );
1179*/ 1179*/
1180#else 1180#else
1181 dst[i] = fix4_to_color ( a0, 1181 dst[i] = fix4_to_color ( a0,
1182 clampfix_maxcolor ( imulFix (r0,a0 ) + r1 ), 1182 clampfix_maxcolor ( imulFix (r0,a0 ) + r1 ),
1183 clampfix_maxcolor ( imulFix (g0,a0 ) + g1 ), 1183 clampfix_maxcolor ( imulFix (g0,a0 ) + g1 ),
1184 clampfix_maxcolor ( imulFix (b0,a0 ) + b1 ) 1184 clampfix_maxcolor ( imulFix (b0,a0 ) + b1 )
1185 ); 1185 );
1186 1186
1187#endif 1187#endif
1188 1188
1189#ifdef WRITE_W 1189#ifdef WRITE_W
1190 z[i] = line.w[0]; 1190 z[i] = line.w[0];
1191#endif 1191#endif
1192 } 1192 }
1193 } 1193 }
1194#ifdef IPOL_W 1194#ifdef IPOL_W
1195 line.w[0] += slopeW; 1195 line.w[0] += slopeW;
1196#endif 1196#endif
1197#ifdef IPOL_T0 1197#ifdef IPOL_T0
1198 line.t[0][0] += slopeT[0]; 1198 line.t[0][0] += slopeT[0];
1199#endif 1199#endif
1200#ifdef IPOL_C0 1200#ifdef IPOL_C0
1201 line.c[0][0] += slopeC[0]; 1201 line.c[0][0] += slopeC[0];
1202#endif 1202#endif
1203 }break; 1203 }break;
1204 } // zcompare 1204 } // zcompare
1205 1205
1206} 1206}
1207 1207
1208 1208
1209/*! 1209/*!
1210*/ 1210*/
1211void CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha () 1211void CTRTextureBlend::fragment_dst_color_one_minus_dst_alpha ()
1212{ 1212{
1213 tVideoSample *dst; 1213 tVideoSample *dst;
1214 1214
1215#ifdef USE_ZBUFFER 1215#ifdef USE_ZBUFFER
1216 fp24 *z; 1216 fp24 *z;
1217#endif 1217#endif
1218 1218
1219 s32 xStart; 1219 s32 xStart;
1220 s32 xEnd; 1220 s32 xEnd;
1221 s32 dx; 1221 s32 dx;
1222 1222
1223 1223
1224#ifdef SUBTEXEL 1224#ifdef SUBTEXEL
1225 f32 subPixel; 1225 f32 subPixel;
1226#endif 1226#endif
1227 1227
1228#ifdef IPOL_Z 1228#ifdef IPOL_Z
1229 f32 slopeZ; 1229 f32 slopeZ;
1230#endif 1230#endif
1231#ifdef IPOL_W 1231#ifdef IPOL_W
1232 fp24 slopeW; 1232 fp24 slopeW;
1233#endif 1233#endif
1234#ifdef IPOL_C0 1234#ifdef IPOL_C0
1235 sVec4 slopeC[MATERIAL_MAX_COLORS]; 1235 sVec4 slopeC[MATERIAL_MAX_COLORS];
1236#endif 1236#endif
1237#ifdef IPOL_T0 1237#ifdef IPOL_T0
1238 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 1238 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
1239#endif 1239#endif
1240 1240
1241 // apply top-left fill-convention, left 1241 // apply top-left fill-convention, left
1242 xStart = core::ceil32( line.x[0] ); 1242 xStart = core::ceil32( line.x[0] );
1243 xEnd = core::ceil32( line.x[1] ) - 1; 1243 xEnd = core::ceil32( line.x[1] ) - 1;
1244 1244
1245 dx = xEnd - xStart; 1245 dx = xEnd - xStart;
1246 1246
1247 if ( dx < 0 ) 1247 if ( dx < 0 )
1248 return; 1248 return;
1249 1249
1250 // slopes 1250 // slopes
1251 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 1251 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
1252 1252
1253#ifdef IPOL_Z 1253#ifdef IPOL_Z
1254 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 1254 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
1255#endif 1255#endif
1256#ifdef IPOL_W 1256#ifdef IPOL_W
1257 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 1257 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
1258#endif 1258#endif
1259#ifdef IPOL_C0 1259#ifdef IPOL_C0
1260 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 1260 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
1261#endif 1261#endif
1262#ifdef IPOL_T0 1262#ifdef IPOL_T0
1263 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 1263 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
1264#endif 1264#endif
1265#ifdef IPOL_T1 1265#ifdef IPOL_T1
1266 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 1266 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
1267#endif 1267#endif
1268 1268
1269#ifdef SUBTEXEL 1269#ifdef SUBTEXEL
1270 subPixel = ( (f32) xStart ) - line.x[0]; 1270 subPixel = ( (f32) xStart ) - line.x[0];
1271#ifdef IPOL_Z 1271#ifdef IPOL_Z
1272 line.z[0] += slopeZ * subPixel; 1272 line.z[0] += slopeZ * subPixel;
1273#endif 1273#endif
1274#ifdef IPOL_W 1274#ifdef IPOL_W
1275 line.w[0] += slopeW * subPixel; 1275 line.w[0] += slopeW * subPixel;
1276#endif 1276#endif
1277#ifdef IPOL_C0 1277#ifdef IPOL_C0
1278 line.c[0][0] += slopeC[0] * subPixel; 1278 line.c[0][0] += slopeC[0] * subPixel;
1279#endif 1279#endif
1280#ifdef IPOL_T0 1280#ifdef IPOL_T0
1281 line.t[0][0] += slopeT[0] * subPixel; 1281 line.t[0][0] += slopeT[0] * subPixel;
1282#endif 1282#endif
1283#ifdef IPOL_T1 1283#ifdef IPOL_T1
1284 line.t[1][0] += slopeT[1] * subPixel; 1284 line.t[1][0] += slopeT[1] * subPixel;
1285#endif 1285#endif
1286#endif 1286#endif
1287 1287
1288 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1288 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1289 1289
1290#ifdef USE_ZBUFFER 1290#ifdef USE_ZBUFFER
1291 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1291 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1292#endif 1292#endif
1293 1293
1294 1294
1295 f32 iw = FIX_POINT_F32_MUL; 1295 f32 iw = FIX_POINT_F32_MUL;
1296 1296
1297 tFixPoint r0, g0, b0; 1297 tFixPoint r0, g0, b0;
1298 tFixPoint a1, r1, g1, b1; 1298 tFixPoint a1, r1, g1, b1;
1299 tFixPoint r2, g2, b2; 1299 tFixPoint r2, g2, b2;
1300 1300
1301 s32 i; 1301 s32 i;
1302 1302
1303 switch ( ZCompare ) 1303 switch ( ZCompare )
1304 { 1304 {
1305 case 1: 1305 case 1:
1306 for ( i = 0; i <= dx; ++i ) 1306 for ( i = 0; i <= dx; ++i )
1307 { 1307 {
1308#ifdef CMP_W 1308#ifdef CMP_W
1309 if ( line.w[0] >= z[i] ) 1309 if ( line.w[0] >= z[i] )
1310#endif 1310#endif
1311 1311
1312 { 1312 {
1313 1313
1314#ifdef WRITE_W 1314#ifdef WRITE_W
1315 z[i] = line.w[0]; 1315 z[i] = line.w[0];
1316#endif 1316#endif
1317 1317
1318#ifdef INVERSE_W 1318#ifdef INVERSE_W
1319 iw = fix_inverse32 ( line.w[0] ); 1319 iw = fix_inverse32 ( line.w[0] );
1320#endif 1320#endif
1321 1321
1322 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1322 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1323 color_to_fix1 ( a1, r1, g1, b1, dst[i] ); 1323 color_to_fix1 ( a1, r1, g1, b1, dst[i] );
1324#ifdef IPOL_C0 1324#ifdef IPOL_C0
1325 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1325 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1326 1326
1327 a1 = FIX_POINT_ONE - a1; 1327 a1 = FIX_POINT_ONE - a1;
1328 dst[i] = fix_to_color ( imulFix ( imulFix ( r1, r0 + a1 ), r2 ), 1328 dst[i] = fix_to_color ( imulFix ( imulFix ( r1, r0 + a1 ), r2 ),
1329 imulFix ( imulFix ( g1, g0 + a1 ), g2 ), 1329 imulFix ( imulFix ( g1, g0 + a1 ), g2 ),
1330 imulFix ( imulFix ( b1, b0 + a1 ), b2 ) 1330 imulFix ( imulFix ( b1, b0 + a1 ), b2 )
1331 ); 1331 );
1332#else 1332#else
1333 dst[i] = fix_to_color ( imulFix ( r1, r0 + a1 ), 1333 dst[i] = fix_to_color ( imulFix ( r1, r0 + a1 ),
1334 imulFix ( g1, g0 + a1 ), 1334 imulFix ( g1, g0 + a1 ),
1335 imulFix ( b1, b0 + a1 ) 1335 imulFix ( b1, b0 + a1 )
1336 ); 1336 );
1337 1337
1338#endif 1338#endif
1339 1339
1340 } 1340 }
1341 1341
1342#ifdef IPOL_W 1342#ifdef IPOL_W
1343 line.w[0] += slopeW; 1343 line.w[0] += slopeW;
1344#endif 1344#endif
1345#ifdef IPOL_T0 1345#ifdef IPOL_T0
1346 line.t[0][0] += slopeT[0]; 1346 line.t[0][0] += slopeT[0];
1347#endif 1347#endif
1348#ifdef IPOL_C0 1348#ifdef IPOL_C0
1349 line.c[0][0] += slopeC[0]; 1349 line.c[0][0] += slopeC[0];
1350#endif 1350#endif
1351 } 1351 }
1352 break; 1352 break;
1353 1353
1354 case 2: 1354 case 2:
1355 for ( i = 0; i <= dx; ++i ) 1355 for ( i = 0; i <= dx; ++i )
1356 { 1356 {
1357#ifdef CMP_W 1357#ifdef CMP_W
1358 if ( line.w[0] == z[i] ) 1358 if ( line.w[0] == z[i] )
1359#endif 1359#endif
1360 1360
1361 { 1361 {
1362 1362
1363#ifdef WRITE_W 1363#ifdef WRITE_W
1364 z[i] = line.w[0]; 1364 z[i] = line.w[0];
1365#endif 1365#endif
1366 1366
1367#ifdef INVERSE_W 1367#ifdef INVERSE_W
1368 iw = fix_inverse32 ( line.w[0] ); 1368 iw = fix_inverse32 ( line.w[0] );
1369#endif 1369#endif
1370 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1370 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1371 color_to_fix1 ( a1, r1, g1, b1, dst[i] ); 1371 color_to_fix1 ( a1, r1, g1, b1, dst[i] );
1372 1372
1373#ifdef IPOL_C0 1373#ifdef IPOL_C0
1374 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1374 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1375 1375
1376 a1 = FIX_POINT_ONE - a1; 1376 a1 = FIX_POINT_ONE - a1;
1377 dst[i] = fix_to_color ( imulFix ( imulFix ( r1, r0 + a1 ), r2 ), 1377 dst[i] = fix_to_color ( imulFix ( imulFix ( r1, r0 + a1 ), r2 ),
1378 imulFix ( imulFix ( g1, g0 + a1 ), g2 ), 1378 imulFix ( imulFix ( g1, g0 + a1 ), g2 ),
1379 imulFix ( imulFix ( b1, b0 + a1 ), b2 ) 1379 imulFix ( imulFix ( b1, b0 + a1 ), b2 )
1380 ); 1380 );
1381#else 1381#else
1382 dst[i] = fix_to_color ( imulFix ( r1, r0 + a1 ), 1382 dst[i] = fix_to_color ( imulFix ( r1, r0 + a1 ),
1383 imulFix ( g1, g0 + a1 ), 1383 imulFix ( g1, g0 + a1 ),
1384 imulFix ( b1, b0 + a1 ) 1384 imulFix ( b1, b0 + a1 )
1385 ); 1385 );
1386 1386
1387#endif 1387#endif
1388 1388
1389 } 1389 }
1390 1390
1391#ifdef IPOL_W 1391#ifdef IPOL_W
1392 line.w[0] += slopeW; 1392 line.w[0] += slopeW;
1393#endif 1393#endif
1394#ifdef IPOL_T0 1394#ifdef IPOL_T0
1395 line.t[0][0] += slopeT[0]; 1395 line.t[0][0] += slopeT[0];
1396#endif 1396#endif
1397#ifdef IPOL_C0 1397#ifdef IPOL_C0
1398 line.c[0][0] += slopeC[0]; 1398 line.c[0][0] += slopeC[0];
1399#endif 1399#endif
1400 }break; 1400 }break;
1401 } // zcompare 1401 } // zcompare
1402 1402
1403} 1403}
1404 1404
1405/*! 1405/*!
1406*/ 1406*/
1407void CTRTextureBlend::fragment_dst_color_zero () 1407void CTRTextureBlend::fragment_dst_color_zero ()
1408{ 1408{
1409 tVideoSample *dst; 1409 tVideoSample *dst;
1410 1410
1411#ifdef USE_ZBUFFER 1411#ifdef USE_ZBUFFER
1412 fp24 *z; 1412 fp24 *z;
1413#endif 1413#endif
1414 1414
1415 s32 xStart; 1415 s32 xStart;
1416 s32 xEnd; 1416 s32 xEnd;
1417 s32 dx; 1417 s32 dx;
1418 1418
1419 1419
1420#ifdef SUBTEXEL 1420#ifdef SUBTEXEL
1421 f32 subPixel; 1421 f32 subPixel;
1422#endif 1422#endif
1423 1423
1424#ifdef IPOL_Z 1424#ifdef IPOL_Z
1425 f32 slopeZ; 1425 f32 slopeZ;
1426#endif 1426#endif
1427#ifdef IPOL_W 1427#ifdef IPOL_W
1428 fp24 slopeW; 1428 fp24 slopeW;
1429#endif 1429#endif
1430#ifdef IPOL_C0 1430#ifdef IPOL_C0
1431 sVec4 slopeC[MATERIAL_MAX_COLORS]; 1431 sVec4 slopeC[MATERIAL_MAX_COLORS];
1432#endif 1432#endif
1433#ifdef IPOL_T0 1433#ifdef IPOL_T0
1434 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 1434 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
1435#endif 1435#endif
1436 1436
1437 // apply top-left fill-convention, left 1437 // apply top-left fill-convention, left
1438 xStart = core::ceil32( line.x[0] ); 1438 xStart = core::ceil32( line.x[0] );
1439 xEnd = core::ceil32( line.x[1] ) - 1; 1439 xEnd = core::ceil32( line.x[1] ) - 1;
1440 1440
1441 dx = xEnd - xStart; 1441 dx = xEnd - xStart;
1442 1442
1443 if ( dx < 0 ) 1443 if ( dx < 0 )
1444 return; 1444 return;
1445 1445
1446 // slopes 1446 // slopes
1447 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 1447 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
1448 1448
1449#ifdef IPOL_Z 1449#ifdef IPOL_Z
1450 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 1450 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
1451#endif 1451#endif
1452#ifdef IPOL_W 1452#ifdef IPOL_W
1453 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 1453 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
1454#endif 1454#endif
1455#ifdef IPOL_C0 1455#ifdef IPOL_C0
1456 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 1456 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
1457#endif 1457#endif
1458#ifdef IPOL_T0 1458#ifdef IPOL_T0
1459 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 1459 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
1460#endif 1460#endif
1461#ifdef IPOL_T1 1461#ifdef IPOL_T1
1462 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 1462 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
1463#endif 1463#endif
1464 1464
1465#ifdef SUBTEXEL 1465#ifdef SUBTEXEL
1466 subPixel = ( (f32) xStart ) - line.x[0]; 1466 subPixel = ( (f32) xStart ) - line.x[0];
1467#ifdef IPOL_Z 1467#ifdef IPOL_Z
1468 line.z[0] += slopeZ * subPixel; 1468 line.z[0] += slopeZ * subPixel;
1469#endif 1469#endif
1470#ifdef IPOL_W 1470#ifdef IPOL_W
1471 line.w[0] += slopeW * subPixel; 1471 line.w[0] += slopeW * subPixel;
1472#endif 1472#endif
1473#ifdef IPOL_C0 1473#ifdef IPOL_C0
1474 line.c[0][0] += slopeC[0] * subPixel; 1474 line.c[0][0] += slopeC[0] * subPixel;
1475#endif 1475#endif
1476#ifdef IPOL_T0 1476#ifdef IPOL_T0
1477 line.t[0][0] += slopeT[0] * subPixel; 1477 line.t[0][0] += slopeT[0] * subPixel;
1478#endif 1478#endif
1479#ifdef IPOL_T1 1479#ifdef IPOL_T1
1480 line.t[1][0] += slopeT[1] * subPixel; 1480 line.t[1][0] += slopeT[1] * subPixel;
1481#endif 1481#endif
1482#endif 1482#endif
1483 1483
1484 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1484 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1485 1485
1486#ifdef USE_ZBUFFER 1486#ifdef USE_ZBUFFER
1487 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1487 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1488#endif 1488#endif
1489 1489
1490 1490
1491 f32 iw = FIX_POINT_F32_MUL; 1491 f32 iw = FIX_POINT_F32_MUL;
1492 1492
1493 tFixPoint r0, g0, b0; 1493 tFixPoint r0, g0, b0;
1494 tFixPoint r1, g1, b1; 1494 tFixPoint r1, g1, b1;
1495 tFixPoint r2, g2, b2; 1495 tFixPoint r2, g2, b2;
1496 1496
1497 s32 i; 1497 s32 i;
1498 1498
1499 switch ( ZCompare ) 1499 switch ( ZCompare )
1500 { 1500 {
1501 case 1: 1501 case 1:
1502 for ( i = 0; i <= dx; ++i ) 1502 for ( i = 0; i <= dx; ++i )
1503 { 1503 {
1504#ifdef CMP_W 1504#ifdef CMP_W
1505 if ( line.w[0] >= z[i] ) 1505 if ( line.w[0] >= z[i] )
1506#endif 1506#endif
1507 1507
1508 { 1508 {
1509 1509
1510#ifdef WRITE_W 1510#ifdef WRITE_W
1511 z[i] = line.w[0]; 1511 z[i] = line.w[0];
1512#endif 1512#endif
1513 1513
1514#ifdef INVERSE_W 1514#ifdef INVERSE_W
1515 iw = fix_inverse32 ( line.w[0] ); 1515 iw = fix_inverse32 ( line.w[0] );
1516#endif 1516#endif
1517 1517
1518 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1518 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1519 color_to_fix1 ( r1, g1, b1, dst[i] ); 1519 color_to_fix1 ( r1, g1, b1, dst[i] );
1520 1520
1521#ifdef IPOL_C0 1521#ifdef IPOL_C0
1522 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1522 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1523 1523
1524 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, r1 ), r2 ), 1524 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, r1 ), r2 ),
1525 imulFix ( imulFix ( g0, g1 ), g2 ), 1525 imulFix ( imulFix ( g0, g1 ), g2 ),
1526 imulFix ( imulFix ( b0, b1 ), b2 ) ); 1526 imulFix ( imulFix ( b0, b1 ), b2 ) );
1527#else 1527#else
1528 dst[i] = fix_to_color ( imulFix ( r0, r1 ), 1528 dst[i] = fix_to_color ( imulFix ( r0, r1 ),
1529 imulFix ( g0, g1 ), 1529 imulFix ( g0, g1 ),
1530 imulFix ( b0, b1 ) 1530 imulFix ( b0, b1 )
1531 ); 1531 );
1532 1532
1533#endif 1533#endif
1534 1534
1535 } 1535 }
1536 1536
1537#ifdef IPOL_W 1537#ifdef IPOL_W
1538 line.w[0] += slopeW; 1538 line.w[0] += slopeW;
1539#endif 1539#endif
1540#ifdef IPOL_T0 1540#ifdef IPOL_T0
1541 line.t[0][0] += slopeT[0]; 1541 line.t[0][0] += slopeT[0];
1542#endif 1542#endif
1543#ifdef IPOL_C0 1543#ifdef IPOL_C0
1544 line.c[0][0] += slopeC[0]; 1544 line.c[0][0] += slopeC[0];
1545#endif 1545#endif
1546 } 1546 }
1547 break; 1547 break;
1548 1548
1549 case 2: 1549 case 2:
1550 for ( i = 0; i <= dx; ++i ) 1550 for ( i = 0; i <= dx; ++i )
1551 { 1551 {
1552#ifdef CMP_W 1552#ifdef CMP_W
1553 if ( line.w[0] == z[i] ) 1553 if ( line.w[0] == z[i] )
1554#endif 1554#endif
1555 1555
1556 { 1556 {
1557 1557
1558#ifdef WRITE_W 1558#ifdef WRITE_W
1559 z[i] = line.w[0]; 1559 z[i] = line.w[0];
1560#endif 1560#endif
1561 1561
1562#ifdef INVERSE_W 1562#ifdef INVERSE_W
1563 iw = fix_inverse32 ( line.w[0] ); 1563 iw = fix_inverse32 ( line.w[0] );
1564#endif 1564#endif
1565 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1565 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1566 color_to_fix1 ( r1, g1, b1, dst[i] ); 1566 color_to_fix1 ( r1, g1, b1, dst[i] );
1567 1567
1568#ifdef IPOL_C0 1568#ifdef IPOL_C0
1569 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1569 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1570 1570
1571 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, r1 ), r2 ), 1571 dst[i] = fix_to_color ( imulFix ( imulFix ( r0, r1 ), r2 ),
1572 imulFix ( imulFix ( g0, g1 ), g2 ), 1572 imulFix ( imulFix ( g0, g1 ), g2 ),
1573 imulFix ( imulFix ( b0, b1 ), b2 ) 1573 imulFix ( imulFix ( b0, b1 ), b2 )
1574 ); 1574 );
1575#else 1575#else
1576 dst[i] = fix_to_color ( imulFix ( r0, r1 ), 1576 dst[i] = fix_to_color ( imulFix ( r0, r1 ),
1577 imulFix ( g0, g1 ), 1577 imulFix ( g0, g1 ),
1578 imulFix ( b0, b1 ) 1578 imulFix ( b0, b1 )
1579 ); 1579 );
1580 1580
1581#endif 1581#endif
1582 1582
1583 } 1583 }
1584 1584
1585#ifdef IPOL_W 1585#ifdef IPOL_W
1586 line.w[0] += slopeW; 1586 line.w[0] += slopeW;
1587#endif 1587#endif
1588#ifdef IPOL_T0 1588#ifdef IPOL_T0
1589 line.t[0][0] += slopeT[0]; 1589 line.t[0][0] += slopeT[0];
1590#endif 1590#endif
1591#ifdef IPOL_C0 1591#ifdef IPOL_C0
1592 line.c[0][0] += slopeC[0]; 1592 line.c[0][0] += slopeC[0];
1593#endif 1593#endif
1594 }break; 1594 }break;
1595 } // zcompare 1595 } // zcompare
1596 1596
1597} 1597}
1598 1598
1599/*! 1599/*!
1600*/ 1600*/
1601void CTRTextureBlend::fragment_dst_color_one () 1601void CTRTextureBlend::fragment_dst_color_one ()
1602{ 1602{
1603 tVideoSample *dst; 1603 tVideoSample *dst;
1604 1604
1605#ifdef USE_ZBUFFER 1605#ifdef USE_ZBUFFER
1606 fp24 *z; 1606 fp24 *z;
1607#endif 1607#endif
1608 1608
1609 s32 xStart; 1609 s32 xStart;
1610 s32 xEnd; 1610 s32 xEnd;
1611 s32 dx; 1611 s32 dx;
1612 1612
1613 1613
1614#ifdef SUBTEXEL 1614#ifdef SUBTEXEL
1615 f32 subPixel; 1615 f32 subPixel;
1616#endif 1616#endif
1617 1617
1618#ifdef IPOL_Z 1618#ifdef IPOL_Z
1619 f32 slopeZ; 1619 f32 slopeZ;
1620#endif 1620#endif
1621#ifdef IPOL_W 1621#ifdef IPOL_W
1622 fp24 slopeW; 1622 fp24 slopeW;
1623#endif 1623#endif
1624#ifdef IPOL_C0 1624#ifdef IPOL_C0
1625 sVec4 slopeC[MATERIAL_MAX_COLORS]; 1625 sVec4 slopeC[MATERIAL_MAX_COLORS];
1626#endif 1626#endif
1627#ifdef IPOL_T0 1627#ifdef IPOL_T0
1628 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 1628 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
1629#endif 1629#endif
1630 1630
1631 // apply top-left fill-convention, left 1631 // apply top-left fill-convention, left
1632 xStart = core::ceil32( line.x[0] ); 1632 xStart = core::ceil32( line.x[0] );
1633 xEnd = core::ceil32( line.x[1] ) - 1; 1633 xEnd = core::ceil32( line.x[1] ) - 1;
1634 1634
1635 dx = xEnd - xStart; 1635 dx = xEnd - xStart;
1636 1636
1637 if ( dx < 0 ) 1637 if ( dx < 0 )
1638 return; 1638 return;
1639 1639
1640 // slopes 1640 // slopes
1641 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 1641 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
1642 1642
1643#ifdef IPOL_Z 1643#ifdef IPOL_Z
1644 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 1644 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
1645#endif 1645#endif
1646#ifdef IPOL_W 1646#ifdef IPOL_W
1647 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 1647 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
1648#endif 1648#endif
1649#ifdef IPOL_C0 1649#ifdef IPOL_C0
1650 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 1650 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
1651#endif 1651#endif
1652#ifdef IPOL_T0 1652#ifdef IPOL_T0
1653 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 1653 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
1654#endif 1654#endif
1655#ifdef IPOL_T1 1655#ifdef IPOL_T1
1656 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 1656 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
1657#endif 1657#endif
1658 1658
1659#ifdef SUBTEXEL 1659#ifdef SUBTEXEL
1660 subPixel = ( (f32) xStart ) - line.x[0]; 1660 subPixel = ( (f32) xStart ) - line.x[0];
1661#ifdef IPOL_Z 1661#ifdef IPOL_Z
1662 line.z[0] += slopeZ * subPixel; 1662 line.z[0] += slopeZ * subPixel;
1663#endif 1663#endif
1664#ifdef IPOL_W 1664#ifdef IPOL_W
1665 line.w[0] += slopeW * subPixel; 1665 line.w[0] += slopeW * subPixel;
1666#endif 1666#endif
1667#ifdef IPOL_C0 1667#ifdef IPOL_C0
1668 line.c[0][0] += slopeC[0] * subPixel; 1668 line.c[0][0] += slopeC[0] * subPixel;
1669#endif 1669#endif
1670#ifdef IPOL_T0 1670#ifdef IPOL_T0
1671 line.t[0][0] += slopeT[0] * subPixel; 1671 line.t[0][0] += slopeT[0] * subPixel;
1672#endif 1672#endif
1673#ifdef IPOL_T1 1673#ifdef IPOL_T1
1674 line.t[1][0] += slopeT[1] * subPixel; 1674 line.t[1][0] += slopeT[1] * subPixel;
1675#endif 1675#endif
1676#endif 1676#endif
1677 1677
1678 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1678 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1679 1679
1680#ifdef USE_ZBUFFER 1680#ifdef USE_ZBUFFER
1681 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1681 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1682#endif 1682#endif
1683 1683
1684 1684
1685 f32 iw = FIX_POINT_F32_MUL; 1685 f32 iw = FIX_POINT_F32_MUL;
1686 1686
1687 tFixPoint r0, g0, b0; 1687 tFixPoint r0, g0, b0;
1688 tFixPoint r1, g1, b1; 1688 tFixPoint r1, g1, b1;
1689 tFixPoint r2, g2, b2; 1689 tFixPoint r2, g2, b2;
1690 1690
1691 s32 i; 1691 s32 i;
1692 1692
1693 switch ( ZCompare ) 1693 switch ( ZCompare )
1694 { 1694 {
1695 case 1: 1695 case 1:
1696 for ( i = 0; i <= dx; ++i ) 1696 for ( i = 0; i <= dx; ++i )
1697 { 1697 {
1698#ifdef CMP_W 1698#ifdef CMP_W
1699 if ( line.w[0] >= z[i] ) 1699 if ( line.w[0] >= z[i] )
1700#endif 1700#endif
1701 1701
1702 { 1702 {
1703 1703
1704#ifdef WRITE_W 1704#ifdef WRITE_W
1705 z[i] = line.w[0]; 1705 z[i] = line.w[0];
1706#endif 1706#endif
1707 1707
1708#ifdef INVERSE_W 1708#ifdef INVERSE_W
1709 iw = fix_inverse32 ( line.w[0] ); 1709 iw = fix_inverse32 ( line.w[0] );
1710#endif 1710#endif
1711 1711
1712 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1712 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1713 color_to_fix ( r1, g1, b1, dst[i] ); 1713 color_to_fix ( r1, g1, b1, dst[i] );
1714#ifdef IPOL_C0 1714#ifdef IPOL_C0
1715 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1715 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1716 1716
1717 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), 1717 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ),
1718 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), 1718 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ),
1719 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) 1719 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 )
1720 ); 1720 );
1721 1721
1722#else 1722#else
1723 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), 1723 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ),
1724 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), 1724 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ),
1725 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) 1725 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 )
1726 ); 1726 );
1727 1727
1728#endif 1728#endif
1729 1729
1730 } 1730 }
1731 1731
1732#ifdef IPOL_W 1732#ifdef IPOL_W
1733 line.w[0] += slopeW; 1733 line.w[0] += slopeW;
1734#endif 1734#endif
1735#ifdef IPOL_T0 1735#ifdef IPOL_T0
1736 line.t[0][0] += slopeT[0]; 1736 line.t[0][0] += slopeT[0];
1737#endif 1737#endif
1738#ifdef IPOL_C0 1738#ifdef IPOL_C0
1739 line.c[0][0] += slopeC[0]; 1739 line.c[0][0] += slopeC[0];
1740#endif 1740#endif
1741 } 1741 }
1742 break; 1742 break;
1743 1743
1744 case 2: 1744 case 2:
1745 for ( i = 0; i <= dx; ++i ) 1745 for ( i = 0; i <= dx; ++i )
1746 { 1746 {
1747#ifdef CMP_W 1747#ifdef CMP_W
1748 if ( line.w[0] == z[i] ) 1748 if ( line.w[0] == z[i] )
1749#endif 1749#endif
1750 1750
1751 { 1751 {
1752 1752
1753#ifdef WRITE_W 1753#ifdef WRITE_W
1754 z[i] = line.w[0]; 1754 z[i] = line.w[0];
1755#endif 1755#endif
1756 1756
1757#ifdef INVERSE_W 1757#ifdef INVERSE_W
1758 iw = fix_inverse32 ( line.w[0] ); 1758 iw = fix_inverse32 ( line.w[0] );
1759#endif 1759#endif
1760 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1760 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1761 color_to_fix ( r1, g1, b1, dst[i] ); 1761 color_to_fix ( r1, g1, b1, dst[i] );
1762 1762
1763#ifdef IPOL_C0 1763#ifdef IPOL_C0
1764 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1764 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1765 1765
1766 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), 1766 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ),
1767 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), 1767 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ),
1768 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) 1768 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 )
1769 ); 1769 );
1770 1770
1771#else 1771#else
1772 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ), 1772 dst[i] = fix_to_color ( clampfix_maxcolor ( imulFix_tex1 ( r0, r1 ) + r1 ),
1773 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ), 1773 clampfix_maxcolor ( imulFix_tex1 ( g0, g1 ) + g1 ),
1774 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 ) 1774 clampfix_maxcolor ( imulFix_tex1 ( b0, b1 ) + b1 )
1775 ); 1775 );
1776 1776
1777#endif 1777#endif
1778 1778
1779 1779
1780 } 1780 }
1781 1781
1782#ifdef IPOL_W 1782#ifdef IPOL_W
1783 line.w[0] += slopeW; 1783 line.w[0] += slopeW;
1784#endif 1784#endif
1785#ifdef IPOL_T0 1785#ifdef IPOL_T0
1786 line.t[0][0] += slopeT[0]; 1786 line.t[0][0] += slopeT[0];
1787#endif 1787#endif
1788#ifdef IPOL_C0 1788#ifdef IPOL_C0
1789 line.c[0][0] += slopeC[0]; 1789 line.c[0][0] += slopeC[0];
1790#endif 1790#endif
1791 }break; 1791 }break;
1792 } // zcompare 1792 } // zcompare
1793 1793
1794} 1794}
1795 1795
1796/*! 1796/*!
1797*/ 1797*/
1798void CTRTextureBlend::fragment_zero_one_minus_scr_color () 1798void CTRTextureBlend::fragment_zero_one_minus_scr_color ()
1799{ 1799{
1800 tVideoSample *dst; 1800 tVideoSample *dst;
1801 1801
1802#ifdef USE_ZBUFFER 1802#ifdef USE_ZBUFFER
1803 fp24 *z; 1803 fp24 *z;
1804#endif 1804#endif
1805 1805
1806 s32 xStart; 1806 s32 xStart;
1807 s32 xEnd; 1807 s32 xEnd;
1808 s32 dx; 1808 s32 dx;
1809 1809
1810 1810
1811#ifdef SUBTEXEL 1811#ifdef SUBTEXEL
1812 f32 subPixel; 1812 f32 subPixel;
1813#endif 1813#endif
1814 1814
1815#ifdef IPOL_Z 1815#ifdef IPOL_Z
1816 f32 slopeZ; 1816 f32 slopeZ;
1817#endif 1817#endif
1818#ifdef IPOL_W 1818#ifdef IPOL_W
1819 fp24 slopeW; 1819 fp24 slopeW;
1820#endif 1820#endif
1821#ifdef IPOL_C0 1821#ifdef IPOL_C0
1822 sVec4 slopeC[MATERIAL_MAX_COLORS]; 1822 sVec4 slopeC[MATERIAL_MAX_COLORS];
1823#endif 1823#endif
1824#ifdef IPOL_T0 1824#ifdef IPOL_T0
1825 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; 1825 sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES];
1826#endif 1826#endif
1827 1827
1828 // apply top-left fill-convention, left 1828 // apply top-left fill-convention, left
1829 xStart = core::ceil32( line.x[0] ); 1829 xStart = core::ceil32( line.x[0] );
1830 xEnd = core::ceil32( line.x[1] ) - 1; 1830 xEnd = core::ceil32( line.x[1] ) - 1;
1831 1831
1832 dx = xEnd - xStart; 1832 dx = xEnd - xStart;
1833 1833
1834 if ( dx < 0 ) 1834 if ( dx < 0 )
1835 return; 1835 return;
1836 1836
1837 // slopes 1837 // slopes
1838 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); 1838 const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] );
1839 1839
1840#ifdef IPOL_Z 1840#ifdef IPOL_Z
1841 slopeZ = (line.z[1] - line.z[0]) * invDeltaX; 1841 slopeZ = (line.z[1] - line.z[0]) * invDeltaX;
1842#endif 1842#endif
1843#ifdef IPOL_W 1843#ifdef IPOL_W
1844 slopeW = (line.w[1] - line.w[0]) * invDeltaX; 1844 slopeW = (line.w[1] - line.w[0]) * invDeltaX;
1845#endif 1845#endif
1846#ifdef IPOL_C0 1846#ifdef IPOL_C0
1847 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; 1847 slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX;
1848#endif 1848#endif
1849#ifdef IPOL_T0 1849#ifdef IPOL_T0
1850 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; 1850 slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX;
1851#endif 1851#endif
1852#ifdef IPOL_T1 1852#ifdef IPOL_T1
1853 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; 1853 slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX;
1854#endif 1854#endif
1855 1855
1856#ifdef SUBTEXEL 1856#ifdef SUBTEXEL
1857 subPixel = ( (f32) xStart ) - line.x[0]; 1857 subPixel = ( (f32) xStart ) - line.x[0];
1858#ifdef IPOL_Z 1858#ifdef IPOL_Z
1859 line.z[0] += slopeZ * subPixel; 1859 line.z[0] += slopeZ * subPixel;
1860#endif 1860#endif
1861#ifdef IPOL_W 1861#ifdef IPOL_W
1862 line.w[0] += slopeW * subPixel; 1862 line.w[0] += slopeW * subPixel;
1863#endif 1863#endif
1864#ifdef IPOL_C0 1864#ifdef IPOL_C0
1865 line.c[0][0] += slopeC[0] * subPixel; 1865 line.c[0][0] += slopeC[0] * subPixel;
1866#endif 1866#endif
1867#ifdef IPOL_T0 1867#ifdef IPOL_T0
1868 line.t[0][0] += slopeT[0] * subPixel; 1868 line.t[0][0] += slopeT[0] * subPixel;
1869#endif 1869#endif
1870#ifdef IPOL_T1 1870#ifdef IPOL_T1
1871 line.t[1][0] += slopeT[1] * subPixel; 1871 line.t[1][0] += slopeT[1] * subPixel;
1872#endif 1872#endif
1873#endif 1873#endif
1874 1874
1875 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1875 dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1876 1876
1877#ifdef USE_ZBUFFER 1877#ifdef USE_ZBUFFER
1878 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; 1878 z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart;
1879#endif 1879#endif
1880 1880
1881 1881
1882 f32 iw = FIX_POINT_F32_MUL; 1882 f32 iw = FIX_POINT_F32_MUL;
1883 1883
1884 tFixPoint r0, g0, b0; 1884 tFixPoint r0, g0, b0;
1885 tFixPoint r1, g1, b1; 1885 tFixPoint r1, g1, b1;
1886 tFixPoint r2, g2, b2; 1886 tFixPoint r2, g2, b2;
1887 1887
1888 s32 i; 1888 s32 i;
1889 1889
1890 switch ( ZCompare ) 1890 switch ( ZCompare )
1891 { 1891 {
1892 case 1: 1892 case 1:
1893 for ( i = 0; i <= dx; ++i ) 1893 for ( i = 0; i <= dx; ++i )
1894 { 1894 {
1895#ifdef CMP_W 1895#ifdef CMP_W
1896 if ( line.w[0] >= z[i] ) 1896 if ( line.w[0] >= z[i] )
1897#endif 1897#endif
1898 1898
1899 { 1899 {
1900 1900
1901#ifdef WRITE_W 1901#ifdef WRITE_W
1902 z[i] = line.w[0]; 1902 z[i] = line.w[0];
1903#endif 1903#endif
1904 1904
1905#ifdef INVERSE_W 1905#ifdef INVERSE_W
1906 iw = fix_inverse32 ( line.w[0] ); 1906 iw = fix_inverse32 ( line.w[0] );
1907#endif 1907#endif
1908 1908
1909 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1909 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1910 color_to_fix1 ( r1, g1, b1, dst[i] ); 1910 color_to_fix1 ( r1, g1, b1, dst[i] );
1911#ifdef IPOL_C0 1911#ifdef IPOL_C0
1912 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1912 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1913 1913
1914 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), 1914 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ),
1915 imulFix ( FIX_POINT_ONE - g0, g1 ), 1915 imulFix ( FIX_POINT_ONE - g0, g1 ),
1916 imulFix ( FIX_POINT_ONE - b0, b1 ) 1916 imulFix ( FIX_POINT_ONE - b0, b1 )
1917 ); 1917 );
1918 1918
1919#else 1919#else
1920 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), 1920 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ),
1921 imulFix ( FIX_POINT_ONE - g0, g1 ), 1921 imulFix ( FIX_POINT_ONE - g0, g1 ),
1922 imulFix ( FIX_POINT_ONE - b0, b1 ) 1922 imulFix ( FIX_POINT_ONE - b0, b1 )
1923 ); 1923 );
1924 1924
1925#endif 1925#endif
1926 1926
1927 } 1927 }
1928 1928
1929#ifdef IPOL_W 1929#ifdef IPOL_W
1930 line.w[0] += slopeW; 1930 line.w[0] += slopeW;
1931#endif 1931#endif
1932#ifdef IPOL_T0 1932#ifdef IPOL_T0
1933 line.t[0][0] += slopeT[0]; 1933 line.t[0][0] += slopeT[0];
1934#endif 1934#endif
1935#ifdef IPOL_C0 1935#ifdef IPOL_C0
1936 line.c[0][0] += slopeC[0]; 1936 line.c[0][0] += slopeC[0];
1937#endif 1937#endif
1938 } 1938 }
1939 break; 1939 break;
1940 1940
1941 case 2: 1941 case 2:
1942 for ( i = 0; i <= dx; ++i ) 1942 for ( i = 0; i <= dx; ++i )
1943 { 1943 {
1944#ifdef CMP_W 1944#ifdef CMP_W
1945 if ( line.w[0] == z[i] ) 1945 if ( line.w[0] == z[i] )
1946#endif 1946#endif
1947 1947
1948 { 1948 {
1949 1949
1950#ifdef WRITE_W 1950#ifdef WRITE_W
1951 z[i] = line.w[0]; 1951 z[i] = line.w[0];
1952#endif 1952#endif
1953 1953
1954#ifdef INVERSE_W 1954#ifdef INVERSE_W
1955 iw = fix_inverse32 ( line.w[0] ); 1955 iw = fix_inverse32 ( line.w[0] );
1956#endif 1956#endif
1957 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) ); 1957 getSample_texture ( r0, g0, b0, IT + 0, tofix ( line.t[0][0].x,iw),tofix ( line.t[0][0].y,iw) );
1958 color_to_fix1 ( r1, g1, b1, dst[i] ); 1958 color_to_fix1 ( r1, g1, b1, dst[i] );
1959#ifdef IPOL_C0 1959#ifdef IPOL_C0
1960 getSample_color ( r2, g2, b2, line.c[0][0],iw ); 1960 getSample_color ( r2, g2, b2, line.c[0][0],iw );
1961 1961
1962 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), 1962 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ),
1963 imulFix ( FIX_POINT_ONE - g0, g1 ), 1963 imulFix ( FIX_POINT_ONE - g0, g1 ),
1964 imulFix ( FIX_POINT_ONE - b0, b1 ) 1964 imulFix ( FIX_POINT_ONE - b0, b1 )
1965 ); 1965 );
1966 1966
1967#else 1967#else
1968 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ), 1968 dst[i] = fix_to_color ( imulFix ( FIX_POINT_ONE - r0, r1 ),
1969 imulFix ( FIX_POINT_ONE - g0, g1 ), 1969 imulFix ( FIX_POINT_ONE - g0, g1 ),
1970 imulFix ( FIX_POINT_ONE - b0, b1 ) 1970 imulFix ( FIX_POINT_ONE - b0, b1 )
1971 ); 1971 );
1972 1972
1973#endif 1973#endif
1974 1974
1975 } 1975 }
1976 1976
1977#ifdef IPOL_W 1977#ifdef IPOL_W
1978 line.w[0] += slopeW; 1978 line.w[0] += slopeW;
1979#endif 1979#endif
1980#ifdef IPOL_T0 1980#ifdef IPOL_T0
1981 line.t[0][0] += slopeT[0]; 1981 line.t[0][0] += slopeT[0];
1982#endif 1982#endif
1983#ifdef IPOL_C0 1983#ifdef IPOL_C0
1984 line.c[0][0] += slopeC[0]; 1984 line.c[0][0] += slopeC[0];
1985#endif 1985#endif
1986 }break; 1986 }break;
1987 } // zcompare 1987 } // zcompare
1988 1988
1989} 1989}
1990 1990
1991 1991
1992 1992
1993void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) 1993void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
1994{ 1994{
1995 if ( 0 == fragmentShader ) 1995 if ( 0 == fragmentShader )
1996 return; 1996 return;
1997 1997
1998 // sort on height, y 1998 // sort on height, y
1999 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 1999 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
2000 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); 2000 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
2001 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 2001 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
2002 2002
2003 const f32 ca = c->Pos.y - a->Pos.y; 2003 const f32 ca = c->Pos.y - a->Pos.y;
2004 const f32 ba = b->Pos.y - a->Pos.y; 2004 const f32 ba = b->Pos.y - a->Pos.y;
2005 const f32 cb = c->Pos.y - b->Pos.y; 2005 const f32 cb = c->Pos.y - b->Pos.y;
2006 // calculate delta y of the edges 2006 // calculate delta y of the edges
2007 scan.invDeltaY[0] = core::reciprocal( ca ); 2007 scan.invDeltaY[0] = core::reciprocal( ca );
2008 scan.invDeltaY[1] = core::reciprocal( ba ); 2008 scan.invDeltaY[1] = core::reciprocal( ba );
2009 scan.invDeltaY[2] = core::reciprocal( cb ); 2009 scan.invDeltaY[2] = core::reciprocal( cb );
2010 2010
2011 if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) 2011 if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
2012 return; 2012 return;
2013 2013
2014 // find if the major edge is left or right aligned 2014 // find if the major edge is left or right aligned
2015 f32 temp[4]; 2015 f32 temp[4];
2016 2016
2017 temp[0] = a->Pos.x - c->Pos.x; 2017 temp[0] = a->Pos.x - c->Pos.x;
2018 temp[1] = -ca; 2018 temp[1] = -ca;
2019 temp[2] = b->Pos.x - a->Pos.x; 2019 temp[2] = b->Pos.x - a->Pos.x;
2020 temp[3] = ba; 2020 temp[3] = ba;
2021 2021
2022 scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; 2022 scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
2023 scan.right = 1 - scan.left; 2023 scan.right = 1 - scan.left;
2024 2024
2025 // calculate slopes for the major edge 2025 // calculate slopes for the major edge
2026 scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; 2026 scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0];
2027 scan.x[0] = a->Pos.x; 2027 scan.x[0] = a->Pos.x;
2028 2028
2029#ifdef IPOL_Z 2029#ifdef IPOL_Z
2030 scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; 2030 scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0];
2031 scan.z[0] = a->Pos.z; 2031 scan.z[0] = a->Pos.z;
2032#endif 2032#endif
2033 2033
2034#ifdef IPOL_W 2034#ifdef IPOL_W
2035 scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; 2035 scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0];
2036 scan.w[0] = a->Pos.w; 2036 scan.w[0] = a->Pos.w;
2037#endif 2037#endif
2038 2038
2039#ifdef IPOL_C0 2039#ifdef IPOL_C0
2040 scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; 2040 scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0];
2041 scan.c[0][0] = a->Color[0]; 2041 scan.c[0][0] = a->Color[0];
2042#endif 2042#endif
2043 2043
2044#ifdef IPOL_T0 2044#ifdef IPOL_T0
2045 scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; 2045 scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0];
2046 scan.t[0][0] = a->Tex[0]; 2046 scan.t[0][0] = a->Tex[0];
2047#endif 2047#endif
2048 2048
2049#ifdef IPOL_T1 2049#ifdef IPOL_T1
2050 scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; 2050 scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0];
2051 scan.t[1][0] = a->Tex[1]; 2051 scan.t[1][0] = a->Tex[1];
2052#endif 2052#endif
2053 2053
2054 // top left fill convention y run 2054 // top left fill convention y run
2055 s32 yStart; 2055 s32 yStart;
2056 s32 yEnd; 2056 s32 yEnd;
2057 2057
2058#ifdef SUBTEXEL 2058#ifdef SUBTEXEL
2059 f32 subPixel; 2059 f32 subPixel;
2060#endif 2060#endif
2061 2061
2062 // rasterize upper sub-triangle 2062 // rasterize upper sub-triangle
2063 if ( (f32) 0.0 != scan.invDeltaY[1] ) 2063 if ( (f32) 0.0 != scan.invDeltaY[1] )
2064 { 2064 {
2065 // calculate slopes for top edge 2065 // calculate slopes for top edge
2066 scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; 2066 scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1];
2067 scan.x[1] = a->Pos.x; 2067 scan.x[1] = a->Pos.x;
2068 2068
2069#ifdef IPOL_Z 2069#ifdef IPOL_Z
2070 scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; 2070 scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1];
2071 scan.z[1] = a->Pos.z; 2071 scan.z[1] = a->Pos.z;
2072#endif 2072#endif
2073 2073
2074#ifdef IPOL_W 2074#ifdef IPOL_W
2075 scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; 2075 scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1];
2076 scan.w[1] = a->Pos.w; 2076 scan.w[1] = a->Pos.w;
2077#endif 2077#endif
2078 2078
2079#ifdef IPOL_C0 2079#ifdef IPOL_C0
2080 scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; 2080 scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1];
2081 scan.c[0][1] = a->Color[0]; 2081 scan.c[0][1] = a->Color[0];
2082#endif 2082#endif
2083 2083
2084#ifdef IPOL_T0 2084#ifdef IPOL_T0
2085 scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; 2085 scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1];
2086 scan.t[0][1] = a->Tex[0]; 2086 scan.t[0][1] = a->Tex[0];
2087#endif 2087#endif
2088 2088
2089#ifdef IPOL_T1 2089#ifdef IPOL_T1
2090 scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; 2090 scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1];
2091 scan.t[1][1] = a->Tex[1]; 2091 scan.t[1][1] = a->Tex[1];
2092#endif 2092#endif
2093 2093
2094 // apply top-left fill convention, top part 2094 // apply top-left fill convention, top part
2095 yStart = core::ceil32( a->Pos.y ); 2095 yStart = core::ceil32( a->Pos.y );
2096 yEnd = core::ceil32( b->Pos.y ) - 1; 2096 yEnd = core::ceil32( b->Pos.y ) - 1;
2097 2097
2098#ifdef SUBTEXEL 2098#ifdef SUBTEXEL
2099 subPixel = ( (f32) yStart ) - a->Pos.y; 2099 subPixel = ( (f32) yStart ) - a->Pos.y;
2100 2100
2101 // correct to pixel center 2101 // correct to pixel center
2102 scan.x[0] += scan.slopeX[0] * subPixel; 2102 scan.x[0] += scan.slopeX[0] * subPixel;
2103 scan.x[1] += scan.slopeX[1] * subPixel; 2103 scan.x[1] += scan.slopeX[1] * subPixel;
2104 2104
2105#ifdef IPOL_Z 2105#ifdef IPOL_Z
2106 scan.z[0] += scan.slopeZ[0] * subPixel; 2106 scan.z[0] += scan.slopeZ[0] * subPixel;
2107 scan.z[1] += scan.slopeZ[1] * subPixel; 2107 scan.z[1] += scan.slopeZ[1] * subPixel;
2108#endif 2108#endif
2109 2109
2110#ifdef IPOL_W 2110#ifdef IPOL_W
2111 scan.w[0] += scan.slopeW[0] * subPixel; 2111 scan.w[0] += scan.slopeW[0] * subPixel;
2112 scan.w[1] += scan.slopeW[1] * subPixel; 2112 scan.w[1] += scan.slopeW[1] * subPixel;
2113#endif 2113#endif
2114 2114
2115#ifdef IPOL_C0 2115#ifdef IPOL_C0
2116 scan.c[0][0] += scan.slopeC[0][0] * subPixel; 2116 scan.c[0][0] += scan.slopeC[0][0] * subPixel;
2117 scan.c[0][1] += scan.slopeC[0][1] * subPixel; 2117 scan.c[0][1] += scan.slopeC[0][1] * subPixel;
2118#endif 2118#endif
2119 2119
2120#ifdef IPOL_T0 2120#ifdef IPOL_T0
2121 scan.t[0][0] += scan.slopeT[0][0] * subPixel; 2121 scan.t[0][0] += scan.slopeT[0][0] * subPixel;
2122 scan.t[0][1] += scan.slopeT[0][1] * subPixel; 2122 scan.t[0][1] += scan.slopeT[0][1] * subPixel;
2123#endif 2123#endif
2124 2124
2125#ifdef IPOL_T1 2125#ifdef IPOL_T1
2126 scan.t[1][0] += scan.slopeT[1][0] * subPixel; 2126 scan.t[1][0] += scan.slopeT[1][0] * subPixel;
2127 scan.t[1][1] += scan.slopeT[1][1] * subPixel; 2127 scan.t[1][1] += scan.slopeT[1][1] * subPixel;
2128#endif 2128#endif
2129 2129
2130#endif 2130#endif
2131 2131
2132 // rasterize the edge scanlines 2132 // rasterize the edge scanlines
2133 for( line.y = yStart; line.y <= yEnd; ++line.y) 2133 for( line.y = yStart; line.y <= yEnd; ++line.y)
2134 { 2134 {
2135 line.x[scan.left] = scan.x[0]; 2135 line.x[scan.left] = scan.x[0];
2136 line.x[scan.right] = scan.x[1]; 2136 line.x[scan.right] = scan.x[1];
2137 2137
2138#ifdef IPOL_Z 2138#ifdef IPOL_Z
2139 line.z[scan.left] = scan.z[0]; 2139 line.z[scan.left] = scan.z[0];
2140 line.z[scan.right] = scan.z[1]; 2140 line.z[scan.right] = scan.z[1];
2141#endif 2141#endif
2142 2142
2143#ifdef IPOL_W 2143#ifdef IPOL_W
2144 line.w[scan.left] = scan.w[0]; 2144 line.w[scan.left] = scan.w[0];
2145 line.w[scan.right] = scan.w[1]; 2145 line.w[scan.right] = scan.w[1];
2146#endif 2146#endif
2147 2147
2148#ifdef IPOL_C0 2148#ifdef IPOL_C0
2149 line.c[0][scan.left] = scan.c[0][0]; 2149 line.c[0][scan.left] = scan.c[0][0];
2150 line.c[0][scan.right] = scan.c[0][1]; 2150 line.c[0][scan.right] = scan.c[0][1];
2151#endif 2151#endif
2152 2152
2153#ifdef IPOL_T0 2153#ifdef IPOL_T0
2154 line.t[0][scan.left] = scan.t[0][0]; 2154 line.t[0][scan.left] = scan.t[0][0];
2155 line.t[0][scan.right] = scan.t[0][1]; 2155 line.t[0][scan.right] = scan.t[0][1];
2156#endif 2156#endif
2157 2157
2158#ifdef IPOL_T1 2158#ifdef IPOL_T1
2159 line.t[1][scan.left] = scan.t[1][0]; 2159 line.t[1][scan.left] = scan.t[1][0];
2160 line.t[1][scan.right] = scan.t[1][1]; 2160 line.t[1][scan.right] = scan.t[1][1];
2161#endif 2161#endif
2162 2162
2163 // render a scanline 2163 // render a scanline
2164 (this->*fragmentShader) (); 2164 (this->*fragmentShader) ();
2165 2165
2166 scan.x[0] += scan.slopeX[0]; 2166 scan.x[0] += scan.slopeX[0];
2167 scan.x[1] += scan.slopeX[1]; 2167 scan.x[1] += scan.slopeX[1];
2168 2168
2169#ifdef IPOL_Z 2169#ifdef IPOL_Z
2170 scan.z[0] += scan.slopeZ[0]; 2170 scan.z[0] += scan.slopeZ[0];
2171 scan.z[1] += scan.slopeZ[1]; 2171 scan.z[1] += scan.slopeZ[1];
2172#endif 2172#endif
2173 2173
2174#ifdef IPOL_W 2174#ifdef IPOL_W
2175 scan.w[0] += scan.slopeW[0]; 2175 scan.w[0] += scan.slopeW[0];
2176 scan.w[1] += scan.slopeW[1]; 2176 scan.w[1] += scan.slopeW[1];
2177#endif 2177#endif
2178 2178
2179#ifdef IPOL_C0 2179#ifdef IPOL_C0
2180 scan.c[0][0] += scan.slopeC[0][0]; 2180 scan.c[0][0] += scan.slopeC[0][0];
2181 scan.c[0][1] += scan.slopeC[0][1]; 2181 scan.c[0][1] += scan.slopeC[0][1];
2182#endif 2182#endif
2183 2183
2184#ifdef IPOL_T0 2184#ifdef IPOL_T0
2185 scan.t[0][0] += scan.slopeT[0][0]; 2185 scan.t[0][0] += scan.slopeT[0][0];
2186 scan.t[0][1] += scan.slopeT[0][1]; 2186 scan.t[0][1] += scan.slopeT[0][1];
2187#endif 2187#endif
2188 2188
2189#ifdef IPOL_T1 2189#ifdef IPOL_T1
2190 scan.t[1][0] += scan.slopeT[1][0]; 2190 scan.t[1][0] += scan.slopeT[1][0];
2191 scan.t[1][1] += scan.slopeT[1][1]; 2191 scan.t[1][1] += scan.slopeT[1][1];
2192#endif 2192#endif
2193 2193
2194 } 2194 }
2195 } 2195 }
2196 2196
2197 // rasterize lower sub-triangle 2197 // rasterize lower sub-triangle
2198 if ( (f32) 0.0 != scan.invDeltaY[2] ) 2198 if ( (f32) 0.0 != scan.invDeltaY[2] )
2199 { 2199 {
2200 // advance to middle point 2200 // advance to middle point
2201 if( (f32) 0.0 != scan.invDeltaY[1] ) 2201 if( (f32) 0.0 != scan.invDeltaY[1] )
2202 { 2202 {
2203 temp[0] = b->Pos.y - a->Pos.y; // dy 2203 temp[0] = b->Pos.y - a->Pos.y; // dy
2204 2204
2205 scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; 2205 scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0];
2206#ifdef IPOL_Z 2206#ifdef IPOL_Z
2207 scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; 2207 scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0];
2208#endif 2208#endif
2209#ifdef IPOL_W 2209#ifdef IPOL_W
2210 scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; 2210 scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0];
2211#endif 2211#endif
2212#ifdef IPOL_C0 2212#ifdef IPOL_C0
2213 scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; 2213 scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0];
2214#endif 2214#endif
2215#ifdef IPOL_T0 2215#ifdef IPOL_T0
2216 scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; 2216 scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0];
2217#endif 2217#endif
2218#ifdef IPOL_T1 2218#ifdef IPOL_T1
2219 scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; 2219 scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0];
2220#endif 2220#endif
2221 2221
2222 } 2222 }
2223 2223
2224 // calculate slopes for bottom edge 2224 // calculate slopes for bottom edge
2225 scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; 2225 scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2];
2226 scan.x[1] = b->Pos.x; 2226 scan.x[1] = b->Pos.x;
2227 2227
2228#ifdef IPOL_Z 2228#ifdef IPOL_Z
2229 scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; 2229 scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2];
2230 scan.z[1] = b->Pos.z; 2230 scan.z[1] = b->Pos.z;
2231#endif 2231#endif
2232 2232
2233#ifdef IPOL_W 2233#ifdef IPOL_W
2234 scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; 2234 scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2];
2235 scan.w[1] = b->Pos.w; 2235 scan.w[1] = b->Pos.w;
2236#endif 2236#endif
2237 2237
2238#ifdef IPOL_C0 2238#ifdef IPOL_C0
2239 scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; 2239 scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2];
2240 scan.c[0][1] = b->Color[0]; 2240 scan.c[0][1] = b->Color[0];
2241#endif 2241#endif
2242 2242
2243#ifdef IPOL_T0 2243#ifdef IPOL_T0
2244 scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; 2244 scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2];
2245 scan.t[0][1] = b->Tex[0]; 2245 scan.t[0][1] = b->Tex[0];
2246#endif 2246#endif
2247 2247
2248#ifdef IPOL_T1 2248#ifdef IPOL_T1
2249 scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; 2249 scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2];
2250 scan.t[1][1] = b->Tex[1]; 2250 scan.t[1][1] = b->Tex[1];
2251#endif 2251#endif
2252 2252
2253 // apply top-left fill convention, top part 2253 // apply top-left fill convention, top part
2254 yStart = core::ceil32( b->Pos.y ); 2254 yStart = core::ceil32( b->Pos.y );
2255 yEnd = core::ceil32( c->Pos.y ) - 1; 2255 yEnd = core::ceil32( c->Pos.y ) - 1;
2256 2256
2257#ifdef SUBTEXEL 2257#ifdef SUBTEXEL
2258 2258
2259 subPixel = ( (f32) yStart ) - b->Pos.y; 2259 subPixel = ( (f32) yStart ) - b->Pos.y;
2260 2260
2261 // correct to pixel center 2261 // correct to pixel center
2262 scan.x[0] += scan.slopeX[0] * subPixel; 2262 scan.x[0] += scan.slopeX[0] * subPixel;
2263 scan.x[1] += scan.slopeX[1] * subPixel; 2263 scan.x[1] += scan.slopeX[1] * subPixel;
2264 2264
2265#ifdef IPOL_Z 2265#ifdef IPOL_Z
2266 scan.z[0] += scan.slopeZ[0] * subPixel; 2266 scan.z[0] += scan.slopeZ[0] * subPixel;
2267 scan.z[1] += scan.slopeZ[1] * subPixel; 2267 scan.z[1] += scan.slopeZ[1] * subPixel;
2268#endif 2268#endif
2269 2269
2270#ifdef IPOL_W 2270#ifdef IPOL_W
2271 scan.w[0] += scan.slopeW[0] * subPixel; 2271 scan.w[0] += scan.slopeW[0] * subPixel;
2272 scan.w[1] += scan.slopeW[1] * subPixel; 2272 scan.w[1] += scan.slopeW[1] * subPixel;
2273#endif 2273#endif
2274 2274
2275#ifdef IPOL_C0 2275#ifdef IPOL_C0
2276 scan.c[0][0] += scan.slopeC[0][0] * subPixel; 2276 scan.c[0][0] += scan.slopeC[0][0] * subPixel;
2277 scan.c[0][1] += scan.slopeC[0][1] * subPixel; 2277 scan.c[0][1] += scan.slopeC[0][1] * subPixel;
2278#endif 2278#endif
2279 2279
2280#ifdef IPOL_T0 2280#ifdef IPOL_T0
2281 scan.t[0][0] += scan.slopeT[0][0] * subPixel; 2281 scan.t[0][0] += scan.slopeT[0][0] * subPixel;
2282 scan.t[0][1] += scan.slopeT[0][1] * subPixel; 2282 scan.t[0][1] += scan.slopeT[0][1] * subPixel;
2283#endif 2283#endif
2284 2284
2285#ifdef IPOL_T1 2285#ifdef IPOL_T1
2286 scan.t[1][0] += scan.slopeT[1][0] * subPixel; 2286 scan.t[1][0] += scan.slopeT[1][0] * subPixel;
2287 scan.t[1][1] += scan.slopeT[1][1] * subPixel; 2287 scan.t[1][1] += scan.slopeT[1][1] * subPixel;
2288#endif 2288#endif
2289 2289
2290#endif 2290#endif
2291 2291
2292 // rasterize the edge scanlines 2292 // rasterize the edge scanlines
2293 for( line.y = yStart; line.y <= yEnd; ++line.y) 2293 for( line.y = yStart; line.y <= yEnd; ++line.y)
2294 { 2294 {
2295 line.x[scan.left] = scan.x[0]; 2295 line.x[scan.left] = scan.x[0];
2296 line.x[scan.right] = scan.x[1]; 2296 line.x[scan.right] = scan.x[1];
2297 2297
2298#ifdef IPOL_Z 2298#ifdef IPOL_Z
2299 line.z[scan.left] = scan.z[0]; 2299 line.z[scan.left] = scan.z[0];
2300 line.z[scan.right] = scan.z[1]; 2300 line.z[scan.right] = scan.z[1];
2301#endif 2301#endif
2302 2302
2303#ifdef IPOL_W 2303#ifdef IPOL_W
2304 line.w[scan.left] = scan.w[0]; 2304 line.w[scan.left] = scan.w[0];
2305 line.w[scan.right] = scan.w[1]; 2305 line.w[scan.right] = scan.w[1];
2306#endif 2306#endif
2307 2307
2308#ifdef IPOL_C0 2308#ifdef IPOL_C0
2309 line.c[0][scan.left] = scan.c[0][0]; 2309 line.c[0][scan.left] = scan.c[0][0];
2310 line.c[0][scan.right] = scan.c[0][1]; 2310 line.c[0][scan.right] = scan.c[0][1];
2311#endif 2311#endif
2312 2312
2313#ifdef IPOL_T0 2313#ifdef IPOL_T0
2314 line.t[0][scan.left] = scan.t[0][0]; 2314 line.t[0][scan.left] = scan.t[0][0];
2315 line.t[0][scan.right] = scan.t[0][1]; 2315 line.t[0][scan.right] = scan.t[0][1];
2316#endif 2316#endif
2317 2317
2318#ifdef IPOL_T1 2318#ifdef IPOL_T1
2319 line.t[1][scan.left] = scan.t[1][0]; 2319 line.t[1][scan.left] = scan.t[1][0];
2320 line.t[1][scan.right] = scan.t[1][1]; 2320 line.t[1][scan.right] = scan.t[1][1];
2321#endif 2321#endif
2322 2322
2323 // render a scanline 2323 // render a scanline
2324 (this->*fragmentShader) (); 2324 (this->*fragmentShader) ();
2325 2325
2326 scan.x[0] += scan.slopeX[0]; 2326 scan.x[0] += scan.slopeX[0];
2327 scan.x[1] += scan.slopeX[1]; 2327 scan.x[1] += scan.slopeX[1];
2328 2328
2329#ifdef IPOL_Z 2329#ifdef IPOL_Z
2330 scan.z[0] += scan.slopeZ[0]; 2330 scan.z[0] += scan.slopeZ[0];
2331 scan.z[1] += scan.slopeZ[1]; 2331 scan.z[1] += scan.slopeZ[1];
2332#endif 2332#endif
2333 2333
2334#ifdef IPOL_W 2334#ifdef IPOL_W
2335 scan.w[0] += scan.slopeW[0]; 2335 scan.w[0] += scan.slopeW[0];
2336 scan.w[1] += scan.slopeW[1]; 2336 scan.w[1] += scan.slopeW[1];
2337#endif 2337#endif
2338 2338
2339#ifdef IPOL_C0 2339#ifdef IPOL_C0
2340 scan.c[0][0] += scan.slopeC[0][0]; 2340 scan.c[0][0] += scan.slopeC[0][0];
2341 scan.c[0][1] += scan.slopeC[0][1]; 2341 scan.c[0][1] += scan.slopeC[0][1];
2342#endif 2342#endif
2343 2343
2344#ifdef IPOL_T0 2344#ifdef IPOL_T0
2345 scan.t[0][0] += scan.slopeT[0][0]; 2345 scan.t[0][0] += scan.slopeT[0][0];
2346 scan.t[0][1] += scan.slopeT[0][1]; 2346 scan.t[0][1] += scan.slopeT[0][1];
2347#endif 2347#endif
2348 2348
2349#ifdef IPOL_T1 2349#ifdef IPOL_T1
2350 scan.t[1][0] += scan.slopeT[1][0]; 2350 scan.t[1][0] += scan.slopeT[1][0];
2351 scan.t[1][1] += scan.slopeT[1][1]; 2351 scan.t[1][1] += scan.slopeT[1][1];
2352#endif 2352#endif
2353 2353
2354 } 2354 }
2355 } 2355 }
2356 2356
2357} 2357}
2358 2358
2359 2359
2360 2360
2361} // end namespace video 2361} // end namespace video
2362} // end namespace irr 2362} // end namespace irr
2363 2363
2364#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 2364#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
2365 2365
2366namespace irr 2366namespace irr
2367{ 2367{
2368namespace video 2368namespace video
2369{ 2369{
2370 2370
2371//! creates a flat triangle renderer 2371//! creates a flat triangle renderer
2372IBurningShader* createTRTextureBlend(CBurningVideoDriver* driver) 2372IBurningShader* createTRTextureBlend(CBurningVideoDriver* driver)
2373{ 2373{
2374 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 2374 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
2375 return new CTRTextureBlend(driver); 2375 return new CTRTextureBlend(driver);
2376 #else 2376 #else
2377 return 0; 2377 return 0;
2378 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 2378 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
2379} 2379}
2380 2380
2381 2381
2382} // end namespace video 2382} // end namespace video
2383} // end namespace irr 2383} // end namespace irr
2384 2384
2385 2385