Merge remote-tracking branch 'origin/master' into Networking

This commit is contained in:
stiffly
2016-01-23 17:51:06 +01:00
7 changed files with 54 additions and 20 deletions
+2 -3
View File
@@ -17,8 +17,7 @@
#include "ImGuiRenderPass.h" #include "ImGuiRenderPass.h"
#include "Camera.h" #include "Camera.h"
#include "../Core/Transform.h" #include "../Core/Transform.h"
#include "TextPass.h"
#include "TextRenderer.h"
class Renderer : public IRenderer class Renderer : public IRenderer
{ {
@@ -36,7 +35,7 @@ public:
private: private:
//----------------------Variables----------------------// //----------------------Variables----------------------//
EventBroker* m_EventBroker; EventBroker* m_EventBroker;
TextRenderer* m_TextRenderer; TextPass* m_TextPass;
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);
+15
View File
@@ -0,0 +1,15 @@
#ifndef TextPassState_h__
#define TextPassState_h__
#include "Rendering/RenderState.h"
class TextPassState : public RenderState
{
public:
TextPassState();
~TextPassState();
private:
};
#endif
+4 -4
View File
@@ -9,8 +9,8 @@ void Renderer::Initialize()
glfwSwapInterval(m_VSYNC); glfwSwapInterval(m_VSYNC);
InitializeShaders(); InitializeShaders();
InitializeTextures(); InitializeTextures();
m_TextRenderer = new TextRenderer(); m_TextPass = new TextPass();
m_TextRenderer->Initialize(); m_TextPass->Initialize();
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj"); m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
@@ -80,7 +80,7 @@ void Renderer::Update(double dt)
{ {
m_EventBroker->Process<Renderer>(); m_EventBroker->Process<Renderer>();
InputUpdate(dt); InputUpdate(dt);
m_TextRenderer->Update(); m_TextPass->Update();
m_ImGuiRenderPass->Update(dt); m_ImGuiRenderPass->Update(dt);
} }
@@ -102,7 +102,7 @@ void Renderer::Draw(RenderFrame& frame)
GLERROR("Renderer::Draw m_DrawScenePass->Draw"); GLERROR("Renderer::Draw m_DrawScenePass->Draw");
m_TextRenderer->Draw(*scene); m_TextPass->Draw(*scene);
} }
@@ -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);
+16
View File
@@ -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()
{
}
+6
View File
@@ -66,6 +66,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
nextPossibleCapturePoint["Blue"] = -1; nextPossibleCapturePoint["Blue"] = -1;
for (size_t i = 0; i < m_NumberOfCapturePoints; i++) for (size_t i = 0; i < m_NumberOfCapturePoints; i++)
{ {
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
continue;
}
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team"); ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) { if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) {
nextPossibleCapturePoint["Red"] = i + 1; nextPossibleCapturePoint["Red"] = i + 1;
@@ -76,6 +79,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
} }
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
{ {
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
continue;
}
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team"); ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) { if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) {
nextPossibleCapturePoint["Red"] = i - 1; nextPossibleCapturePoint["Red"] = i - 1;