#ifndef __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
#define __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
#include "SoftwareDriver2_compile_config.h"
#include "ITexture.h"
#include "CImage.h"
namespace irr
{
namespace video
{
class CSoftwareTexture2 : public ITexture
{
public:
enum eTex2Flags
{
GEN_MIPMAP = 1,
IS_RENDERTARGET = 2,
NP2_SIZE = 4,
HAS_ALPHA = 8
};
CSoftwareTexture2(IImage* surface, const io::path& name, u32 flags, void* mipmapData=0);
virtual ~CSoftwareTexture2();
virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0)
{
if (Flags & GEN_MIPMAP)
MipMapLOD=mipmapLevel;
return MipMap[MipMapLOD]->lock();
}
virtual void unlock()
{
MipMap[MipMapLOD]->unlock();
}
virtual const core::dimension2d<u32>& getOriginalSize() const
{
return OrigSize;
}
f32 getLODFactor( const f32 texArea ) const
{
return OrigImageDataSizeInPixels * texArea;
}
virtual const core::dimension2d<u32>& getSize() const
{
return MipMap[MipMapLOD]->getDimension();
}
virtual CImage* getImage() const
{
return MipMap[0];
}
virtual CImage* getTexture() const
{
return MipMap[MipMapLOD];
}
virtual E_DRIVER_TYPE getDriverType() const
{
return EDT_BURNINGSVIDEO;
}
virtual ECOLOR_FORMAT getColorFormat() const
{
return BURNINGSHADER_COLOR_FORMAT;
}
virtual u32 getPitch() const
{
return MipMap[MipMapLOD]->getPitch();
}
virtual void regenerateMipMapLevels(void* mipmapData=0);
virtual bool hasMipMaps() const
{
return (Flags & GEN_MIPMAP ) != 0;
}
virtual bool hasAlpha() const
{
return (Flags & HAS_ALPHA ) != 0;
}
virtual bool isRenderTarget() const
{
return (Flags & IS_RENDERTARGET) != 0;
}
private:
f32 OrigImageDataSizeInPixels;
core::dimension2d<u32> OrigSize;
CImage * MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
u32 MipMapLOD;
u32 Flags;
ECOLOR_FORMAT OriginalFormat;
};
}
}
#endif