How to connect the backbuffer in DirectX11 using Direct2D-DirectWrite?
How to connect bacbuffer in Dx11 with Direct2D-DriectWrite
Hello guys.
When I used Direct2D, It was possible to connect DriectWrite to Direct2D and write 2d characters. But in Dx11, it seems unable to connect DirectWrite to Dx11 framework. So I create other Direct2D RanderTarget to draw 2d characters. but in this solution fps plummeted to half, and crashes. so i need another solution Is this possible to use DriectWrite in Dx11 framwork?
Here is my Direct2D Init Function ID2D1RenderTarget & ID2D1Factory Value
extern ID2D1RenderTarget* Rendtrg;
extern ID2D1Factory* factory;
extern IDXGISurface* pBackBuffer;
//Create BackBuffer
{
HRESULT hr;
ID3D11Texture2D* BackBuffer;
hr = SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&BackBuffer);
assert(SUCCEEDED(hr));
hr = Device->CreateRenderTargetView(BackBuffer, NULL, &RTV);
assert(SUCCEEDED(hr));
BackBuffer->Release();
DeviceContext->OMSetRenderTargets(1, &RTV, NULL);
}
//Initailize Direct2D Funtion
HRESULT hr;
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, factory);
if (FAILED(hr))
return hr;
hr = SwapChain->GetBuffer(
0,
IID_PPV_ARGS(&pBackBuffer)
);
FLOAT dpiX;
FLOAT dpiY;
(*factory)->GetDesktopDpi(&dpiX, &dpiY);
D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties
(
D2D1_RENDER_TARGET_TYPE_DEFAULT,
D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
dpiX,
dpiY
);
hr = (*factory)->CreateDxgiSurfaceRenderTarget
(
pBackBuffer,
&props,
Rt
);