Skip to content

Commit

Permalink
cgame: automatic fov adjustment for wide screens, fixes #470
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarquis committed Mar 24, 2015
1 parent 91e4bb6 commit 00949de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ cvarTable_t cvarTable[] =
{ &cg_zoomDefaultSniper, "cg_zoomDefaultSniper", "20", CVAR_ARCHIVE }, // changed per atvi req
{ &cg_zoomStepSniper, "cg_zoomStepSniper", "2", CVAR_ARCHIVE },
{ &cg_fov, "cg_fov", "90", CVAR_ARCHIVE },
{ &cg_gun_fovscale, "cg_gun_fovscale", "1", 0 },
{ &cg_gun_fovscale, "cg_gun_fovscale", "0", 0 },
{ &cg_muzzleFlash, "cg_muzzleFlash", "1", CVAR_ARCHIVE },
{ &cg_letterbox, "cg_letterbox", "0", CVAR_TEMP },
{ &cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE },
Expand Down
6 changes: 6 additions & 0 deletions src/cgame/cg_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,9 @@ static int CG_CalcFov(void)
fov_x = fov_y = 60.f;
}

// automatic fov adjustment for wide screens
fov_x = atan(tan(fov_x * M_PI / 360.0f) * 0.75f * (float)cgs.glconfig.vidWidth / (float)cgs.glconfig.vidHeight) * 360.0f / M_PI;

// this is weird... (but ensures square pixel ratio!)
x = cg.refdef_current->width / tan(fov_x / 360 * M_PI);
fov_y = atan2(cg.refdef_current->height, x);
Expand Down Expand Up @@ -1594,6 +1597,9 @@ void CG_DrawSkyBoxPortal(qboolean fLocalView)
fov_x = 55;
}

// automatic fov adjustment for wide screens
fov_x = atan(tan(fov_x * M_PI / 360.0f) * 0.75f * (float)cgs.glconfig.vidWidth / (float)cgs.glconfig.vidHeight) * 360.0f / M_PI;

x = rd.width / tan(fov_x / 360 * M_PI);
fov_y = atan2(rd.height, x);
fov_y = fov_y * 360 / M_PI;
Expand Down

0 comments on commit 00949de

Please sign in to comment.