Looking for a faster-than-GDI solution for rendering dynamic data plots

这一生的挚爱 提交于 2019-12-04 17:45:55

Managed DirectX has been deprecated for some time. You really don't want to use that. Instead, you should use SlimDX which is an open source interop layer for the DirectX SDK APIs written in C++/CLI. It is better than Managed DirectX and is supported by an expert community of developers. (I'm going to be working on improving the DirectWrite support with them soon.)

From my experience, you won't get good enough performance out of using GDI+. Even for simple drawing, you will quickly realize that there's a lot of overhead.

Alternatives would (as you mentioned) be Direct3D, or you could consider regular GDI with system calls. That obviously makes the code platform dependent but it can be quite fast. I've had good results using that.

It all depends on how much complexity you're willing to deal with. GDI can be relatively easy once you figure out the basics, Direct3D is a bit more complex. Though Direct3D is more future proof.

BeeWarloc

It is true that GDI+ isn't very good performance-wise, however I have myself written a GDI+ plotter in a work-related project that's able to spit out graphs with thousand of points at ~30 frames pr second at 1680x1050 resolution (scrolling graph).

It took a lot of tuning to achieve this:

  • Convert everything to one single path before drawing.
  • If using back-buffer, use one with pixel format Format32bppPArgb, this can speed up blitting 2-4x.
  • If drawing a path with a lot of vertical lines (high frequency signal), draw them as horizontal lines on a back buffer instead, and then draw the image rotated on the screen. Be aware that drawing an image rotated also have certain cost.

I can't see how your scenario requires a whole lot of optimization though, 128 points of data is nothing. Putting these points into one GraphicsPath could make a difference though, since that would mean less marshalling overhead.

What resolution and frame rate are we talking about here by the way?

Microsoft now also has Direct2D, which is hardware accelerated 2D drawing:

Direct2D is a hardware-accelerated, immediate-mode, 2-D graphics API that provides high performance and high-quality rendering for 2-D geometry, bitmaps, and text. The Direct2D API is designed to interoperate well with GDI, GDI+, and Direct3D.

It requires Windows 7/Server 2008 R2, but support has been back-added to Vista/Server 2008 through the Platform Update:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!