I want make a Direct2D GUI that will run on a DLL and will render with the Direct3D of the application that I inject into it.
I know that I can simply use ID2D1Factory::CreateDxgiSurfaceRenderTarget to make a DXGI surface and use it as d2d render target, but this require enabling the flag D3D11_CREATE_DEVICE_BGRA_SUPPORT on Direct3D's device.
The problem is that the application creates its device without enabling this flag and, for this reason, ID2D1Factory::CreateDxgiSurfaceRenderTarget fails.
I am trying to find a other way to draw on the application window (externally or inside window's render target) that also works if that window is in full-screen.
I tried these alternatives so far:
Create a d2d render target with
ID2D1Factory::CreateDCRenderTarget. This worked, but the part I rendered was blinking/flashing (show and hide very fast in loop). I also calledID2D1DCRenderTarget::BindDCbeforeID2D1RenderTarget::BeginDraw, but it just blinks but a bit less, so I still had the same issue.Create a new window that will always be on the top of every other window and render there with d2d but, if the application goes into full-screen, then this window does not show on screen.
Create a second D3D device with enabled the
D3D11_CREATE_DEVICE_BGRA_SUPPORTflag and share anID3D11Texture2Dresource between the device of the window and my own, but I wasn't able to make it work... There are not a lot of examples on how to do it. The idea was to create a 2nd device, draw with d2d on that device and then sync the 2 D3D devices – I followed this example (with direct11).Create a D2D device and share the data of d2d device with d3d device; but, when I call
ID2D1Factory1::CreateDeviceto create the device it fails because the D3D device is created without enabling theD3D11_CREATE_DEVICE_BGRA_SUPPORTflag. I started with this example.
I've heard of hardware overlay but it works only on some graphics cards and I think I will have problems with this https://docs.microsoft.com/el-gr/windows/win32/medfound/hardware-overlay-support.
I am currently at a dead end; I don't know what to do. Does anyone have any idea that may help me?
Maybe is there any way to draw on screen and work even if a window is in full-screen?