thanks for the answer
I did the conversion and the problem was not solved completely. I have tracked down the problem to the following issue:
I have a number of 3d cubes on the screen. These cubes are jumbled up together. I want to generate two textures. First textures records depth map of the front faces of the visible cubes. Second texture records depth map of the back faces of the visible cubes.
This works fine for the left handed system. The setup is shown below:
/* glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glCullFace(GL_BACK); projection = matrix4x4::perspectiveFovLHGL(fov, (float)w / h, zNear, zFar); glLoadMatrixf(projection); glMatrixMode(GL_MODELVIEW); glTranslatef(0, 0, 379); glScalef(256, 256, 128); //---------------------------------- // render depth projection glViewport(0, 0, fbWidth, fbHeight); glUseProgram(0); for (int pass = 0; pass < 2; ++pass) { switch (pass) { case 0: // render back depth into framebuffer 0 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer0); glDepthFunc(GL_GREATER); glClearDepth(0.0f); glCullFace(GL_FRONT); break; case 1: // render front depth into framebuffer 1 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer1); glDepthFunc(GL_LESS); glClearDepth(1.0f); glCullFace(GL_BACK); break; } 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 tried but i am not able to convert it to right handed system. I did the following but it just not goes fine. The following is the setup. I have marked with ** the lines which are different from code snippet above:
/* glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE);** // glFrontFace(GL_CW); glCullFace(GL_BACK);** projection = matrix4x4::perspectiveFovRHGL(fov, (float)w / h, zNear, zFar); glLoadMatrixf(projection); glMatrixMode(GL_MODELVIEW);** glTranslatef(0, 0, -379); glScalef(256, 256, 128); //---------------------------------- // render depth projection glViewport(0, 0, fbWidth, fbHeight); glUseProgram(0); for (int pass = 0; pass < 2; ++pass) { switch (pass) { case 0: // render back depth into framebuffer 0 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer0); glDepthFunc(GL_GREATER); glClearDepth(0.0f); glCullFace(GL_FRONT); break; case 1: // render front depth into framebuffer 1 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer1); glDepthFunc(GL_LESS); glClearDepth(1.0f); glCullFace(GL_BACK); break; } 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 am calculating cubes using a library at another stage
I need help converting this piece of code
thanks in abvance