mono/MonoGame — pull request #1463 by jamesford42 (2013-02-26 22:32:07+00:00)
Title: Multiwindow

Adding support for multiple GameWindow(s) within a single game.

This is only implemented for WINDOWS && DIRECTX

Non-primary windows do not handle any input and for input events to reach the users game the primary window must be active. This can be improved at a later time when it is a needed feature.

The existing Game / Platform / GraphicsDevice code is largely unchanged and only deals directly with the standard, primary window which it also creates.

Additional windows can be created by the users game code like:
GameWindow.Create(Game, Width, Height);

To allow rendering to the window, the user creates a swap chain:
SwapChain = new SwapChainRenderTarget(windowHandle: Window.Handle,
graphicsDevice: _device,
width: Window.ClientBounds.Width,
height: Window.ClientBounds.Height,
mipMap: false,
presentInterval: PresentInterval.Default,
surfaceFormat: SurfaceFormat.Color,
depthFormat: DepthFormat.Depth16,
preferredMultiSampleCount: 1,
usage: RenderTargetUsage.DiscardContents);

Secondary windows must be rendered before the primary, and is done by embedding code like this within your draw method:

MyGame::Draw(GameTime)
{
_device.SetRenderTarget(SwapChain);

// Draw stuff...

SwapChain.Present();

// Setup to draw to primary window like this...
_device.SetRenderTarget(null);

// Draw to primary window
// Done.
base.Draw(gameTime);
}