-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathatlas.h
48 lines (38 loc) · 1.02 KB
/
atlas.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
#ifndef _ATLASH_H
#define _ATLASH_H
#include "glutil.h"
#include "actionmode.h"
#include <freetype2/ft2build.h>
#include FT_FREETYPE_H
#include <string>
#include <unordered_map>
struct char_info_t {
float left, top;
float width, height;
float ax, ay; //advanced
float offset; // horizontal offset inside atlas
};
struct atlas_t {
float width, height;
//struct char_info_t infos[128];
std::unordered_map<FT_ULong, struct char_info_t> infos;
int point_size;
};
struct text_mode_t {
struct atlas_t atlas;
GLProcess proc;
};
class TextMode: public ActionMode {
public:
bool init(int width, int height);
void deinit();
void render();
void setFontPath(const std::string& path);
private:
atlas_t _atlas;
std::string _fontPath;
void create_atlas(FT_Face face, int pointSize, std::string preloads);
void render_str(std::string s, float x, float y, float sx, float sy);
bool load_char_helper(FT_ULong char_code);
};
#endif