From 8e6bdd72faa9a1a2ea466c520fe79f7633c08d16 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Oct 2022 14:25:19 +0200 Subject: [PATCH] - moved UpdateVRModes, AppActive and gamestate into the backend. --- src/common/console/c_console.cpp | 2 +- src/common/engine/i_interface.cpp | 5 +++++ src/common/rendering/gl/gl_stereo3d.cpp | 28 ++++++++++++++++++++++++- src/d_main.cpp | 2 +- src/g_game.cpp | 1 - src/menu/doommenu.cpp | 28 ------------------------- 6 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/common/console/c_console.cpp b/src/common/console/c_console.cpp index 928c026f2b..26c0b0819a 100644 --- a/src/common/console/c_console.cpp +++ b/src/common/console/c_console.cpp @@ -70,8 +70,8 @@ #define RIGHTMARGIN 8 #define BOTTOMARGIN 12 +// todo: move these variables to a better place. extern bool AppActive; -int chatmodeon; CUSTOM_CVAR(Int, con_buffersize, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { diff --git a/src/common/engine/i_interface.cpp b/src/common/engine/i_interface.cpp index 13d35a3a90..f2e2e5e2b2 100644 --- a/src/common/engine/i_interface.cpp +++ b/src/common/engine/i_interface.cpp @@ -1,5 +1,6 @@ #include "i_interface.h" #include "st_start.h" +#include "gamestate.h" static_assert(sizeof(void*) == 8, "32 builds are not supported"); @@ -10,3 +11,7 @@ FString endoomName; bool batchrun; float menuBlurAmount; +bool AppActive = true; +int chatmodeon; +gamestate_t gamestate = GS_STARTUP; + diff --git a/src/common/rendering/gl/gl_stereo3d.cpp b/src/common/rendering/gl/gl_stereo3d.cpp index 9f6bb56f5e..c13914e226 100644 --- a/src/common/rendering/gl/gl_stereo3d.cpp +++ b/src/common/rendering/gl/gl_stereo3d.cpp @@ -44,6 +44,7 @@ #include "gl_framebuffer.h" #include "gl_shaderprogram.h" #include "gl_buffers.h" +#include "menu.h" EXTERN_CVAR(Int, vr_mode) @@ -53,7 +54,32 @@ EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Int, gl_satformula) EXTERN_CVAR(Int, gl_dither_bpc) -void UpdateVRModes(bool considerQuadBuffered = true); +#ifdef _WIN32 +EXTERN_CVAR(Bool, vr_enable_quadbuffered) +#endif + +void UpdateVRModes(bool considerQuadBuffered) +{ + FOptionValues** pVRModes = OptionValues.CheckKey("VRMode"); + if (pVRModes == nullptr) return; + + TArray& vals = (*pVRModes)->mValues; + TArray filteredValues; + int cnt = vals.Size(); + for (int i = 0; i < cnt; ++i) { + auto const& mode = vals[i]; + if (mode.Value == 7) { // Quad-buffered stereo +#ifdef _WIN32 + if (!vr_enable_quadbuffered) continue; +#else + continue; // Remove quad-buffered option on Mac and Linux +#endif + if (!considerQuadBuffered) continue; // Probably no compatible screen mode was found + } + filteredValues.Push(mode); + } + vals = filteredValues; +} namespace OpenGLRenderer { diff --git a/src/d_main.cpp b/src/d_main.cpp index 59695e07a1..ec4d3dd12b 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -332,7 +332,7 @@ bool nospriterename; FStartupInfo GameStartupInfo; FString lastIWAD; int restart = 0; -bool AppActive = true; +extern bool AppActive; bool playedtitlemusic; FStartScreen* StartScreen; diff --git a/src/g_game.cpp b/src/g_game.cpp index e66bea5e2c..00453a4867 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -144,7 +144,6 @@ CVAR(Int, nametagcolor, CR_GOLD, CVAR_ARCHIVE) extern bool playedtitlemusic; gameaction_t gameaction; -gamestate_t gamestate = GS_STARTUP; int paused; bool pauseext; diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 932e5e7e92..9cf3f60cb3 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -1463,31 +1463,3 @@ CCMD (menu_video) M_StartControlPanel (true); M_SetMenu(NAME_VideoModeMenu, -1); } - - -#ifdef _WIN32 -EXTERN_CVAR(Bool, vr_enable_quadbuffered) -#endif - -void UpdateVRModes(bool considerQuadBuffered) -{ - FOptionValues** pVRModes = OptionValues.CheckKey("VRMode"); - if (pVRModes == nullptr) return; - - TArray& vals = (*pVRModes)->mValues; - TArray filteredValues; - int cnt = vals.Size(); - for (int i = 0; i < cnt; ++i) { - auto const& mode = vals[i]; - if (mode.Value == 7) { // Quad-buffered stereo -#ifdef _WIN32 - if (!vr_enable_quadbuffered) continue; -#else - continue; // Remove quad-buffered option on Mac and Linux -#endif - if (!considerQuadBuffered) continue; // Probably no compatible screen mode was found - } - filteredValues.Push(mode); - } - vals = filteredValues; -}