Text renderer up and working, needs more work to be compatible with the ResourceManager and the Entity Component system

This commit is contained in:
viktorljung
2015-12-11 16:12:29 +01:00
parent 8f007f6daf
commit a8a38716bd
8 changed files with 239 additions and 2 deletions
+3
View File
@@ -14,6 +14,8 @@
#include "../Core/EventBroker.h"
#include "EPicking.h"
#include "TextRenderer.h"
class Renderer : public IRenderer
{
public:
@@ -28,6 +30,7 @@ public:
private:
//----------------------Variables----------------------//
EventBroker* m_EventBroker;
TextRenderer* m_TextRenderer;
Texture* m_ErrorTexture;
Texture* m_WhiteTexture;
+5
View File
@@ -1,4 +1,7 @@
#ifndef ShaderProgram_h__
#define ShaderProgram_h__
#include "../Common.h"
#include "../OpenGL.h"
#include <fstream>
@@ -79,3 +82,5 @@ private:
GLuint m_ShaderProgramHandle;
std::vector<std::shared_ptr<Shader>> m_Shaders;
};
#endif
+28
View File
@@ -4,12 +4,40 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include "OpenGL.h"
#include "GLM.h"
#include "ShaderProgram.h"
class TextRenderer
{
public:
TextRenderer();
void Initialize();
void Update();
void Draw(glm::mat4 projection, glm::mat4 view);
private:
struct Character {
GLuint TextureID; // ID handle of the glyph texture
glm::ivec2 Size; // Size of glyph
glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
GLuint Advance; // Offset to advance to next glyph
};
std::map<GLchar, Character> Characters;
GLuint VAO, VBO;
void RenderText(std::string text, GLfloat x, GLfloat y, GLfloat scale, glm::vec3 color, glm::mat4 projection, glm::mat4 view);
ShaderProgram m_TextProgram;
std::string text = "";
int counter = 0;
};