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-2023 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 {
27namespace asset {
28struct Character {
29 unsigned int TextureID; // ID handle of the glyph texture
30 glm::ivec2 Size; // Size of glyph
31 glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
32 unsigned int Advance; // Horizontal offset to advance to next glyph
33};
34
35class Font : public Asset {
36 public:
37 std::map<unsigned char, Character> characters;
38 unsigned int VAO, VBO;
39 unsigned int texture;
41
42 AssetType GetAssetType() override { return AssetType::FONT; }
43};
44
45void LoadFontData(Font& font, unsigned char* fontBuffer, uint64_t size);
46void RenderText(cqsp::asset::ShaderProgram& shader, Font& font, std::string text, float x, float y, float scale,
47 glm::vec3 color);
48} // namespace asset
49} // namespace cqsp
The base class for assets.
Definition: asset.h:157
Definition: text.h:35
unsigned int VAO
Definition: text.h:38
float initial_size
Definition: text.h:40
unsigned int texture
Definition: text.h:39
AssetType GetAssetType() override
Definition: text.h:42
unsigned int VBO
Definition: text.h:38
std::map< unsigned char, Character > characters
Definition: text.h:37
A shader program.
Definition: shader.h:68
AssetType
Definition: asset.h:31
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
When adding assets, it is extremely crucial that you read cqsp::asset::AssetLoader::LoadResources to ...
Definition: clientctx.h:21
Definition: text.h:28
unsigned int Advance
Definition: text.h:32
unsigned int TextureID
Definition: text.h:29
glm::ivec2 Size
Definition: text.h:30
glm::ivec2 Bearing
Definition: text.h:31