home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 10 / Engine / Font.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-01  |  1.4 KB  |  36 lines

  1. //-----------------------------------------------------------------------------
  2. // A font render that draws the characters using textured quads.
  3. //
  4. // Note: This is just a cutdown, modified version of the CD3DFont class. 
  5. //
  6. // Programming a Multiplayer First Person Shooter in DirectX
  7. // Copyright (c) 2004 Vaughan Young
  8. //-----------------------------------------------------------------------------
  9. #ifndef FONT_H
  10. #define FONT_H
  11.  
  12. //-----------------------------------------------------------------------------
  13. // Font Class
  14. //-----------------------------------------------------------------------------
  15. class Font
  16. {
  17. public:
  18.     Font( char *name = "Arial", short size = 10, unsigned long bold = FW_NORMAL, bool italic = false );
  19.     virtual ~Font();
  20.  
  21.     void Render( char *text, float x, float y, D3DCOLOR colour = D3DCOLOR_COLORVALUE( 1.0f, 1.0f, 1.0f, 1.0f ) );
  22.  
  23. private:
  24.     bool PrepareFont( HDC hDC, bool measure = false );
  25.  
  26. private:
  27.     IDirect3DStateBlock9 *m_states; // State block used for restoring the render states.
  28.     IDirect3DVertexBuffer9 *m_vb; // Vertex buffer for rendering the text.
  29.     IDirect3DTexture9 *m_texture; // Direct3D texture for the font.
  30.     unsigned long m_textureWidth; // Width of the texture.
  31.     unsigned long m_textureHeight; // Height of the texture.
  32.     float m_textureCoords[96][4]; // Character texture coordinates.
  33.     short m_spacing; // Character pixel spacing per side.
  34. };
  35.  
  36. #endif