From 4c7353a3a46708bda229b5a0ca5ea679f9869e93 Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 8 Nov 2022 12:08:27 +0800 Subject: [PATCH] Add fullscreen desktop option for non-ge capable device --- lib/graphics_engine/include/ge_main.hpp | 2 +- lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp | 9 ++++----- src/config/user_config.hpp | 4 ++++ src/graphics/irr_driver.cpp | 9 +++++++-- src/states_screens/options/options_screen_video.cpp | 13 ++++++++----- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/graphics_engine/include/ge_main.hpp b/lib/graphics_engine/include/ge_main.hpp index 83ba0084f..7fa2a8ba5 100644 --- a/lib/graphics_engine/include/ge_main.hpp +++ b/lib/graphics_engine/include/ge_main.hpp @@ -24,7 +24,7 @@ struct GEConfig bool m_disable_npot_texture; bool m_convert_irrlicht_mesh; bool m_texture_compression; -bool m_vulkan_fullscreen_desktop; +bool m_fullscreen_desktop; bool m_enable_draw_call_cache; std::unordered_set m_ondemand_load_texture_paths; float m_render_scale; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp index 88df161f5..62fe15e5b 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp @@ -94,9 +94,9 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) // Prevent fullscreen minimizes when losing focus if (CreationParams.Fullscreen) { - if (CreationParams.DriverType != video::EDT_VULKAN) + if (!GE::getGEConfig()->m_fullscreen_desktop) SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); - else if (!GE::getGEConfig()->m_vulkan_fullscreen_desktop) + else if (CreationParams.DriverType != video::EDT_VULKAN) SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); } #endif @@ -356,7 +356,7 @@ bool versionCorrect(int major, int minor) extern "C" void update_fullscreen_desktop(int val) { GE::GEVulkanDriver* gevk = GE::getVKDriver(); - if (!gevk || !GE::getGEConfig()->m_vulkan_fullscreen_desktop) + if (!gevk || !GE::getGEConfig()->m_fullscreen_desktop) return; SDL_Window* window = gevk->getSDLWindow(); @@ -442,8 +442,7 @@ bool CIrrDeviceSDL::createWindow() if (CreationParams.Fullscreen) { - if (CreationParams.DriverType == video::EDT_VULKAN && - GE::getGEConfig()->m_vulkan_fullscreen_desktop) + if (GE::getGEConfig()->m_fullscreen_desktop) { flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; CreationParams.Fullscreen = false; diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 9c5f91243..1486e574d 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -732,6 +732,10 @@ namespace UserConfigParams &m_video_group, "Use SDL_WINDOW_FULLSCREEN_DESKTOP for vulkan device")); #endif + PARAM_PREFIX BoolUserConfigParam m_non_ge_fullscreen_desktop + PARAM_DEFAULT(BoolUserConfigParam(false, "non_ge_fullscreen_desktop", + &m_video_group, "Use SDL_WINDOW_FULLSCREEN_DESKTOP for non-ge device")); + // ---- Recording PARAM_PREFIX GroupUserConfigParam m_recording_group PARAM_DEFAULT(GroupUserConfigParam("Recording", diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 763311a52..6b0e5ca2e 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -510,8 +510,6 @@ begin: UserConfigParams::m_texture_compression; GE::getGEConfig()->m_render_scale = UserConfigParams::m_scale_rtts_factor; - GE::getGEConfig()->m_vulkan_fullscreen_desktop = - UserConfigParams::m_vulkan_fullscreen_desktop; #endif } else @@ -526,6 +524,13 @@ begin: #endif } +#ifndef SERVER_ONLY + GE::getGEConfig()->m_fullscreen_desktop = + (driver_created == video::EDT_VULKAN && + UserConfigParams::m_vulkan_fullscreen_desktop) || + UserConfigParams::m_non_ge_fullscreen_desktop; +#endif + // Try 32 and, upon failure, 24 then 16 bit per pixels for (int bits=32; bits>15; bits -=8) { diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index bd8eea6d7..4bdf2c1cb 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -321,11 +321,14 @@ void OptionsScreenVideo::init() assert( rememberWinposText != NULL ); #endif + bool is_fullscreen_desktop = false; bool is_vulkan_fullscreen_desktop = false; #ifndef SERVER_ONLY + is_fullscreen_desktop = + GE::getGEConfig()->m_fullscreen_desktop; is_vulkan_fullscreen_desktop = GE::getDriver()->getDriverType() == video::EDT_VULKAN && - GE::getGEConfig()->m_vulkan_fullscreen_desktop; + is_fullscreen_desktop; #endif // --- get resolution list from irrlicht the first time @@ -371,8 +374,8 @@ void OptionsScreenVideo::init() } } - // Vulkan use fullscreen desktop so only show current screen size - if (is_vulkan_fullscreen_desktop) + // Use fullscreen desktop so only show current screen size + if (is_fullscreen_desktop) { found_config_res = false; m_resolutions.clear(); @@ -384,7 +387,7 @@ void OptionsScreenVideo::init() { r.width = UserConfigParams::m_real_width; r.height = UserConfigParams::m_real_height; - r.fullscreen = is_vulkan_fullscreen_desktop; + r.fullscreen = is_fullscreen_desktop; m_resolutions.push_back(r); if (r.width == 1024 && r.height == 768) @@ -896,7 +899,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, rememberWinpos->setActive(!fullscreen->getState()); #ifndef SERVER_ONLY GE::GEVulkanDriver* gevk = GE::getVKDriver(); - if (gevk && GE::getGEConfig()->m_vulkan_fullscreen_desktop) + if (gevk && GE::getGEConfig()->m_fullscreen_desktop) { UserConfigParams::m_fullscreen = fullscreen->getState(); update_fullscreen_desktop(UserConfigParams::m_fullscreen);