mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-03 00:40:41 +01:00
86dd0cde26
- 10 year anniversary update - Lighting model reworked. moved to eyespace like openGL. [Specular Highlights, Fog, Sphere/Reflection Map] - increased internal s4DVertex to support 4 Textures and 4 Colors [switchable] - Textures are handled as sRGB during Mipmap Generation. More accurate, less visual disruption - 2D is drawn as 3D like hardware drivers. [switchable]. enables viewport scaling, material2D - Texture Spatial Resolution Limiting working. [lower memory consumption,SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE] - SuperTuxKart 8.0.1 playable git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6086 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
|
|
|
|
|
|
|