Changed name and made a TextPassState
This commit is contained in:
+1
-1
Submodule assets updated: b6592dbb02...e8174f630f
@@ -19,7 +19,7 @@
|
|||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "../Core/Transform.h"
|
#include "../Core/Transform.h"
|
||||||
|
|
||||||
#include "TextRenderer.h"
|
#include "TextPass.h"
|
||||||
|
|
||||||
class Renderer : public IRenderer
|
class Renderer : public IRenderer
|
||||||
{
|
{
|
||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
//----------------------Variables----------------------//
|
//----------------------Variables----------------------//
|
||||||
EventBroker* m_EventBroker;
|
EventBroker* m_EventBroker;
|
||||||
TextRenderer* m_TextRenderer;
|
TextPass* m_TextRenderer;
|
||||||
|
|
||||||
Texture* m_ErrorTexture;
|
Texture* m_ErrorTexture;
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
#include "../Core/ResourceManager.h"
|
#include "../Core/ResourceManager.h"
|
||||||
#include "RenderQueue.h"
|
#include "RenderQueue.h"
|
||||||
|
#include "TextPassState.h"
|
||||||
|
|
||||||
class TextRenderer
|
class TextPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextRenderer();
|
TextPass();
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Update();
|
void Update();
|
||||||
void Draw(RenderScene& scene);
|
void Draw(RenderScene& scene);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef TextPassState_h__
|
||||||
|
#define TextPassState_h__
|
||||||
|
|
||||||
|
#include "Rendering/RenderState.h"
|
||||||
|
|
||||||
|
class TextPassState : public RenderState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextPassState();
|
||||||
|
~TextPassState();
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,7 +9,7 @@ void Renderer::Initialize()
|
|||||||
glfwSwapInterval(m_VSYNC);
|
glfwSwapInterval(m_VSYNC);
|
||||||
InitializeShaders();
|
InitializeShaders();
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
m_TextRenderer = new TextRenderer();
|
m_TextRenderer = new TextPass();
|
||||||
m_TextRenderer->Initialize();
|
m_TextRenderer->Initialize();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "Rendering/TextRenderer.h"
|
#include "Rendering/TextPass.h"
|
||||||
|
|
||||||
TextRenderer::TextRenderer()
|
TextPass::TextPass()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRenderer::Initialize()
|
void TextPass::Initialize()
|
||||||
{
|
{
|
||||||
glGenVertexArrays(1, &VAO);
|
glGenVertexArrays(1, &VAO);
|
||||||
glGenBuffers(1, &VBO);
|
glGenBuffers(1, &VBO);
|
||||||
@@ -24,12 +24,12 @@ void TextRenderer::Initialize()
|
|||||||
m_TextProgram->Link();
|
m_TextProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRenderer::Update()
|
void TextPass::Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRenderer::Draw(RenderScene& scene)
|
void TextPass::Draw(RenderScene& scene)
|
||||||
{
|
{
|
||||||
for (auto &job : scene.TextJobs) {
|
for (auto &job : scene.TextJobs) {
|
||||||
auto textJob = std::dynamic_pointer_cast<TextJob>(job);
|
auto textJob = std::dynamic_pointer_cast<TextJob>(job);
|
||||||
@@ -40,11 +40,11 @@ void TextRenderer::Draw(RenderScene& scene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRenderer::renderText(std::string text, Font* font, TextJob::AlignmentEnum alignment, glm::vec4 color, glm::mat4 modelMatrix, glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
|
void TextPass::renderText(std::string text, Font* font, TextJob::AlignmentEnum alignment, glm::vec4 color, glm::mat4 modelMatrix, glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
|
||||||
{
|
{
|
||||||
GLfloat penX = 0;
|
GLfloat penX = 0;
|
||||||
GLfloat penY = 0;
|
GLfloat penY = 0;
|
||||||
float scale = 1.0/font->FontSize;
|
GLfloat scale = 1.0/font->FontSize;
|
||||||
|
|
||||||
GLfloat stringWidth = 0.f;
|
GLfloat stringWidth = 0.f;
|
||||||
|
|
||||||
@@ -61,10 +61,7 @@ void TextRenderer::renderText(std::string text, Font* font, TextJob::AlignmentEn
|
|||||||
penX = 0;
|
penX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
TextPassState state;
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
m_TextProgram->Bind();
|
m_TextProgram->Bind();
|
||||||
glUniform3f(glGetUniformLocation(m_TextProgram->GetHandle(), "textColor"), color.x, color.y, color.z);
|
glUniform3f(glGetUniformLocation(m_TextProgram->GetHandle(), "textColor"), color.x, color.y, color.z);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "Rendering/TextPassState.h"
|
||||||
|
|
||||||
|
|
||||||
|
TextPassState::TextPassState()
|
||||||
|
{
|
||||||
|
BindFramebuffer(0);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextPassState::~TextPassState()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user