I decided to spend a few minutes tonight implementing a Direct2D renderer for the Linkage program. After a few failed attempts a year ago, I finally got it right and am able to draw lines. Just lines. Nothing more – no circles or text or anything else.
And this is what the Jansen mechanism sample looks like (above). I’m rather disappointed in how the almost horizontal line looks. But it is much smoother than the GDI lines. I don’t seem to see artifacts like this in the video and image exports although the lines in those files are all thicker than this. So some experimentation is needed.
I also need to figure out how to deal with text. I know that I can mix GDI and Direct2D rendering because I am using a GDI memory device context as the render target. The reason that there is no text in this image above is because the EndDraw() function of the Direct2D render target is being called after all rendering is done. It seems as if that somehow causes the GDI parts of the image to be overwritten. Maybe.
For a comparison, here is the GDI version of the same mechanism, of course with all the connectors drawn too:
Yes, the Direct2D coloring is not right yet either. it is the most basic functionality that I could get working in the short time I have right now. Notice the difference in the anti-aliasing of the lines.
I have no idea how hard it will be to get circles or dotted lines to draw. I look forward to finding out. And maybe if I do things right, I can switch between GDI rendering of the text and Direct2D rendering of everything else. As long as I don’t switch back and forth too much, it might work out. It will be a long time before this is working but if I ever get it finished, it will add some polish to a program that’s already way more than I ever expected to build.