Clearing Surfaces

Before rendering objects in a scene, you should clear the viewport on the render target surface (or a subset of the viewport). Clearing the viewport causes the system to set the desired portion of the render target surface and any attached depth or stencil buffers to a desired state. This resets the areas of the surface that will be rendered again and resets the corresponding areas of the depth and stencil buffers, if any are in use. Clearing a render target surface can set the desired region to a default color or texture. For depth and stencil buffers, this can set a depth or stencil value.

The IDirect3DViewport3 interface offers the IDirect3DViewport3::Clear and IDirect3DViewport3::Clear2 methods to clear the viewport. For more information about using these methods, see Clearing a Viewport in the Viewports and Clipping section.