2 #include "AssetEntity.h" 51 static int GetFormatByFileName(
const std::string& filename);
86 int m_width, m_height;
101 TextureInfo(
int width,
int height, TEXTURE_FORMAT format, SUB_TYPE subtype)
102 : m_width(width), m_height(height), m_format(format), m_subtype(subtype){};
104 : m_width(0), m_height(0), m_format(FMT_UNKNOWN), m_subtype(TYPE_UNKNOWN){};
106 : m_width(t.m_width), m_height(t.m_height), m_format(t.m_format), m_subtype(t.m_subtype){};
109 TEXTURE_FORMAT GetFormat()
const {
return m_format; }
110 int GetHeight()
const {
return m_height; }
111 int GetWidth()
const {
return m_width; }
119 int m_nCurrentFrameIndex;
123 AnimatedTextureInfo() :m_fFPS(15.f), m_nFrameCount(0), m_nCurrentFrameIndex(0), m_bAutoAnimation(true){};
161 virtual HRESULT InitDeviceObjects();
162 virtual HRESULT RestoreDeviceObjects();
163 virtual HRESULT InvalidateDeviceObjects();
164 virtual HRESULT DeleteDeviceObjects();
168 virtual HRESULT
LoadFromMemory(
const char* buffer, DWORD nFileSize, UINT nMipLevels, D3DFORMAT dwTextureFormat = D3DFMT_UNKNOWN,
void** ppTexture = NULL) {
return E_FAIL; };
175 virtual bool LoadFromImage(
ImageEntity * image, D3DFORMAT dwTextureFormat = D3DFMT_UNKNOWN, UINT nMipLevels = 0,
void** ppTexture = NULL);
188 virtual HRESULT CreateTextureFromFile_Async(
void* pContext,
RenderDevicePtr pDev = NULL,
const char* sFileName = NULL,
void** ppTexture = NULL, D3DFORMAT dwTextureFormat = D3DFMT_UNKNOWN, UINT nMipLevels = D3DX_DEFAULT,
Color dwColorKey = 0);
191 bool IsAsyncLoad()
const;
192 void SetAsyncLoad(
bool val);
195 virtual bool SetRenderTarget(
int nIndex = 0) {
return false; };
198 virtual void SetSamplerStateBlocky(
bool bIsBlocky);
199 virtual bool IsSamplerStateBlocky();
204 void SetColorKey(
Color colorKey);
212 virtual bool IsLoaded();
219 void SetRawData(
char* pData,
int nSize);
223 int GetRawDataSize();
225 bool GiveupRawDataOwnership();
232 virtual void SetTextureInfo(
const TextureInfo& tInfo);
238 virtual int32 GetWidth();
239 virtual int32 GetHeight();
244 virtual bool IsFlipY();
248 int GetHitCount(){
return m_nHitCount; }
252 void SetHitCount(
int nHitCount){ m_nHitCount = nHitCount; }
263 void Refresh(
const char* sFilename = NULL,
bool bLazyLoad =
false);
275 void SetTextureFPS(
float FPS);
280 void EnableTextureAutoAnimation(
bool bEnable);
285 void SetCurrentFrameNumber(
int nFrame);
290 int GetCurrentFrameNumber();
301 virtual bool SaveToFile(
const char* filename, D3DFORMAT dwFormat,
int width,
int height, UINT MipLevels = 1, DWORD Filter = D3DX_DEFAULT,
Color ColorKey = 0);;
311 static void LoadImage(
char *sBufMemFile,
int sizeBuf,
int &width,
int &height, byte ** ppBuffer,
bool bAlpha);
316 static bool LoadImageOfFormat(
const std::string& sTextureFileName,
char *sBufMemFile,
int sizeBuf,
int &width,
int &height, byte ** ppBuffer,
int* pBytesPerPixel = NULL,
int nFormat = -1);
317 static bool LoadImageOfFormatEx(
const std::string& sTextureFileName,
char *sBufMemFile,
int sizeBuf,
int &width,
int &height, byte ** ppBuffer,
int* pBytesPerPixel = NULL,
int nFormat = -1,
ImageExtendInfo *info =
nullptr);
320 static TextureEntity* CreateTexture(
const uint8 * pTexels,
int width,
int height,
int rowLength,
int bytesPerPixel, uint32 nMipLevels = 0, D3DPOOL dwCreatePool= D3DPOOL_MANAGED, DWORD nFormat = 0);
322 static TextureEntity* CreateTexture(
const char* pFileName, uint32 nMipLevels = 0, D3DPOOL dwCreatePool = D3DPOOL_MANAGED);
327 #ifdef USE_DIRECTX_RENDERER 328 #include "TextureEntityDirectX.h" 329 #elif defined(USE_OPENGL_RENDERER) 330 #include "TextureEntityOpenGL.h" Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
AnimatedTextureInfo * m_pAnimatedTextureInfo
only animated texture use this type.
Definition: TextureEntity.h:133
bool m_bAutoAnimation
if true, the animation texture will be automatically animated.
Definition: TextureEntity.h:121
CTextureProcessor implementation of IDataProcessor.
Definition: ContentLoaderTexture.h:71
detailed terrain texture
Definition: TextureEntity.h:69
HTML renderer textures, <html>name:initial page url.
Definition: TextureEntity.h:75
a group of textures, such as xxx_a001.jpg, ..., xxx_a009.jpg
Definition: TextureEntity.h:63
virtual DeviceTexturePtr_type GetTexture()
Get the texture for rendering.
Definition: TextureEntity.h:159
AssetType
each asset type has a unique asset type number
Definition: AssetEntity.h:82
basic texture information
Definition: TextureEntity.h:83
different physics engine has different winding order.
Definition: EventBinding.h:32
cube texture for environment mapping, etc.
Definition: TextureEntity.h:71
normal managed texture, with all mip-mapping level created
Definition: TextureEntity.h:61
for animated texture
Definition: TextureEntity.h:115
a very thin wrapper to DirectX device with a portable version of openGL implementation.
Definition: RenderDeviceDirectX.h:10
BLP textures.
Definition: TextureEntity.h:67
char * m_pRawData
raw data
Definition: TextureEntity.h:137
AssetManager manages a set of asset entities of a certain type.
Definition: AssetManager.h:13
Definition: TextureEntity.h:8
a pure texture surface
Definition: TextureEntity.h:77
flash textures, such as swf and flv streaming video files, etc.
Definition: TextureEntity.h:73
TextureInfo * m_pTextureInfo
currently all surface types except the animated texture use this struct
Definition: TextureEntity.h:131
virtual HRESULT LoadFromMemory(const char *buffer, DWORD nFileSize, UINT nMipLevels, D3DFORMAT dwTextureFormat=D3DFMT_UNKNOWN, void **ppTexture=NULL)
load from memory buffer.
Definition: TextureEntity.h:168
depth stencil surface
Definition: TextureEntity.h:79
int32 m_nRawDataSize
raw data size
Definition: TextureEntity.h:139
_SurfaceType
Definition: TextureEntity.h:55
static int g_nTextureLOD
Most detailed level-of-detail value to set for the mipmap chain.
Definition: TextureEntity.h:42
static bool g_bEnable32bitsTexture
whether we will load files whose name ends with _32bits as 32 bits textures.
Definition: TextureEntity.h:46
float m_fFPS
default value is 15
Definition: TextureEntity.h:117
static const std::string DEFAULT_STATIC_TEXTURE
default texture to replaced downloading one.
Definition: TextureEntity.h:35
std::string AssetKey
the unique key object for asset entity.
Definition: AssetEntity.h:13
Definition: ParaColor.h:275
texture in memory
Definition: TextureEntity.h:65
Unlike TextureEntity, ImageEntity is a device independent entity in memory.
Definition: ImageEntity.h:9
bool m_bAsyncLoad
whether to async loading the texture.
Definition: TextureEntity.h:149
Base class for managed asset entity in ParaEngine.
Definition: AssetEntity.h:25