我需要创建 ID2D1DCRenderTarget,因为我需要与 GDI 兼容。我用下面的代码来做:
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);
程序在最后一行崩溃。但是当我尝试类似地创建 ID2D1HwndRenderTarget 时,一切正常。有人可以帮我吗?