I'm having a problem with Depth Test
. I have a scene where it contains three objects. A plan a cube and a cylinder. In my Render I'm doing for when rendering the cube it should disable the Depth Test. With this the cube (in orange) should overlap the plane (green) and the cylinder (blue). But that does not happen.
Normal render with Depth Test on and GL_LEQUAL mode.
RenderwithDepthTestturnedoffonlyforthecube.
Thecubeisoverlappingthegreenplane,butdoesnotoverlapthebluecylinder.
voidHOpenGLForwardRenderer::RenderOpaqueMesh(HGameObject*gameObject,HMaterial*material,HShader::HRenderPasspass){gEngine=HEngine::GetInstance();glEnable(GL_CULL_FACE);glCullFace(GL_BACK);glDepthMask(true);if(gameObject->mName=="Cube.1") {
glDisable(GL_DEPTH_TEST);
}
else {
glEnable(GL_DEPTH_TEST);
}
glDepthFunc(GL_LEQUAL);
glUseProgram(pass.gpuProgram);....
What can I be doing wrong? I'm using OpenGL 2.1 and three shaders one for each object but with the same code (color only changes).
#version 120
uniform mat4 HEngine_MatrixMVP;
attribute vec3 in_Position;
void main()
{
gl_Position = HEngine_MatrixMVP * vec4(in_Position, 1.0);
}
#version 120
void main()
{
gl_FragColor = vec4(0.8, 0.4, 0, 1);
}