Depth Buffer Render


Im new in OpenGL and I have been reading this fantastic forum for a while. This is my first post.

Im trying implement Shadow Mapping without sucess. I rendered a simple scene (one cube and one plane) from the light perspective in DepthBuffer.
After that I rendered the Depth Buffer converting depth distances in grayscales in order to display a visual representation of depths. My problem is in the rendering process order.

In the first render…when I am copyng the distances in the depth buffer. If I render

1.- plane
2.- cube

All is ok. The visual representation of depth distances show a cube on a plane.

If I render:

1.- cube
2.- plane

The depth distances of plane overwrite the depth distances of the cube. The cube is not visible in the visual representation of depths.

Is there a method to avoid this?


You probably forgot to enable depth testing.

Yes!!! I forgot the depth testing. Its ok now.

Thanks random_dude!!!