Brenta Engine 1.1
Loading...
Searching...
No Matches
text.hpp
1/*
2 * MIT License
3 *
4 * Copyright (c) 2024 Giovanni Santini
5
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 */
26
27#pragma once
28
29#include <ft2build.h>
30#include <glm/glm.hpp>
31#include <glm/gtc/matrix_transform.hpp>
32#include <glm/gtc/type_ptr.hpp>
33#include <map>
34#include <string>
35#include FT_FREETYPE_H
36
37#include "engine.hpp"
38
39namespace brenta
40{
41
42namespace types
43{
44
54{
55 unsigned int texture_id; // ID handle of the glyph texture
56 glm::ivec2 size; // Size of glyph
57 glm::ivec2 bearing; // Offset from baseline to left/top of glyph
58 unsigned int advance; // Offset to advance to next glyph
59};
60
61} // namespace types
62
70class text
71{
72 public:
78 static std::map<char, types::character> characters;
79
80 text() = delete;
92 static void init();
93
104 static void load(std::string font_name, unsigned int font_size);
119 static void render_text(std::string text, float x, float y, float scale,
120 glm::vec3 color);
121
122 private:
123 static types::shader_name_t text_shader;
124 static types::vao text_vao;
125 static types::buffer text_vbo;
126};
127
128} // namespace brenta
Text subsystem.
Definition text.hpp:71
static void render_text(std::string text, float x, float y, float scale, glm::vec3 color)
Render text.
Definition text.cpp:137
static void init()
Initialize the text subsystem.
Definition text.cpp:41
static void load(std::string font_name, unsigned int font_size)
Load a font.
Definition text.cpp:49
static std::map< char, types::character > characters
Map of characters.
Definition text.hpp:78
Buffer wrapper around OpenGL buffer objects.
Definition buffer.hpp:50
Vertex Array Object (VAO)
Definition vao.hpp:45
Character struct.
Definition text.hpp:54