Use fullscreen desktop for vulkan
This commit is contained in:
parent
e6f8dcfdb0
commit
bba636263e
@ -358,6 +358,7 @@ namespace GE
|
||||
{ return m_separate_rtt_texture; }
|
||||
void handleDeletedTextures();
|
||||
void addRTTPolyCount(unsigned count) { m_rtt_polycount += count; }
|
||||
SDL_Window* getWindow() const { return m_window; }
|
||||
private:
|
||||
struct SwapChainSupportDetails
|
||||
{
|
||||
|
@ -58,7 +58,6 @@ extern "C" int Android_disablePadding();
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param),
|
||||
@ -93,7 +92,8 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
|
||||
#ifndef MOBILE_STK
|
||||
// Prevent fullscreen minimizes when losing focus
|
||||
if (CreationParams.Fullscreen)
|
||||
if (CreationParams.Fullscreen &&
|
||||
CreationParams.DriverType != video::EDT_VULKAN)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
#endif
|
||||
|
||||
@ -155,7 +155,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
}
|
||||
else
|
||||
return;
|
||||
updateNativeScale();
|
||||
updateNativeScale(&Width, &Height);
|
||||
Width = (u32)((f32)Width * NativeScaleX);
|
||||
Height = (u32)((f32)Height * NativeScaleY);
|
||||
CreationParams.WindowSize.Width = Width;
|
||||
@ -181,7 +181,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
}
|
||||
|
||||
|
||||
void CIrrDeviceSDL::updateNativeScale()
|
||||
void CIrrDeviceSDL::updateNativeScale(u32* saving_width, u32* saving_height)
|
||||
{
|
||||
int width, height = 0;
|
||||
SDL_GetWindowSize(Window, &width, &height);
|
||||
@ -198,6 +198,10 @@ void CIrrDeviceSDL::updateNativeScale()
|
||||
}
|
||||
NativeScaleX = (f32)real_width / (f32)width;
|
||||
NativeScaleY = (f32)real_height / (f32)height;
|
||||
if (saving_width)
|
||||
*saving_width = width;
|
||||
if (saving_height)
|
||||
*saving_height = height;
|
||||
}
|
||||
|
||||
|
||||
@ -328,6 +332,29 @@ bool versionCorrect(int major, int minor)
|
||||
}
|
||||
|
||||
|
||||
// Used in OptionsScreenVideo for live fullscreen toggle for vulkan driver
|
||||
extern "C" void update_fullscreen_desktop(int val)
|
||||
{
|
||||
GE::GEVulkanDriver* gevk = GE::getVKDriver();
|
||||
if (!gevk)
|
||||
return;
|
||||
SDL_Window* window = gevk->getWindow();
|
||||
|
||||
int prev_width = 0;
|
||||
int prev_height = 0;
|
||||
SDL_GetWindowSize(window, &prev_width, &prev_height);
|
||||
|
||||
if (val != 0)
|
||||
val = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
SDL_SetWindowFullscreen(window, val);
|
||||
if (val == 0)
|
||||
{
|
||||
SDL_SetWindowSize(window, prev_width * 0.8f, prev_height * 0.8f);
|
||||
SDL_RaiseWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Used in OptionsScreenVideo for live updating vertical sync config
|
||||
extern "C" void update_swap_interval(int swap_interval)
|
||||
{
|
||||
@ -394,7 +421,17 @@ bool CIrrDeviceSDL::createWindow()
|
||||
#endif
|
||||
|
||||
if (CreationParams.Fullscreen)
|
||||
flags |= SDL_WINDOW_FULLSCREEN;
|
||||
{
|
||||
#ifndef MOBILE_STK
|
||||
if (CreationParams.DriverType == video::EDT_VULKAN)
|
||||
{
|
||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
CreationParams.Fullscreen = false;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
flags |= SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL ||
|
||||
CreationParams.DriverType == video::EDT_OGLES2)
|
||||
@ -651,7 +688,7 @@ void CIrrDeviceSDL::createDriver()
|
||||
{
|
||||
VideoDriver = video::createVulkanDriver(CreationParams, FileSystem, Window, this);
|
||||
// SDL_Vulkan_GetDrawableSize only works after driver is created
|
||||
updateNativeScale();
|
||||
updateNativeScale(&Width, &Height);
|
||||
Width = (u32)((f32)Width * NativeScaleX);
|
||||
Height = (u32)((f32)Height * NativeScaleY);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ class MoltenVK;
|
||||
class CIrrDeviceSDL : public CIrrDeviceStub, video::IImagePresenter
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceSDL(const SIrrlichtCreationParameters& param);
|
||||
|
||||
@ -330,7 +329,7 @@ class MoltenVK;
|
||||
MoltenVK* m_moltenvk;
|
||||
#endif
|
||||
void createGUIAndVulkanScene();
|
||||
void updateNativeScale();
|
||||
void updateNativeScale(u32* saving_width = NULL, u32* saving_height = NULL);
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
@ -608,8 +608,11 @@ void IrrDriver::initDevice()
|
||||
{
|
||||
Log::fatal("irr_driver", "Couldn't initialise irrlicht device. Quitting.\n");
|
||||
}
|
||||
UserConfigParams::m_width = (unsigned)((float)UserConfigParams::m_real_width * m_device->getNativeScaleX());
|
||||
UserConfigParams::m_height = (unsigned)((float)UserConfigParams::m_real_height * m_device->getNativeScaleY());
|
||||
m_actual_screen_size = m_device->getVideoDriver()->getCurrentRenderTargetSize();
|
||||
UserConfigParams::m_width = m_actual_screen_size.Width;
|
||||
UserConfigParams::m_height = m_actual_screen_size.Height;
|
||||
UserConfigParams::m_real_width = (unsigned)((float)UserConfigParams::m_width / m_device->getNativeScaleX());
|
||||
UserConfigParams::m_real_height = (unsigned)((float)UserConfigParams::m_height / m_device->getNativeScaleY());
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
|
||||
@ -693,8 +696,6 @@ void IrrDriver::initDevice()
|
||||
m_scene_manager->addExternalMeshLoader(spml);
|
||||
spml->drop();
|
||||
|
||||
m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize();
|
||||
|
||||
#ifdef ENABLE_RECORDER
|
||||
ogrRegGeneralCallback(OGR_CBT_START_RECORDING,
|
||||
[] (void* user_data)
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include <ge_vulkan_texture_descriptor.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@ -317,6 +316,12 @@ void OptionsScreenVideo::init()
|
||||
getWidget<LabelWidget>("rememberWinposText");
|
||||
assert( rememberWinposText != NULL );
|
||||
#endif
|
||||
|
||||
bool is_vulkan = false;
|
||||
#ifndef SERVER_ONLY
|
||||
is_vulkan = GE::getDriver()->getDriverType() == video::EDT_VULKAN;
|
||||
#endif
|
||||
|
||||
// --- get resolution list from irrlicht the first time
|
||||
if (!m_inited)
|
||||
{
|
||||
@ -360,11 +365,20 @@ void OptionsScreenVideo::init()
|
||||
}
|
||||
}
|
||||
|
||||
// Vulkan use fullscreen desktop so only show current screen size
|
||||
if (is_vulkan)
|
||||
{
|
||||
found_config_res = false;
|
||||
m_resolutions.clear();
|
||||
found_1024_768 = true;
|
||||
found_1280_720 = true;
|
||||
}
|
||||
|
||||
if (!found_config_res)
|
||||
{
|
||||
r.width = UserConfigParams::m_real_width;
|
||||
r.height = UserConfigParams::m_real_height;
|
||||
r.fullscreen = false;
|
||||
r.fullscreen = is_vulkan;
|
||||
m_resolutions.push_back(r);
|
||||
|
||||
if (r.width == 1024 && r.height == 768)
|
||||
@ -457,8 +471,8 @@ void OptionsScreenVideo::init()
|
||||
// disabled)
|
||||
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
|
||||
|
||||
res->setActive(!in_game);
|
||||
full->setActive(!in_game);
|
||||
res->setActive(!in_game || is_vulkan);
|
||||
full->setActive(!in_game || is_vulkan);
|
||||
applyBtn->setActive(!in_game);
|
||||
#ifndef SERVER_ONLY
|
||||
gfx->setActive(!in_game && CVS->isGLSL());
|
||||
@ -466,7 +480,7 @@ void OptionsScreenVideo::init()
|
||||
if (getWidget<SpinnerWidget>("scale_rtts")->isActivated())
|
||||
{
|
||||
getWidget<SpinnerWidget>("scale_rtts")->setActive(!in_game ||
|
||||
GE::getDriver()->getDriverType() == video::EDT_VULKAN);
|
||||
is_vulkan);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -719,6 +733,7 @@ void OptionsScreenVideo::updateBlurTooltip()
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
extern "C" void update_swap_interval(int swap_interval);
|
||||
extern "C" void update_fullscreen_desktop(int val);
|
||||
|
||||
void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
||||
const int playerID)
|
||||
@ -867,8 +882,15 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
||||
CheckBoxWidget* rememberWinpos = getWidget<CheckBoxWidget>("rememberWinpos");
|
||||
|
||||
rememberWinpos->setActive(!fullscreen->getState());
|
||||
|
||||
updateResolutionsList();
|
||||
#ifndef SERVER_ONLY
|
||||
if (GE::getDriver()->getDriverType() == video::EDT_VULKAN)
|
||||
{
|
||||
UserConfigParams::m_fullscreen = fullscreen->getState();
|
||||
update_fullscreen_desktop(UserConfigParams::m_fullscreen);
|
||||
}
|
||||
else
|
||||
updateResolutionsList();
|
||||
#endif
|
||||
}
|
||||
} // eventCallback
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user