Dephtbuffer on render-to-texture using FBO

How i can use GL_DEPTH_TEST and glDepthFunc on render-to-texture using FBO.

see the below code:

glEnable(GL_DEPTH_TEST);

// depth operations
glColorMask(true, false, false, false);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS);
drawPoints();

In that code i render many points at pos (x, y) but different z
i want only render the point with less z

does The FBO need an depthbuffer?

glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, dbo);

could somebody help me?

Thanks in advance.

Yes. If you don’t attach a depth buffer to the FBO there won’t be any depth testing.

this article: OpenGL FrameBuffer Object 101 should be a good reference.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.