mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fix switch screen and blackscreen on opengl + window borderless
This commit is contained in:
parent
68ee8a758b
commit
6b7c8f1a28
|
@ -173,7 +173,7 @@ public:
|
||||||
virtual void ServerBrowserUpdate() = 0;
|
virtual void ServerBrowserUpdate() = 0;
|
||||||
|
|
||||||
// gfx
|
// gfx
|
||||||
virtual void SwitchWindowScreen(int Index) = 0;
|
virtual void SwitchWindowScreen(int Index, int WindowMode = -1) = 0;
|
||||||
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless) = 0;
|
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless) = 0;
|
||||||
virtual void ToggleWindowVSync() = 0;
|
virtual void ToggleWindowVSync() = 0;
|
||||||
virtual void Notify(const char *pTitle, const char *pMessage) = 0;
|
virtual void Notify(const char *pTitle, const char *pMessage) = 0;
|
||||||
|
|
|
@ -3880,21 +3880,41 @@ int CClient::HandleChecksum(int Conn, CUuid Uuid, CUnpacker *pUnpacker)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::SwitchWindowScreen(int Index)
|
void CClient::SwitchWindowScreen(int Index, int WindowMode)
|
||||||
{
|
{
|
||||||
// Todo SDL: remove this when fixed (changing screen when in fullscreen is bugged)
|
SetWindowParams(0, false);
|
||||||
if(g_Config.m_GfxFullscreen)
|
if(Graphics()->SetWindowScreen(Index))
|
||||||
{
|
{
|
||||||
SetWindowParams(0, g_Config.m_GfxBorderless);
|
g_Config.m_GfxScreen = Index;
|
||||||
if(Graphics()->SetWindowScreen(Index))
|
|
||||||
g_Config.m_GfxScreen = Index;
|
|
||||||
SetWindowParams(g_Config.m_GfxFullscreen, g_Config.m_GfxBorderless);
|
|
||||||
}
|
}
|
||||||
else
|
static const int MAX_RESOLUTIONS = 256;
|
||||||
|
static CVideoMode s_aModes[MAX_RESOLUTIONS];
|
||||||
|
static int s_NumNodes = Graphics()->GetVideoModes(s_aModes, MAX_RESOLUTIONS, g_Config.m_GfxScreen);
|
||||||
|
for(int i = 0; i < s_NumNodes; ++i)
|
||||||
{
|
{
|
||||||
if(Graphics()->SetWindowScreen(Index))
|
SetWindowParams(3, false);
|
||||||
g_Config.m_GfxScreen = Index;
|
if(s_aModes[i].m_WindowWidth == g_Config.m_GfxDesktopWidth && s_aModes[i].m_WindowHeight == g_Config.m_GfxDesktopHeight)
|
||||||
|
{
|
||||||
|
const int Depth = s_aModes[i].m_Red + s_aModes[i].m_Green + s_aModes[i].m_Blue > 16 ? 24 : 16;
|
||||||
|
g_Config.m_GfxColorDepth = Depth;
|
||||||
|
g_Config.m_GfxScreenWidth = s_aModes[i].m_WindowWidth;
|
||||||
|
g_Config.m_GfxScreenHeight = s_aModes[i].m_WindowHeight;
|
||||||
|
g_Config.m_GfxScreenRefreshRate = s_aModes[i].m_RefreshRate;
|
||||||
|
Graphics()->Resize(g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight, g_Config.m_GfxScreenRefreshRate);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(WindowMode == 0)
|
||||||
|
SetWindowParams(0, false);
|
||||||
|
else if(WindowMode == 1)
|
||||||
|
SetWindowParams(0, true);
|
||||||
|
else if(WindowMode == 2)
|
||||||
|
SetWindowParams(3, false);
|
||||||
|
else if(WindowMode == 3)
|
||||||
|
SetWindowParams(2, false);
|
||||||
|
else if(WindowMode == 4)
|
||||||
|
SetWindowParams(1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
void CClient::ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||||
|
@ -3903,7 +3923,7 @@ void CClient::ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData,
|
||||||
if(pSelf->Graphics() && pResult->NumArguments())
|
if(pSelf->Graphics() && pResult->NumArguments())
|
||||||
{
|
{
|
||||||
if(g_Config.m_GfxScreen != pResult->GetInteger(0))
|
if(g_Config.m_GfxScreen != pResult->GetInteger(0))
|
||||||
pSelf->SwitchWindowScreen(pResult->GetInteger(0));
|
pSelf->SwitchWindowScreen(pResult->GetInteger(0), g_Config.m_GfxWindowMode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pfnCallback(pResult, pCallbackUserData);
|
pfnCallback(pResult, pCallbackUserData);
|
||||||
|
|
|
@ -457,7 +457,7 @@ public:
|
||||||
virtual int HandleChecksum(int Conn, CUuid Uuid, CUnpacker *pUnpacker);
|
virtual int HandleChecksum(int Conn, CUuid Uuid, CUnpacker *pUnpacker);
|
||||||
|
|
||||||
// gfx
|
// gfx
|
||||||
void SwitchWindowScreen(int Index) override;
|
void SwitchWindowScreen(int Index, int WindowMode = -1) override;
|
||||||
void SetWindowParams(int FullscreenMode, bool IsBorderless) override;
|
void SetWindowParams(int FullscreenMode, bool IsBorderless) override;
|
||||||
void ToggleWindowVSync() override;
|
void ToggleWindowVSync() override;
|
||||||
void Notify(const char *pTitle, const char *pMessage) override;
|
void Notify(const char *pTitle, const char *pMessage) override;
|
||||||
|
|
|
@ -318,6 +318,7 @@ MACRO_CONFIG_INT(SndServerMessage, snd_servermessage, 1, 0, 1, CFGFLAG_SAVE | CF
|
||||||
MACRO_CONFIG_INT(SndHighlight, snd_highlight, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable highlighted chat sound")
|
MACRO_CONFIG_INT(SndHighlight, snd_highlight, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable highlighted chat sound")
|
||||||
|
|
||||||
MACRO_CONFIG_INT(GfxScreen, gfx_screen, 0, 0, 15, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen index")
|
MACRO_CONFIG_INT(GfxScreen, gfx_screen, 0, 0, 15, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen index")
|
||||||
|
MACRO_CONFIG_INT(GfxWindowMode, gfx_window_mode, 0, 0, 5, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen window mode")
|
||||||
MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen resolution width")
|
MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen resolution width")
|
||||||
MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen resolution height")
|
MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen resolution height")
|
||||||
MACRO_CONFIG_INT(GfxScreenRefreshRate, gfx_screen_refresh_rate, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen refresh rate")
|
MACRO_CONFIG_INT(GfxScreenRefreshRate, gfx_screen_refresh_rate, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen refresh rate")
|
||||||
|
|
|
@ -1551,6 +1551,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
||||||
Client()->SetWindowParams(2, false);
|
Client()->SetWindowParams(2, false);
|
||||||
else if(NewWindowMode == 4)
|
else if(NewWindowMode == 4)
|
||||||
Client()->SetWindowParams(1, false);
|
Client()->SetWindowParams(1, false);
|
||||||
|
|
||||||
|
g_Config.m_GfxWindowMode = NewWindowMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Graphics()->GetNumScreens() > 1)
|
if(Graphics()->GetNumScreens() > 1)
|
||||||
|
@ -1578,7 +1580,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
||||||
const int NewScreen = UI()->DoDropDown(&ScreenDropDown, g_Config.m_GfxScreen, s_vpScreenNames.data(), s_vpScreenNames.size(), s_ScreenDropDownState);
|
const int NewScreen = UI()->DoDropDown(&ScreenDropDown, g_Config.m_GfxScreen, s_vpScreenNames.data(), s_vpScreenNames.size(), s_ScreenDropDownState);
|
||||||
if(NewScreen != g_Config.m_GfxScreen)
|
if(NewScreen != g_Config.m_GfxScreen)
|
||||||
{
|
{
|
||||||
Client()->SwitchWindowScreen(NewScreen);
|
Client()->SwitchWindowScreen(NewScreen, g_Config.m_GfxWindowMode);
|
||||||
s_NumNodes = Graphics()->GetVideoModes(s_aModes, MAX_RESOLUTIONS, g_Config.m_GfxScreen);
|
s_NumNodes = Graphics()->GetVideoModes(s_aModes, MAX_RESOLUTIONS, g_Config.m_GfxScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,3 +14,10 @@ void RustVersionPrint(const ::IConsole &console) noexcept {
|
||||||
void RustVersionRegister(::IConsole &console) noexcept {
|
void RustVersionRegister(::IConsole &console) noexcept {
|
||||||
cxxbridge1$RustVersionRegister(console);
|
cxxbridge1$RustVersionRegister(console);
|
||||||
}
|
}
|
||||||
|
void cxxbridge1$RustVersionPrint(const ::IConsole &console) noexcept
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void cxxbridge1$RustVersionRegister(::IConsole &console) noexcept
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue