Share via


MÉTHODES ID2D1RenderTarget::Clear

Efface la zone de dessin à la couleur spécifiée.

Liste de surcharge

Méthode Description
Clear(D2D1_COLOR_F*) Efface la zone de dessin à la couleur spécifiée.
Clear(D2D1_COLOR_F&) Efface la zone de dessin à la couleur spécifiée.

Notes

Direct2D interprète clearColor comme une alpha droite (non prémultipliée). Si le mode alpha de la cible de rendu est D2D1_ALPHA_MODE_IGNORE, le canal alpha de clearColor est ignoré et remplacé par 1.0f (entièrement opaque).

Si la cible de rendu a un clip actif (spécifié par PushAxisAlignedClip), la commande clear est appliquée uniquement à la zone dans la région de clip.

Exemples

L’exemple suivant utilise la méthode Clear pour créer un arrière-plan blanc avant de restituer un autre contenu.

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

Spécifications

Condition requise Valeur
Bibliothèque
D2d1.lib
DLL
D2d1.dll

Voir aussi

ID2D1RenderTarget