ID2D1EffectImpl::Initialize method (d2d1effectauthor.h)

The effect can use this method to do one time initialization tasks. If this method is not needed, the method can just return S_OK.

Syntax

HRESULT Initialize(
  [in] ID2D1EffectContext  *effectContext,
  [in] ID2D1TransformGraph *transformGraph
);

Parameters

[in] effectContext

Type: ID2D1EffectContext*

An internal context interface that creates and returns effect author–centric types.

[in] transformGraph

Type: ID2D1TransformGraph*

The effect can populate the transform graph with a topology and can update it later.

Return value

Type: HRESULT

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

Remarks

This moves resource creation cost to the CreateEffect call, rather than during rendering.

If the implementation fails this call, the corresponding ID2D1DeviceContext::CreateEffect call also fails.

The following example shows an effect implementing an initialize method.

Examples

The example here shows an effect implementing an initialize method.

class CEffectImplementation : public ID2D1EffectImpl
{
public:

    virtual ~CEffectImplementation()
    {
        if (_pContextInternal != NULL)
        {
            _pContextInternal->Release();
        }
    }

    IFACEMETHODIMP Initialize(__in ID2D1DeviceContextInternal *pContextInternal, __in ID2D1TransformGraph *pTransformGraph)
    {
        HRESULT hr = S_OK;

        _pContextInternal = pContextInternal;
        _pContextInternal->AddRef();

								_pTransformGraph = pTransformGraph;
        _pTransformGraph>AddRef();

								// Populate the transform graph.					    

        return S_OK;
    }

private:

    ID2D1EffectContext *_pContextInternal;
    ID2D1TransformGraph *_pTransformGraph;
};

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 d2d1effectauthor.h
Library D2D1.lib

See also

ID2D1DeviceContext

ID2D1EffectImpl