-
Notifications
You must be signed in to change notification settings - Fork 1
/
font_rendering.h
54 lines (40 loc) · 1.09 KB
/
font_rendering.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
51
52
53
#ifndef FONT_RENDERING_H
#define FONT_RENDERING_H
#include <vector>
#include <string>
#include <OpenGL/gl.h>
#include "types.h"
#include "lin_alg.h"
class FontRendering
{
public:
FontRendering() : m_font_tex((GLuint) -1) { }
~FontRendering()
{
// Delete OpenGL font texture
if (m_font_tex != (GLuint) - 1)
glDeleteTextures(1, &m_font_tex);
}
void DrawStringFixed6x12(
int x, int y,
const char *str,
uint32 color = 0xFFFFFFFF,
bool vertical = false);
void Render(bool filter_font_texture = false);
protected:
GLuint m_font_tex;
std::vector<Vec2f> m_pos;
std::vector<Vec2f> m_tex_coords;
std::vector<uint32> m_colors;
std::vector<GLuint> m_indices;
std::string m_text;
std::string m_last_frame_text;
const uint font_grid_wdh = 16 ;
const uint font_grid_hgt = 16 ;
const uint font_img_wdh = 96 ;
const uint font_img_hgt = 192;
const uint font_char_wdh = 6 ;
const uint font_char_hgt = 12 ;
const uint font_tex_wdh = 256;
};
#endif // FONT_RENDERING_H