1
// Copyright (C) 2002-2011 Nikolaus Gebhardt / Thomas Alten
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#include "IrrCompileConfig.h"
6
#include "IBurningShader.h"
8
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
10
// compile flag for this file
41
// apply global override
42
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
46
#ifndef SOFTWARE_DRIVER_2_SUBTEXEL
50
#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
51
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
75
class CTRTextureWire2 : public IBurningShader
80
CTRTextureWire2(CBurningVideoDriver* driver);
82
//! draws an indexed triangle list
83
virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c );
84
virtual void drawLine ( const s4DVertex *a,const s4DVertex *b);
89
void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const;
90
void renderLine ( const s4DVertex *a,const s4DVertex *b ) const;
95
CTRTextureWire2::CTRTextureWire2(CBurningVideoDriver* driver)
96
: IBurningShader(driver)
99
setDebugName("CTRTextureWire2");
104
// swap integer with xor
105
static inline void swap_xor ( s32 &a, s32 &b )
115
void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b ) const
118
int pitch0 = RenderTarget->getDimension().Width << VIDEO_SAMPLE_GRANULARITY;
119
int pitch1 = RenderTarget->getDimension().Width << 2;
121
int aposx = (int) a->Pos.x;
122
int aposy = (int) a->Pos.y;
123
int bposx = (int) b->Pos.x;
124
int bposy = (int) b->Pos.y;
126
int dx = bposx - aposx;
127
int dy = bposy - aposy;
139
int xInc0 = 1 << VIDEO_SAMPLE_GRANULARITY;
147
#ifdef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR
148
tFixPoint r0, g0, b0;
149
getSample_color ( r0, g0, b0, a->Color[0] );
150
color = fix_to_color ( r0, g0, b0 );
152
color = (tVideoSample) 0xFFFFFFFF;
157
xInc0 = - ( 1 << VIDEO_SAMPLE_GRANULARITY);
165
swap_xor ( xInc0, yInc0 );
166
swap_xor ( xInc1, yInc1 );
172
dst = (tVideoSample*) ( (u8*) (tVideoSample*)RenderTarget->lock() + ( aposy * pitch0 ) + (aposx << VIDEO_SAMPLE_GRANULARITY ) );
174
z = (fp24*) ( (u8*) (fp24*) DepthBuffer->lock() + ( aposy * pitch1 ) + (aposx << 2 ) );
181
f32 slopeZ = (b->Pos.z - a->Pos.z) / f32(dx);
182
f32 dataZ = a->Pos.z;
186
fp24 slopeW = (b->Pos.w - a->Pos.w) / f32( dx );
187
fp24 dataW = a->Pos.w;
211
dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc
213
z = (fp24*) ( (u8*) z + xInc1 );
216
z = (fp24*) ( (u8*) z + xInc1 );
222
dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc
224
z = (fp24*) ( (u8*) z + yInc1 );
227
z = (fp24*) ( (u8*) z + yInc1 );
244
void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c )
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);
251
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
260
void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b)
263
// query access to TexMaps
266
if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b);
273
} // end namespace video
274
} // end namespace irr
276
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
284
//! creates a flat triangle renderer
285
IBurningShader* createTriangleRendererTextureGouraudWire2(CBurningVideoDriver* driver)
287
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
288
return new CTRTextureWire2(driver);
291
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
295
} // end namespace video
296
} // end namespace irr