diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index b3fc57ed8..ee48efd70 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -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) diff --git a/src/engine/client/backend_sdl.h b/src/engine/client/backend_sdl.h index aff6928f6..fdb194f4f 100644 --- a/src/engine/client/backend_sdl.h +++ b/src/engine/client/backend_sdl.h @@ -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 diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 9d37e9f51..062ce5921 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -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(); diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index f54377d71..8ed61fc6a 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -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); diff --git a/src/engine/graphics.h b/src/engine/graphics.h index ce62ac890..4b1ec5edd 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -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; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 842550007..6af2cf3d6 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -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);