I am kindda stuck into it for quite some time now:
below is the working code in the left handed coordinate system:
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CW);
projection = matrix4x4:: perspectiveFovLHGL(fov, (float)w / h,
zNear, zFar);
glLoadMatrixf(projection);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0,0, 300); // should be (0,0,-300) in RightHanded system
glScalef(256, 256, 128);
glViewport(0, 0, fbWidth, fbHeight);
glUseProgram(0);
// render back depth into framebuffer 0
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer0);
glDepthFunc(GL_GREATER);
glClearDepth(0.0f);
glCullFace(GL_BACK);
glClear(GL_DEPTH_BUFFER_BIT);
if (volume.cubeQuads > 0) {
glBindBuffer(GL_ARRAY_BUFFER, volume.vbCubes);
glVertexPointer(3, GL_FLOAT, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume.ibCubes);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_QUADS, volume.cubeQuads * 4, GL_UNSIGNED_INT, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
I have to use glTranslate(0,0,-300) rather then glTranslate(0,0,300) in line 9.
I tried doing it by changing the following lines:
glFrontFace(GL_CW); TO glFrontFace(GL_CCW);
projection = matrix4x4:: perspectiveFovLHGL(fov, (float)w / h,
zNear, zFar);
TO
projection = matrix4x4:: perspectiveFovRHGL(fov, (float)w / h,
zNear, zFar); (is a correct library call)
glTranslatef(0,0, 300); TO glTranslatef(0,0, -300);
AND
case 0: // render back depth into framebuffer 0 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer0); glDepthFunc(GL_GREATER); glClearDepth(0.0f); glCullFace(GL_BACK); break; TO case 0: // render back depth into framebuffer 0 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer0); glDepthFunc(GL_LESS); glClearDepth(0.0f); glCullFace(GL_FRONT); break;
it does not work :(
I posted this on another forum but could not get any help :(












