From 385a1965e762d90a778400760ad22f045d37e548 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 28 Oct 2012 03:46:56 +0100 Subject: [PATCH] Guess x/y FOV/aspectratio from resolution Added r_aspectratio -1 which means "auto" (as new default). This mode sets fov_x and fov_y according to screen-width/height. => No need to set r_aspectratio manually anymore (assuming your display's pixels are about square). The standard aspect ratios can still be enforced as before, though. --- d3xp/Game_local.cpp | 5 +++++ d3xp/gamesys/SysCvar.cpp | 2 +- game/Game_local.cpp | 5 +++++ game/gamesys/SysCvar.cpp | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/d3xp/Game_local.cpp b/d3xp/Game_local.cpp index ed4d7cf..77614cd 100644 --- a/d3xp/Game_local.cpp +++ b/d3xp/Game_local.cpp @@ -2658,6 +2658,11 @@ void idGameLocal::CalcFov( float base_fov, float &fov_x, float &fov_y ) const { switch( r_aspectRatio.GetInteger() ) { default : + case -1 : + // auto mode => use aspect ratio from resolution, assuming screen's pixels are squares + ratio_x = renderSystem->GetScreenWidth(); + ratio_y = renderSystem->GetScreenHeight(); + break; case 0 : // 4:3 fov_x = base_fov; diff --git a/d3xp/gamesys/SysCvar.cpp b/d3xp/gamesys/SysCvar.cpp index 73ca491..5ed1b1a 100644 --- a/d3xp/gamesys/SysCvar.cpp +++ b/d3xp/gamesys/SysCvar.cpp @@ -116,7 +116,7 @@ idCVar ui_chat( "ui_chat", "0", CVAR_GAME | CVAR_USERINFO | CVAR_BOOL // change anytime vars idCVar developer( "developer", "0", CVAR_GAME | CVAR_BOOL, "" ); -idCVar r_aspectRatio( "r_aspectRatio", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "aspect ratio of view:\n0 = 4:3\n1 = 16:9\n2 = 16:10", 0, 2 ); +idCVar r_aspectRatio( "r_aspectRatio", "-1", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "aspect ratio of view:\n0 = 4:3\n1 = 16:9\n2 = 16:10\n-1 = auto (guess from resolution)", -1, 2 ); idCVar g_cinematic( "g_cinematic", "1", CVAR_GAME | CVAR_BOOL, "skips updating entities that aren't marked 'cinematic' '1' during cinematics" ); idCVar g_cinematicMaxSkipTime( "g_cinematicMaxSkipTime", "600", CVAR_GAME | CVAR_FLOAT, "# of seconds to allow game to run when skipping cinematic. prevents lock-up when cinematic doesn't end.", 0, 3600 ); diff --git a/game/Game_local.cpp b/game/Game_local.cpp index 892efce..d7c846c 100644 --- a/game/Game_local.cpp +++ b/game/Game_local.cpp @@ -2392,6 +2392,11 @@ void idGameLocal::CalcFov( float base_fov, float &fov_x, float &fov_y ) const { switch( r_aspectRatio.GetInteger() ) { default : + case -1 : + // auto mode => use aspect ratio from resolution, assuming screen's pixels are squares + ratio_x = renderSystem->GetScreenWidth(); + ratio_y = renderSystem->GetScreenHeight(); + break; case 0 : // 4:3 fov_x = base_fov; diff --git a/game/gamesys/SysCvar.cpp b/game/gamesys/SysCvar.cpp index 5710276..9751ca8 100644 --- a/game/gamesys/SysCvar.cpp +++ b/game/gamesys/SysCvar.cpp @@ -93,7 +93,7 @@ idCVar ui_chat( "ui_chat", "0", CVAR_GAME | CVAR_USERINFO | CVAR_BOOL // change anytime vars idCVar developer( "developer", "0", CVAR_GAME | CVAR_BOOL, "" ); -idCVar r_aspectRatio( "r_aspectRatio", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "aspect ratio of view:\n0 = 4:3\n1 = 16:9\n2 = 16:10", 0, 2 ); +idCVar r_aspectRatio( "r_aspectRatio", "-1", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "aspect ratio of view:\n0 = 4:3\n1 = 16:9\n2 = 16:10\n-1 = auto (guess from resolution)", -1, 2 ); idCVar g_cinematic( "g_cinematic", "1", CVAR_GAME | CVAR_BOOL, "skips updating entities that aren't marked 'cinematic' '1' during cinematics" ); idCVar g_cinematicMaxSkipTime( "g_cinematicMaxSkipTime", "600", CVAR_GAME | CVAR_FLOAT, "# of seconds to allow game to run when skipping cinematic. prevents lock-up when cinematic doesn't end.", 0, 3600 );