Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
loader.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "client/core.hpp"
5
6// freetype needs this extra include for whatever unholy reason
7#include <ft2build.h>
8#include FT_FREETYPE_H
9
10#include <unordered_map>
11
12namespace gui::font {
13
14// modified from https://learnopengl.com/In-Practice/Text-Rendering
15
19struct Character {
20 unsigned int texture_id;
21 glm::ivec2 size;
22 glm::ivec2 bearing;
23 unsigned int advance;
24};
25
30class Loader {
31public:
32 Loader() = default;
33
38 bool init();
39
47 [[nodiscard]] const Character& loadChar(char c, Font font) const;
48
49private:
50 FT_Library ft;
51
55 bool _loadFont(Font font);
56
57 std::unordered_map<
58 Font,
59 std::unordered_map<unsigned char, Character>
60 > font_map;
61};
62
63}
Definition: loader.hpp:30
const Character & loadChar(char c, Font font) const
Definition: loader.cpp:34
bool init()
Definition: loader.cpp:13
Definition: font.hpp:9
Font
Definition: font.hpp:15
Definition: loader.hpp:19
unsigned int texture_id
Definition: loader.hpp:20
unsigned int advance
offset from baseline to left/top of glyph
Definition: loader.hpp:23
glm::ivec2 bearing
size of glyph
Definition: loader.hpp:22
glm::ivec2 size
id handle for glyph texture
Definition: loader.hpp:21