Clears the drawing area to the specified color.
Syntax
void Clear( const D2D1_COLOR_F &clearColor );
Parameters
- clearColor [ref]
-
Type: const D2D1_COLOR_F
The color to which the drawing area is cleared.
Return value
This method does not return a value.
Remarks
Direct2D interprets the clearColor as straight alpha (not premultiplied). If the render target's alpha mode is D2D1_ALPHA_MODE_IGNORE, the alpha channel of clearColor is ignored and replaced with 1.0f (fully opaque).
If the render target has an active clip (specified by PushAxisAlignedClip), the clear command is applied only to the area within the clip region.
Examples
The following example uses the Clear method to create a white background before rendering other content.
For the complete example, see the "Hello, World" Sample Application.
// Called whenever the application needs to display the client // window. This method writes "Hello, World" // // Note that this function will automatically discard device-specific // resources if the Direct3D device disappears during function // invocation, and will recreate the resources the next time it's // invoked. // HRESULT DemoApp::OnRender() { HRESULT hr; hr = CreateDeviceResources(); if (SUCCEEDED(hr)) { static const WCHAR sc_helloWorld[] = L"Hello, World!"; // Retrieve the size of the render target. D2D1_SIZE_F renderTargetSize = m_pRenderTarget->GetSize(); m_pRenderTarget->BeginDraw(); m_pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity()); m_pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White)); m_pRenderTarget->DrawText( sc_helloWorld, ARRAYSIZE(sc_helloWorld) - 1, m_pTextFormat, D2D1::RectF(0, 0, renderTargetSize.width, renderTargetSize.height), m_pBlackBrush ); hr = m_pRenderTarget->EndDraw(); if (hr == D2DERR_RECREATE_TARGET) { hr = S_OK; DiscardDeviceResources(); } } return hr; }
Requirements
|
Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps] |
|---|---|
|
Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/29/2012