Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/textEngine: some minor changes

File size: 1.5 KB
Line 
1/*!
2    \file glfont.h
3    \brief Handles the display of glFonts.
4*/
5
6#ifndef _GLFONT_H
7#define _GLFONT_H
8
9#include "glincl.h"
10#include "SDL_ttf.h"
11
12
13//! A struct for handling glyphs
14struct glyph
15{
16  Uint16 character;
17  int minX;
18  int maxX;
19  int minY;
20  int maxY;
21  int width;
22  int height;
23  int bearingX;
24  int bearingY;
25  int advance;
26};
27
28
29class GLFont
30{
31 
32 private:
33
34   
35
36 public:
37  GLFont();
38  GLFont(const char* fontFile);
39  virtual ~GLFont();
40
41  static void enableFonts(void);
42  static void disableFonts(void);
43
44
45  bool setFont(const char* fontFile);
46  void setText(const char* text);
47
48  void setStyle(char* renderStyle);
49  void setSize(unsigned int fontSize);
50  void setColor(Uint8 r, Uint8 g, Uint8 b);
51  void setPosition(int x, int y);
52
53  void createTexture(void);
54 
55  void renderText(void);
56  void renderText(const char* text, int x, int y);
57
58 private:
59  // information about the Font
60  TTF_Font* font;
61  char* fontFile;
62  char* text;
63  unsigned int fontSize;
64  SDL_Color color;
65
66  // placement in openGL
67  GLuint texture;
68  int positionX;
69  int positionY;
70  int renderStyle;
71  SDL_Surface* surface;
72  GLfloat* texcoord;
73
74  bool init(const char* fontFile);
75  int getMaxHeight(void);
76  int getMaxAscent(void);
77  int getMaxDescent(void);
78  glyph getGlyphMetrics(Uint16 character);
79
80  static bool ttfInitialized;
81
82  void enter2DMode(void);
83  void leave2DMode(void);
84
85  static bool checkVersion(void);
86
87  GLuint loadTexture(SDL_Surface* surface, GLfloat* texcoord);
88
89  static int powerOfTwo(int input);
90
91  void debug(void);
92
93};
94
95#endif /* _GLFONT_H */
Note: See TracBrowser for help on using the repository browser.