Some state stuff, some draw stuff, some QA map stuff

This commit is contained in:
Tleety
2016-02-03 18:09:44 +01:00
parent 5665c0f298
commit bc01e147c2
10 changed files with 369 additions and 39 deletions
+4 -1
View File
@@ -31,7 +31,9 @@ private:
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene);
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
@@ -54,6 +56,7 @@ private:
ShaderProgram* m_ForwardPlusProgram;
ShaderProgram* m_ExplosionEffectProgram;
ShaderProgram* m_ShieldToStencilProgram;
};
#endif
@@ -12,4 +12,11 @@ private:
};
class DrawStencilState : public RenderState
{
public:
DrawStencilState(GLuint frameBuffer);
~DrawStencilState();
};
#endif
+1
View File
@@ -19,6 +19,7 @@ public:
bool BindFramebuffer(GLint framebuffer);
bool BlendEquation(GLenum mode);
bool BlendFunc(GLenum sfactor, GLenum dfactor);
bool StencilFunc(GLenum sfail, GLenum dpfail, GLenum dppass);
bool DepthMask(GLboolean flag);
private:
+150 -35
View File
@@ -40,7 +40,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="7364.78809" Z="0"/>
<Orientation X="0" Y="9161.41992" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -105,7 +105,7 @@
</c:RaptorCopter>
<c:Transform>
<Position X="2.1529963" Y="6.59221172" Z="0.169116676"/>
<Orientation X="4.16300011" Y="15381.7266" Z="0"/>
<Orientation X="4.16300011" Y="17199.7988" Z="0"/>
</c:Transform>
</Components>
<Children/>
@@ -122,7 +122,7 @@
<Components>
<c:Animation>
<Name>Run</Name>
<Time>0.28223692849998105</Time>
<Time>0.79292191744688711</Time>
<Speed>1</Speed>
</c:Animation>
<c:Model>
@@ -138,7 +138,7 @@
<Components>
<c:Animation>
<Name>Walk</Name>
<Time>0.44951638260048998</Time>
<Time>0.96020137154739604</Time>
<Speed>1</Speed>
</c:Animation>
<c:Model>
@@ -188,7 +188,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="2019.28528" Z="0"/>
<Orientation X="0" Y="2918.14111" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -196,7 +196,7 @@
<Components>
<c:Animation>
<Name>Run</Name>
<Time>0.021047045591223501</Time>
<Time>0.53173203453812956</Time>
<Speed>1</Speed>
</c:Animation>
<c:Model>
@@ -237,7 +237,7 @@
<Axis X="1" Y="1" Z="1"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="13996.3721" Y="13996.3721" Z="13996.3721"/>
<Orientation X="15792.2051" Y="15792.2051" Z="15792.2051"/>
</c:Transform>
</Components>
<Children>
@@ -301,7 +301,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="13793.4053" Z="0"/>
<Orientation X="0" Y="15589.2383" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -333,7 +333,7 @@
<Axis X="0.699999988" Y="1" Z="0.300000012"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="10188.9443" Y="14517.8643" Z="4350.31738"/>
<Orientation X="11456.2695" Y="16313.6973" Z="4881.66504"/>
</c:Transform>
</Components>
<Children>
@@ -683,7 +683,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="316.5047" Z="0"/>
<Orientation X="0" Y="1217.6123" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -730,7 +730,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="316.5047" Z="0"/>
<Orientation X="0" Y="1217.6123" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -790,7 +790,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="316.5047" Z="0"/>
<Orientation X="0" Y="1217.6123" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -837,7 +837,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="316.5047" Z="0"/>
<Orientation X="0" Y="1217.6123" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -883,7 +883,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="316.5047" Z="0"/>
<Orientation X="0" Y="1217.6123" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -930,7 +930,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="316.5047" Z="0"/>
<Orientation X="0" Y="1217.6123" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -977,7 +977,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="316.5047" Z="0"/>
<Orientation X="0" Y="1217.6123" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -1350,6 +1350,19 @@
</c:Transform>
</Components>
<Children>
<Entity name="Text">
<Components>
<c:Text>
<Content>ExplosionEffect Test</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
</c:Text>
<c:Transform>
<Position X="0" Y="3.80000019" Z="0"/>
<Orientation X="0" Y="1.5710001" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AssetBase">
<Components>
<c:Model>
@@ -1377,7 +1390,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="850.207092" Z="0"/>
<Orientation X="0" Y="1750.85364" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -1386,7 +1399,7 @@
<c:ExplosionEffect>
<ColorByDistance>true</ColorByDistance>
<Velocity X="0.800000012" Y="0.0379999988" Z="0"/>
<TimeSinceDeath>0.75055150002244431</TimeSinceDeath>
<TimeSinceDeath>1.3668564709912516</TimeSinceDeath>
<ExplosionDuration>3.7999999523162842</ExplosionDuration>
<EndColor A="0" B="23.5294113" G="11.7647057" R="0"/>
<Randomness>true</Randomness>
@@ -1433,7 +1446,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="850.207092" Z="0"/>
<Orientation X="0" Y="1750.85364" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -1442,7 +1455,7 @@
<c:ExplosionEffect>
<Velocity X="0.5" Y="1" Z="0"/>
<ExplosionOrigin X="0" Y="0.900000036" Z="0"/>
<TimeSinceDeath>1.2004572506365514</TimeSinceDeath>
<TimeSinceDeath>0.316796204374441</TimeSinceDeath>
</c:ExplosionEffect>
<c:Model>
<Resource>Models/Assault.mesh</Resource>
@@ -1485,7 +1498,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="850.207092" Z="0"/>
<Orientation X="0" Y="1750.85364" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -1493,14 +1506,14 @@
<Components>
<c:Animation>
<Name>Walk</Name>
<Time>0.23053304095120097</Time>
<Time>0.74121802989810703</Time>
<Speed>1</Speed>
</c:Animation>
<c:ExplosionEffect>
<ColorByDistance>true</ColorByDistance>
<Velocity X="0.300000012" Y="2" Z="0"/>
<ExplosionOrigin X="0" Y="1.30000007" Z="-0.200000003"/>
<TimeSinceDeath>0.68390303429648269</TimeSinceDeath>
<TimeSinceDeath>0.316796204374441</TimeSinceDeath>
<EndColor A="0" B="0.333333343" G="0.933333337" R="3.92156863"/>
<Randomness>true</Randomness>
</c:ExplosionEffect>
@@ -1518,18 +1531,120 @@
</Entity>
</Children>
</Entity>
<Entity name="Text">
<Entity name="AssetBase">
<Components>
<c:Text>
<Content>ExplosionEffect Test</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
</c:Text>
<c:Model>
<Resource>Models/Core/UnitCylinder.mesh</Resource>
<Color A="1" B="1.56862748" G="1.56862748" R="1.56862748"/>
</c:Model>
<c:Transform>
<Position X="0" Y="3.80000019" Z="0"/>
<Orientation X="0" Y="1.5710001" Z="0"/>
<Position X="0" Y="-0.231354833" Z="-2.92637157"/>
</c:Transform>
</Components>
<Children/>
<Children>
<Entity name="Light">
<Components>
<c:PointLight/>
<c:Transform>
<Position X="0" Y="0.663784981" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="RotationOrigin">
<Components>
<c:RaptorCopter>
<Speed>0.5</Speed>
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="857.983582" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Asset">
<Components>
<c:ExplosionEffect>
<ColorByDistance>true</ColorByDistance>
<Velocity X="0" Y="0.699999988" Z="0"/>
<ExplosionOrigin X="0" Y="-1.10000002" Z="0"/>
<TimeSinceDeath>0.95015514958004132</TimeSinceDeath>
<ExplosionDuration>10</ExplosionDuration>
<EndColor A="1" B="0" G="0" R="1"/>
<RandomnessScalar>3</RandomnessScalar>
<Randomness>true</Randomness>
</c:ExplosionEffect>
<c:Model>
<Resource>Models/Core/UnitSphere.mesh</Resource>
<Color A="0" B="1" G="0" R="0"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.5" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity name="AssetBase">
<Components>
<c:Model>
<Resource>Models/Core/UnitCylinder.mesh</Resource>
<Color A="1" B="1.56862748" G="1.56862748" R="1.56862748"/>
</c:Model>
<c:Transform>
<Position X="0" Y="-0.231354833" Z="-4.48872519"/>
</c:Transform>
</Components>
<Children>
<Entity name="Light">
<Components>
<c:PointLight/>
<c:Transform>
<Position X="0" Y="0.663784981" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="RotationOrigin">
<Components>
<c:RaptorCopter>
<Speed>0.5</Speed>
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="456.135437" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Asset">
<Components>
<c:ExplosionEffect>
<ColorByDistance>true</ColorByDistance>
<Velocity X="6" Y="0.100000001" Z="0"/>
<ExplosionOrigin X="0" Y="-10" Z="0"/>
<TimeSinceDeath>1.3501834109561059</TimeSinceDeath>
<ExponentialAccelaration>true</ExponentialAccelaration>
<ExplosionDuration>5</ExplosionDuration>
<Randomness>true</Randomness>
</c:ExplosionEffect>
<c:Model>
<Resource>Models/Assault.mesh</Resource>
<Color A="1" B="1" G="0.392156869" R="0"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0.5" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
@@ -1597,7 +1712,7 @@
<c:Collidable/>
<c:Health/>
<c:Physics>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
<Velocity X="2.30999646e-23" Y="-16286.3516" Z="1.05272533e-23"/>
</c:Physics>
<c:Player>
<MovementSpeed>5</MovementSpeed>
@@ -1608,7 +1723,7 @@
</Team>
</c:Team>
<c:Transform>
<Position X="-1.56735241" Y="0.527999997" Z="0.929739475"/>
<Position X="-1.56735241" Y="-13504349" Z="0.929739475"/>
</c:Transform>
</Components>
<Children>
@@ -1691,7 +1806,7 @@
<c:ExplosionEffect>
<ColorByDistance>true</ColorByDistance>
<Velocity X="0.800000012" Y="0.0379999988" Z="0"/>
<TimeSinceDeath>0.0003117967054762083</TimeSinceDeath>
<TimeSinceDeath>1.3668564709912516</TimeSinceDeath>
<ExplosionDuration>3.7999999523162842</ExplosionDuration>
<EndColor A="0" B="23.5294113" G="11.7647057" R="0"/>
<Randomness>true</Randomness>
@@ -1736,7 +1851,7 @@
<Components>
<c:Animation>
<Name>Hold Pos</Name>
<Time>0.73506627647571587</Time>
<Time>0.39573681725672838</Time>
<Speed>1</Speed>
</c:Animation>
<c:HiddenForLocalPlayer/>
+2
View File
@@ -38,6 +38,8 @@
<xs:element ref="c:HiddenForLocalPlayer" minOccurs="0"/>
<xs:element ref="c:Fill" minOccurs="0"/>
<xs:element ref="c:Animation" minOccurs="0"/>
<xs:element ref="c:Shield" minOccurs="0"/>
<xs:element ref="c:Shielded" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
+15
View File
@@ -0,0 +1,15 @@
#version 430
in VertexData{
vec3 Position;
}Input;
out vec4 fragmentColor;
void main()
{
fragmentColor = vec4(0.5, 0.5, 0.5, 1.0);
}
+19
View File
@@ -0,0 +1,19 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout(location = 0) in vec3 Position;
out VertexData{
vec3 Position;
}Output;
void main()
{
gl_Position = P * V * M * vec4(Position, 1.0);
Output.Position = Position;
}
+141 -3
View File
@@ -55,6 +55,14 @@ void DrawFinalPass::InitializeShaderPrograms()
m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor");
m_ExplosionEffectProgram->Link();
GLERROR("Creating explosion program");
m_ShieldToStencilProgram = ResourceManager::Load<ShaderProgram>("#ShieldToStencilProgram");
m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShieldStencil.vert.glsl")));
m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ShieldStencil.frag.glsl")));
m_ShieldToStencilProgram->Compile();
m_ShieldToStencilProgram->Link();
GLERROR("Creating Shield program");
}
void DrawFinalPass::Draw(RenderScene& scene)
@@ -65,14 +73,30 @@ void DrawFinalPass::Draw(RenderScene& scene)
if (scene.ClearDepth) {
glClear(GL_DEPTH_BUFFER_BIT);
}
//might need to clear stencil here
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects");
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
GLERROR("TransparentObjects");
delete state;
DrawStencilState* stencilState = new DrawStencilState(m_FinalPassFrameBuffer.GetHandle());
glClear(GL_STENCIL_BUFFER_BIT);
//Draw shields to stencil pass
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
GLERROR("StencilPass");
//Draw Opaque shielded objects
DrawShieldedModelRenderQueue(scene.Jobs.OpaqueShieldedObjects, scene);
GLERROR("Shielded Opaque object");
//Draw Transparen Shielded objects
//DrawShieldedModelRenderQueue(scene.Jobs.TransparentShieldedObjects, scene);
GLERROR("Shielded Transparent objects");
GLERROR("END");
delete stencilState;
}
@@ -110,7 +134,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
GLERROR("MipMap Texture initialization failed");
}
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene)
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
GLERROR("forwardHandle");
@@ -121,7 +145,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
for(auto &job : job)
for(auto &job : jobs)
{
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
if(explosionEffectJob) {
@@ -201,6 +225,120 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
}
void DrawFinalPass::DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{
m_ShieldToStencilProgram->Bind();
GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
for (auto &job : jobs) {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if (modelJob) {
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
if (GLERROR("models end")) {
continue;
}
}
}
}
void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
GLERROR("forwardHandle");
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
GLERROR("explosionHandle");
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
for (auto &job : jobs) {
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
if (explosionEffectJob) {
//Bind program
if (GLERROR("Prebind")) {
continue;
}
m_ExplosionEffectProgram->Bind();
if (GLERROR("BindProgram")) {
continue;
}
glDisable(GL_CULL_FACE);
//Bind uniforms
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
if (GLERROR("BindExplosionUniforms")) {
continue;
}
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
if (explosionEffectJob->Animation != nullptr) {
std::vector<glm::mat4> frameBones = explosionEffectJob->Skeleton->GetFrameBones(*explosionEffectJob->Animation, explosionEffectJob->AnimationTime);
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
}
if (GLERROR("Animation")) {
continue;
}
//bind textures
BindExplosionTextures(explosionEffectJob);
if (GLERROR("BindExplosionTextures")) {
continue;
}
//draw
glBindVertexArray(explosionEffectJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
glEnable(GL_CULL_FACE);
if (GLERROR("explosion effect end")) {
continue;
}
} else {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if (modelJob) {
//bind forward program
m_ForwardPlusProgram->Bind();
glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
//bind uniforms
BindModelUniforms(forwardHandle, modelJob, scene);
//bind textures
BindModelTextures(modelJob);
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
if (modelJob->Animation != nullptr) {
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
}
//draw
glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
if (GLERROR("models end")) {
continue;
}
}
}
}
}
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
{
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
@@ -1,6 +1,7 @@
#include "Rendering/DrawFinalPassState.h"
DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
{
BindFramebuffer(frameBuffer);
@@ -15,3 +16,18 @@ DrawFinalPassState::~DrawFinalPassState()
{
}
DrawStencilState::DrawStencilState(GLuint frameBuffer)
{
BindFramebuffer(frameBuffer);
Enable(GL_STENCIL_TEST);
StencilFunc(GL_KEEP, GL_KEEP, GL_REPLACE);
Enable(GL_DEPTH_TEST);
ClearColor(glm::vec4(0.f));
}
DrawStencilState::~DrawStencilState()
{
}
+14
View File
@@ -85,6 +85,20 @@ bool RenderState::BlendFunc(GLenum sfactor, GLenum dfactor)
return !GLERROR("RenderState::BlendFunc");
}
bool RenderState::StencilFunc(GLenum sfail, GLenum dpfail, GLenum dppass)
{
GLint originalSFail;
glGetIntegerv(GL_STENCIL_FAIL, &originalSFail);
GLint originalDPFail;
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &originalDPFail);
GLint originalDPPass;
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &originalDPPass);
m_ResetFunctions.push_back(std::bind(glStencilOp, originalSFail, originalDPFail, originalDPPass));
glStencilOp(sfail, dpfail, dppass);
return !GLERROR("StencilFunc");
}
bool RenderState::DepthMask(GLboolean flag)
{
GLboolean original;