WPF real-time rendering

前端 未结 1 1298
陌清茗
陌清茗 2021-01-07 11:43

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

Is it possible to render basic 2d-graphics in WPF in real-tim

相关标签:
1条回答
  • 2021-01-07 12:12

    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.

    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.

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

    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.

    0 讨论(0)
提交回复
热议问题