0001:
0002:
0003:
0004:
0005:
0006: #ifndef D3DFONT_H
0007: #define D3DFONT_H
0008: #include <tchar.h>
0009: #include <D3D9.h>
0010:
0011:
0012:
0013: #define D3DFONT_BOLD 0x0001
0014: #define D3DFONT_ITALIC 0x0002
0015: #define D3DFONT_ZENABLE 0x0004
0016:
0017:
0018: #define D3DFONT_CENTERED_X 0x0001
0019: #define D3DFONT_CENTERED_Y 0x0002
0020: #define D3DFONT_TWOSIDED 0x0004
0021: #define D3DFONT_FILTERED 0x0008
0022:
0023:
0024:
0025:
0026:
0027:
0028:
0029:
0030: class CD3DFont
0031: {
0032: TCHAR m_strFontName[80];
0033: DWORD m_dwFontHeight;
0034: DWORD m_dwFontFlags;
0035:
0036: LPDIRECT3DDEVICE9 m_pd3dDevice;
0037: LPDIRECT3DTEXTURE9 m_pTexture;
0038: LPDIRECT3DVERTEXBUFFER9 m_pVB;
0039: DWORD m_dwTexWidth;
0040: DWORD m_dwTexHeight;
0041: FLOAT m_fTextScale;
0042: FLOAT m_fTexCoords[128-32][4];
0043: DWORD m_dwSpacing;
0044:
0045:
0046: LPDIRECT3DSTATEBLOCK9 m_pStateBlockSaved;
0047: LPDIRECT3DSTATEBLOCK9 m_pStateBlockDrawText;
0048:
0049: public:
0050:
0051: HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor,
0052: const TCHAR* strText, DWORD dwFlags=0L );
0053: HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
0054: FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
0055: const TCHAR* strText, DWORD dwFlags=0L );
0056: HRESULT Render3DText( const TCHAR* strText, DWORD dwFlags=0L );
0057:
0058:
0059: HRESULT GetTextExtent( const TCHAR* strText, SIZE* pSize );
0060:
0061:
0062: HRESULT InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );
0063: HRESULT RestoreDeviceObjects();
0064: HRESULT InvalidateDeviceObjects();
0065: HRESULT DeleteDeviceObjects();
0066:
0067:
0068: CD3DFont( const TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
0069: ~CD3DFont();
0070: };
0071:
0072:
0073:
0074:
0075: #endif
0076:
0077:
0078: