Text renderer up and working, needs more work to be compatible with the ResourceManager and the Entity Component system
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user