I don't set the window position in fullscreen mode, and I'm pretty sure it works properly. Edit - checked this, and because I'm using SwapChainFlags.None it just adopts the desktop resolution. Just learnt something about resizing the 'front buffer' ... I tried setting the form manually, but that just won't work, it can and will ignore the width height values you pass in. Instead, use
swapChain.ResizeTargets()
Which will also resize your window, and fire a Resize event, so that your backbuffers can adjust.
Well, I'm not sure if you were saying to do this or not, but I tried calling ResizeTarget and letting that in turn call my Resize method. So both ResizeTarget and ResizeBuffers end up being called. My monitor is now properly reporting 1920x1080 as the resolution and the mouse positioning is working correctly. No where have I seen any examples or documentation that stated BOTH of these needed to be called.
This is what worked for me in the end:
public static void ApplySettings()
{
swapChain.SetFullscreenState(Settings.WindowMode == GameSettings.WindowModeSetting.Fullscreen, null);
if(Settings.WindowMode != GameSettings.WindowModeSetting.Fullscreen)
{
Form.ClientSize = new Size(Settings.DisplayMode.Width, Settings.DisplayMode.Height);
Resize(Settings.DisplayMode.Width, Settings.DisplayMode.Height);
}
else
{
var mode = Settings.DisplayMode;
swapChain.ResizeTarget(ref mode);
}
}
private static void Resize(int width, int height)
{
BackBuffer.Dispose();
LinearBackBuffer.Dispose();
swapChain.ResizeBuffers(0, width, height, Format.Unknown, SwapChainFlags.AllowModeSwitch);
Viewport = new Viewport(0, 0, width, height);
Console.WriteLine("Viewport size: {0}x{1}", Viewport.Width, Viewport.Height);
using(var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0))
{
BackBuffer = new RenderTargetView(device, resource);
LinearBackBuffer = new RenderTargetView(device, resource, new RenderTargetViewDescription
{
Dimension = RenderTargetViewDimension.Texture2D,
Format = Format.R8G8B8A8_UNorm
});
}
if(OnResize != null)
OnResize();
}