Direct2D的 - 保留现有的内容和覆盖新值(Direct2D - preserve the e

2019-10-20 12:10发布

I am planning to develop a XY Plotter for my application. To give some basic idea, how it should look like (of course the implementation would be different), please refer here and here.

During the simulation (let's assume, it takes 4 hours to complete the simulation), on a fixed X axis, the new Y values should be (over)written.

But, the problem with Direct2D is that, every time pRenderTarget->BeginDraw() is called, the existing Drawing(/Plot/BitMap/Image, etc) is deleted and a new image is being drawn. Therefore I would lose the old values.

Of course, I can always buffer the old Y values in a buffer/variable and use it in the next drawing. But, the simulation runs for 4 hours and unfortunately I can't afford to save all the Y values. That's why, I need to render/draw the new Y values on the existing target-image/plot/etc.

And, If don't call pRenderTarget->EndDraw() within a definite amount of time, my application would crash due to resource constraints.

How do I prevent this problem and achieve the requirement?

Answer 1:

什么你问是一个相当复杂的需求 - 这是比看起来更困难! Direct2D的是直接模式绘图API 。 还有就是你画在即时模式图形画面没有什么状态检修或持久性。

在最直接的模式图形API,还有剪裁和肮脏rects的概念。 在Direct2D中,你可以使用一个这三种技术来绘制到屏幕上的一个子集。 渲染屏幕外的位图和双缓冲可能是一个很好的技术尝试。 例如,你的过程就变成了:

  • 画到离屏位图
  • BLIT位图到屏幕
  • 在新的数据,得出一个新的位图/与现有的位图结合

如果你的阴谋没有滚动或规模改变,因为你追加新的数据/得出这样的技术将只工作。



文章来源: Direct2D - preserve the existing content and overwrite the new values