#ifndef __C_DIRECTX9_TEXTURE_H_INCLUDED__
#define __C_DIRECTX9_TEXTURE_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
#include "ITexture.h"
#include "IImage.h"
#if defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
#include "irrMath.h"
#endif
#include <d3d9.h>
namespace irr
{
namespace video
{
class CD3D9Driver;
struct SDepthSurface;
class CD3D9Texture : public ITexture
{
public:
CD3D9Texture(IImage* image, CD3D9Driver* driver,
u32 flags, const io::path& name, void* mipmapData=0);
CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const io::path& name,
const ECOLOR_FORMAT format = ECF_UNKNOWN);
virtual ~CD3D9Texture();
virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0);
virtual void unlock();
virtual const core::dimension2d<u32>& getOriginalSize() const;
virtual const core::dimension2d<u32>& getSize() const;
virtual E_DRIVER_TYPE getDriverType() const;
virtual ECOLOR_FORMAT getColorFormat() const;
virtual u32 getPitch() const;
IDirect3DBaseTexture9* getDX9Texture() const;
bool hasMipMaps() const;
virtual void regenerateMipMapLevels(void* mipmapData=0);
virtual bool isRenderTarget() const;
IDirect3DSurface9* getRenderTargetSurface();
private:
friend class CD3D9Driver;
void createRenderTarget(const ECOLOR_FORMAT format = ECF_UNKNOWN);
bool createTexture(u32 flags, IImage * image);
bool copyTexture(IImage * image);
bool createMipMaps(u32 level=1);
void copy16BitMipMap(char* src, char* tgt,
s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const;
void copy32BitMipMap(char* src, char* tgt,
s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const;
void setPitch(D3DFORMAT d3dformat);
IDirect3DDevice9* Device;
IDirect3DTexture9* Texture;
IDirect3DSurface9* RTTSurface;
CD3D9Driver* Driver;
SDepthSurface* DepthSurface;
core::dimension2d<u32> TextureSize;
core::dimension2d<u32> ImageSize;
s32 Pitch;
u32 MipLevelLocked;
ECOLOR_FORMAT ColorFormat;
bool HasMipMaps;
bool HardwareMipMaps;
bool IsRenderTarget;
};
}
}
#endif
#endif