-
Notifications
You must be signed in to change notification settings - Fork 0
/
esfont.h
50 lines (43 loc) · 1.2 KB
/
esfont.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <ft2build.h>
#include FT_FREETYPE_H
#include "esfontbase.h"
struct Character
{
GLuint texture;
glm::vec3 scale; // scaling factor for the quad
glm::vec3 v0; // location of v0 relative to baseline
float advance; // amount to advance on the baseline
};
class FreeTypeFont
{
private:
bool loaded;
bool quad_initialized;
Character characters[128];
GLuint program;
GLuint vbo;
GLuint vao;
GLint mvp_loc;
GLint s_texture_loc;
float descender;
void InitQuad(void);
void DeleteQuad(void);
void LoadCharacter(
FT_Library library,
FT_Face face,
unsigned char charcode,
glm::vec4 &fontCol,
glm::vec4 &outlineCol,
float outlineWidth );
public:
FreeTypeFont( void );
~FreeTypeFont( );
void LoadOutline( const char *filename, unsigned int fontsize,
glm::vec4 &fontColor, glm::vec4 &outlineColor,
float outlineWidth);
void Free( void );
void Printf( double x, double y, const char *format, ... );
float PrintfAdvance(const char *format, ...);
};