home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8a_sdk.exe / samples / multimedia / common / include / d3dfont.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-04  |  2.4 KB  |  77 lines

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