WPF实时渲染 [英] WPF real-time rendering

查看:325
本文介绍了WPF实时渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计游戏,并考虑使用WPF制作基本游戏玩法的简单原型。

I'm designing a game and thinking about using WPF for making a simple prototype of the basic gameplay.

是否可以在WPF中渲染基本的2D图形实时?基本图形是指简单的形状,例如直线,圆形等。实时是指根据诸如速度,加速度等参数进行渲染,这些参数根据玩家的输入而变化-我认为这意味着我可以

Is it possible to render basic 2d-graphics in WPF in real-time? By basic graphics I mean simple shapes such as lines, circles, etc. By "real-time" I mean things are rendered based on parameters such as velocity, acceleration, etc. that changes depending on player input - which I assume means I can't use storyboards for the animations.

谢谢

推荐答案

检查排除上一个问题使用WPF可视层的高性能图形进行良好的相关讨论。虽然WPF为丰富的矢量图形提供了一个很好的框架,但它缺乏实时2D性能。

Check out the previous question High Performance Graphics using the WPF Visual Layer for a good related discussion. While WPF provides a great framework for rich vector graphics, it lacks somewhat for real-time 2D performance.

例如,有一些变通办法,具体取决于您的场景复杂性,使用 DrawingVisuals 或虚拟Shape类(WPF矢量图形)来绘制精灵。再往下一点,您可以使用 BitmapCache 模式,或将它们预先提供给Bitmap并使用各种优化模式以提高吞吐量。

There are workarounds, for instance, depending on your scene complexity you may get away with using DrawingVisuals or virtualized Shape classes (WPF Vector graphics) to draw your sprites. Going a little lower level, you could cache sprites using the BitmapCache mode available in .NET4.0, or pre-prendering them to Bitmaps and using various optimization patterns to improve throughput.

要进一步降低水平,您可以使用幻想的 WriteableBitmapEx 项目或使用 D3DImage的Vector / GPU图形

Going lower level still, you can mix Vector/Raster graphics using the fantantastic WriteableBitmapEx project, or Vector/GPU graphics using the D3DImage.

关于如何更新场景,您需要编写一个原始的游戏引擎,其中在 CompositionTarget.Rendering 事件(在屏幕重绘时触发),您将获得更新的参数并计算位置/精灵的方向。很棒的 codeplex项目可能会对此有所帮助,该项目集成了WPF / Silverlight和Farseer物理学。

Regarding how to update your scene, you'll need to write a primitive game engine where on the CompositionTarget.Rendering event (fired on redraw of the screen) you get the updated parameters and compute positions/orientations of your sprites. Something that might help with this is this great codeplex project which integrates WPF/Silverlight and Farseer physics.

这篇关于WPF实时渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆