-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextRenderer.h
More file actions
47 lines (37 loc) · 860 Bytes
/
TextRenderer.h
File metadata and controls
47 lines (37 loc) · 860 Bytes
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
#ifndef TEXT_RENDERER
#define TEXT_RENDERER
#include <ft2build.h>
#include FT_FREETYPE_H
#include "TextShader.h"
#include <GL/glew.h>
#include <map>
struct Character
{
GLuint textureID;
glm::ivec2 size;
glm::ivec2 bearing;
glm::ivec2 advance;
};
class TextRenderer
{
public:
TextRenderer();
~TextRenderer();
void init(TextShader* shader, int width, int height);
void prepare(TextShader* shader);
void end(TextShader* shader);
void renderText(TextShader* shader, const std::string text, float x, float y, float size, glm::vec3 color);
glm::vec2 getStringSize(std::string text, float size);
private:
GLuint _vaoID, _vboID;
std::map<GLchar, Character> _characters;
int _width, _height;
float vertices[10] = {
1,1,
1,-1,
-1,-1,
-1,1,
1,1
};
};
#endif