2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_DIRECTX9_TEXTURE_H_INCLUDED
|
|
|
|
#define IRR_C_DIRECTX9_TEXTURE_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
|
|
|
|
|
|
|
|
#include "irrArray.h"
|
|
|
|
#include "ITexture.h"
|
|
|
|
#include "IImage.h"
|
|
|
|
#if defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
|
|
|
#include "irrMath.h" // needed by borland for sqrtf define
|
|
|
|
#endif
|
|
|
|
#include <d3d9.h>
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
|
|
|
|
|
|
|
class CD3D9Driver;
|
|
|
|
|
|
|
|
class CD3D9Texture : public ITexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CD3D9Texture(const io::path& name, const core::array<IImage*>& image, E_TEXTURE_TYPE type, CD3D9Driver* driver);
|
|
|
|
|
|
|
|
CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const io::path& name, E_TEXTURE_TYPE type, const ECOLOR_FORMAT format = ECF_UNKNOWN);
|
|
|
|
|
|
|
|
virtual ~CD3D9Texture();
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void unlock() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
IDirect3DBaseTexture9* getDX9BaseTexture() const;
|
|
|
|
IDirect3DTexture9* getDX9Texture() const;
|
|
|
|
IDirect3DCubeTexture9* getDX9CubeTexture() const;
|
|
|
|
|
2021-06-04 14:17:01 +02:00
|
|
|
inline bool HasVertexTextureSupport() const
|
|
|
|
{
|
|
|
|
return VertexTextureSupport;
|
|
|
|
}
|
|
|
|
|
2019-12-12 17:32:41 +01:00
|
|
|
private:
|
|
|
|
friend class CD3D9Driver;
|
|
|
|
|
|
|
|
void releaseTexture();
|
|
|
|
|
|
|
|
void generateRenderTarget();
|
|
|
|
|
|
|
|
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
|
|
|
|
|
|
|
|
void getImageValues(const IImage* image);
|
|
|
|
|
|
|
|
void uploadTexture(void* data, u32 mipmapLevel, u32 layer);
|
|
|
|
|
|
|
|
//! Helper function for mipmap generation.
|
|
|
|
bool createManualMipMaps(u32 level);
|
|
|
|
|
|
|
|
//! Helper function for mipmap generation.
|
|
|
|
void copy16BitMipMap(char* src, char* tgt,
|
|
|
|
s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const;
|
|
|
|
|
|
|
|
//! Helper function for mipmap generation.
|
|
|
|
void copy32BitMipMap(char* src, char* tgt,
|
|
|
|
s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const;
|
|
|
|
|
|
|
|
|
|
|
|
CD3D9Driver* Driver;
|
|
|
|
|
|
|
|
D3DFORMAT InternalFormat;
|
|
|
|
|
|
|
|
bool LockReadOnly;
|
|
|
|
void* LockData;
|
|
|
|
u32 LockLayer;
|
|
|
|
u32 MipLevelLocked;
|
|
|
|
|
|
|
|
bool HardwareMipMaps;
|
2021-06-04 14:17:01 +02:00
|
|
|
bool VertexTextureSupport;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
IDirect3DDevice9* Device;
|
|
|
|
IDirect3DTexture9* Texture;
|
|
|
|
IDirect3DCubeTexture9* CubeTexture;
|
|
|
|
IDirect3DSurface9* RTTSurface;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|