Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/textEngine/src/lib/graphics/font/glfont.h @ 3694

Last change on this file since 3694 was 3694, checked in by bensch, 19 years ago

orxonox/textEngine: doxygen tags, some minor fix

File size: 2.9 KB
RevLine 
[3478]1/*!
2    \file glfont.h
3    \brief Handles the display of glFonts.
4*/
5
6#ifndef _GLFONT_H
7#define _GLFONT_H
8
[3682]9#include "glincl.h"
[3691]10#include "SDL_ttf.h"
[3478]11
[3691]12
[3693]13/* some default values */
[3694]14#define FONT_DEFAULT_SIZE       50                   //!< default size of the Text
15#define FONT_DEFAULT_TEXT       "orxonox 1234567890" //!< some default text to display
16#define FONT_DEFAULT_COLOR_R    256                  //!< the default red part (color) of the text
17#define FONT_DEFAULT_COLOR_G    256                  //!< the default red green (color) of the text
18#define FONT_DEFAULT_COLOR_B    256                  //!< the default red blue (color) of the text
19#define FONT_NUM_COLORS         256                  //!< The number of colors.
[3693]20
21
22
[3691]23//! A struct for handling glyphs
[3694]24/**
25   a Glyph is one letter of a certain font
26*/
27struct Glyph
[3691]28{
[3694]29  Uint16 character;              //!< The character
30  int minX;                      //!< The minimum distance from the origin in X
31  int maxX;                      //!< The maximum distance from the origin in X
32  int minY;                      //!< The minimum distance from the origin in Y
33  int maxY;                      //!< The maximum distance from the origin in Y
34  int width;                     //!< The width of the Glyph
35  int height;                    //!< The height of the Glyph
36  int bearingX;                  //!< How much is right of the Origin
37  int bearingY;                  //!< How much is above the Origin
38  int advance;                   //!< How big a Glyph would be in monospace-mode
[3691]39};
40
[3694]41//! A class to handle a Font
[3478]42class GLFont
43{
44 public:
[3693]45  GLFont(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE);
[3691]46  virtual ~GLFont();
[3478]47
[3691]48  static void enableFonts(void);
49  static void disableFonts(void);
[3478]50
51  bool setFont(const char* fontFile);
52  void setText(const char* text);
53
[3691]54  void setStyle(char* renderStyle);
[3692]55  void setSize(unsigned int fontSize);
56  void setColor(Uint8 r, Uint8 g, Uint8 b);
[3478]57  void setPosition(int x, int y);
[3692]58
59  void createTexture(void);
[3478]60 
61  void renderText(void);
62  void renderText(const char* text, int x, int y);
63
[3693]64  virtual void draw(void);
65
[3478]66 private:
[3691]67  // information about the Font
68  TTF_Font* font;
[3478]69  char* fontFile;
70  char* text;
[3691]71  unsigned int fontSize;
[3692]72  SDL_Color color;
[3691]73
74  // placement in openGL
[3478]75  GLuint texture;
[3694]76  SDL_Rect textPosSize;               //!< A SDL-Rectangle representing the position and size of the Text on the screen.
[3478]77  int positionX;
78  int positionY;
[3694]79  int width;
80  int height;
[3478]81  int renderStyle;
82  SDL_Surface* surface;
83  GLfloat* texcoord;
84
[3693]85  bool init(const char* fontFile, unsigned int fontSize = FONT_DEFAULT_SIZE);
[3691]86  int getMaxHeight(void);
87  int getMaxAscent(void);
88  int getMaxDescent(void);
[3694]89  Glyph getGlyphMetrics(Uint16 character);
[3478]90
91  static bool ttfInitialized;
92
[3682]93  void enter2DMode(void);
94  void leave2DMode(void);
95
[3691]96  static bool checkVersion(void);
97
[3682]98  GLuint loadTexture(SDL_Surface* surface, GLfloat* texcoord);
99
[3691]100  static int powerOfTwo(int input);
[3682]101
[3691]102  void debug(void);
103
[3478]104};
105
106#endif /* _GLFONT_H */
Note: See TracBrowser for help on using the repository browser.