Factorize solid state changes.
This commit is contained in:
parent
c6e466fdcc
commit
5ae0d2f4dc
@ -190,9 +190,14 @@ void IrrDriver::renderGLSL(float dt)
|
||||
}*/
|
||||
|
||||
// Fire up the MRT
|
||||
m_video_driver->setRenderTarget(m_mrt, false, false);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
|
||||
@ -225,6 +230,10 @@ void IrrDriver::renderGLSL(float dt)
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF);
|
||||
irr_driver->setPhase(SOLID_LIT_PASS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||
m_scene_manager->drawAll(m_renderpass);
|
||||
|
||||
|
@ -41,13 +41,6 @@ void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
{
|
||||
case SOLID_NORMAL_AND_DEPTH_PASS:
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
computeMVP(ModelViewProjectionMatrix);
|
||||
computeTIMV(TransposeInverseModelView);
|
||||
|
||||
@ -55,18 +48,10 @@ void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
drawObjectRefPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
else
|
||||
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
|
||||
break;
|
||||
}
|
||||
case SOLID_LIT_PASS:
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
drawObjectRefPass2(mesh, ModelViewProjectionMatrix);
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
@ -158,24 +143,14 @@ void STKAnimatedMesh::render()
|
||||
initvaostate(GLmeshes[i], material.MaterialType);
|
||||
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
|
||||
{
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices());
|
||||
}
|
||||
if (isTransparentPass)
|
||||
drawTransparent(GLmeshes[i], material.MaterialType);
|
||||
else
|
||||
{
|
||||
drawSolid(GLmeshes[i], material.MaterialType);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
video::SMaterial material;
|
||||
material.MaterialType = irr_driver->getShader(ES_RAIN);
|
||||
material.BlendOperation = video::EBO_NONE;
|
||||
material.ZWriteEnable = true;
|
||||
material.Lighting = false;
|
||||
irr_driver->getVideoDriver()->setMaterial(material);
|
||||
static_cast<irr::video::COpenGLDriver*>(irr_driver->getVideoDriver())->setRenderStates3DMode();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -60,10 +60,10 @@ GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_t
|
||||
|
||||
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
|
||||
{
|
||||
initGL();
|
||||
GLMesh result = {};
|
||||
if (!mb)
|
||||
return result;
|
||||
glBindVertexArray(0);
|
||||
glGenBuffers(1, &(result.vertex_buffer));
|
||||
glGenBuffers(1, &(result.index_buffer));
|
||||
|
||||
@ -472,7 +472,6 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
|
||||
}
|
||||
|
||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
@ -703,7 +702,6 @@ void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
case SOLID_NORMAL_AND_DEPTH_PASS:
|
||||
{
|
||||
windDir = getWind();
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
@ -721,18 +719,10 @@ void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
drawGrassPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, windDir);
|
||||
else
|
||||
drawObjectPass1(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getMainSetup(), false, false);
|
||||
break;
|
||||
}
|
||||
case SOLID_LIT_PASS:
|
||||
{
|
||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||
drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
else if (type == irr_driver->getShader(ES_SPLATTING))
|
||||
@ -950,18 +940,7 @@ void STKMesh::render()
|
||||
if (transparent)
|
||||
drawTransparent(GLmeshes[i], material.MaterialType);
|
||||
else
|
||||
{
|
||||
drawSolid(GLmeshes[i], material.MaterialType);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
video::SMaterial material;
|
||||
material.MaterialType = irr_driver->getShader(ES_RAIN);
|
||||
material.BlendOperation = video::EBO_NONE;
|
||||
material.ZWriteEnable = true;
|
||||
material.Lighting = false;
|
||||
irr_driver->getVideoDriver()->setMaterial(material);
|
||||
static_cast<irr::video::COpenGLDriver*>(irr_driver->getVideoDriver())->setRenderStates3DMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user