diff --git a/include/QF/plugin/vid_render.h b/include/QF/plugin/vid_render.h index bdec285d1..4d2a133aa 100644 --- a/include/QF/plugin/vid_render.h +++ b/include/QF/plugin/vid_render.h @@ -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); diff --git a/include/r_screen.h b/include/r_screen.h index 8d3b08e91..737097fdb 100644 --- a/include/r_screen.h +++ b/include/r_screen.h @@ -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); diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index d463880d8..0e0d2f654 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -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 (); diff --git a/libs/video/renderer/glsl/glsl_screen.c b/libs/video/renderer/glsl/glsl_screen.c index 56e481c41..7ee1c0bb7 100644 --- a/libs/video/renderer/glsl/glsl_screen.c +++ b/libs/video/renderer/glsl/glsl_screen.c @@ -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 (); diff --git a/libs/video/renderer/r_cvar.c b/libs/video/renderer/r_cvar.c index d9f3e14d2..0f6406f61 100644 --- a/libs/video/renderer/r_cvar.c +++ b/libs/video/renderer/r_cvar.c @@ -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 " diff --git a/libs/video/renderer/r_screen.c b/libs/video/renderer/r_screen.c index a6d129674..86e6a38a8 100644 --- a/libs/video/renderer/r_screen.c +++ b/libs/video/renderer/r_screen.c @@ -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) { diff --git a/libs/video/renderer/sw/screen.c b/libs/video/renderer/sw/screen.c index d425f6549..66a8224b1 100644 --- a/libs/video/renderer/sw/screen.c +++ b/libs/video/renderer/sw/screen.c @@ -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 (); diff --git a/libs/video/renderer/sw32/screen.c b/libs/video/renderer/sw32/screen.c index 63f0ce6e1..f1bd73c85 100644 --- a/libs/video/renderer/sw32/screen.c +++ b/libs/video/renderer/sw32/screen.c @@ -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 (); diff --git a/libs/video/renderer/vid_render_gl.c b/libs/video/renderer/vid_render_gl.c index c79bfaa20..ac6be77f7 100644 --- a/libs/video/renderer/vid_render_gl.c +++ b/libs/video/renderer/vid_render_gl.c @@ -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, diff --git a/libs/video/renderer/vid_render_glsl.c b/libs/video/renderer/vid_render_glsl.c index f09820ab3..b88c7af11 100644 --- a/libs/video/renderer/vid_render_glsl.c +++ b/libs/video/renderer/vid_render_glsl.c @@ -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, diff --git a/libs/video/renderer/vid_render_sw.c b/libs/video/renderer/vid_render_sw.c index 7ac10a4d4..d9dcfb90d 100644 --- a/libs/video/renderer/vid_render_sw.c +++ b/libs/video/renderer/vid_render_sw.c @@ -83,6 +83,7 @@ vid_render_funcs_t sw_vid_render_funcs = { Draw_Picf, Draw_SubPic, + SCR_SetFOV, SCR_UpdateScreen, SCR_DrawRam, SCR_DrawTurtle, diff --git a/libs/video/renderer/vid_render_sw32.c b/libs/video/renderer/vid_render_sw32.c index 9bc135c78..cb0ac344d 100644 --- a/libs/video/renderer/vid_render_sw32.c +++ b/libs/video/renderer/vid_render_sw32.c @@ -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,