mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-24 13:01:00 +00:00
Merge branch 'sdlres'
This commit is contained in:
commit
bc95084804
|
@ -94,24 +94,14 @@ namespace OpenTK.Platform.SDL2
|
||||||
|
|
||||||
public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
|
public override bool TryChangeResolution(DisplayDevice device, DisplayResolution resolution)
|
||||||
{
|
{
|
||||||
// Todo: we need a temporary window to change resolutions, most probably
|
Sdl2Factory.UseFullscreenDesktop = false;
|
||||||
Trace.WriteLine("SDL2 driver does not implement TryChangeResolution");
|
|
||||||
return true;
|
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)
|
public override bool TryRestoreResolution(DisplayDevice device)
|
||||||
{
|
{
|
||||||
Trace.WriteLine("SDL2 driver does not support TryRestoreResolution");
|
Sdl2Factory.UseFullscreenDesktop = true;
|
||||||
return true;
|
return true;
|
||||||
//throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -37,8 +37,21 @@ namespace OpenTK.Platform.SDL2
|
||||||
readonly IInputDriver2 InputDriver = new Sdl2InputDriver();
|
readonly IInputDriver2 InputDriver = new Sdl2InputDriver();
|
||||||
bool disposed;
|
bool disposed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>>
|
||||||
|
/// This is a workaround for the lack of ChangeResolution support in SDL2.
|
||||||
|
/// When and if this changes upstream, we should remove this code.
|
||||||
|
/// </remarks>
|
||||||
|
public static bool UseFullscreenDesktop { get; set; }
|
||||||
|
|
||||||
public Sdl2Factory()
|
public Sdl2Factory()
|
||||||
{
|
{
|
||||||
|
UseFullscreenDesktop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IPlatformFactory implementation
|
#region IPlatformFactory implementation
|
||||||
|
|
|
@ -122,7 +122,10 @@ namespace OpenTK.Platform.SDL2
|
||||||
switch (flags)
|
switch (flags)
|
||||||
{
|
{
|
||||||
case GameWindowFlags.Fullscreen:
|
case GameWindowFlags.Fullscreen:
|
||||||
|
if (Sdl2Factory.UseFullscreenDesktop)
|
||||||
return WindowFlags.FULLSCREEN_DESKTOP;
|
return WindowFlags.FULLSCREEN_DESKTOP;
|
||||||
|
else
|
||||||
|
return WindowFlags.FULLSCREEN;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return WindowFlags.Default;
|
return WindowFlags.Default;
|
||||||
|
@ -646,13 +649,15 @@ namespace OpenTK.Platform.SDL2
|
||||||
{
|
{
|
||||||
case WindowState.Fullscreen:
|
case WindowState.Fullscreen:
|
||||||
RestoreWindow();
|
RestoreWindow();
|
||||||
if (SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN_DESKTOP) < 0)
|
bool success = Sdl2Factory.UseFullscreenDesktop ?
|
||||||
{
|
SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN_DESKTOP) < 0 :
|
||||||
if (SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN) < 0)
|
SDL.SetWindowFullscreen(window.Handle, (uint)WindowFlags.FULLSCREEN) < 0;
|
||||||
|
|
||||||
|
if (!success)
|
||||||
{
|
{
|
||||||
Debug.Print("SDL2 failed to enter fullscreen mode: {0}", SDL.GetError());
|
Debug.Print("SDL2 failed to enter fullscreen mode: {0}", SDL.GetError());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
SDL.RaiseWindow(window.Handle);
|
SDL.RaiseWindow(window.Handle);
|
||||||
// There is no "fullscreen" message in the event loop
|
// There is no "fullscreen" message in the event loop
|
||||||
// so we have to mark that ourselves
|
// so we have to mark that ourselves
|
||||||
|
|
Loading…
Reference in a new issue