Aether3D Game Engine
TextRendererComponent.hpp
1 #ifndef TEXT_RENDERER_H
2 #define TEXT_RENDERER_H
3 
4 #include <type_traits>
5 #include <string>
6 
7 namespace ae3d
8 {
11  {
12  public:
14  enum class ShaderType { Sprite, SDF };
15 
18 
21 
24 
27 
29  class GameObject* GetGameObject() const { return gameObject; }
30 
32  void SetColor( const struct Vec4& color );
33 
35  void SetFont( class Font* font );
36 
38  void SetText( const char* text );
39 
41  void SetShader( ShaderType shaderType );
42 
44  std::string GetSerialized() const;
45 
46  private:
47  friend class GameObject;
48  friend class Scene;
49 
51  static int Type() { return 4; }
52 
54  static unsigned New();
55 
57  static TextRendererComponent* Get( unsigned index );
58 
60  void Render( const float* projectionModelMatrix );
61 
62  struct Impl;
63  Impl& m() { return reinterpret_cast<Impl&>(_storage); }
64  Impl const& m() const { return reinterpret_cast<Impl const&>(_storage); }
65 
66  static const std::size_t StorageSize = 1384;
67  static const std::size_t StorageAlign = 16;
68 
69  std::aligned_storage<StorageSize, StorageAlign>::type _storage = {};
70 
71  GameObject* gameObject = nullptr;
72  };
73 }
74 
75 #endif
Contains glyphs loaded from AngelCode BMFont files. For Mac there is a compatible program called BMGl...
Definition: Font.hpp:12
Definition: AudioClip.hpp:4
ShaderType
Shader type for rendering text.
Definition: TextRendererComponent.hpp:14
void SetShader(ShaderType shaderType)
4-component vector.
Definition: Vec3.hpp:351
class GameObject * GetGameObject() const
Definition: TextRendererComponent.hpp:29
Contains text.
Definition: TextRendererComponent.hpp:10
void SetColor(const struct Vec4 &color)
void SetFont(class Font *font)
void SetText(const char *text)
TextRendererComponent()
Constructor.
TextRendererComponent & operator=(const TextRendererComponent &other)
GameObject is composed of components that define its behavior.
Definition: GameObject.hpp:9
std::string GetSerialized() const
~TextRendererComponent()
Destructor.
Contains game objects in a transform hierarchy.
Definition: Scene.hpp:17