diff options
-rw-r--r-- | src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs | 18 | ||||
-rw-r--r-- | src/Ryujinx.Headless.SDL2/Options.cs | 3 | ||||
-rw-r--r-- | src/Ryujinx.Headless.SDL2/Program.cs | 5 | ||||
-rw-r--r-- | src/Ryujinx.Headless.SDL2/WindowBase.cs | 19 |
4 files changed, 38 insertions, 7 deletions
diff --git a/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs b/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs index 199f723e9..355dcf6c7 100644 --- a/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs +++ b/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs | |||
@@ -151,8 +151,22 @@ namespace Ryujinx.Headless.SDL2.OpenGL | |||
151 | GL.Clear(ClearBufferMask.ColorBufferBit); | 151 | GL.Clear(ClearBufferMask.ColorBufferBit); |
152 | SwapBuffers(); | 152 | SwapBuffers(); |
153 | 153 | ||
154 | Renderer?.Window.SetSize(DefaultWidth, DefaultHeight); | 154 | if (IsFullscreen) |
155 | MouseDriver.SetClientSize(DefaultWidth, DefaultHeight); | 155 | { |
156 | // NOTE: grabbing the main display's dimensions directly as OpenGL doesn't scale along like the VulkanWindow. | ||
157 | // we might have to amend this if people run this on a non-primary display set to a different resolution. | ||
158 | SDL_Rect displayBounds; | ||
159 | SDL_GetDisplayBounds(0, out displayBounds); | ||
160 | |||
161 | Renderer?.Window.SetSize(displayBounds.w, displayBounds.h); | ||
162 | MouseDriver.SetClientSize(displayBounds.w, displayBounds.h); | ||
163 | } | ||
164 | |||
165 | else | ||
166 | { | ||
167 | Renderer?.Window.SetSize(DefaultWidth, DefaultHeight); | ||
168 | MouseDriver.SetClientSize(DefaultWidth, DefaultHeight); | ||
169 | } | ||
156 | } | 170 | } |
157 | 171 | ||
158 | protected override void InitializeRenderer() { } | 172 | protected override void InitializeRenderer() { } |
diff --git a/src/Ryujinx.Headless.SDL2/Options.cs b/src/Ryujinx.Headless.SDL2/Options.cs index 86a6c63c4..e44cedec9 100644 --- a/src/Ryujinx.Headless.SDL2/Options.cs +++ b/src/Ryujinx.Headless.SDL2/Options.cs | |||
@@ -14,6 +14,9 @@ namespace Ryujinx.Headless.SDL2 | |||
14 | [Option("profile", Required = false, HelpText = "Set the user profile to launch the game with.")] | 14 | [Option("profile", Required = false, HelpText = "Set the user profile to launch the game with.")] |
15 | public string UserProfile { get; set; } | 15 | public string UserProfile { get; set; } |
16 | 16 | ||
17 | [Option("fullscreen", Required = false, HelpText = "Launch the game in fullscreen mode.")] | ||
18 | public bool IsFullscreen { get; set; } | ||
19 | |||
17 | // Input | 20 | // Input |
18 | 21 | ||
19 | [Option("input-profile-1", Required = false, HelpText = "Set the input profile in use for Player 1.")] | 22 | [Option("input-profile-1", Required = false, HelpText = "Set the input profile in use for Player 1.")] |
diff --git a/src/Ryujinx.Headless.SDL2/Program.cs b/src/Ryujinx.Headless.SDL2/Program.cs index 39eae14a8..98cc5abf4 100644 --- a/src/Ryujinx.Headless.SDL2/Program.cs +++ b/src/Ryujinx.Headless.SDL2/Program.cs | |||
@@ -64,6 +64,9 @@ namespace Ryujinx.Headless.SDL2 | |||
64 | { | 64 | { |
65 | Version = ReleaseInformation.GetVersion(); | 65 | Version = ReleaseInformation.GetVersion(); |
66 | 66 | ||
67 | // Make process DPI aware for proper window sizing on high-res screens. | ||
68 | ForceDpiAware.Windows(); | ||
69 | |||
67 | Console.Title = $"Ryujinx Console {Version} (Headless SDL2)"; | 70 | Console.Title = $"Ryujinx Console {Version} (Headless SDL2)"; |
68 | 71 | ||
69 | if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux()) | 72 | if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux()) |
@@ -592,6 +595,8 @@ namespace Ryujinx.Headless.SDL2 | |||
592 | 595 | ||
593 | _window = window; | 596 | _window = window; |
594 | 597 | ||
598 | _window.IsFullscreen = options.IsFullscreen; | ||
599 | |||
595 | _emulationContext = InitializeEmulationContext(window, renderer, options); | 600 | _emulationContext = InitializeEmulationContext(window, renderer, options); |
596 | 601 | ||
597 | SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion(); | 602 | SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion(); |
diff --git a/src/Ryujinx.Headless.SDL2/WindowBase.cs b/src/Ryujinx.Headless.SDL2/WindowBase.cs index 2fcd00f86..c542a4e61 100644 --- a/src/Ryujinx.Headless.SDL2/WindowBase.cs +++ b/src/Ryujinx.Headless.SDL2/WindowBase.cs | |||
@@ -55,6 +55,7 @@ namespace Ryujinx.Headless.SDL2 | |||
55 | public IHostUiTheme HostUiTheme { get; } | 55 | public IHostUiTheme HostUiTheme { get; } |
56 | public int Width { get; private set; } | 56 | public int Width { get; private set; } |
57 | public int Height { get; private set; } | 57 | public int Height { get; private set; } |
58 | public bool IsFullscreen { get; set; } | ||
58 | 59 | ||
59 | protected SDL2MouseDriver MouseDriver; | 60 | protected SDL2MouseDriver MouseDriver; |
60 | private readonly InputManager _inputManager; | 61 | private readonly InputManager _inputManager; |
@@ -158,7 +159,9 @@ namespace Ryujinx.Headless.SDL2 | |||
158 | string titleIdSection = string.IsNullOrWhiteSpace(activeProcess.ProgramIdText) ? string.Empty : $" ({activeProcess.ProgramIdText.ToUpper()})"; | 159 | string titleIdSection = string.IsNullOrWhiteSpace(activeProcess.ProgramIdText) ? string.Empty : $" ({activeProcess.ProgramIdText.ToUpper()})"; |
159 | string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)"; | 160 | string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)"; |
160 | 161 | ||
161 | WindowHandle = SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, DefaultWidth, DefaultHeight, DefaultFlags | GetWindowFlags()); | 162 | SDL_WindowFlags fullscreenFlag = IsFullscreen ? SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP : 0; |
163 | |||
164 | WindowHandle = SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, DefaultWidth, DefaultHeight, DefaultFlags | fullscreenFlag | GetWindowFlags()); | ||
162 | 165 | ||
163 | if (WindowHandle == IntPtr.Zero) | 166 | if (WindowHandle == IntPtr.Zero) |
164 | { | 167 | { |
@@ -185,10 +188,16 @@ namespace Ryujinx.Headless.SDL2 | |||
185 | switch (evnt.window.windowEvent) | 188 | switch (evnt.window.windowEvent) |
186 | { | 189 | { |
187 | case SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED: | 190 | case SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED: |
188 | Width = evnt.window.data1; | 191 | // Unlike on Windows, this event fires on macOS when triggering fullscreen mode. |
189 | Height = evnt.window.data2; | 192 | // And promptly crashes the process because `Renderer?.window.SetSize` is undefined. |
190 | Renderer?.Window.SetSize(Width, Height); | 193 | // As we don't need this to fire in either case we can test for isFullscreen. |
191 | MouseDriver.SetClientSize(Width, Height); | 194 | if (!IsFullscreen) |
195 | { | ||
196 | Width = evnt.window.data1; | ||
197 | Height = evnt.window.data2; | ||
198 | Renderer?.Window.SetSize(Width, Height); | ||
199 | MouseDriver.SetClientSize(Width, Height); | ||
200 | } | ||
192 | break; | 201 | break; |
193 | 202 | ||
194 | case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE: | 203 | case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE: |