diff --git a/Source/OpenTK/Platform/SDL2/Sdl2DisplayDeviceDriver.cs b/Source/OpenTK/Platform/SDL2/Sdl2DisplayDeviceDriver.cs
index 5bd34689..4cf53446 100644
--- a/Source/OpenTK/Platform/SDL2/Sdl2DisplayDeviceDriver.cs
+++ b/Source/OpenTK/Platform/SDL2/Sdl2DisplayDeviceDriver.cs
@@ -94,24 +94,14 @@ namespace OpenTK.Platform.SDL2
public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
{
- // Todo: we need a temporary window to change resolutions, most probably
- Trace.WriteLine("SDL2 driver does not implement TryChangeResolution");
+ Sdl2Factory.UseFullscreenDesktop = false;
return true;
-
- //SDL2.SDL_DisplayMode desired, closest;
- //desired.w = resolution.Width;
- //desired.h = resolution.Height;
- //desired.format = SDL.SDL_PIXELFORMAT_BGRA8888;
-
- //SDL2.SDL_GetClosestDisplayMode((int)device.Id, ref desired, out closest);
- //SDL2.SDL_SetWindowDisplayMode(IntPtr.Zero, ref closest);
}
public override bool TryRestoreResolution(DisplayDevice device)
{
- Trace.WriteLine("SDL2 driver does not support TryRestoreResolution");
+ Sdl2Factory.UseFullscreenDesktop = true;
return true;
- //throw new NotImplementedException();
}
#endregion
diff --git a/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs b/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs
index b9b3dd6b..9f2447ba 100644
--- a/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs
+++ b/Source/OpenTK/Platform/SDL2/Sdl2Factory.cs
@@ -37,8 +37,21 @@ namespace OpenTK.Platform.SDL2
readonly IInputDriver2 InputDriver = new Sdl2InputDriver();
bool disposed;
+ ///
+ /// Gets or sets a value indicating whether to use SDL2 fullscreen-desktop mode
+ /// for fullscreen windows. When true, then GameWindow instances will not change
+ /// DisplayDevice resolutions when going fullscreen. When false, fullscreen GameWindows
+ /// will change the device resolution to match their size.
+ ///
+ /// >
+ /// This is a workaround for the lack of ChangeResolution support in SDL2.
+ /// When and if this changes upstream, we should remove this code.
+ ///
+ public static bool UseFullscreenDesktop { get; set; }
+
public Sdl2Factory()
{
+ UseFullscreenDesktop = true;
}
#region IPlatformFactory implementation
diff --git a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs
index 34f65b65..410a480e 100644
--- a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs
+++ b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs
@@ -122,8 +122,11 @@ namespace OpenTK.Platform.SDL2
switch (flags)
{
case GameWindowFlags.Fullscreen:
- return WindowFlags.FULLSCREEN_DESKTOP;
-
+ if (Sdl2Factory.UseFullscreenDesktop)
+ return WindowFlags.FULLSCREEN_DESKTOP;
+ else
+ return WindowFlags.FULLSCREEN;
+
default:
return WindowFlags.Default;
}
@@ -646,13 +649,15 @@ namespace OpenTK.Platform.SDL2
{
case WindowState.Fullscreen:
RestoreWindow();
- if (SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN_DESKTOP) < 0)
+ bool success = Sdl2Factory.UseFullscreenDesktop ?
+ SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN_DESKTOP) < 0 :
+ SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN) < 0;
+
+ if (!success)
{
- if (SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN) < 0)
- {
Debug.Print("SDL2 failed to enter fullscreen mode: {0}", SDL.GetError());
- }
}
+
SDL.RaiseWindow(window.Handle);
// There is no "fullscreen" message in the event loop
// so we have to mark that ourselves