Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (38 sloc) 870 Bytes
#pragma once
class SpriteFont;
class Shader;
class TextRenderer : public Singleton<TextRenderer>
{
public:
#undef DrawText
void DrawText(std::string &text, glm::vec2 pos);
void SetFont(SpriteFont* pFont);
void SetColor(glm::vec4 color) { m_Color = color; }
private:
friend class Singleton<TextRenderer>;
friend class Scene;
TextRenderer();
~TextRenderer();
struct TextVertex
{
glm::vec3 Position;
glm::vec4 Color;
glm::vec2 TexCoord;
glm::vec2 CharacterDimension;
unsigned int ChannelId;
};
void Init();
void Draw();
void UpdateBuffer();
Shader* m_pTextShader;
std::vector<SpriteFont*> m_pSpriteFonts;
unsigned int m_BufferSize, m_NumCharacters;
glm::mat4 m_Transform;
glm::vec4 m_Color = glm::vec4(0, 0, 0, 1);
size_t m_ActiveFontIdx;
GLint m_uTransform;
GLint m_uTexSize;
GLint m_uTexture;
GLuint m_VAO;
GLuint m_VBO;
};