889 questions
You used same colors for background and brush
And don't use CreateHwndRenderTarget (old method) but Device Context
If I replace Render in the sample I posted in the other thread :
HRESULT Render()
{
HRESULT hr = HRESULT.S_OK;
if (m_pD2DDeviceContext != null)
{
m_pD2DDeviceContext.BeginDraw();
m_pD2DDeviceContext.Clear(new ColorF(ColorF.Enum.Blue, 1.0f));
D2D1_RECT_F rectf = new D2D1_RECT_F();
rectf.left = 50;
rectf.top = 50;
rectf.right = 500;
rectf.bottom = 300;
m_pD2DDeviceContext.FillRectangle(ref rectf, m_pMainBrush);
hr = m_pD2DDeviceContext.EndDraw(out ulong tag1, out ulong tag2);
if ((uint)hr == D2DTools.D2DERR_RECREATE_TARGET)
{
m_pD2DDeviceContext.SetTarget(null);
SafeRelease(ref m_pD2DDeviceContext);
hr = CreateDeviceContext();
CleanDeviceResources();
hr = CreateDeviceResources();
hr = CreateSwapChain(IntPtr.Zero);
hr = ConfigureSwapChain();
}
hr = m_pDXGISwapChain1.Present(1, 0);
}
return (hr);
}
with :
ID2D1SolidColorBrush m_pMainBrush = null;
HRESULT CreateDeviceResources()
{
HRESULT hr = HRESULT.S_OK;
if (m_pD2DDeviceContext != null)
{
if (m_pMainBrush == null)
hr = m_pD2DDeviceContext.CreateSolidColorBrush(new ColorF(ColorF.Enum.Red, 1.0f), null, out m_pMainBrush);
}
return hr;
}
at end :
SafeRelease(ref m_pMainBrush);
I get :