Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
text.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2025 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <map>
20#include <string>
21
22#include <glm/glm.hpp>
23
25
26namespace cqsp::asset {
27struct Character {
28 unsigned int TextureID; // ID handle of the glyph texture
29 glm::ivec2 Size; // Size of glyph
30 glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
31 unsigned int Advance; // Horizontal offset to advance to next glyph
32};
33
34class Font : public Asset {
35 public:
36 std::map<unsigned char, Character> characters;
37 unsigned int VAO, VBO;
38 unsigned int texture;
40
41 AssetType GetAssetType() override { return AssetType::FONT; }
42};
43
44void LoadFontData(Font& font, unsigned char* fontBuffer, uint64_t size);
45void RenderText(cqsp::asset::ShaderProgram& shader, Font& font, std::string text, float x, float y, float scale,
46 glm::vec3 color);
47} // namespace cqsp::asset
The base class for assets.
Definition: asset.h:165
Definition: text.h:34
unsigned int VAO
Definition: text.h:37
float initial_size
Definition: text.h:39
unsigned int texture
Definition: text.h:38
AssetType GetAssetType() override
Definition: text.h:41
unsigned int VBO
Definition: text.h:37
std::map< unsigned char, Character > characters
Definition: text.h:36
A shader program.
Definition: shader.h:68
When adding assets, it is extremely crucial that you read cqsp::asset::AssetLoader::LoadResources to ...
Definition: asset.h:29
AssetType
Definition: asset.h:32
void LoadFontData(Font &font, unsigned char *fontBuffer, uint64_t size)
Definition: text.cpp:32
@ FONT
Font prototype.
Definition: assetprototype.h:28
void RenderText(cqsp::asset::ShaderProgram &shader, Font &font, std::string text, float x, float y, float scale, glm::vec3 color)
Definition: text.cpp:98
Definition: text.h:27
unsigned int Advance
Definition: text.h:31
unsigned int TextureID
Definition: text.h:28
glm::ivec2 Size
Definition: text.h:29
glm::ivec2 Bearing
Definition: text.h:30