简体   繁体   English

显示实时图形(.net 2.0)

[英]Displaying real-time graphics (.net 2.0)

This puzzles me for years, since MFC. 自MFC以来,这困扰了我多年。 We all know DC limitations in Windows, and I really want to break free from it this time. 我们都知道Windows中的DC限制,这次我真的很想摆脱它。

What I need is to be able to draw at some hWnd, ie control, at any time - from any thread, even using direct bit manipulation! 我需要的是能够在任何时候从任何线程,甚至使用直接位操作,在任何时候绘制(即控制)! Is there anybody that can shed some light to it. 是否有人可以对此有所了解。

I prefer that question should stay WPF-free. 我希望这个问题不涉及WPF。 I like GDI, and I would like to stay in its embrace. 我喜欢GDI,也希望一直坚持下去。

draw at some hWnd, ie control, at any time - from any thread 在任何时候从任何线程在任何位置绘制,即控制

This isn't going to happen in Windows. 在Windows中不会发生这种情况。 The basic windows controls are designed with thread affinity. 基本的Windows控件设计为具有线程关联性。 You must use the thread which created the control to draw into the control (even with WPF). 您必须使用创建控件的线程来吸引控件(即使使用WPF)。 GDI (and GDI+) is based on these technologies, and will always require using a single rendering thread. GDI(和GDI +)基于这些技术,并且始终需要使用单个渲染线程。

That being said, you can still do real time graphics. 话虽如此,您仍然可以进行实时图形处理。 Just handle all of the processing on graphics threads, and only marshal the drawing onto the UI thread. 只需处理图形线程上的所有处理,并且仅将图形编组到UI线程上即可。 This will be fast enough to draw nearly everything required. 这将足够快地绘制几乎所有需要的东西。

If absolute rendering speed is required, you may want to switch to Direct2D or Direct3D for rendering. 如果需要绝对渲染速度,则可能要切换到Direct2D或Direct3D进行渲染。 There are options for multithreaded rendering in Direct3D, though internally they still use locking. Direct3D中有用于多线程渲染的选项,尽管它们在内部仍使用锁定。

However, you should be able to render at much greater than your monitor's refresh rate using D3D. 但是,使用D3D,您应该能够以比显示器的刷新率高得多的速度进行渲染。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM