Using Depth Buffers

A depth buffer (often referred to as a z-buffer or a w-buffer) is how Direct3D stores “depth” information for rendering. This depth information is used during rasterization to determine how pixels block (occlude) each other. Currently, our application has no depth buffer associated with it, so no pixels are occluded during rasterization. However, we have no pixels that are occluded anyway, so let's try to draw a few more cubes that will actually overlap some of our existing cubes. Add the following DrawBox calls to the end of our existing DrawBox calls:

 DrawBox(angle / (float)Math.PI, angle / (float)Math.PI * 2.0f, angle / (float)Math.PI / 4.0f, 0.0f, (float)Math.Cos(angle), (float)Math.Sin(angle)); DrawBox(angle / (float)Math.PI, ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.