summaryrefslogtreecommitdiff
path: root/src/video.cpp
AgeCommit message (Collapse)AuthorFilesLines
6 daysWork around issue with minimizing maximized windowsThorbjørn Lindeijer1-0/+12
Only call `SDL_ShowWindow` once, since it seems old SDL versions (like 2.30.0, shipping with Ubuntu 24.04) do not allow a maximized window to be minimized when `SDL_ShowWindow` is called each frame.
2025-07-04Added logging priorities and use SDLs logging facilitiesThorbjørn Lindeijer1-13/+12
By using SDL logging, we can rely on SDL to filter the log messages by their priority before they get sent to our custom output function. For example, we now no longer get entries for created and destroyed Window instances by default, since these have only "debug" priority whereas the default priority for the "app" category is "info". We can also get log messages raised by SDL itself in our log now. Log levels can be controlled per category through the "SDL_LOGGING" environment variable. Many existing log messages have been assigned a category based on their existing prefix.
2025-07-04Allow the window to keep updating during move/resize on Windows and macOSThorbjørn Lindeijer1-5/+5
On Windows, the SDL event loop would get blocked during move/resize, which made the game stop updating. Since version 2.30, SDL will send its SDL_WINDOWEVENT_EXPOSED event on an internal timer during window move/resize so the application can keep redrawing. Since no window size changed events can be received either, the size of the window and the renderer is now updated at the start of each frame. On macOS the SDL event loop was similarly blocked during resize. The event watcher is only used on Windows and macOS because on X11 the processing of all the queued up expose events can cause a delayed response to resizing. Besides, the issues fixed by this watcher don't exist on X11 and Wayland.
2025-07-02Delay showing of the window to avoid startup flickerThorbjørn Lindeijer1-0/+8
Otherwise, at least on X11, the window is (visibly) re-created once the SDL renderer is created. Also the window icon can be seen changing on startup. Showing the window only after all related setup has been completed avoids this. On X11 this appears to have the added benefit of putting a "windowed fullscreen" window on the active screen (in terms of where the mouse is) rather than always using the primary screen. On Windows, showing the window only after the initial paint avoids the window initially appearing with its contents entirely black. The window is still immediately shown in the following cases: * In exclusive fullscreen mode, because on Windows this caused the initial show of a fullscreen window to take much longer and on X11 it could cause the resolution of the primary screen to be changed while maximizing the Mana window on the active screen. * In "windowed fullscreen" mode when the legacy OpenGL renderer is used, where it was causing an additional flicker on Windows.
2024-03-22Added support for scaling the outputThorbjørn Lindeijer1-26/+43
* Added "Scale" user option, which can either by "Auto" or an explicit scaling factor. Its maximum value depends on the current resolution. The "Auto" factor is based on keeping the logical resolution on at least 800x600, wheres the maximum scale is based on keeping the logical resolution on at least 640x480. * Enabled support for High DPI. This means the rendering target can now have a different resolution than the window size, which can happen on macOS, Windows and Wayland. The resulting scale is multiplied by the above user-controlled scale. Currently, this looks ugly for non-integer scales, which are not used on macOS and can only be configured on some Wayland compositors. Has not been tested on Windows. * Simplified OpenGL initialization (moved out of _beginDraw). * Made sure _beginDraw/_endDraw sets a clip area also for SDLGraphics.
2024-02-27Added VSync and windowed fullscreen optionsThorbjørn Lindeijer1-0/+263
The configuration and setup UI were adjusted to the new options. This also fixes issues in applying new video settings. Default resolution was changed from 800x600 to 1280x720. VSync is enabled by default while FPS limit was disabled. Display aspect ratio for the resolution options. I had to work around some macOS issues: * Don't change window size when it appears to be "maximized", since it just changes the rendering area while leaving the window maximized. * Unset fullscreen display mode temporarily to allow changing resolutions, otherwise the rendering area no longer matches the screen and mouse input is also off. * Removed SDL_WINDOW_ALLOW_HIGHDPI for now because it causes issues on macOS, since we're not actually handling the scaling factor. A Video class and an SDLGraphics subclass were split off from Graphics. This setup has Less duplication and leaves the OpenGLGraphics and SDLGraphics better separated. Fixes #57 Fixes #58