Device.Clear Method (ClearFlags, Color, Single, Int32)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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 _
)
'Usage
Dim instance As Device
Dim flags As ClearFlags
Dim color As Color
Dim zdepth As Single
Dim stencil As Integer

instance.Clear(flags, color, zdepth, stencil)
public void Clear(
    ClearFlags flags,
    Color color,
    float zdepth,
    int stencil
)
public:
void Clear(
    ClearFlags flags, 
    Color color, 
    float zdepth, 
    int stencil
)
member Clear : 
        flags:ClearFlags * 
        color:Color * 
        zdepth:float32 * 
        stencil:int -> unit 

Parameters

  • flags
    Type: Microsoft.WindowsMobile.DirectX.Direct3D.ClearFlags
    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.

  • zdepth
    Type: System.Single
    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
    Type: System.Int32
    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.

Exceptions

Exception 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.

Examples

The following example demonstrates how to use the Clear property.

Private Sub Render()
    If device Is Nothing Then
        Return
    End If
    'Clear the backbuffer to a blue color. 
    device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0F, 0)
    'Begin the scene.
    device.BeginScene()

    'Render scene objects, if desired.
    'End the scene.
    device.EndScene()
    device.Present()

End Sub
private void Render()
{
    if (device == null)
        return;

    //Clear the backbuffer to a blue color. 
    device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
    //Begin the scene.
    device.BeginScene();

    // Rendering scene objects, if desired.

    //End the scene.
    device.EndScene();
    device.Present();
}

.NET Framework Security

Platforms

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Compact Framework

Supported in: 3.5, 2.0

See Also

Reference

Device Class

Device Members

Clear Overload

Microsoft.WindowsMobile.DirectX.Direct3D Namespace