FAQ/Depth Buffer: Difference between revisions
< FAQ
Jump to navigation
Jump to search
m (Categorizing) |
(Start on cleanup.) |
||
Line 1: | Line 1: | ||
== Enabling depth buffering == | |||
In order to use depth buffering, the following must occur:. | |||
* The current framebuffer, whether an [[Framebuffer Object|FBO]] or the [[Default Framebuffer|default framebuffer]], must have a depth buffer. | |||
* Depth testing must be enabled. This is done by calling {{code|glEnable(GL_DEPTH_TEST)}}. | |||
* The depth range zNear and zFar must be set properly. Use {{code|glDepthRange}} to set these values. | |||
* The depth buffer must be cleared when appropriate. This can be done by using glClear with the GL_DEPTH_BUFFER_BIT (along with glClearDepth to set the value that it will be cleared to). glClearBuffer can also be used to clear specific buffers. | |||
== Depth buffer precision == | |||
{{main|Depth Buffer Precision}} | |||
; [[Depth Buffer and Perspective Rendering]] : Depth buffering doesn't work in my perspective rendering. What's going on? | ; [[Depth Buffer and Perspective Rendering]] : Depth buffering doesn't work in my perspective rendering. What's going on? | ||
; | ; Write Image To Depth Buffer : How do I write a previously stored depth image to the depth buffer? | ||
; How do I turn off the zNear clipping plane? : See [http://www.opengl.org/resources/faq/technical/clipping.htm#0050 this question] in the Clipping section. | ; How do I turn off the zNear clipping plane? : See [http://www.opengl.org/resources/faq/technical/clipping.htm#0050 this question] in the Clipping section. | ||
; An article about depth buffer precision http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html | ; An article about depth buffer precision http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html | ||
{{stub}} | |||
[[Category:Framebuffer]] | [[Category:Framebuffer]] | ||
[[Category:Depth Buffering]] |
Revision as of 08:32, 11 April 2011
Enabling depth buffering
In order to use depth buffering, the following must occur:.
- The current framebuffer, whether an FBO or the default framebuffer, must have a depth buffer.
- Depth testing must be enabled. This is done by calling glEnable(GL_DEPTH_TEST).
- The depth range zNear and zFar must be set properly. Use glDepthRange to set these values.
- The depth buffer must be cleared when appropriate. This can be done by using glClear with the GL_DEPTH_BUFFER_BIT (along with glClearDepth to set the value that it will be cleared to). glClearBuffer can also be used to clear specific buffers.
Depth buffer precision
Main article: Depth Buffer Precision
- Depth Buffer and Perspective Rendering
- Depth buffering doesn't work in my perspective rendering. What's going on?
- Write Image To Depth Buffer
- How do I write a previously stored depth image to the depth buffer?
- How do I turn off the zNear clipping plane?
- See this question in the Clipping section.
- An article about depth buffer precision http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html
This article is a stub. You can help the OpenGL Wiki by expanding it. |