-
-
Notifications
You must be signed in to change notification settings - Fork 299
Xna module
Robert B Colton edited this page Aug 12, 2016
·
1 revision
Provides a number of utilities and controls for working with XNA content in WPF. In the screenshot above,
the document on the left uses DrawingSurface
, and the tool window on the right uses GraphicsDeviceControl
.
Note that the GraphicsDeviceControl
is clipped correctly against its parent ScrollViewer
bounds.
-
GraphicsDeviceService
service that implements XNA'sIGraphicsDeviceService
-
ClippingHwndHost
control that clips hosted Win32 content to a WPF control's bounds
The Xna module includes 2 alternatives for hosting XNA content in WPF:
-
DrawingSurface
control that usesD3DImage
as described here. -
GraphicsDeviceControl
control that implements Nick Gravelyn's technique for hosting WPF content using an HwndHost, described here
Both DrawingSurface
and GraphicsDeviceControl
provide similar APIs, but they are
subtly different. DrawingSurface
works seamlessly with WPF mouse and keyboard input,
but GraphicsDeviceControl
routes mouse input through its own set of methods
(RaiseHwndLButtonDown
etc.).
public class MyDrawingSurface : DrawingSurface
{
protected override RaiseDraw(DrawEventArgs args)
{
args.GraphicsDevice.Clear(Color.LightGreen);
base.RaiseDraw(args);
}
}
public class MyGraphicsDeviceControl : GraphicsDeviceControl
{
protected override void RaiseRenderXna(GraphicsDeviceEventArgs args)
{
args.GraphicsDevice.Clear(Color.LightGreen);
base.RaiseRenderXna(args);
}
}