// Z3DTexture.h: interface for the Z3DTexture class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_Z3DTEXTURE_H__DDBD9A61_EC01_11D4_AD2B_0000E8EB4C69__INCLUDED_) #define AFX_Z3DTEXTURE_H__DDBD9A61_EC01_11D4_AD2B_0000E8EB4C69__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "misc.h" #include "SimpleString.h" #include #include #include #include struct Z3DTextureCacheNode { long lWidth; long lHeight; long lMipCount; D3DFORMAT format; IDirect3DTexture8* pTexture; Z3DTextureCacheNode* pNext; }; struct Z3DTexture { public: Z3DTexture() { m_pTexture = NULL; } ~Z3DTexture(); bool Create( int x, int y ) { return SUCCEEDED( D3DXCreateTexture( ms_pDevice, x, y, 10, 0, D3DFMT_A1R5G5B5, D3DPOOL_DEFAULT, &m_pTexture ) ); return true; } bool Load( const char* szFileName, UINT width = 0, UINT height = 0 ); bool Save( const char* szFilename ); bool Convert( const D3DFORMAT targetFormat ); bool ReadDDSheader( const char* szFileName, DDS_HEADER* pHeader ); bool LoadAllMipSurfaces(LPDIRECT3DBASETEXTURE8 ptex,long numMips, FILE *fp); bool IsEmpty() { return (NULL == m_pTexture); } void Flush() { SAFE_RELEASE( m_pTexture ); } D3DFORMAT GetTextureFormat() { if( NULL == m_pTexture ) { return D3DFMT_UNKNOWN; } D3DSURFACE_DESC sd; m_pTexture->GetLevelDesc( 0, &sd ); return sd.Format; } operator IDirect3DTexture8* () { return m_pTexture; } static bool _Init( IDirect3DDevice8* pDevice, const char* szPath, long level = 0, long lMaxCacheCount = 20 ); static void _Close(); static long _GetDetailLevel() { return ms_lDetailLevel; } static IDirect3DTexture8* _GetD3DTextureInterface( long lWidth, long lHeight, long lMipCount, D3DFORMAT fmt ); static void _ReleaseD3DTextureInterface( IDirect3DTexture8* pTexture ); char m_strName[256]; protected: IDirect3DTexture8* m_pTexture; static IDirect3DDevice8* ms_pDevice; //static char* ms_szDataPath; static SimpleString ms_strDataPath; static long ms_lDetailLevel; // ij½Ã ¸®½ºÆ®. SLL À̸ç Ãß°¡´Â header, »èÁ¦´Â tail ¿¡¼­ ÀϾ static long ms_lMaxCacheCount; static long ms_lCacheCount; static Z3DTextureCacheNode* ms_pCacheChainHeader; }; #endif // !defined(AFX_Z3DTEXTURE_H__DDBD9A61_EC01_11D4_AD2B_0000E8EB4C69__INCLUDED_)