質問

I need to create ID2D1DCRenderTarget, because I need compability with GDI. I do it with the following code:

ID2D1Factory* factory;
ID2D1DCRenderTarget* target;
ID2D1SolidColorBrush* brush;

using namespace D2D1;
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory);

D2D1_RENDER_TARGET_PROPERTIES rtp = RenderTargetProperties();
rtp.usage = D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE;

factory->CreateDCRenderTarget(&rtp, &target);

target->CreateSolidColorBrush(ColorF(ColorF::White), &brush);

Program crashes in the last line. But when I try to similarily create ID2D1HwndRenderTarget everything works fine. Could anyone help me?

役に立ちましたか?

解決

As I checked it, it appears that problem is with RenderTargetProperties(), beacuse if D2D1_RENDER_TARGET_PROPERTIES is filled for example like that:

D2D1_RENDER_TARGET_PROPERTIES rtp = D2D1::RenderTargetProperties(
    D2D1_RENDER_TARGET_TYPE_DEFAULT,
    D2D1::PixelFormat(
        DXGI_FORMAT_B8G8R8A8_UNORM,
        D2D1_ALPHA_MODE_IGNORE),
    0,
    0,
    D2D1_RENDER_TARGET_USAGE_NONE,
    D2D1_FEATURE_LEVEL_DEFAULT
    );

everything works.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top