I'm experiencing a strange issue with Direct2D, I figured someone here might be able to help since you guys always help with my Direct3D questions
I'm trying to draw some ID2D1Bitmaps to my window using SharpDX and a WindowRenderTarget object.
The bitmaps are first loaded into a SharpDX.Direct2D1.Bitmap object, then drawn to the screen using myRenderTarget.DrawBitmap.
The code runs fine on my system and other Nvidia systems, but I recently tested it using an ATI device and I'm getting a D2DERR_UNSUPPORTED_PIXEL_FORMAT error.
I found this post on another site that was very helpful:
"In order to solve the issue do this:
1) For Windows 7 Direct2D 1.0 (Direct2D before Platform Update) put m_pRenderTarget->BeginDraw() before creating any bitmaps;
2) For Windows 8 Direct2D 1.1 (or for Windows 7 with Platform Update) put m_pRenderTarget->SetTarget (in case you have ID2D1DeviceContext as a type for m_pRenderTarget), or the same m_pRenderTarget->BeginDraw() (in case you have ID2D1HwndRenderTarget as a type for m_pRenderTarget);
The problem is that right after you created m_pRenderTarget in fact this render target does not have a DXGI surface to draw at. And because of it the render target unable to find a pixel format for new bitmaps. That's why you got WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT."
My issue is I can't call BeginDraw before I create my bitmaps because they are created before the window is ever drawn. So instead of using a WindowRenderTarget I tried using Direct3D 10 for the backend like the samples included with SharpDX, and calling myDevice.OutputMerger.SetTargets right after the device is created.
This seems to work except for one problem. The render target and back-buffer must be recreated every time the window is resized and in conjunction my bitmaps must be recreated too. This results in a very noticeable lag when resizing the window. With a WindowRenderTarget I can just call myRenderTarget.Resize without having to recreate anything so I would prefer to use a WindowRenderTarget instead.
Does anyone know of a solution that allows me to use a WindowRenderTarget and create my bitmaps without calling BeginDraw? If not, is it possible to resize the D3D swap chain without having to reset the render target? Any help would be greatly appreciated.
Edited by ta0soft, 26 February 2014 - 06:16 AM.