PDA

View Full Version : depth buffer 32 bits



nachovall
05-14-2010, 03:17 AM
Hi all

Sorry for the question but I didn't find it anywhere. I want to work with 32 bits depth buffer precision. Actually I'm using 24:

GLint depthBits;
glGetIntegerv(GL_DEPTH_BITS, &depthBits);

depthBits takes value 24.

My graphic card supports GL_NV_depth_buffer_float extension but I don't know the instruction to set the depth buffer up to 32 bits.

Can anyone tell me it?

Thank you very much.

overlay
05-14-2010, 06:55 AM
GL_NV_depth_buffer_float provides a format of texture that can store depth buffer information not only in 32-bit but also in float. This is for use with a FBO (framebuffer object)

ref: http://www.opengl.org/registry/specs/NV/depth_buffer_float.txt

In your case, you want to deal with the default/system framebuffer.
You have to request this format from the system.

If you use glut, it is not exposed, so you cant do it.

if you are under Unix using glx, in the FBConfig you can request
GLX_DEPTH_SIZE to be 32. (check with glxinfo the formats that are actually supported)

ref: http://www.opengl.org/documentation/specs/glx/glx1.4.pdf

If you are on windows, using wgl, deal with the pixel format descriptor, and set cDepthBits to 32.

ref: http://msdn.microsoft.com/en-us/library/dd368826%28v=VS.85%29.aspx

If you are on mac, using Cocoa, set the value of NSOpenGLPFADepthSize to be 32 in the NSOpenGLPixelFormatAttribute structure:

ref: http://developer.apple.com/mac/library/d...nGLPFADepthSize (http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSOpenGLPixelFormat_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSOpenGLPFADepthSize)

ref: http://developer.apple.com/mac/library/d...01987-CH214-SW9 (http://developer.apple.com/mac/library/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_pixelformats/opengl_pixelformats.html#//apple_ref/doc/uid/TP40001987-CH214-SW9)

Dark Photon
05-14-2010, 06:58 PM
I want to work with 32 bits depth buffer precision. ...I'm using 24 ... My graphic card supports GL_NV_depth_buffer_float extension but I don't know the instruction to set the depth buffer up to 32 bits.
Not sure if you can set the system (window) framebuffer's depth buffer to 32-bits, but more than likely you can configure a framebuffer object (FBO) with a depth buffer that has 32-bits, render to that, and then merely copy the resulting color buffer to the system color buffer.

Try this:

* http://www.lmgtfy.com/?q=DEPTH_COMPONENT32+site:opengl.org+inurl:registr y (http://www.lmgtfy.com/?q=DEPTH_COMPONENT32+site%3Aopengl.org+inurl%3Areg istry)

Here you can see that ARB_depth_texture provides GL_DEPTH_COMPONENT32 (32-bit int depth buffer). Further, you can see this is part of the OpenGL 3.3 or 4.0 specs. So if you're using one of those versions, or your OpenGL driver provides ARB_depth_texture, you should be able to create a 32-bit depth texture and render to it with an FBO (assuming you have ARB_framebuffer_object, or are running OpenGL 3.0+).

For more info on framebuffer objects, see:

* http://www.opengl.org/wiki/Framebuffer_Object
* http://www.opengl.org/wiki/GL_EXT_framebuffer_object
* http://www.opengl.org/wiki/GL_EXT_frameb...texture_ONLY.29 (http://www.opengl.org/wiki/GL_EXT_framebuffer_object#Quick_example.2C_render_ to_texture_.282D_Depth_texture_ONLY.29)
* http://www.opengl.org/wiki/Image_Format#Depth_formats

In particular, #3.

nachovall
05-17-2010, 03:58 AM
Try this:

* http://www.lmgtfy.com/?q=DEPTH_COMPONENT32+site:opengl.org+inurl:registr y (http://www.lmgtfy.com/?q=DEPTH_COMPONENT32+site%3Aopengl.org+inurl%3Areg istry)


Thank you. I already know that.

I was just asking about if it is possible to do that whithout using FBO.

nachovall
05-17-2010, 04:00 AM
GL_NV_depth_buffer_float provides a format of texture that can store depth buffer information not only in 32-bit but also in float. This is for use with a FBO (framebuffer object)

Thank you I didn't know that was only for FBO.



In your case, you want to deal with the default/system framebuffer.
You have to request this format from the system.

If you use glut, it is not exposed, so you cant do it.


Thank you very much for your help. I'll try it.