Brenta Engine 1.0
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 TextureID; // 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 fontSize);
119 static void RenderText(std::string text, float x, float y, float scale,
120 glm::vec3 color);
121
122 private:
123 static Types::ShaderName textShader;
124 static Types::VAO textVao;
125 static Types::Buffer textVbo;
126};
127
128} // namespace Brenta
Text subsystem.
Definition text.hpp:71
static void Load(std::string font_name, unsigned int fontSize)
Load a font.
Definition text.cpp:50
static void RenderText(std::string text, float x, float y, float scale, glm::vec3 color)
Render text.
Definition text.cpp:138
static std::map< char, Types::Character > characters
Map of characters.
Definition text.hpp:78
static void Init()
Initialize the text subsystem.
Definition text.cpp:41
Buffer wrapper around OpenGL buffer objects.
Definition buffer.hpp:50
Vertex Array Object (VAO)
Definition vao.hpp:45
Character struct.
Definition text.hpp:54