다음을 통해 공유


ID2D1RenderTarget::Clear 메서드

드로잉 영역을 지정된 색으로 지웁니다.

오버로드 목록

메서드 설명
Clear(D2D1_COLOR_F*) 드로잉 영역을 지정된 색으로 지웁니다.
Clear(D2D1_COLOR_F>) 드로잉 영역을 지정된 색으로 지웁니다.

설명

Direct2D는 clearColor직선 알파로 해석합니다(미리 곱하지 않음). 렌더링 대상의 알파 모드가 D2D1_ALPHA_MODE_IGNORE 경우 clearColor알파 채널이 무시되고 1.0f(완전히 불투명)로 바뀝니다.

렌더링 대상에 활성 클립(PushAxisAlignedClip으로 지정됨)이 있는 경우 지우기 명령은 클립 영역 내의 영역에만 적용됩니다.

예제

다음 예제에서는 Clear 메서드를 사용하여 다른 콘텐츠를 렌더링하기 전에 흰색 배경을 만듭니다.

//  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;
}

요구 사항

요구 사항
라이브러리
D2d1.lib
DLL
D2d1.dll

참고 항목

ID2D1RenderTarget