Depth problem on render to texture.

Hi all, I am trying to render my scene in a texture, all works fine, but there is a problem whith the z value when I render in a texture, it produces differents colours in the scenes. In the texture render is like if the depth buffer not work fine. I have been testing my program and when I set “0” in the “near plane” argument on the glPerspective function, it produces the same effects than the texture render. Its seem that near plane change when I render on my texture. I have to say that I render equal the texture scene, and the main scene ( front buffer ). You can see the picture where in order to understand better the issue.

Thanks for your time.

It’s much more likely that you simply forgot to attach a depth buffer to your FBO when you rendered to your texture. The default framebuffer (usually) comes with its own depth buffer. But if you’re rendering to a texture, you must provide one yourself. Either as a depth-format texture or a depth-format renderbuffer.

Otherwise, depth testing does not work.

Lot of thanks Alfonse, I have attached a depth buffer a now all works fine.

Best regards!