home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / Common / include / d3dfont.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  2.4 KB  |  78 lines

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