From 51bf2eb9fae3dce1666d5274ba70c39998ddad2c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Apr 2018 19:18:16 +0200 Subject: [PATCH] - took GetMaxViewPitch out of renderer interfaces. With live switching and both renderers on the same backend the old approach will no longer work. --- src/gl/scene/gl_scene.cpp | 14 -------------- src/p_user.cpp | 29 +++++++++++++++++++++++++++-- src/r_renderer.h | 2 -- src/swrenderer/r_swrenderer.cpp | 7 ------- src/swrenderer/r_swrenderer.h | 2 -- src/win32/hardware.cpp | 15 ++------------- 6 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 8c5d9f7ad..986578b1c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -1005,7 +1005,6 @@ struct FGLInterface : public FRenderer void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, double fov) override; void PreprocessLevel() override; - int GetMaxViewPitch(bool down) override; void SetClearColor(int color) override; uint32_t GetCaps() override; }; @@ -1022,19 +1021,6 @@ void FGLInterface::Precache(uint8_t *texhitlist, TMap &actor gl_PrecacheTexture(texhitlist, actorhitlist); } -//=========================================================================== -// -// Get max. view angle (renderer specific information so it goes here now) -// -//=========================================================================== - -EXTERN_CVAR(Float, maxviewpitch) - -int FGLInterface::GetMaxViewPitch(bool down) -{ - return int(maxviewpitch); -} - //=========================================================================== // // diff --git a/src/p_user.cpp b/src/p_user.cpp index d264d1ca5..7bf85b4a4 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -730,13 +730,38 @@ bool player_t::GetPainFlash(FName type, PalEntry *color) const // //=========================================================================== +EXTERN_CVAR(Float, maxviewpitch) +EXTERN_CVAR(Bool, r_polyrenderer) +EXTERN_CVAR(Bool, cl_oldfreelooklimit); +extern int currentrenderer; + + +static int GetSoftPitch(bool down) +{ + int MAX_DN_ANGLE = MIN(56, (int)maxviewpitch); // Max looking down angle + int MAX_UP_ANGLE = MIN(32, (int)maxviewpitch); // Max looking up angle + return (down ? MAX_DN_ANGLE : ((cl_oldfreelooklimit) ? MAX_UP_ANGLE : MAX_DN_ANGLE)); +} + void player_t::SendPitchLimits() const { if (this - players == consoleplayer) { + int uppitch, downpitch; + + if (currentrenderer == 0 && !r_polyrenderer) + { + uppitch = GetSoftPitch(false); + downpitch = GetSoftPitch(true); + } + else + { + uppitch = downpitch = (int)maxviewpitch; + } + Net_WriteByte(DEM_SETPITCHLIMIT); - Net_WriteByte(Renderer->GetMaxViewPitch(false)); // up - Net_WriteByte(Renderer->GetMaxViewPitch(true)); // down + Net_WriteByte(uppitch); + Net_WriteByte(downpitch); } } diff --git a/src/r_renderer.h b/src/r_renderer.h index 7e70a1bbf..6ab9aaa9a 100644 --- a/src/r_renderer.h +++ b/src/r_renderer.h @@ -37,8 +37,6 @@ struct FRenderer // draws player sprites with hardware acceleration (only useful for software rendering) virtual void DrawRemainingPlayerSprites() {} - virtual int GetMaxViewPitch(bool down) = 0; // return value is in plain degrees - virtual void OnModeSet () {} virtual void SetClearColor(int color) = 0; virtual void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, double fov) = 0; diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index 1d640c9d8..a8114dc69 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -235,13 +235,6 @@ void FSoftwareRenderer::DrawRemainingPlayerSprites() } } -int FSoftwareRenderer::GetMaxViewPitch(bool down) -{ - int MAX_DN_ANGLE = MIN(56, (int)maxviewpitch); // Max looking down angle - int MAX_UP_ANGLE = MIN(32, (int)maxviewpitch); // Max looking up angle - return (r_polyrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : ((cl_oldfreelooklimit) ? MAX_UP_ANGLE : MAX_DN_ANGLE)); -} - void FSoftwareRenderer::OnModeSet () { mScene.ScreenResized(); diff --git a/src/swrenderer/r_swrenderer.h b/src/swrenderer/r_swrenderer.h index 7f01b2d2c..4a83c0b8c 100644 --- a/src/swrenderer/r_swrenderer.h +++ b/src/swrenderer/r_swrenderer.h @@ -21,8 +21,6 @@ struct FSoftwareRenderer : public FRenderer // draws player sprites with hardware acceleration (only useful for software rendering) void DrawRemainingPlayerSprites() override; - int GetMaxViewPitch(bool down) override; - void OnModeSet() override; void SetClearColor(int color) override; void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, double fov) override; diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index d329e0e21..5d89cf43f 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -98,13 +98,6 @@ CUSTOM_CVAR(Int, vid_gpuswitch, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI } } -// Software OpenGL canvas -CUSTOM_CVAR(Bool, vid_glswfb, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) -{ - if ((self ? 1 : 0) != currentcanvas) - Printf("You must restart " GAMENAME " for this change to take effect.\n"); -} - // [ZDoomGL] CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { @@ -195,15 +188,11 @@ static void I_DeleteRenderer() void I_CreateRenderer() { currentrenderer = vid_renderer; - currentcanvas = vid_glswfb; if (currentrenderer == 1) Printf("Renderer: OpenGL\n"); - else if (currentcanvas == 1) - Printf("Renderer: Software on OpenGL\n"); - else if (currentcanvas == 0) - Printf("Renderer: Software on Direct3D\n"); else - Printf("Renderer: Unknown\n"); + Printf("Renderer: Software on OpenGL\n"); + if (Renderer == NULL) { if (currentrenderer==1) Renderer = gl_CreateInterface();