From 509da82ee81585f9d8b53df930d4848cc4dc015b Mon Sep 17 00:00:00 2001 From: Dave Milici Date: Fri, 12 Mar 2021 10:07:45 -0800 Subject: [PATCH] Add -gl_stereoview option for selecting stereo viewport modes. --- common/include/args.h | 1 + common/main/game.h | 1 + similar/main/game.cpp | 13 +++++++++---- similar/main/gamecntl.cpp | 8 ++------ similar/main/inferno.cpp | 4 ++++ similar/misc/args.cpp | 2 ++ 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/common/include/args.h b/common/include/args.h index 52ce2245f..b9668c3a4 100644 --- a/common/include/args.h +++ b/common/include/args.h @@ -102,6 +102,7 @@ struct CArg : prohibit_void_ptr bool DbgGlRGBA2Ok; unsigned OglSyncWait; bool OglStereo; + int OglStereoView; #else bool DbgSdlHWSurface; bool DbgSdlASyncBlit; diff --git a/common/main/game.h b/common/main/game.h index 621a56b53..07b7f06d9 100644 --- a/common/main/game.h +++ b/common/main/game.h @@ -205,6 +205,7 @@ extern game_window *Game_wind; void game(); void init_game(); +void init_stereo(); void init_cockpit(); extern void PALETTE_FLASH_ADD(int dr, int dg, int db); diff --git a/similar/main/game.cpp b/similar/main/game.cpp index 1ad75764d..3740ea6bf 100644 --- a/similar/main/game.cpp +++ b/similar/main/game.cpp @@ -193,10 +193,15 @@ namespace dsx { void init_stereo() { // init stereo options - if (CGameArg.OglStereo) { - VR_stereo = true; -// VR_half_width = true; - VR_half_height = true; + if (CGameArg.OglStereo || CGameArg.OglStereoView) { + if (!VR_stereo && !VR_eye_offset) + VR_stereo = (CGameArg.OglStereoView) ? CGameArg.OglStereoView % 4 : true; + switch (VR_stereo) { + case 0: VR_half_width = VR_half_height = false; break; + case 1: VR_half_width = false; VR_half_height = true; break; + case 2: VR_half_width = true; VR_half_height = false; break; + case 3: VR_half_width = VR_half_height = true; break; + } VR_eye_width = (F1_0 * 7) / 10; // Descent 1.5 defaults VR_eye_offset = (VR_half_width) ? -6 : -12; PlayerCfg.CockpitMode[1] = CM_FULL_SCREEN; diff --git a/similar/main/gamecntl.cpp b/similar/main/gamecntl.cpp index 7f6bab7cb..0b3dbbe18 100644 --- a/similar/main/gamecntl.cpp +++ b/similar/main/gamecntl.cpp @@ -931,13 +931,9 @@ static window_event_result HandleSystemKey(int key) break; case KEY_SHIFTED + KEY_F8: case KEY_SHIFTED + KEY_ALTED + KEY_F8: - if (CGameArg.OglStereo) + if (CGameArg.OglStereo || CGameArg.OglStereoView) { ++VR_stereo %= 4; - switch (VR_stereo) { - case 0: VR_half_width = VR_half_height = false; break; - case 1: VR_half_width = false; VR_half_height = true; break; - case 2: VR_half_width = true; VR_half_height = false; break; - case 3: VR_half_width = VR_half_height = true; break; + init_stereo(); } break; diff --git a/similar/main/inferno.cpp b/similar/main/inferno.cpp index c873d80e9..c98e4bdfa 100644 --- a/similar/main/inferno.cpp +++ b/similar/main/inferno.cpp @@ -206,6 +206,10 @@ static void print_commandline_help() VERB(" -gl_syncwait Wait interval (ms) for sync mode 2 (default: " DXX_STRINGIZE(OGL_SYNC_WAIT_DEFAULT) ")\n") \ VERB(" -gl_darkedges Re-enable dark edges around filtered textures (as present in earlier versions of the engine)\n") \ VERB(" -gl_stereo Enable OpenGL stereo quad buffering, if available\n") \ + VERB(" -gl_stereoview Select OpenGL stereo viewport mode\n") \ + VERB(" 1: above/below half-height format\n") \ + VERB(" 2: side/by/side half-width format\n") \ + VERB(" 3: side/by/side half-size format, normal aspect ratio\n") \ ) \ DXX_if_defined_01(DXX_USE_UDP, ( \ VERB("\n Multiplayer:\n\n") \ diff --git a/similar/misc/args.cpp b/similar/misc/args.cpp index df5752f0a..f04519bf3 100644 --- a/similar/misc/args.cpp +++ b/similar/misc/args.cpp @@ -295,6 +295,8 @@ static void ReadCmdArgs(Inilist &ini, Arglist &Args) CGameArg.OglDarkEdges = true; else if (!d_stricmp(p, "-gl_stereo")) CGameArg.OglStereo = true; + else if (!d_stricmp(p, "-gl_stereoview")) + CGameArg.OglStereoView = arg_integer(pp, end); #endif // Multiplayer Options