summaryrefslogtreecommitdiff
path: root/engine-ocean/Graphics/font.h
blob: ea42a29edc2b156d17b89c0dc28c4f7e3ef7b11f (plain)
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
#pragma once

// Credit to https://learnopengl.com/In-Practice/Text-Rendering

#include "ft2build.h"
#include "freetype/freetype.h"
#include <GL/glew.h>
#include "glm/glm.hpp"
#include <map>
#include <string>

struct Character {
    GLuint textureID;
    glm::ivec2   size;
    glm::ivec2   bearing;
    unsigned int advance;
};

class Font {
public:
    Font(const std::string filepath);
    ~Font();

    Character& getCharacter(char c);

private:
    void createGlyphTexture(unsigned char c, FT_Face &face);
    std::map<char, Character> m_characters;
};