Share via


Device.Clear Method (ClearFlags, Color, Single, Int32, Rectangle[])

Clears the viewport or a set of rectangles in the viewport to a specified RGBA color, clears the depth buffer, and erases the stencil buffer.

Namespace: Microsoft.WindowsMobile.DirectX.Direct3D
Assembly: Microsoft.WindowsMobile.DirectX (in microsoft.windowsmobile.directx.dll)

Syntax

'Declaration
Public Sub Clear ( _
    flags As ClearFlags, _
    color As Color, _
    zdepth As Single, _
    stencil As Integer, _
    rectangles As Rectangle() _
)
'Usage
Dim instance As Device
Dim flags As ClearFlags
Dim color As Color
Dim zdepth As Single
Dim stencil As Integer
Dim rectangles As Rectangle()

instance.Clear(flags, color, zdepth, stencil, rectangles)
public void Clear (
    ClearFlags flags,
    Color color,
    float zdepth,
    int stencil,
    Rectangle[] rectangles
)
public:
void Clear (
    ClearFlags flags, 
    Color color, 
    float zdepth, 
    int stencil, 
    array<Rectangle>^ rectangles
)
public void Clear (
    ClearFlags flags, 
    Color color, 
    float zdepth, 
    int stencil, 
    Rectangle[] rectangles
)
public function Clear (
    flags : ClearFlags, 
    color : Color, 
    zdepth : float, 
    stencil : int, 
    rectangles : Rectangle[]
)
Not applicable.

Parameters

  • flags
    The flags that indicate which surfaces to clear. This parameter can be any combination of the following flags, but at least one flag must be used:

    • Stencil: Clears the stencil buffer to the value in the stencil parameter.

    • Target: Clears the render target to the color in the color parameter.

    • ZBuffer: Clears the depth buffer to the value in the zdepth parameter.

  • color
    A Color object that represents the color to which the render target surface is cleared.
  • zdepth
    A new zdepth value that this method stores in the depth buffer. This parameter can be in the range of 0.0 through 1.0 (for z-based or w-based depth buffers). A value of 0.0 represents the nearest distance to the viewer; a value of 1.0 represents the farthest distance.
  • stencil
    An integer value to store in each stencil-buffer entry. This parameter can be in the range of 0 through 2n-1, where n is the bit depth of the stencil buffer.
  • rectangles
    An array of Rectangle structures that describe the rectangles to clear. To clear the entire surface, set a rectangle to the dimensions of the rendering target. Each rectangle uses screen coordinates that correspond to points on the render target surface. Coordinates are clipped to the bounds of the viewport rectangle.

Exceptions

Exception type Condition

InvalidCallException

The method call is invalid. For example, a parameter might contain an invalid value.

Remarks

This method fails if the ZBuffer or Stencil flags are specified when the render target does not have an attached depth buffer. Similarly, the method fails if the Stencil flag is specified when the depth-buffer format does not contain stencil buffer information.

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Compact Framework

Supported in: 2.0

See Also

Reference

Device Class
Device Members
Microsoft.WindowsMobile.DirectX.Direct3D Namespace