afTexture.h
资源名称:AirForce.rar [点击查看]
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:2k
源码类别:
其他游戏
开发平台:
Visual C++
- #ifndef AF_TEXTURE
- #define AF_TEXTURE
- #include "afImage.h"
- #include "afString.h"
- #include <D3D9.h>
- /// afTextur class
- class afTexture
- {
- public:
- afTexture();
- afTexture(const afString& nName, LPDIRECT3DTEXTURE9 nD3DTex, int nWidth, int nHeight, afImage::FORMAT nFormat);
- /// Returns a pointer to the underlying Direct3D texture
- /**
- * The special case the texture object is invalid (NULL)
- * is caught and NULL is returned
- */
- LPDIRECT3DTEXTURE9 getD3DTexture() { return (this==NULL) ? NULL : d3dTexture; }
- /// Cast operator to cast the texture to a Direct3D texture
- /**
- * The special case the texture object is invalid (NULL)
- * is caught and NULL is returned
- */
- operator LPDIRECT3DTEXTURE9() { return (this==NULL) ? NULL : d3dTexture; }
- /// Returns true if the texture in a compressed format
- bool isCompressed() const;
- /// Returns the width of the texture
- int getWidth() const { return width; }
- /// Returns the height of the texture
- int getHeight() const { return height; }
- /// Returns the name of the texture
- const afString& getName() const { return name; }
- /// Retrieves a pointer to the texture data
- /**
- * In order to get a pointer to the texture's data, the texture must be locked.
- * Before the texture can be used for further rendering it must be unlocked
- * by calling releaseData()
- */
- bool getData(unsigned char*& nData, int& nPitch, int nLevel=0, bool nReadOnly=true);
- /// returns the texture's image format
- afImage::FORMAT getFormat() const { return format; }
- /// Releases a texture which was by getData()
- void releaseData();
- LPDIRECT3DTEXTURE9 d3dTexture;
- int width, height;
- afImage::FORMAT format;
- afString name;
- int lockLevel;
- };
- typedef afTexture *afTexturePtr;
- #endif