Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
label.h
Go to the documentation of this file.
1 #pragma once
2 #include <iostream>
3 #include <map>
4 #include <string>
5 // FreeType
6 #include <ft2build.h>
7 #include FT_FREETYPE_H
8 
9 #include "renderable2d.h"
10 
11 #include <src/utils/glassert.h>
12 
13 namespace fireworks { namespace graphics {
14 
16  struct Character
17  {
18  unsigned int TextureID;
19  glm::vec2 Size;
20  glm::vec2 Bearing;
21  unsigned int Advance;
22  };
23 
25  struct Font
26  {
27  const char* fontPath;
28  unsigned int fontSize;
29 
30  Font(const char* path, unsigned int size)
31  {
32  this->fontPath = path;
33  this->fontSize = size;
34  }
35  };
36 
37  // TODO: The projection matrix dimensions should be updated for the label
39  class Label
40  {
41  public:
43  std::string text;
45  glm::vec3 position;
47  glm::vec3 color;
50  private:
51  mutable std::map<char, Character> m_Characters;
52  Shader* m_FontShader;
53  unsigned int m_VAO;
54  unsigned int m_VBO;
55  public:
65  Label(const char* text, glm::vec3 position, glm::vec3 color, Font& font);
66 
68  void renderText() const;
69  private:
70  void load();
71  };
72 
73 } }
glm::vec3 position
The position of the label.
Definition: label.h:45
glm::vec2 Bearing
Definition: label.h:20
unsigned int Advance
Definition: label.h:21
Definition: audioclip.cpp:3
glm::vec3 color
The color of the label.
Definition: label.h:47
The class responsible for creating amazing shaders.
Definition: Shader.h:22
unsigned int fontSize
Definition: label.h:28
The label class to render text onto the screen.
Definition: label.h:39
Font font
The font used to render the label.
Definition: label.h:49
Font(const char *path, unsigned int size)
Definition: label.h:30
glm::vec2 Size
Definition: label.h:19
std::string text
The text of the label.
Definition: label.h:43
Engine specific font data type.
Definition: label.h:25
unsigned int TextureID
Definition: label.h:18
const char * fontPath
Definition: label.h:27
Struct denoting the text character of the font.
Definition: label.h:16