Merging r6364 through r6379 from trunk to ogl-es branch
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6380 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@@ -28,10 +28,10 @@
|
||||
#define SUBTEXEL
|
||||
#define INVERSE_W
|
||||
|
||||
//#define USE_ZBUFFER
|
||||
#define USE_ZBUFFER
|
||||
#define IPOL_W
|
||||
//#define CMP_W
|
||||
//#define WRITE_W
|
||||
#define CMP_W
|
||||
#define WRITE_W
|
||||
|
||||
|
||||
#define IPOL_C0
|
||||
@@ -40,41 +40,36 @@
|
||||
|
||||
// apply global override
|
||||
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
|
||||
#undef INVERSE_W
|
||||
#undef INVERSE_W
|
||||
#endif
|
||||
|
||||
#ifndef SOFTWARE_DRIVER_2_SUBTEXEL
|
||||
#undef SUBTEXEL
|
||||
#undef SUBTEXEL
|
||||
#endif
|
||||
|
||||
#if BURNING_MATERIAL_MAX_COLORS < 1
|
||||
#undef IPOL_C0
|
||||
#undef IPOL_C0
|
||||
#endif
|
||||
|
||||
#if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER )
|
||||
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
|
||||
#undef IPOL_W
|
||||
#endif
|
||||
#define IPOL_Z
|
||||
#ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT
|
||||
#undef IPOL_W
|
||||
#endif
|
||||
#define IPOL_Z
|
||||
|
||||
#ifdef CMP_W
|
||||
#undef CMP_W
|
||||
#define CMP_Z
|
||||
#endif
|
||||
#ifdef CMP_W
|
||||
#undef CMP_W
|
||||
#define CMP_Z
|
||||
#endif
|
||||
|
||||
#ifdef WRITE_W
|
||||
#undef WRITE_W
|
||||
#define WRITE_Z
|
||||
#endif
|
||||
#ifdef WRITE_W
|
||||
#undef WRITE_W
|
||||
#define WRITE_Z
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
namespace video
|
||||
{
|
||||
burning_namespace_start
|
||||
|
||||
class CTRTextureWire2 : public IBurningShader
|
||||
{
|
||||
@@ -83,43 +78,54 @@ public:
|
||||
//! constructor
|
||||
CTRTextureWire2(CBurningVideoDriver* driver);
|
||||
|
||||
virtual void OnSetMaterialBurning(const SBurningShaderMaterial& material) IRR_OVERRIDE;
|
||||
|
||||
//! draws an indexed triangle list
|
||||
virtual void drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c) IRR_OVERRIDE;
|
||||
virtual void drawLine ( const s4DVertex *a,const s4DVertex *b) IRR_OVERRIDE;
|
||||
virtual void drawPoint( const s4DVertex *a) IRR_OVERRIDE;
|
||||
virtual bool canWireFrame () IRR_OVERRIDE { return true; }
|
||||
virtual bool canPointCloud() IRR_OVERRIDE { return true; }
|
||||
virtual void drawLine(const s4DVertex* a, const s4DVertex* b) IRR_OVERRIDE;
|
||||
virtual void drawPoint(const s4DVertex* a) IRR_OVERRIDE;
|
||||
virtual bool canWireFrame() IRR_OVERRIDE { return true; }
|
||||
virtual bool canPointCloud() IRR_OVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
virtual void fragmentShader();
|
||||
|
||||
void renderAlphaLine ( const s4DVertex *a,const s4DVertex *b ) const;
|
||||
void renderLine ( const s4DVertex *a,const s4DVertex *b, int renderZero = 0 ) const;
|
||||
void renderLine(const s4DVertex* a, const s4DVertex* b) const;
|
||||
|
||||
int renderZero;
|
||||
int depth_pass;
|
||||
int depth_write;
|
||||
};
|
||||
|
||||
//! constructor
|
||||
CTRTextureWire2::CTRTextureWire2(CBurningVideoDriver* driver)
|
||||
: IBurningShader(driver)
|
||||
: IBurningShader(driver, EMT_SOLID)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CTRTextureWire2");
|
||||
#endif
|
||||
#endif
|
||||
renderZero = 0;
|
||||
depth_pass = 1;
|
||||
depth_write = 0;
|
||||
}
|
||||
|
||||
void CTRTextureWire2::OnSetMaterialBurning(const SBurningShaderMaterial& material)
|
||||
{
|
||||
depth_pass = material.depth_test == 0;
|
||||
depth_write = material.depth_write;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
2d line
|
||||
*/
|
||||
void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int renderZero) const
|
||||
void CTRTextureWire2::renderLine(const s4DVertex* a, const s4DVertex* b) const
|
||||
{
|
||||
int pitch0 = RenderTarget->getDimension().Width << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY;
|
||||
const int pitch0 = RenderTarget->getDimension().Width << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY;
|
||||
#ifdef USE_ZBUFFER
|
||||
int pitch1 = RenderTarget->getDimension().Width << 2;
|
||||
const int pitch1 = RenderTarget->getDimension().Width * sizeof(fp24);
|
||||
#endif
|
||||
|
||||
//todo:!
|
||||
//todo: fill_convention_none!
|
||||
int aposx = fill_convention_none(a->Pos.x);
|
||||
int aposy = fill_convention_none(a->Pos.y);
|
||||
int bposx = fill_convention_none(b->Pos.x);
|
||||
@@ -133,36 +139,36 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re
|
||||
int d = 0;
|
||||
int run;
|
||||
|
||||
tVideoSample *dst;
|
||||
tVideoSample* dst;
|
||||
#ifdef USE_ZBUFFER
|
||||
fp24 *z;
|
||||
fp24* z;
|
||||
#endif
|
||||
|
||||
int xInc0 = 1 << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY;
|
||||
int yInc0 = pitch0;
|
||||
|
||||
#ifdef USE_ZBUFFER
|
||||
int xInc1 = 4;
|
||||
int xInc1 = sizeof(fp24);
|
||||
int yInc1 = pitch1;
|
||||
#endif
|
||||
|
||||
if ( dx < 0 )
|
||||
if (dx < 0)
|
||||
{
|
||||
xInc0 = - ( 1 << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY);
|
||||
xInc0 = -xInc0;
|
||||
#ifdef USE_ZBUFFER
|
||||
xInc1 = -4;
|
||||
#endif
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy > dx )
|
||||
if (dy > dx)
|
||||
{
|
||||
//swap
|
||||
s32 t;
|
||||
t = dx;dx=dy;dy=t;
|
||||
t = xInc0;xInc0=yInc0;yInc0=t;
|
||||
t = dx; dx = dy; dy = t;
|
||||
t = xInc0; xInc0 = yInc0; yInc0 = t;
|
||||
#ifdef USE_ZBUFFER
|
||||
t = xInc1;xInc1=yInc1;yInc1=t;
|
||||
t = xInc1; xInc1 = yInc1; yInc1 = t;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -173,16 +179,17 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re
|
||||
}
|
||||
|
||||
SOFTWARE_DRIVER_2_CLIPCHECK_WIRE;
|
||||
dst = (tVideoSample*) ( (u8*) RenderTarget->getData() + ( aposy * pitch0 ) + (aposx* (1<< SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY) ) );
|
||||
dst = (tVideoSample*)((u8*)RenderTarget->getData() + (aposy * pitch0) + (aposx << SOFTWARE_DRIVER_2_RENDERTARGET_GRANULARITY));
|
||||
|
||||
#ifdef USE_ZBUFFER
|
||||
z = (fp24*) ( (u8*) (fp24*) DepthBuffer->lock() + ( aposy * pitch1 ) + (aposx << 2 ) );
|
||||
z = (fp24*)((u8*)DepthBuffer->lock() + (aposy * pitch1) + (aposx << 2));
|
||||
#endif
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
// slopes
|
||||
const f32 invDeltaX = fill_step_x( (f32)dx );
|
||||
const f32 invDeltaX = fill_step_x((f32)dx);
|
||||
|
||||
#ifdef IPOL_Z
|
||||
f32 slopeZ = (b->Pos.z - a->Pos.z) * invDeltaX;
|
||||
@@ -210,59 +217,59 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re
|
||||
inversew = fix_inverse32_color(dataW);
|
||||
#endif
|
||||
|
||||
vec4_to_fix( r0, g0, b0, a->Color[0], inversew);
|
||||
color = fix_to_sample( r0, g0, b0 );
|
||||
vec4_to_fix(r0, g0, b0, a->Color[0], inversew);
|
||||
color = fix_to_sample(r0, g0, b0);
|
||||
|
||||
#else
|
||||
color = (tVideoSample) 0xFFFFFFFF;
|
||||
color = (tVideoSample)0xFFFFFFFF;
|
||||
#endif
|
||||
|
||||
|
||||
run = dx;
|
||||
while ( run )
|
||||
while (run)
|
||||
{
|
||||
#ifdef CMP_Z
|
||||
if ( *z >= dataZ )
|
||||
if (*z >= dataZ)
|
||||
#endif
|
||||
#ifdef CMP_W
|
||||
if ( dataW >= *z )
|
||||
if (depth_pass || dataW >= *z)
|
||||
#endif
|
||||
{
|
||||
#ifdef WRITE_Z
|
||||
*z = dataZ;
|
||||
#endif
|
||||
#ifdef WRITE_W
|
||||
*z = dataW;
|
||||
if (depth_write) *z = dataW;
|
||||
#endif
|
||||
|
||||
#ifdef IPOL_C0
|
||||
#ifdef INVERSE_W
|
||||
inversew = fix_inverse32_color(dataW);
|
||||
#endif
|
||||
vec4_to_fix(r0, g0, b0, C,inversew);
|
||||
color = fix_to_sample( r0, g0, b0 );
|
||||
vec4_to_fix(r0, g0, b0, C, inversew);
|
||||
color = fix_to_sample(r0, g0, b0);
|
||||
#endif
|
||||
*dst = color;
|
||||
* dst = color;
|
||||
|
||||
}
|
||||
|
||||
dst = (tVideoSample*) ( (u8*) dst + xInc0 ); // x += xInc
|
||||
dst = (tVideoSample*)((u8*)dst + xInc0); // x += xInc
|
||||
#ifdef CMP_Z
|
||||
z = (fp24*) ( (u8*) z + xInc1 );
|
||||
z = (fp24*)((u8*)z + xInc1);
|
||||
#endif
|
||||
#ifdef CMP_W
|
||||
z = (fp24*) ( (u8*) z + xInc1 );
|
||||
z = (fp24*)((u8*)z + xInc1);
|
||||
#endif
|
||||
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
if (d > dx)
|
||||
{
|
||||
dst = (tVideoSample*) ( (u8*) dst + yInc0 ); // y += yInc
|
||||
dst = (tVideoSample*)((u8*)dst + yInc0); // y += yInc
|
||||
#ifdef CMP_Z
|
||||
z = (fp24*) ( (u8*) z + yInc1 );
|
||||
z = (fp24*)((u8*)z + yInc1);
|
||||
#endif
|
||||
#ifdef CMP_W
|
||||
z = (fp24*) ( (u8*) z + yInc1 );
|
||||
z = (fp24*)((u8*)z + yInc1);
|
||||
#endif
|
||||
|
||||
d -= c;
|
||||
@@ -278,69 +285,61 @@ void CTRTextureWire2::renderLine ( const s4DVertex *a,const s4DVertex *b, int re
|
||||
C += slopeC;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CTRTextureWire2::fragmentShader()
|
||||
{
|
||||
}
|
||||
|
||||
void CTRTextureWire2::drawTriangle(const s4DVertex* burning_restrict a, const s4DVertex* burning_restrict b, const s4DVertex* burning_restrict c)
|
||||
{
|
||||
// sort on height, y
|
||||
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
|
||||
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
|
||||
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
|
||||
if (F32_A_GREATER_B(a->Pos.y, b->Pos.y)) swapVertexPointer(&a, &b);
|
||||
if (F32_A_GREATER_B(b->Pos.y, c->Pos.y)) swapVertexPointer(&b, &c);
|
||||
if (F32_A_GREATER_B(a->Pos.y, b->Pos.y)) swapVertexPointer(&a, &b);
|
||||
|
||||
renderLine ( a, b );
|
||||
renderLine ( b, c );
|
||||
renderLine ( a, c );
|
||||
renderLine(a, b);
|
||||
renderLine(b, c);
|
||||
renderLine(a, c);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b)
|
||||
void CTRTextureWire2::drawLine(const s4DVertex* a, const s4DVertex* b)
|
||||
{
|
||||
// query access to TexMaps
|
||||
|
||||
// sort on height, y
|
||||
if (F32_A_GREATER_B(a->Pos.y,b->Pos.y )) swapVertexPointer(&a, &b);
|
||||
if (F32_A_GREATER_B(a->Pos.y, b->Pos.y)) swapVertexPointer(&a, &b);
|
||||
|
||||
renderLine ( a, b );
|
||||
renderLine(a, b);
|
||||
}
|
||||
|
||||
void CTRTextureWire2::drawPoint(const s4DVertex *a)
|
||||
void CTRTextureWire2::drawPoint(const s4DVertex* a)
|
||||
{
|
||||
if ( (a->flag & VERTEX4D_CLIPMASK ) == VERTEX4D_INSIDE ) renderLine(a, a,1);
|
||||
if ((a->flag & VERTEX4D_CLIPMASK) == VERTEX4D_INSIDE)
|
||||
{
|
||||
renderZero = 1;
|
||||
renderLine(a, a);
|
||||
renderZero = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
burning_namespace_end
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
burning_namespace_start
|
||||
|
||||
//! creates a flat triangle renderer
|
||||
IBurningShader* createTriangleRendererTextureGouraudWire2(CBurningVideoDriver* driver)
|
||||
{
|
||||
//ETR_TEXTURE_GOURAUD_WIRE
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
return new CTRTextureWire2(driver);
|
||||
#else
|
||||
#else
|
||||
return 0;
|
||||
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
burning_namespace_end
|
||||
|
||||
|
Reference in New Issue
Block a user