added a menu setting to switch the screen

This commit is contained in:
oy 2015-10-22 20:28:19 +02:00
parent dd98fd86eb
commit 6d038bd621
6 changed files with 26 additions and 7 deletions

View file

@ -638,10 +638,10 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
// set screen
SDL_Rect ScreenPos;
int NumScreens = SDL_GetNumVideoDisplays();
if(NumScreens > 0)
m_NumScreens = SDL_GetNumVideoDisplays();
if(m_NumScreens > 0)
{
clamp(*Screen, 0, NumScreens-1);
clamp(*Screen, 0, m_NumScreens-1);
if(SDL_GetDisplayBounds(*Screen, &ScreenPos) != 0)
{
dbg_msg("gfx", "unable to retrieve screen information: %s", SDL_GetError());
@ -785,8 +785,7 @@ void CGraphicsBackend_SDL_OpenGL::SetWindowBordered(bool State)
bool CGraphicsBackend_SDL_OpenGL::SetWindowScreen(int Index)
{
int NumScreens = SDL_GetNumVideoDisplays();
if(Index >= 0 && Index < NumScreens)
if(Index >= 0 && Index < m_NumScreens)
{
SDL_Rect ScreenPos;
if(SDL_GetDisplayBounds(Index, &ScreenPos) == 0)

View file

@ -188,12 +188,15 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
SDL_GLContext m_GLContext;
ICommandProcessor *m_pProcessor;
volatile int m_TextureMemoryUsage;
int m_NumScreens;
public:
virtual int Init(const char *pName, int *Screen, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight);
virtual int Shutdown();
virtual int MemoryUsage() const;
virtual int GetNumScreens() const { return m_NumScreens; }
virtual void Minimize();
virtual void Maximize();
virtual bool Fullscreen(bool State); // on=true/off=false

View file

@ -833,6 +833,11 @@ void CGraphics_Threaded::Shutdown()
delete m_apCommandBuffers[i];
}
int CGraphics_Threaded::GetNumScreens() const
{
return m_pBackend->GetNumScreens();
}
void CGraphics_Threaded::Minimize()
{
m_pBackend->Minimize();

View file

@ -315,6 +315,8 @@ public:
virtual int MemoryUsage() const = 0;
virtual int GetNumScreens() const = 0;
virtual void Minimize() = 0;
virtual void Maximize() = 0;
virtual bool Fullscreen(bool State) = 0;
@ -434,6 +436,7 @@ public:
virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num);
virtual void QuadsText(float x, float y, float Size, const char *pText);
virtual int GetNumScreens() const;
virtual void Minimize();
virtual void Maximize();
virtual bool Fullscreen(bool State);

View file

@ -174,7 +174,8 @@ public:
virtual int GetDesktopScreenHeight() const = 0;
virtual void Swap() = 0;
virtual bool SetVSync(bool State) = 0;
virtual int GetNumScreens() const = 0;
// syncronization
virtual void InsertSignal(class semaphore *pSemaphore) = 0;
@ -200,6 +201,7 @@ public:
virtual bool Fullscreen(bool State) = 0;
virtual void SetWindowBordered(bool State) = 0;
virtual bool SetWindowScreen(int Index) = 0;
virtual bool SetVSync(bool State) = 0;
virtual void Minimize() = 0;
virtual void Maximize() = 0;

View file

@ -1177,7 +1177,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
BottomView.HSplitTop(20.f, 0, &BottomView);
// render screen menu background
int NumOptions = g_Config.m_GfxFullscreen ? 3 : 4;
int NumOptions = g_Config.m_GfxFullscreen ? 4 : 5;
float ButtonHeight = 20.0f;
float Spacing = 2.0f;
float BackgroundHeight = (float)(NumOptions+1)*ButtonHeight+(float)NumOptions*Spacing;
@ -1221,6 +1221,13 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
if(DoButton_CheckBox(&s_ButtonGfxVsync, Localize("V-Sync"), g_Config.m_GfxVsync, &Button))
Client()->ToggleWindowVSync();
Screen.HSplitTop(Spacing, 0, &Screen);
Screen.HSplitTop(ButtonHeight, &Button, &Screen);
int Index = g_Config.m_GfxScreen;
DoScrollbarOption(&g_Config.m_GfxScreen, &Index, &Button, Localize("Screen"), 110.0f, 0, Graphics()->GetNumScreens()-1);
if(Index != g_Config.m_GfxScreen)
Client()->SwitchWindowScreen(Index);
// FSAA button
{
Screen.HSplitTop(Spacing, 0, &Screen);