PDA

View Full Version : z buffer into FBO



tkostas
09-15-2015, 02:22 AM
Hi,

I'm a new programmer to Opengl,
My aim is to retrieve the depth buffer into a FBO to be able to transfer to cuda without using glReadpixels

Here is what I've done




void make_Fbo()
{

glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferRenderbuffer(GL_FRAMEBUFFER,
GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER,
fbo);
check_gl_error("make_fbo");
}


void make_render_buffer()
{
glGenRenderbuffers(1, &rb);
glBindRenderbuffer(GL_RENDERBUFFER, rb);
glRenderbufferStorage(GL_RENDERBUFFER,
GL_DEPTH_COMPONENT,
win.width,
win.height);
check_gl_error("make render_buffer");
}


EDIT : my call order is make_render_buffer() and then make_Fbo().

First of all, i would like to know how to print my depth buffer attachement form fbo for debug reasons.

Then I honestly think this code looks to simple to do what I want If you have any guidance to give me it will be a pleasure.

--
tkostas

Alfonse Reinheart
09-15-2015, 06:23 AM
First of all, i would like to know how to print my depth buffer attachement form fbo for debug reasons.

You use glReadPixels to read the data in it. That's the only way to read from a renderbuffer (in OpenGL).

tkostas
09-16-2015, 12:57 AM
You use glReadPixels to read the data in it. That's the only way to read from a renderbuffer (in OpenGL).

Hi, I used it and it looks like my depth buffer is correct.
Thank you for your help :)

But now a new issue appears to me.


The following Quotes comme from " fast triangle rasterization using
irregular z-buffer on cuda " wich is an article published in 2010.


Textures or render buffers can be attached onto the depth
attachment point of FBOs to accommodate the depth values. However, as far as
we have tested, they cannot be accessed by CUDA kernels.

Is this still true ?




we managed to use the color attachment points on the FBO. Apparently
in this case we have to write a simple shader program to dump the depth values onto
the color channels of the frame buffer. According to the GLSL specification [KBR06],
the special variable gl_FragCoord"


Does anyone used already this strategy ? is this not a more simple day nowadays to do that ?


Thank you for your help, feel free to comment or to give me ideas about a new strategy or about the one
presented in the article.