#include "IrrCompileConfig.h"
#include "CZBuffer.h"
#include "irrString.h"
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
namespace irr
{
namespace video
{
CZBuffer::CZBuffer(const core::dimension2d<u32>& size)
: Buffer(0), BufferEnd(0), Size(0,0), TotalSize(0)
{
#ifdef _DEBUG
setDebugName("CZBuffer");
#endif
setSize(size);
}
CZBuffer::~CZBuffer()
{
delete [] Buffer;
}
void CZBuffer::clear()
{
memset(Buffer, 0, (BufferEnd-Buffer)*sizeof(TZBufferType));
}
void CZBuffer::setSize(const core::dimension2d<u32>& size)
{
if (size == Size)
return;
Size = size;
delete [] Buffer;
TotalSize = size.Width * size.Height;
Buffer = new TZBufferType[TotalSize];
BufferEnd = Buffer + TotalSize;
}
const core::dimension2d<u32>& CZBuffer::getSize() const
{
return Size;
}
TZBufferType* CZBuffer::lock()
{
return Buffer;
}
void CZBuffer::unlock()
{
}
}
}
#endif
namespace irr
{
namespace video
{
IZBuffer* createZBuffer(const core::dimension2d<u32>& size)
{
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
return new CZBuffer(size);
#else
return 0;
#endif
}
}
}