C# 结合 GDI+ 和 OpenGL/DirectX
背景:我目前在我的 C# 项目中使用自定义控件(基本控件只是绘制自定义外观和感觉(使用 gdi+?))。 这些控件中的大多数都有用于不规则形状等的透明部分。
问题:我希望在一组控件上覆盖一个半透明(不规则形状)面板。 目前,我将覆盖面板剪切到涉及的控件区域。 这工作得很好,结果看起来也不错,但过程太慢了。
问题:是否有某种方式可以通过混合一点 OpenGL/DirectX 并让显卡执行所有必要的渲染而不是依赖相当慢的 CPU 来加速渲染过程?
Background: I am currently using custom controls within my C# project (basic controls just drawing a custom look and feel (using gdi+?)). The majoritiy of these controls have transparent segments for irregular shapes etc.
Problem: I am looking to overlay a semi-transparent (irregularly shaped) panel over a group of controls. Currently I Clip the covering panel to the region of the controls involved. This works fine and the results look good, however the process is so slow.
Question: Is there some manner I can speed up the rendering process by mixing in a little OpenGL/DirectX and getting the video card to perform all the necessary rendering rather than relying on the rather slow CPU?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
AFAIK 你不能真正混合 GDI+ 和 OpenGL/DX。
如果您的性能下降,并且绝对确定这是 GDI+ 的瓶颈,而不是代码的瓶颈,那么放弃 GDI+ 并用 DX 替代可能是有意义的/OGL。 (不过,您必须编写自己的控件,这将是 @$$ 中的一个主要痛苦)
或者,对于更简单的方法,请尝试 WPF/Silverlight! 默认情况下它是可定制和可换肤的,并且基于 DX。
AFAIK you can't really mix GDI+ and OpenGL/DX.
If you're getting slow performance and are absolutely sure that it's a bottleneck in GDI+ rather than in your code, than it could make sense to ditch GDI+ and replace it with DX/OGL. (You would have to write your own controls, though, which would be a major pain in the @$$)
Or, for a simpler approach, try WPF/Silverlight! It's customizable and skinnable by default and it's based on DX.
看看 WPF 和 Silverlight。 你晚上会睡得更好。
Look at WPF and Silverlight. you would sleep better at night.
您是否尝试过在控件上打开 DoubleBuferring 以查看是否可以提高性能?
http://www.codeproject.com/KB/graphics/DoubleBuffering.aspx
Did you try turning on DoubleBuferring on your controls to see if that gives you a performance boost?
http://www.codeproject.com/KB/graphics/DoubleBuffering.aspx