D2D1CreateFactory<Factory>(D2D1_FACTORY_TYPE,Factory**) Function

Creates a factory object that can be used to create Direct2D resources.

template<class Factory>
HRESULT D2D1CreateFactory(
    __in D2D1_FACTORY_TYPE factoryType,
    __out Factory **factory
);

Template Parameters

Parameter Description
Factory The type of ID2D1Factory to create.

Parameters

Parameter Description
factoryType The threading model of the factory and the resources it creates.
factory When this method returns, contains the address of a pointer to the new factory.

Return Value

If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

The following example creates a factory.

HRESULT DemoApp::CreateDeviceIndependentResources()
{
    HRESULT hr = S_OK;

    // Create a Direct2D factory.
    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory);

    return hr;
}

Requirements

Requirement Value
Minimum supported client
Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server
Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Minimum supported phone
Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]
Header
D2d1.h
Library
D2d1.lib
DLL
D2d1.dll