?? texture.h
字號:
//--------------------------------------------------
// Desc: Texture
// Date: 2006.10.26 /update
// Author: artsylee
//
// Copyright (C) 2006 artsylee
//
// 擴展: 添加對自定義格式AMF的支持(2006_12_16)
// Mipmap支持(2006_12_21)
// AMF支持mipmap(2006_12_28)
//
//--------------------------------------------------
#ifndef _TEXTURE_
#define _TEXTURE_
#include <d3dx9.h>
#include <string>
enum MemoryMode
{
MM_AUTO = 0, //自動管理
MM_KEEPINMEMORY = 1, //常駐內存
};
class ASE_DLL CTexture
{
public:
CTexture();
virtual ~CTexture();
bool LoadTexture(const char *szFilename, int mipLevel = 1);
bool LoadTextureDesc(const char *szFilename, int mipLevel = 1);
bool LoadAMFTexture(const char *szFilename, DWORD index = 0, int mipLevel = 1);
bool LoadAMFTextureDesc(const char *szFilename, DWORD index =0, int mipLevel = 1);
int AddRef(void);
int Release(void);
void Destroy(void);
//---------------------------------------------------
// Auto Access
bool AutoLoad(void);
int AutoRemove(void);
//---------------------------------------------------
// 2006_11_02(create keep in memory texture)
// 字體紋理使用,動畫序列幀使用
bool CreateTexture(int width, int height, D3DFORMAT colorFmt, D3DPOOL mem = D3DPOOL_MANAGED);
bool CreateMipTexture(int width, int height, D3DFORMAT colorFmt, D3DPOOL mem = D3DPOOL_MANAGED);
//---------------------------------------------------
LPDIRECT3DTEXTURE9 GetTexture() const { return m_pTexture; }
DWORD GetLastUseTime() const { return m_LastUseTime; }
void SetLastUseTime(DWORD tm){ m_LastUseTime = tm; }
MemoryMode GetMemMode(void) const { return m_MemoryMode; }
void SetMemMode(MemoryMode mode) { m_MemoryMode = mode; }
int GetWidth() const { return m_Width; }
int GetHeight() const { return m_Height; }
bool IsRelease() const { return m_IsAutoRelease;}
std::string GetName(void) const { return m_Name; }
DWORD GetIndex(void) const{ return (m_FileFlag & 0x00ffffff); }
// int GetMipMapLevel(void) const{ return m_MipmapLevel; }
protected:
bool ReLoadAMFTexture(const char *szFilename, DWORD index, int mipLevel = 1);
protected:
int m_Ref;
int m_Width;
int m_Height;
DWORD m_LastUseTime;
D3DPOOL m_MemoryPool;
int m_MipmapLevel;
DWORD m_FileFlag; // 自定義文件標記,帶有圖片索引號
std::string m_Name;
bool m_IsAutoRelease;
MemoryMode m_MemoryMode;
IDirect3DTexture9* m_pTexture;
};
#endif // _TEXTURE_
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -