mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 01:11:18 +00:00
Recalculate the fov when the cvar changes.
This separate the FOV calculations from other refdef calcs, cleaning up the renderer proper and making it easier for other parts of the engine (eg, csqc) to update the fov.
This commit is contained in:
parent
66fda1fddb
commit
91e3769c05
12 changed files with 25 additions and 30 deletions
|
@ -130,7 +130,7 @@ typedef struct vid_render_funcs_s {
|
|||
void (*Draw_Picf) (float x, float y, qpic_t *pic);
|
||||
void (*Draw_SubPic) (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
|
||||
|
||||
|
||||
void (*SCR_SetFOV) (float fov);
|
||||
// scr_funcs is a null terminated array
|
||||
void (*SCR_UpdateScreen) (double realtime, SCR_Func scr_3dfunc,
|
||||
SCR_Func *scr_funcs);
|
||||
|
|
|
@ -52,7 +52,6 @@ extern float scr_con_current;
|
|||
extern float scr_conlines; // lines of console to display
|
||||
|
||||
extern int oldscreensize;
|
||||
extern float oldfov;
|
||||
extern int oldsbar;
|
||||
|
||||
extern qboolean scr_initialized; // ready to draw
|
||||
|
@ -71,7 +70,7 @@ extern vrect_t scr_vrect;
|
|||
|
||||
extern qboolean scr_skipupdate;
|
||||
|
||||
float CalcFov (float fov_x, float width, float height);
|
||||
void SCR_SetFOV (float fov);
|
||||
void SCR_SetUpToDrawConsole (void);
|
||||
void SCR_ScreenShot_f (void);
|
||||
|
||||
|
|
|
@ -226,11 +226,6 @@ gl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
gl_c_alias_polys = 0;
|
||||
}
|
||||
|
||||
if (oldfov != scr_fov->value) { // determine size of refresh window
|
||||
oldfov = scr_fov->value;
|
||||
vid.recalc_refdef = true;
|
||||
}
|
||||
|
||||
if (vid.recalc_refdef)
|
||||
SCR_CalcRefdef ();
|
||||
|
||||
|
|
|
@ -179,10 +179,6 @@ glsl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc,
|
|||
|
||||
begun = 1;
|
||||
|
||||
if (oldfov != scr_fov->value) {
|
||||
oldfov = scr_fov->value;
|
||||
vid.recalc_refdef = true;
|
||||
}
|
||||
if (vid.recalc_refdef)
|
||||
SCR_CalcRefdef ();
|
||||
|
||||
|
|
|
@ -152,6 +152,12 @@ r_nearclip_f (cvar_t *var)
|
|||
vid.recalc_refdef = true;
|
||||
}
|
||||
|
||||
static void
|
||||
scr_fov_f (cvar_t *var)
|
||||
{
|
||||
SCR_SetFOV (var->value);
|
||||
}
|
||||
|
||||
static void
|
||||
scr_fisheye_f (cvar_t *var)
|
||||
{
|
||||
|
@ -291,9 +297,9 @@ R_Init_Cvars (void)
|
|||
r_zgraph = Cvar_Get ("r_zgraph", "0", CVAR_NONE, NULL,
|
||||
"Toggle the graph that reports the changes of "
|
||||
"z-axis position");
|
||||
scr_fov = Cvar_Get ("fov", "90", CVAR_NONE, NULL, "Your field of view in "
|
||||
"degrees. Smaller than 90 zooms in. Don't touch in "
|
||||
"fisheye mode, use ffov instead.");
|
||||
scr_fov = Cvar_Get ("fov", "90", CVAR_NONE, scr_fov_f,
|
||||
"Your field of view in degrees. Smaller than 90 zooms "
|
||||
"in. Don't touch in fisheye mode, use ffov instead.");
|
||||
scr_fisheye = Cvar_Get ("fisheye", "0", CVAR_NONE, scr_fisheye_f,
|
||||
"Toggles fisheye mode.");
|
||||
scr_fviews = Cvar_Get ("fviews", "6", CVAR_NONE, NULL, "The number of "
|
||||
|
|
|
@ -94,7 +94,6 @@
|
|||
int scr_copytop;
|
||||
byte *draw_chars; // 8*8 graphic characters FIXME location
|
||||
|
||||
float oldfov;
|
||||
int oldsbar;
|
||||
|
||||
qboolean scr_initialized; // ready to draw
|
||||
|
@ -164,15 +163,12 @@ SCR_CalcRefdef (void)
|
|||
R_SetVrect (&vrect, &scr_vrect, vr_data.lineadj);
|
||||
|
||||
refdef->vrect = scr_vrect;
|
||||
refdef->fov_x = scr_fov->value;
|
||||
refdef->fov_y =
|
||||
CalcFov (refdef->fov_x, refdef->vrect.width, refdef->vrect.height);
|
||||
|
||||
// notify the refresh of the change
|
||||
vr_funcs->R_ViewChanged (vid.aspect);
|
||||
}
|
||||
|
||||
float
|
||||
static float
|
||||
CalcFov (float fov_x, float width, float height)
|
||||
{
|
||||
float a, x;
|
||||
|
@ -189,6 +185,15 @@ CalcFov (float fov_x, float width, float height)
|
|||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
SCR_SetFOV (float fov)
|
||||
{
|
||||
refdef_t *refdef = r_data->refdef;
|
||||
refdef->fov_x = fov;
|
||||
refdef->fov_y = CalcFov (fov, refdef->vrect.width, refdef->vrect.height);
|
||||
vid.recalc_refdef = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ScreenShot_f (void)
|
||||
{
|
||||
|
|
|
@ -202,11 +202,6 @@ SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
if (!scr_initialized)
|
||||
return; // not initialized yet
|
||||
|
||||
if (oldfov != scr_fov->value) { // determine size of refresh window
|
||||
oldfov = scr_fov->value;
|
||||
vid.recalc_refdef = true;
|
||||
}
|
||||
|
||||
if (vid.recalc_refdef)
|
||||
SCR_CalcRefdef ();
|
||||
|
||||
|
|
|
@ -160,11 +160,6 @@ sw32_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs
|
|||
if (!scr_initialized)
|
||||
return; // not initialized yet
|
||||
|
||||
if (oldfov != scr_fov->value) { // determine size of refresh window
|
||||
oldfov = scr_fov->value;
|
||||
vid.recalc_refdef = true;
|
||||
}
|
||||
|
||||
if (vid.recalc_refdef)
|
||||
SCR_CalcRefdef ();
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ vid_render_funcs_t gl_vid_render_funcs = {
|
|||
gl_Draw_Picf,
|
||||
gl_Draw_SubPic,
|
||||
|
||||
SCR_SetFOV,
|
||||
gl_SCR_UpdateScreen,
|
||||
SCR_DrawRam,
|
||||
SCR_DrawTurtle,
|
||||
|
|
|
@ -90,6 +90,7 @@ vid_render_funcs_t glsl_vid_render_funcs = {
|
|||
glsl_Draw_Picf,
|
||||
glsl_Draw_SubPic,
|
||||
|
||||
SCR_SetFOV,
|
||||
glsl_SCR_UpdateScreen,
|
||||
SCR_DrawRam,
|
||||
SCR_DrawTurtle,
|
||||
|
|
|
@ -83,6 +83,7 @@ vid_render_funcs_t sw_vid_render_funcs = {
|
|||
Draw_Picf,
|
||||
Draw_SubPic,
|
||||
|
||||
SCR_SetFOV,
|
||||
SCR_UpdateScreen,
|
||||
SCR_DrawRam,
|
||||
SCR_DrawTurtle,
|
||||
|
|
|
@ -88,6 +88,7 @@ vid_render_funcs_t sw32_vid_render_funcs = {
|
|||
sw32_Draw_Picf,
|
||||
sw32_Draw_SubPic,
|
||||
|
||||
SCR_SetFOV,
|
||||
sw32_SCR_UpdateScreen,
|
||||
SCR_DrawRam,
|
||||
SCR_DrawTurtle,
|
||||
|
|
Loading…
Reference in a new issue