I have a MFC program that use Direct2D to paint.
Below is a very simple version of the draw method that use FillGeometry to fill a triangle.
// AFX_WM_DRAW2D event handler
afx_msg LRESULT CChildView::OnDraw2d( WPARAM wParam, LPARAM lParam )
{
CHwndRenderTarget* pclRenderTarget = (CHwndRenderTarget*)lParam;
ASSERT_VALID( pclRenderTarget );
// Clear window background
pclRenderTarget->Clear( D2D1::ColorF( D2D1::ColorF::Red ) );
const float fZoom = 0.2f;
const float fOffset = 50000000;
pclRenderTarget->SetTransform( D2D1::Matrix3x2F::Translation( D2D1::Size( -fOffset, -fOffset ) ) * D2D1::Matrix3x2F::Scale( fZoom , fZoom ) );
CD2DPathGeometry clPath( pclRenderTarget );
clPath.Create( pclRenderTarget );
ID2D1GeometrySink* pclSink = clPath.Open();
pclSink->SetFillMode( D2D1_FILL_MODE_WINDING );
pclSink->BeginFigure( D2D1::Point2F( fOffset + 100, fOffset + 100 ), D2D1_FIGURE_BEGIN_FILLED );
pclSink->AddLine( D2D1::Point2F( fOffset + 100, fOffset + 10000 ) );
pclSink->AddLine( D2D1::Point2F( fOffset + 10000, fOffset + 100 ) );
pclSink->EndFigure( D2D1_FIGURE_END_CLOSED );
pclSink->Close();
pclRenderTarget->FillGeometry( &clPath, m_pBlueBrush );
return TRUE;
}
When I run the program it looks like this.
As it can be seen the triangle has some red horizontal and vertical lines that should not be there.
I found that if I remove the D2D1_FILL_MODE_WINDING the triangle is filled without any lines as expected.
I have also found that if I reduced the Offset the lines get thinner and eventually disappear.
I have tried the program on different computers.
Lines shows on
* Windows 10 (1803) with Nvidia GeForce GTX 1050 Ti
* Windows 10 (1803) with AMD Radeon R9 370
* Windows 10 (1709) with Nvidia Quadro P400
* Windows 10 (1803) with Intel HD 5500
Lines do not show on
* Windows 10 (1803) with AMD FirePro2270
* Windows 7 with AMD Radeon 8790M / Intel
* Windows 10 (1803) in VirualBox
But I can not find any patteren in the behaviour.
Can somebody explain what maybe happening here?
First I was thinking it might be a driver bug, but because I see it with different graphics cards I am reluctant to accept this.
Update
This is the output I get in the Visual Studio Graphics Analyzer.
The lines show up in the first Draw.