Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ID2D1Factory::CreateHwndRenderTarget methods

Creates an ID2D1HwndRenderTarget, a render target that renders to a window.

Overload list

MethodDescription
CreateHwndRenderTarget(D2D1_RENDER_TARGET_PROPERTIES*,D2D1_HWND_RENDER_TARGET_PROPERTIES*,ID2D1HwndRenderTarget**)

Creates an ID2D1HwndRenderTarget, a render target that renders to a window.

CreateHwndRenderTarget(D2D1_RENDER_TARGET_PROPERTIES&,D2D1_HWND_RENDER_TARGET_PROPERTIES&,ID2D1HwndRenderTarget**)

Creates an ID2D1HwndRenderTarget, a render target that renders to a window.

Remarks

When you create a render target and hardware acceleration is available, you allocate resources on the computer's GPU. By creating a render target once and retaining it as long as possible, you gain performance benefits. Your application should create render targets once and hold onto them for the life of the application or until the D2DERR_RECREATE_TARGET error is received. When you receive this error, you need to recreate the render target (and any resources it created).

Examples

The following example creates an ID2D1HwndRenderTarget. For the complete code, see the "Hello, World" Sample Application.


RECT rc;
GetClientRect(m_hwnd, &rc);

D2D1_SIZE_U size = D2D1::SizeU(
    rc.right - rc.left,
    rc.bottom - rc.top
    );

// Create a Direct2D render target.
hr = m_pD2DFactory->CreateHwndRenderTarget(
    D2D1::RenderTargetProperties(),
    D2D1::HwndRenderTargetProperties(m_hwnd, size),
    &m_pRenderTarget
    );


Requirements

Library

D2d1.lib

DLL

D2d1.dll

See also

ID2D1Factory
"Hello, World" Sample Application

 

 

Community Additions

Show:
© 2014 Microsoft