Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. #ifndef D3DFONT_H
  2. #define D3DFONT_H
  3. #include <tchar.h>
  4. #include <D3D9.h>
  5.  
  6.  
  7. // Font creation flags
  8. #define D3DFONT_BOLD 0x0001
  9. #define D3DFONT_ITALIC 0x0002
  10. #define D3DFONT_ZENABLE 0x0004
  11.  
  12. // Font rendering flags
  13. #define D3DFONT_CENTERED_X 0x0001
  14. #define D3DFONT_CENTERED_Y 0x0002
  15. #define D3DFONT_TWOSIDED 0x0004
  16. #define D3DFONT_FILTERED 0x0008
  17.  
  18.  
  19. //-----------------------------------------------------------------------------
  20. // Name: class CD3DFont
  21. // Desc: Texture-based font class for doing text in a 3D scene.
  22. //-----------------------------------------------------------------------------
  23. class CD3DFont
  24. {
  25. TCHAR m_strFontName[80]; // Font properties
  26. DWORD m_dwFontHeight;
  27. DWORD m_dwFontFlags;
  28.  
  29. LPDIRECT3DDEVICE9 m_pd3dDevice; // A D3DDevice used for rendering
  30. LPDIRECT3DTEXTURE9 m_pTexture; // The d3d texture for this font
  31. LPDIRECT3DVERTEXBUFFER9 m_pVB; // VertexBuffer for rendering text
  32. DWORD m_dwTexWidth; // Texture dimensions
  33. DWORD m_dwTexHeight;
  34. FLOAT m_fTextScale;
  35. FLOAT m_fTexCoords[128-32][4];
  36. DWORD m_dwSpacing; // Character pixel spacing per side
  37.  
  38. // Stateblocks for setting and restoring render states
  39. LPDIRECT3DSTATEBLOCK9 m_pStateBlockSaved;
  40. LPDIRECT3DSTATEBLOCK9 m_pStateBlockDrawText;
  41.  
  42. HRESULT CreateGDIFont( HDC hDC, HFONT* pFont );
  43. HRESULT PaintAlphabet( HDC hDC, BOOL bMeasureOnly=FALSE );
  44.  
  45. public:
  46. // 2D and 3D text drawing functions
  47. HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor,
  48. TCHAR* strText, DWORD dwFlags=0L );
  49. HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
  50. FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
  51. TCHAR* strText, DWORD dwFlags=0L );
  52. HRESULT Render3DText( TCHAR* strText, DWORD dwFlags=0L );
  53.  
  54. // Function to get extent of text
  55. HRESULT GetTextExtent( TCHAR* strText, SIZE* pSize );
  56.  
  57. // Initializing and destroying device-dependent objects
  58. HRESULT InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice );
  59. HRESULT RestoreDeviceObjects();
  60. HRESULT InvalidateDeviceObjects();
  61. HRESULT DeleteDeviceObjects();
  62.  
  63. // Constructor / destructor
  64. CD3DFont( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
  65. ~CD3DFont();
  66. };
  67.  
  68.  
  69.  
  70.  
  71. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement