Program architecture for Windows 8 C # and XAML application with graphics

If I’m looking to create a game that won’t necessarily work in full screen mode, but just need to display 2D / 3D graphics somewhere on a part of the screen, what is my best approach?

Quick wireframe

Some specific questions may be:

  • Which component will use the resulting area?
  • Are there any game libraries that I could use for the selected area?
  • What will be the most “clean” or “canonical” stack according to Microsoft for use here?
+4
source share
2 answers

Omega - Visual Studio 2010 and 2012 are both WPF applications. WinRT is designed for tablets / mobile devices. WPF is definitely NOT out of date.

If I were you, I wouldn’t do everything the way the canvas can force, perhaps this is the best approach for the center element to be a UI element called Frame, which is the basic element for all user interface related content in WPF.

Thus, you can use all possible types of controls in the frame, regardless of whether you decide that ImageSourceType or Canvas is more applicable to certain functions of the game.

+1
source

Depending on how you want to draw graphics, you can use (but by no means limited):

  • Canvas - which will be completely appropriate for slow moving games. This way you get the benefits of various WPF routines and you can define objects within the scene in XAML / vectors.
  • WPF supports 3D graphics (using Direct3D on the backend), so you can probably create an orthogonal projection matrix and treat it as a Direct3D context (with the WPF API). I don’t have enough experience to know how slowly this compares with D3D, but it is certainly easier (built-in “scene graph”, for example, support for the XAML architecture).
  • If you want to play with Direct3D, you can use SlimDX, which has the WPF gasket that I used in the past, as well as other third-party controls . Other libraries may also be available.
  • Direct blitting to / from Bitmap using WriteableBitmap (see WriteableBitmapEx for a third-party version with a much more friendly API) or similar.

There are probably many other options. My preference would be to use Canvas initially if it's a slow game that doesn't require ultra-fast frame rates (prototyping does come with significant overhead, but it works less and it may be easier to look exactly the way you want).

If you want absolute control and speed, use D3D via SlimDX, but this is a rather complicated learning curve if you are new to this.

0
source

Source: https://habr.com/ru/post/1432279/


All Articles