#include "IrrCompileConfig.h"
#include "SoftwareDriver2_compile_config.h"
#include "CDepthBuffer.h"
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
namespace irr
{
namespace video
{
CDepthBuffer::CDepthBuffer(const core::dimension2d<u32>& size)
: Buffer(0), Size(0,0)
{
#ifdef _DEBUG
setDebugName("CDepthBuffer");
#endif
setSize(size);
}
CDepthBuffer::~CDepthBuffer()
{
if (Buffer)
delete [] Buffer;
}
void CDepthBuffer::clear()
{
#ifdef SOFTWARE_DRIVER_2_USE_WBUFFER
f32 zMax = 0.f;
#else
f32 zMax = 1.f;
#endif
u32 zMaxValue;
zMaxValue = IR(zMax);
memset32 ( Buffer, zMaxValue, TotalSize );
}
void CDepthBuffer::setSize(const core::dimension2d<u32>& size)
{
if (size == Size)
return;
Size = size;
if (Buffer)
delete [] Buffer;
Pitch = size.Width * sizeof ( fp24 );
TotalSize = Pitch * size.Height;
Buffer = new u8[TotalSize];
clear ();
}
const core::dimension2d<u32>& CDepthBuffer::getSize() const
{
return Size;
}
CStencilBuffer::CStencilBuffer(const core::dimension2d<u32>& size)
: Buffer(0), Size(0,0)
{
#ifdef _DEBUG
setDebugName("CDepthBuffer");
#endif
setSize(size);
}
CStencilBuffer::~CStencilBuffer()
{
if (Buffer)
delete [] Buffer;
}
void CStencilBuffer::clear()
{
memset32 ( Buffer, 0, TotalSize );
}
void CStencilBuffer::setSize(const core::dimension2d<u32>& size)
{
if (size == Size)
return;
Size = size;
if (Buffer)
delete [] Buffer;
Pitch = size.Width * sizeof ( u32 );
TotalSize = Pitch * size.Height;
Buffer = new u8[TotalSize];
clear ();
}
const core::dimension2d<u32>& CStencilBuffer::getSize() const
{
return Size;
}
}
}
#endif
namespace irr
{
namespace video
{
IDepthBuffer* createDepthBuffer(const core::dimension2d<u32>& size)
{
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
return new CDepthBuffer(size);
#else
return 0;
#endif
}
IStencilBuffer* createStencilBuffer(const core::dimension2d<u32>& size)
{
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
return new CStencilBuffer(size);
#else
return 0;
#endif
}
}
}