Compare commits

...

1 Commits

Author SHA1 Message Date
viktorljung f89cef7a78 Text still disappears if its behind transparent sprites 2016-03-11 11:23:15 +01:00
5 changed files with 44 additions and 33 deletions
+2 -1
View File
@@ -13,6 +13,7 @@
#include "Texture.h"
#include "ShadowPass.h"
#include "BlurHUD.h"
#include "TextPass.h"
class DrawFinalPass
{
@@ -22,7 +23,7 @@ public:
void InitializeTextures();
void InitializeFrameBuffers();
void InitializeShaderPrograms();
void Draw(RenderScene& scene, BlurHUD* blurHUDPass);
void Draw(RenderScene& scene, BlurHUD* blurHUDPass, TextPass* textPass);
void ClearBuffer();
void OnWindowResize();
+19 -13
View File
@@ -242,7 +242,7 @@ void DrawFinalPass::InitializeShaderPrograms()
}
void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass, TextPass* textPass)
{
GLERROR("Pre");
DrawFinalPassState* stateDethp = new DrawFinalPassState(m_ShieldDepthFrameBuffer.GetHandle());
@@ -282,19 +282,7 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
//state->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects");
//state->Disable(GL_STENCIL_TEST);
//Draw Transparen Shielded objects
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawModelRenderQueuesWithShieldCheck(scene.Jobs.TransparentObjects, scene); //might need changing
GLERROR("Shielded Transparent objects");
//Generate blur texture.
delete state;
if (scene.ShouldBlur) {
//This needs to be drawn only when the full scene is being renderd, and then let be, otherwise sprite and other shit will show on it.
m_FullBlurredTexture = blurHUDPass->Draw(m_SceneTexture, scene);
}
DrawFinalPassState* stateSprite = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
if (scene.ShouldBlur) {
@@ -317,6 +305,24 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
GLERROR("SpriteJobs");
delete stateSprite;
state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
//state->Disable(GL_STENCIL_TEST);
//Draw Transparen Shielded objects
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
textPass->Draw(scene, m_FinalPassFrameBuffer);
DrawModelRenderQueuesWithShieldCheck(scene.Jobs.TransparentObjects, scene); //might need changing
GLERROR("Shielded Transparent objects");
//Generate blur texture.
delete state;
if (scene.ShouldBlur) {
//This needs to be drawn only when the full scene is being renderd, and then let be, otherwise sprite and other shit will show on it.
m_FullBlurredTexture = blurHUDPass->Draw(m_SceneTexture, scene);
}
GLERROR("END");
}
+5 -4
View File
@@ -210,14 +210,15 @@ void Renderer::Draw(RenderFrame& frame)
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
m_LightCullingPass->CullLights(*scene);
GLERROR("LightCulling");
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Text");
//m_TextPass->Draw(*scene, *m_DrawFinalPass->FinalPassFrameBuffer());
GLERROR("Draw Text");
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
m_DrawFinalPass->Draw(*scene, m_BlurHUDPass);
m_DrawFinalPass->Draw(*scene, m_BlurHUDPass, m_TextPass);
GLERROR("Draw Geometry+Light");
//m_DrawScenePass->Draw(*scene);
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Text");
m_TextPass->Draw(*scene, *m_DrawFinalPass->FinalPassFrameBuffer());
GLERROR("Draw Text");
PerformanceTimer::StopTimer("Renderer-Draw Text");
}
+2 -2
View File
@@ -34,7 +34,7 @@ void TextPass::Update()
void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
{
GLERROR("Derp1");
TextPassState* state = new TextPassState(frameBuffer.GetHandle());
//TextPassState* state = new TextPassState(frameBuffer.GetHandle());
for (auto &job : scene.Jobs.Text) {
auto textJob = std::dynamic_pointer_cast<TextJob>(job);
if (textJob) {
@@ -43,7 +43,7 @@ void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
}
}
GLERROR("Derp2");
delete state;
// delete state;
}
void TextPass::renderText(std::string text, Font* font, TextJob::AlignmentEnum alignment, glm::vec4 color, glm::mat4 modelMatrix, glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
+7 -4
View File
@@ -4,10 +4,13 @@
TextPassState::TextPassState(GLuint frameBuffer)
{
BindFramebuffer(frameBuffer);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Enable(GL_BLEND);
Disable(GL_CULL_FACE);
Enable(GL_DEPTH_TEST);
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Enable(GL_ALPHA_TEST);
AlphaFunc(GL_GEQUAL, 0.05f);
}
TextPassState::~TextPassState()