aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp596
1 files changed, 298 insertions, 298 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp
index 5cf8b3c..65875bf 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CTRTextureWire2.cpp
@@ -1,298 +1,298 @@
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 36
37//#define IPOL_C0 37//#define IPOL_C0
38#define IPOL_T0 38#define IPOL_T0
39//#define IPOL_T1 39//#define IPOL_T1
40 40
41// apply global override 41// apply global override
42#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT 42#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
43 #undef INVERSE_W 43 #undef INVERSE_W
44#endif 44#endif
45 45
46#ifndef SOFTWARE_DRIVER_2_SUBTEXEL 46#ifndef SOFTWARE_DRIVER_2_SUBTEXEL
47 #undef SUBTEXEL 47 #undef SUBTEXEL
48#endif 48#endif
49 49
50#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) 50#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
51 #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT 51 #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
52 #undef IPOL_W 52 #undef IPOL_W
53 #endif 53 #endif
54 #define IPOL_Z 54 #define IPOL_Z
55 55
56 #ifdef CMP_W 56 #ifdef CMP_W
57 #undef CMP_W 57 #undef CMP_W
58 #define CMP_Z 58 #define CMP_Z
59 #endif 59 #endif
60 60
61 #ifdef WRITE_W 61 #ifdef WRITE_W
62 #undef WRITE_W 62 #undef WRITE_W
63 #define WRITE_Z 63 #define WRITE_Z
64 #endif 64 #endif
65 65
66#endif 66#endif
67 67
68 68
69namespace irr 69namespace irr
70{ 70{
71 71
72namespace video 72namespace video
73{ 73{
74 74
75class CTRTextureWire2 : public IBurningShader 75class CTRTextureWire2 : public IBurningShader
76{ 76{
77public: 77public:
78 78
79 //! constructor 79 //! constructor
80 CTRTextureWire2(CBurningVideoDriver* driver); 80 CTRTextureWire2(CBurningVideoDriver* driver);
81 81
82 //! draws an indexed triangle list 82 //! draws an indexed triangle list
83 virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); 83 virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c );
84 virtual void drawLine ( const s4DVertex *a,const s4DVertex *b); 84 virtual void drawLine ( const s4DVertex *a,const s4DVertex *b);
85 85
86 86
87 87
88private: 88private:
89 void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const; 89 void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const;
90 void renderLine ( const s4DVertex *a,const s4DVertex *b ) const; 90 void renderLine ( const s4DVertex *a,const s4DVertex *b ) const;
91 91
92}; 92};
93 93
94//! constructor 94//! constructor
95CTRTextureWire2::CTRTextureWire2(CBurningVideoDriver* driver) 95CTRTextureWire2::CTRTextureWire2(CBurningVideoDriver* driver)
96: IBurningShader(driver) 96: IBurningShader(driver)
97{ 97{
98 #ifdef _DEBUG 98 #ifdef _DEBUG
99 setDebugName("CTRTextureWire2"); 99 setDebugName("CTRTextureWire2");
100 #endif 100 #endif
101} 101}
102 102
103 103
104// swap integer with xor 104// swap integer with xor
105static inline void swap_xor ( s32 &a, s32 &b ) 105static inline void swap_xor ( s32 &a, s32 &b )
106{ 106{
107 a ^= b; 107 a ^= b;
108 b ^= a; 108 b ^= a;
109 a ^= b; 109 a ^= b;
110} 110}
111 111
112 112
113/*! 113/*!
114*/ 114*/
115void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const 115void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
116{ 116{
117 117
118 int pitch0 = RenderTarget->getDimension().Width << VIDEO_SAMPLE_GRANULARITY; 118 int pitch0 = RenderTarget->getDimension().Width << VIDEO_SAMPLE_GRANULARITY;
119 int pitch1 = RenderTarget->getDimension().Width << 2; 119 int pitch1 = RenderTarget->getDimension().Width << 2;
120 120
121 int aposx = (int) a->Pos.x; 121 int aposx = (int) a->Pos.x;
122 int aposy = (int) a->Pos.y; 122 int aposy = (int) a->Pos.y;
123 int bposx = (int) b->Pos.x; 123 int bposx = (int) b->Pos.x;
124 int bposy = (int) b->Pos.y; 124 int bposy = (int) b->Pos.y;
125 125
126 int dx = bposx - aposx; 126 int dx = bposx - aposx;
127 int dy = bposy - aposy; 127 int dy = bposy - aposy;
128 128
129 int c; 129 int c;
130 int m; 130 int m;
131 int d = 0; 131 int d = 0;
132 int run; 132 int run;
133 133
134 tVideoSample *dst; 134 tVideoSample *dst;
135#ifdef USE_ZBUFFER 135#ifdef USE_ZBUFFER
136 fp24 *z; 136 fp24 *z;
137#endif 137#endif
138 138
139 int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY; 139 int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY;
140 int yInc0 = pitch0; 140 int yInc0 = pitch0;
141 141
142 int xInc1 = 4; 142 int xInc1 = 4;
143 int yInc1 = pitch1; 143 int yInc1 = pitch1;
144 144
145 tVideoSample color; 145 tVideoSample color;
146 146
147#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR 147#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
148 tFixPoint r0, g0, b0; 148 tFixPoint r0, g0, b0;
149 getSample_color ( r0, g0, b0, a->Color[0] ); 149 getSample_color ( r0, g0, b0, a->Color[0] );
150 color = fix_to_color ( r0, g0, b0 ); 150 color = fix_to_color ( r0, g0, b0 );
151#else 151#else
152 color = (tVideoSample) 0xFFFFFFFF; 152 color = (tVideoSample) 0xFFFFFFFF;
153#endif 153#endif
154 154
155 if ( dx < 0 ) 155 if ( dx < 0 )
156 { 156 {
157 xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY); 157 xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY);
158 xInc1 = -4; 158 xInc1 = -4;
159 dx = -dx; 159 dx = -dx;
160 } 160 }
161 161
162 if ( dy > dx ) 162 if ( dy > dx )
163 { 163 {
164 swap_xor ( dx, dy ); 164 swap_xor ( dx, dy );
165 swap_xor ( xInc0, yInc0 ); 165 swap_xor ( xInc0, yInc0 );
166 swap_xor ( xInc1, yInc1 ); 166 swap_xor ( xInc1, yInc1 );
167 } 167 }
168 168
169 if ( 0 == dx ) 169 if ( 0 == dx )
170 return; 170 return;
171 171
172 dst = (tVideoSample*) ( (u8*) (tVideoSample*)RenderTarget->lock() + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) ); 172 dst = (tVideoSample*) ( (u8*) (tVideoSample*)RenderTarget->lock() + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) );
173#ifdef USE_ZBUFFER 173#ifdef USE_ZBUFFER
174 z = (fp24*) ( (u8*) (fp24*) DepthBuffer->lock() + ( aposy * pitch1 ) + (aposx << 2 ) ); 174 z = (fp24*) ( (u8*) (fp24*) DepthBuffer->lock() + ( aposy * pitch1 ) + (aposx << 2 ) );
175#endif 175#endif
176 176
177 c = dx << 1; 177 c = dx << 1;
178 m = dy << 1; 178 m = dy << 1;
179 179
180#ifdef IPOL_Z 180#ifdef IPOL_Z
181 f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx); 181 f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx);
182 f32 dataZ = a->Pos.z; 182 f32 dataZ = a->Pos.z;
183#endif 183#endif
184 184
185#ifdef IPOL_W 185#ifdef IPOL_W
186 fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx ); 186 fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx );
187 fp24 dataW = a->Pos.w; 187 fp24 dataW = a->Pos.w;
188#endif 188#endif
189 189
190 run = dx; 190 run = dx;
191 while ( run ) 191 while ( run )
192 { 192 {
193#ifdef CMP_Z 193#ifdef CMP_Z
194 if ( *z >= dataZ ) 194 if ( *z >= dataZ )
195#endif 195#endif
196#ifdef CMP_W 196#ifdef CMP_W
197 if ( dataW >= *z ) 197 if ( dataW >= *z )
198#endif 198#endif
199 { 199 {
200#ifdef WRITE_Z 200#ifdef WRITE_Z
201 *z = dataZ; 201 *z = dataZ;
202#endif 202#endif
203#ifdef WRITE_W 203#ifdef WRITE_W
204 *z = dataW; 204 *z = dataW;
205#endif 205#endif
206 206
207 *dst = color; 207 *dst = color;
208 208
209 } 209 }
210 210
211 dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc 211 dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc
212#ifdef IPOL_Z 212#ifdef IPOL_Z
213 z = (fp24*) ( (u8*) z + xInc1 ); 213 z = (fp24*) ( (u8*) z + xInc1 );
214#endif 214#endif
215#ifdef IPOL_W 215#ifdef IPOL_W
216 z = (fp24*) ( (u8*) z + xInc1 ); 216 z = (fp24*) ( (u8*) z + xInc1 );
217#endif 217#endif
218 218
219 d += m; 219 d += m;
220 if ( d > dx ) 220 if ( d > dx )
221 { 221 {
222 dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc 222 dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc
223#ifdef IPOL_Z 223#ifdef IPOL_Z
224 z = (fp24*) ( (u8*) z + yInc1 ); 224 z = (fp24*) ( (u8*) z + yInc1 );
225#endif 225#endif
226#ifdef IPOL_W 226#ifdef IPOL_W
227 z = (fp24*) ( (u8*) z + yInc1 ); 227 z = (fp24*) ( (u8*) z + yInc1 );
228#endif 228#endif
229 229
230 d -= c; 230 d -= c;
231 } 231 }
232 run -= 1; 232 run -= 1;
233#ifdef IPOL_Z 233#ifdef IPOL_Z
234 dataZ += slopeZ; 234 dataZ += slopeZ;
235#endif 235#endif
236#ifdef IPOL_W 236#ifdef IPOL_W
237 dataW += slopeW; 237 dataW += slopeW;
238#endif 238#endif
239 239
240 } 240 }
241 241
242} 242}
243 243
244void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) 244void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
245{ 245{
246 sScanLineData line; 246 sScanLineData line;
247 247
248 // sort on height, y 248 // sort on height, y
249 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 249 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
250 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); 250 if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
251 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); 251 if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
252 252
253 renderLine ( a, b ); 253 renderLine ( a, b );
254 renderLine ( b, c ); 254 renderLine ( b, c );
255 renderLine ( a, c ); 255 renderLine ( a, c );
256 256
257} 257}
258 258
259 259
260void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b) 260void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b)
261{ 261{
262 262
263 // query access to TexMaps 263 // query access to TexMaps
264 264
265 // sort on height, y 265 // sort on height, y
266 if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); 266 if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b);
267 267
268 renderLine ( a, b ); 268 renderLine ( a, b );
269 269
270} 270}
271 271
272 272
273} // end namespace video 273} // end namespace video
274} // end namespace irr 274} // end namespace irr
275 275
276#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 276#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
277 277
278namespace irr 278namespace irr
279{ 279{
280namespace video 280namespace video
281{ 281{
282 282
283 283
284//! creates a flat triangle renderer 284//! creates a flat triangle renderer
285IBurningShader* createTriangleRendererTextureGouraudWire2(CBurningVideoDriver* driver) 285IBurningShader* createTriangleRendererTextureGouraudWire2(CBurningVideoDriver* driver)
286{ 286{
287 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ 287 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
288 return new CTRTextureWire2(driver); 288 return new CTRTextureWire2(driver);
289 #else 289 #else
290 return 0; 290 return 0;
291 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ 291 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
292} 292}
293 293
294 294
295} // end namespace video 295} // end namespace video
296} // end namespace irr 296} // end namespace irr
297 297
298 298