Last change
on this file since 3691 was
3691,
checked in by bensch, 19 years ago
|
orxonox/branches/textEngine: implemented some basic functions
|
File size:
1.4 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 |
---|
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 | |
---|
29 | class 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(void); |
---|
50 | void setPosition(int x, int y); |
---|
51 | |
---|
52 | void renderText(void); |
---|
53 | void renderText(const char* text, int x, int y); |
---|
54 | |
---|
55 | private: |
---|
56 | // information about the Font |
---|
57 | TTF_Font* font; |
---|
58 | char* fontFile; |
---|
59 | char* text; |
---|
60 | unsigned int fontSize; |
---|
61 | |
---|
62 | // placement in openGL |
---|
63 | GLuint texture; |
---|
64 | int positionX; |
---|
65 | int positionY; |
---|
66 | int renderStyle; |
---|
67 | SDL_Surface* surface; |
---|
68 | GLfloat* texcoord; |
---|
69 | |
---|
70 | bool init(const char* fontFile); |
---|
71 | int getMaxHeight(void); |
---|
72 | int getMaxAscent(void); |
---|
73 | int getMaxDescent(void); |
---|
74 | glyph getGlyphMetrics(Uint16 character); |
---|
75 | |
---|
76 | static bool ttfInitialized; |
---|
77 | |
---|
78 | void enter2DMode(void); |
---|
79 | void leave2DMode(void); |
---|
80 | |
---|
81 | static bool checkVersion(void); |
---|
82 | |
---|
83 | GLuint loadTexture(SDL_Surface* surface, GLfloat* texcoord); |
---|
84 | |
---|
85 | static int powerOfTwo(int input); |
---|
86 | |
---|
87 | void debug(void); |
---|
88 | |
---|
89 | }; |
---|
90 | |
---|
91 | #endif /* _GLFONT_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.