mono/MonoGame — pull request #1465 by jamesford42 (2013-02-26 22:48:23+00:00)
Title: Multiple GameWindow support for Windows/DirectX

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.

Any additional windows will be created by the users game code, example:

MyGame::Initialize()
{
base.Initialize();

// Create an additional window.
GameWindow.Create(Game, Width, Height);

// Create a SwapChain to render the window
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);
}