PDA

View Full Version : reading the depth buffer.



CoGiTo
04-23-2006, 01:57 PM
hi,
how can i read the depth buffer?

thanks.

memfr0b
04-23-2006, 02:09 PM
glReadPixels is what you need.

pocketmoon
04-23-2006, 03:06 PM
Depends on what you want to do but if your hardware supports it:


glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);//GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);// GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, _iWidth, _iHeight, 0,
GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);and then bind to an fbo...

After rending you can read this as a texture.

CoGiTo
04-24-2006, 08:14 AM
what kind of texturization is it?

CoGiTo
04-24-2006, 08:17 AM
I want to read the depth buffer to know the distance on a line. at the moment i use

glreadpixel(0,height/2,width,1,GL_DEPTH..,GL_FLOAT,pointer);

but the array is not so good i try to change the SCALE and BIAS, but i have no idea...
maybe i have to use GL_BYTE?
thanks