mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-09 01:03:51 +01:00
20b3d56987
Burnings renderer changes. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6116 dfc29bdd-3216-0410-991c-e03cc46cb475
185 lines
3.1 KiB
C++
185 lines
3.1 KiB
C++
// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
|
|
// This file is part of the "Irrlicht Engine".
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
#include "IrrCompileConfig.h"
|
|
#include "SoftwareDriver2_compile_config.h"
|
|
#include "CDepthBuffer.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
|
|
|
namespace irr
|
|
{
|
|
namespace video
|
|
{
|
|
|
|
|
|
//! constructor
|
|
CDepthBuffer::CDepthBuffer(const core::dimension2d<u32>& size)
|
|
: Buffer(0), Size(0,0)
|
|
{
|
|
#ifdef _DEBUG
|
|
setDebugName("CDepthBuffer");
|
|
#endif
|
|
|
|
setSize(size);
|
|
}
|
|
|
|
|
|
|
|
//! destructor
|
|
CDepthBuffer::~CDepthBuffer()
|
|
{
|
|
if (Buffer)
|
|
{
|
|
delete[] Buffer;
|
|
Buffer = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//! clears the zbuffer
|
|
void CDepthBuffer::clear(f32 value)
|
|
{
|
|
ieee754 zMaxValue;
|
|
|
|
#ifdef SOFTWARE_DRIVER_2_USE_WBUFFER
|
|
zMaxValue.f = 1.f-value;
|
|
#else
|
|
zMaxValue.f = value;
|
|
#endif
|
|
|
|
memset32 ( Buffer, zMaxValue.u, TotalSize );
|
|
}
|
|
|
|
|
|
|
|
//! sets the new size of the buffer
|
|
void CDepthBuffer::setSize(const core::dimension2d<u32>& size)
|
|
{
|
|
if (size == Size)
|
|
return;
|
|
|
|
Size = size;
|
|
|
|
delete [] Buffer;
|
|
|
|
Pitch = size.Width * sizeof ( fp24 );
|
|
TotalSize = Pitch * size.Height;
|
|
Buffer = new u8[align_next(TotalSize,16)];
|
|
clear ();
|
|
}
|
|
|
|
|
|
|
|
//! returns the size of the buffer
|
|
const core::dimension2d<u32>& CDepthBuffer::getSize() const
|
|
{
|
|
return Size;
|
|
}
|
|
|
|
// -----------------------------------------------------------------
|
|
|
|
//! constructor
|
|
CStencilBuffer::CStencilBuffer(const core::dimension2d<u32>& size, unsigned bit)
|
|
: Buffer(0), Size(0,0),Bit(bit)
|
|
{
|
|
#ifdef _DEBUG
|
|
setDebugName("CStencilBuffer");
|
|
#endif
|
|
|
|
setSize(size);
|
|
}
|
|
|
|
|
|
|
|
//! destructor
|
|
CStencilBuffer::~CStencilBuffer()
|
|
{
|
|
if (Buffer)
|
|
{
|
|
delete[] Buffer;
|
|
Buffer = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//! clears the buffer
|
|
void CStencilBuffer::clear(u8 value)
|
|
{
|
|
u32 set = value;
|
|
if (Bit == 8)
|
|
{
|
|
set |= set << 8;
|
|
set |= set << 16;
|
|
}
|
|
memset32 ( Buffer, set, TotalSize );
|
|
}
|
|
|
|
|
|
|
|
//! sets the new size of the buffer
|
|
void CStencilBuffer::setSize(const core::dimension2d<u32>& size)
|
|
{
|
|
if (size == Size)
|
|
return;
|
|
|
|
Size = size;
|
|
|
|
delete [] Buffer;
|
|
|
|
Pitch = size.Width * sizeof (tStencilSample);
|
|
TotalSize = Pitch * size.Height;
|
|
Buffer = new u8[align_next(TotalSize,16)];
|
|
clear ();
|
|
}
|
|
|
|
|
|
|
|
//! returns the size of the buffer
|
|
const core::dimension2d<u32>& CStencilBuffer::getSize() const
|
|
{
|
|
return Size;
|
|
}
|
|
|
|
|
|
|
|
} // end namespace video
|
|
} // end namespace irr
|
|
|
|
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
|
|
|
namespace irr
|
|
{
|
|
namespace video
|
|
{
|
|
|
|
//! creates a ZBuffer
|
|
IDepthBuffer* createDepthBuffer(const core::dimension2d<u32>& size)
|
|
{
|
|
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
|
return new CDepthBuffer(size);
|
|
#else
|
|
return 0;
|
|
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
|
}
|
|
|
|
|
|
//! creates a Stencil Buffer
|
|
IStencilBuffer* createStencilBuffer(const core::dimension2d<u32>& size, u32 bit)
|
|
{
|
|
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
|
return new CStencilBuffer(size,bit);
|
|
#else
|
|
return 0;
|
|
#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
|
|
}
|
|
|
|
} // end namespace video
|
|
} // end namespace irr
|
|
|
|
|
|
|