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 "../Core/Transform.h"
|
||||
|
||||
#include "TextRenderer.h"
|
||||
#include "TextPass.h"
|
||||
|
||||
class Renderer : public IRenderer
|
||||
{
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
private:
|
||||
//----------------------Variables----------------------//
|
||||
EventBroker* m_EventBroker;
|
||||
TextRenderer* m_TextRenderer;
|
||||
TextPass* m_TextRenderer;
|
||||
|
||||
Texture* m_ErrorTexture;
|
||||
Texture* m_WhiteTexture;
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
#include "Font.h"
|
||||
#include "../Core/ResourceManager.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "TextPassState.h"
|
||||
|
||||
class TextRenderer
|
||||
class TextPass
|
||||
{
|
||||
public:
|
||||
TextRenderer();
|
||||
TextPass();
|
||||
void Initialize();
|
||||
void Update();
|
||||
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);
|
||||
InitializeShaders();
|
||||
InitializeTextures();
|
||||
m_TextRenderer = new TextRenderer();
|
||||
m_TextRenderer = new TextPass();
|
||||
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);
|
||||
glGenBuffers(1, &VBO);
|
||||
@@ -24,12 +24,12 @@ void TextRenderer::Initialize()
|
||||
m_TextProgram->Link();
|
||||
}
|
||||
|
||||
void TextRenderer::Update()
|
||||
void TextPass::Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TextRenderer::Draw(RenderScene& scene)
|
||||
void TextPass::Draw(RenderScene& scene)
|
||||
{
|
||||
for (auto &job : scene.TextJobs) {
|
||||
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 penY = 0;
|
||||
float scale = 1.0/font->FontSize;
|
||||
GLfloat scale = 1.0/font->FontSize;
|
||||
|
||||
GLfloat stringWidth = 0.f;
|
||||
|
||||
@@ -61,10 +61,7 @@ void TextRenderer::renderText(std::string text, Font* font, TextJob::AlignmentEn
|
||||
penX = 0;
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
TextPassState state;
|
||||
|
||||
m_TextProgram->Bind();
|
||||
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