Added borderless window functionality

This might become handy for users with multiple monitors,
	might resolve other issues aswell
This commit is contained in:
heinrich5991 2012-06-27 11:46:11 +02:00 committed by oy
parent 56ae76f465
commit 7b545f3ed9
6 changed files with 39 additions and 2 deletions

View file

@ -427,6 +427,13 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height
if(pInfo->blit_hw) // ignore_convention
SdlFlags |= SDL_HWACCEL;
dbg_assert(!(Flags&IGraphicsBackend::INITFLAG_BORDERLESS)
|| !(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN),
"only one of borderless and fullscreen may be activated at the same time");
if(Flags&IGraphicsBackend::INITFLAG_BORDERLESS)
SdlFlags |= SDL_NOFRAME;
if(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN)
SdlFlags |= SDL_FULLSCREEN;

View file

@ -801,7 +801,15 @@ int CGraphics_SDL::TryInit()
if(pInfo->blit_hw) // ignore_convention
Flags |= SDL_HWACCEL;
if(g_Config.m_GfxFullscreen)
if(g_Config.m_GfxBorderless && g_Config.m_GfxFullscreen)
{
dbg_msg("gfx", "both borderless and fullscreen activated, disabling borderless");
g_Config.m_GfxBorderless = 0;
}
if(g_Config.m_GfxBorderless)
Flags |= SDL_NOFRAME;
else if(g_Config.m_GfxFullscreen)
Flags |= SDL_FULLSCREEN;
// set gl attributes

View file

@ -712,7 +712,14 @@ void CGraphics_Threaded::QuadsText(float x, float y, float Size, float r, float
int CGraphics_Threaded::IssueInit()
{
int Flags = 0;
if(g_Config.m_GfxFullscreen) Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN;
if(g_Config.m_GfxBorderless && g_Config.m_GfxFullscreen)
{
dbg_msg("gfx", "both borderless and fullscreen activated, disabling borderless");
g_Config.m_GfxBorderless = 0;
}
if(g_Config.m_GfxBorderless) Flags |= IGraphicsBackend::INITFLAG_BORDERLESS;
else if(g_Config.m_GfxFullscreen) Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN;
if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC;
if(g_Config.m_DbgResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE;

View file

@ -300,6 +300,7 @@ public:
INITFLAG_FULLSCREEN = 1,
INITFLAG_VSYNC = 2,
INITFLAG_RESIZABLE = 4,
INITFLAG_BORDERLESS = 8,
};
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) = 0;

View file

@ -59,6 +59,7 @@ MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE|CFG
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(GfxBorderless, gfx_borderless, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)")
MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Fullscreen")
MACRO_CONFIG_INT(GfxAlphabits, gfx_alphabits, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Alpha bits for framebuffer (fullscreen only)")
MACRO_CONFIG_INT(GfxColorDepth, gfx_color_depth, 24, 16, 24, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Colors bits for framebuffer (fullscreen only)")

View file

@ -613,6 +613,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
static int s_GfxScreenWidth = g_Config.m_GfxScreenWidth;
static int s_GfxScreenHeight = g_Config.m_GfxScreenHeight;
static int s_GfxColorDepth = g_Config.m_GfxColorDepth;
static int s_GfxBorderless = g_Config.m_GfxBorderless;
static int s_GfxFullscreen = g_Config.m_GfxFullscreen;
static int s_GfxVsync = g_Config.m_GfxVsync;
static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples;
@ -667,10 +668,21 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
}
// switches
MainView.HSplitTop(20.0f, &Button, &MainView);
if(DoButton_CheckBox(&g_Config.m_GfxBorderless, Localize("Borderless window"), g_Config.m_GfxBorderless, &Button))
{
g_Config.m_GfxBorderless ^= 1;
if(g_Config.m_GfxBorderless && g_Config.m_GfxFullscreen)
g_Config.m_GfxFullscreen = 0;
CheckSettings = true;
}
MainView.HSplitTop(20.0f, &Button, &MainView);
if(DoButton_CheckBox(&g_Config.m_GfxFullscreen, Localize("Fullscreen"), g_Config.m_GfxFullscreen, &Button))
{
g_Config.m_GfxFullscreen ^= 1;
if(g_Config.m_GfxFullscreen && g_Config.m_GfxBorderless)
g_Config.m_GfxBorderless = 0;
CheckSettings = true;
}
@ -713,6 +725,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
if(s_GfxScreenWidth == g_Config.m_GfxScreenWidth &&
s_GfxScreenHeight == g_Config.m_GfxScreenHeight &&
s_GfxColorDepth == g_Config.m_GfxColorDepth &&
s_GfxBorderless == g_Config.m_GfxBorderless &&
s_GfxFullscreen == g_Config.m_GfxFullscreen &&
s_GfxVsync == g_Config.m_GfxVsync &&
s_GfxFsaaSamples == g_Config.m_GfxFsaaSamples &&