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 | |
---|---|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[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 | |
13 | //! A struct for handling glyphs | |
14 | struct 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 | ||
[3478] | 29 | class GLFont |
30 | { | |
[3691] | 31 | |
32 | private: | |
33 | ||
34 | ||
35 | ||
[3478] | 36 | public: |
37 | GLFont(); | |
38 | GLFont(const char* fontFile); | |
[3691] | 39 | virtual ~GLFont(); |
[3478] | 40 | |
[3691] | 41 | static void enableFonts(void); |
42 | static void disableFonts(void); | |
[3478] | 43 | |
[3691] | 44 | |
[3478] | 45 | bool setFont(const char* fontFile); |
46 | void setText(const char* text); | |
47 | ||
[3691] | 48 | void setStyle(char* renderStyle); |
[3692] | 49 | void setSize(unsigned int fontSize); |
50 | void setColor(Uint8 r, Uint8 g, Uint8 b); | |
[3478] | 51 | void setPosition(int x, int y); |
[3692] | 52 | |
53 | void createTexture(void); | |
[3478] | 54 | |
55 | void renderText(void); | |
56 | void renderText(const char* text, int x, int y); | |
57 | ||
58 | private: | |
[3691] | 59 | // information about the Font |
60 | TTF_Font* font; | |
[3478] | 61 | char* fontFile; |
62 | char* text; | |
[3691] | 63 | unsigned int fontSize; |
[3692] | 64 | SDL_Color color; |
[3691] | 65 | |
66 | // placement in openGL | |
[3478] | 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); | |
[3691] | 75 | int getMaxHeight(void); |
76 | int getMaxAscent(void); | |
77 | int getMaxDescent(void); | |
78 | glyph getGlyphMetrics(Uint16 character); | |
[3478] | 79 | |
80 | static bool ttfInitialized; | |
81 | ||
[3682] | 82 | void enter2DMode(void); |
83 | void leave2DMode(void); | |
84 | ||
[3691] | 85 | static bool checkVersion(void); |
86 | ||
[3682] | 87 | GLuint loadTexture(SDL_Surface* surface, GLfloat* texcoord); |
88 | ||
[3691] | 89 | static int powerOfTwo(int input); |
[3682] | 90 | |
[3691] | 91 | void debug(void); |
92 | ||
[3478] | 93 | }; |
94 | ||
95 | #endif /* _GLFONT_H */ |
Note: See TracBrowser
for help on using the repository browser.