depth buffer 32 bits

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.

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: PIXELFORMATDESCRIPTOR (wingdi.h) - Win32 apps | Microsoft Learn

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

ref: http://developer.apple.com/mac/library/d…01987-CH214-SW9

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:

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:

In particular, #3.

Thank you. I already know that.

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

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.