D2D1CreateDeviceContext function (d2d1_1.h)

Creates a new Direct2D device context associated with a DXGI surface.

Syntax

HRESULT D2D1CreateDeviceContext(
  [in]           IDXGISurface                   *dxgiSurface,
  [in, optional] const D2D1_CREATION_PROPERTIES *creationProperties,
  [out]          ID2D1DeviceContext             **d2dDeviceContext
);

Parameters

[in] dxgiSurface

The DXGI surface the Direct2D device context is associated with.

[in, optional] creationProperties

The properties to apply to the Direct2D device context.

[out] d2dDeviceContext

When this function returns, contains the address of a pointer to a Direct2D device context.

Return value

The function returns an HRESULT. Possible values include, but are not limited to, those in the following table.

HRESULT Description
S_OK No error occurred.
E_OUTOFMEMORY Direct2D could not allocate sufficient memory to complete the call.
E_INVALIDARG An invalid value was passed to the method.

Remarks

This function will also create a new ID2D1Factory1 that can be retrieved through ID2D1Resource::GetFactory.

This function will also create a new ID2D1Device that can be retrieved through ID2D1DeviceContext::GetDevice.

The DXGI device will be specified implicitly through dxgiSurface.

If creationProperties are not specified, the Direct2D device will inherit its threading mode from the DXGI device implied by dxgiSurface and debug tracing will not be enabled.

Requirements

Requirement Value
Minimum supported client Windows 8 and Platform Update for Windows 7 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header d2d1_1.h
DLL D2d1.dll

See also

D2D1CreateDevice

D2D1CreateDeviceContext

D2D1_CREATION_PROPERTIES

ID2D1Device

ID2D1Factory

ID2D1Resource::GetFactory