So I've been working on an unmanaged C++ 2D MFC system in Visual Studio 2013 using GDI+ (Document View architecture). I need simple shapes shaded from each vertex of the shape - either a triangle with a color in each corner, blending those colors to the interior, or a rectangle doing the same.
In GDI plus, this is quite straightforward:
using
namespace
Gdiplus;
void
DrawGradientTriangle( Graphics &rGraphics )
Gdiplus::GraphicsPath gpath;
gpath.AddLine(
100
,
400
,
200
,
400
);
gpath.AddLine(
200
,
400
,
150
,
300
);
gpath.CloseFigure();
int
nColorCount =
3
;
Color agdiClr[] =
Color::Red,
Color::Green,
Color::Blue
PathGradientBrush gbrush( &gpath );
gbrush.SetSurroundColors( agdiClr, &nColorCount );
gbrush.SetCenterColor( Color::White );
rGraphics.FillPath( &gbrush, &gpath );
However, I have enough of these shapes that hardware acceleration would be appreciated, so I would like to move to D2D. Windows7 is the target and my understanding is that hardware acceleration is not necessarily provided with GDI+ in more recent OS's.
Is there any equivalent to this in Direct2D? I have been able to get most aspects of the system working well in D2D, but have not found any convenient way to mimic the above behavior. I know it can be done in Direct3D, but the infrastructure to get that going in an mfc program is a bit odious, and I'm not excited about going in that direction.
Any direction would be greatly appreciated.
What I have tried:
I have looked at more current options within D2D, especially drawing a gradient mesh (see https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/D2DGradientMesh/README.md) but these features appear to be only supported in Windows10 or later.
Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad
spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or
edit the question
and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it.
Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.