Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.4 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: D3DFont.h
  3. //
  4. // Desc: Texture-based font class
  5. //
  6. //@@BEGIN_MSINTERNAL
  7. //
  8. // Hist: 06.01.00 - mwetzel - Last modified
  9. //
  10. //@@END_MSINTERNAL
  11. // Copyright (c) 1999-2000 Microsoft Corporation. All rights reserved.
  12. //-----------------------------------------------------------------------------
  13. #ifndef D3DFONT_H
  14. #define D3DFONT_H
  15. #include <tchar.h>
  16. #include <D3D8.h>
  17. // Font creation flags
  18. #define D3DFONT_BOLD 0x0001
  19. #define D3DFONT_ITALIC 0x0002
  20. // Font rendering flags
  21. #define D3DFONT_CENTERED 0x0001
  22. #define D3DFONT_TWOSIDED 0x0002
  23. #define D3DFONT_FILTERED 0x0004
  24. //-----------------------------------------------------------------------------
  25. // Name: class CD3DFont
  26. // Desc: Texture-based font class for doing text in a 3D scene.
  27. //-----------------------------------------------------------------------------
  28. class CD3DFont
  29. {
  30. TCHAR m_strFontName[80]; // Font properties
  31. DWORD m_dwFontHeight;
  32. DWORD m_dwFontFlags;
  33. LPDIRECT3DDEVICE8 m_pd3dDevice; // A D3DDevice used for rendering
  34. LPDIRECT3DTEXTURE8 m_pTexture; // The d3d texture for this font
  35. LPDIRECT3DVERTEXBUFFER8 m_pVB; // VertexBuffer for rendering text
  36. DWORD m_dwTexWidth; // Texture dimensions
  37. DWORD m_dwTexHeight;
  38. FLOAT m_fTextScale;
  39. FLOAT m_fTexCoords[128-32][4];
  40. // Stateblocks for setting and restoring render states
  41. DWORD m_dwSavedStateBlock;
  42. DWORD m_dwDrawTextStateBlock;
  43. public:
  44. // 2D and 3D text drawing functions
  45. HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor,
  46. TCHAR* strText, DWORD dwFlags=0L );
  47. HRESULT DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
  48. FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
  49. TCHAR* strText, DWORD dwFlags=0L );
  50. HRESULT Render3DText( TCHAR* strText, DWORD dwFlags=0L );
  51. // Function to get extent of text
  52. HRESULT GetTextExtent( TCHAR* strText, SIZE* pSize );
  53. // Initializing and destroying device-dependent objects
  54. HRESULT InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
  55. HRESULT RestoreDeviceObjects();
  56. HRESULT InvalidateDeviceObjects();
  57. HRESULT DeleteDeviceObjects();
  58. // Constructor / destructor
  59. CD3DFont( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
  60. ~CD3DFont();
  61. };
  62. #endif