diff --git a/Source/Toolkit/SharpDX.Toolkit.Game/GraphicsDeviceManager.cs b/Source/Toolkit/SharpDX.Toolkit.Game/GraphicsDeviceManager.cs
index cc29c58c1..b7a1bc89d 100644
--- a/Source/Toolkit/SharpDX.Toolkit.Game/GraphicsDeviceManager.cs
+++ b/Source/Toolkit/SharpDX.Toolkit.Game/GraphicsDeviceManager.cs
@@ -862,7 +862,7 @@ private void ChangeOrCreateDevice(bool forceCreate)
var newOutputIndex = graphicsDeviceInformation.PresentationParameters.PreferredFullScreenOutputIndex;
GraphicsDevice.Presenter.PrefferedFullScreenOutputIndex = newOutputIndex;
- GraphicsDevice.Presenter.Resize(newWidth, newHeight, newFormat);
+ GraphicsDevice.Presenter.Resize(newWidth, newHeight, newFormat, graphicsDeviceInformation.PresentationParameters.RefreshRate);
// Change full screen if needed
GraphicsDevice.Presenter.IsFullScreen = graphicsDeviceInformation.PresentationParameters.IsFullScreen;
diff --git a/Source/Toolkit/SharpDX.Toolkit.Graphics/GraphicsPresenter.cs b/Source/Toolkit/SharpDX.Toolkit.Graphics/GraphicsPresenter.cs
index 86fdb73ae..6b55606b1 100644
--- a/Source/Toolkit/SharpDX.Toolkit.Graphics/GraphicsPresenter.cs
+++ b/Source/Toolkit/SharpDX.Toolkit.Graphics/GraphicsPresenter.cs
@@ -134,8 +134,9 @@ public PresentInterval PresentInterval
/// New backbuffer width
/// New backbuffer height
/// Backbuffer display format.
+ ///
/// true if the presenter was resized, false otherwise
- public virtual bool Resize(int width, int height, DXGI.Format format)
+ public virtual bool Resize(int width, int height, Format format, Rational? refreshRate = null)
{
if (Description.BackBufferWidth == width && Description.BackBufferHeight == height && Description.BackBufferFormat == format)
{
@@ -150,6 +151,10 @@ public virtual bool Resize(int width, int height, DXGI.Format format)
Description.BackBufferWidth = width;
Description.BackBufferHeight = height;
Description.BackBufferFormat = format;
+ if(refreshRate.HasValue)
+ {
+ Description.RefreshRate = refreshRate.Value;
+ }
DefaultViewport = new ViewportF(0, 0, Description.BackBufferWidth, Description.BackBufferHeight);
diff --git a/Source/Toolkit/SharpDX.Toolkit.Graphics/RenderTargetGraphicsPresenter.cs b/Source/Toolkit/SharpDX.Toolkit.Graphics/RenderTargetGraphicsPresenter.cs
index cbd67436b..84170fddc 100644
--- a/Source/Toolkit/SharpDX.Toolkit.Graphics/RenderTargetGraphicsPresenter.cs
+++ b/Source/Toolkit/SharpDX.Toolkit.Graphics/RenderTargetGraphicsPresenter.cs
@@ -139,9 +139,9 @@ public override void Present()
#endif
}
- public override bool Resize(int width, int height, Format format)
+ public override bool Resize(int width, int height, Format format, Rational? refreshRate)
{
- if (!base.Resize(width, height, format)) return false;
+ if (!base.Resize(width, height, format, refreshRate)) return false;
// backbuffer was set externally, do not touch it
if (!allowRecreateBackBuffer) return false;
diff --git a/Source/Toolkit/SharpDX.Toolkit.Graphics/SwapChainGraphicsPresenter.cs b/Source/Toolkit/SharpDX.Toolkit.Graphics/SwapChainGraphicsPresenter.cs
index cfea86489..9c106b111 100644
--- a/Source/Toolkit/SharpDX.Toolkit.Graphics/SwapChainGraphicsPresenter.cs
+++ b/Source/Toolkit/SharpDX.Toolkit.Graphics/SwapChainGraphicsPresenter.cs
@@ -110,16 +110,25 @@ public override bool IsFullScreen
bool switchToFullScreen = value;
// If going to fullscreen mode: call 1) SwapChain.ResizeTarget 2) SwapChain.IsFullScreen
var description = new ModeDescription(backBuffer.Width, backBuffer.Height, Description.RefreshRate, Description.BackBufferFormat);
- if (switchToFullScreen)
+ if(switchToFullScreen)
{
- swapChain.ResizeTarget(ref description);
- swapChain.SetFullscreenState(true, output);
+ Description.IsFullScreen = true;
+ // Destroy and recreate the full swapchain in case of fullscreen switch
+ // It seems to be more reliable then trying to change the current swap-chain.
+ RemoveAndDispose(ref backBuffer);
+ RemoveAndDispose(ref swapChain);
+
+ swapChain = CreateSwapChain();
+ backBuffer = ToDispose(RenderTarget2D.New(GraphicsDevice, swapChain.GetBackBuffer(0)));
}
else
+ {
+ Description.IsFullScreen = false;
swapChain.IsFullScreen = false;
- // call 1) SwapChain.IsFullScreen 2) SwapChain.Resize
- Resize(backBuffer.Width, backBuffer.Height, backBuffer.Format);
+ // call 1) SwapChain.IsFullScreen 2) SwapChain.Resize
+ Resize(backBuffer.Width, backBuffer.Height, backBuffer.Format);
+ }
// If going to window mode:
if (!switchToFullScreen)
@@ -152,9 +161,9 @@ protected override void OnPropertyChanged(string propertyName)
}
}
- public override bool Resize(int width, int height, Format format)
+ public override bool Resize(int width, int height, Format format, Rational? refreshRate = null)
{
- if (!base.Resize(width, height, format)) return false;
+ if (!base.Resize(width, height, format, refreshRate)) return false;
RemoveAndDispose(ref backBuffer);