From 4c12ba740f01be98ea59a99390fa934a01045d76 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 15 Jan 2017 02:46:43 +0100 Subject: [PATCH] Remove SetWindow from FRenderer interface --- src/polyrenderer/poly_renderer.cpp | 34 ++++++++++++++++++++++ src/polyrenderer/poly_renderer.h | 3 +- src/r_renderer.h | 1 - src/r_utility.cpp | 6 +--- src/swrenderer/r_swrenderer.cpp | 45 ++---------------------------- src/swrenderer/r_swrenderer.h | 1 - src/swrenderer/scene/r_scene.cpp | 36 ++++++++++++++++++++++++ src/swrenderer/scene/r_scene.h | 1 + 8 files changed, 77 insertions(+), 50 deletions(-) diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index 67f997c61..ceabfceff 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -30,10 +30,13 @@ #include "gl/data/gl_data.h" #include "d_net.h" #include "po_man.h" +#include "st_stuff.h" #include "swrenderer/scene/r_scene.h" #include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" +#include "swrenderer/drawers/r_draw_rgba.h" +EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Int, screenblocks) void InitGLRMapinfoData(); extern bool r_showviewer; @@ -46,6 +49,33 @@ PolyRenderer *PolyRenderer::Instance() return &scene; } +void PolyRenderer::RenderView(player_t *player) +{ + using namespace swrenderer; + + bool saved_swtruecolor = r_swtruecolor; + r_swtruecolor = screen->IsBgra(); + + int width = SCREENWIDTH; + int height = SCREENHEIGHT; + int stHeight = ST_Y; + float trueratio; + ActiveRatio(width, height, &trueratio); + R_SWRSetWindow(setblocks, width, height, stHeight, trueratio); + + RenderActorView(player->mo, false); + + // Apply special colormap if the target cannot do it + if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) + { + R_BeginDrawerCommands(); + DrawerCommandQueue::QueueCommand(realfixedcolormap, screen); + R_EndDrawerCommands(); + } + + r_swtruecolor = saved_swtruecolor; +} + void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) { const bool savedviewactive = viewactive; @@ -55,6 +85,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int RenderTarget = canvas; swrenderer::bRenderingToCanvas = true; R_SetWindow(12, width, height, height, true); + swrenderer::R_SWRSetWindow(12, width, height, height, WidescreenRatio); viewwindowx = x; viewwindowy = y; viewactive = true; @@ -69,6 +100,9 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int RenderTarget = screen; swrenderer::bRenderingToCanvas = false; R_ExecuteSetViewSize(); + float trueratio; + ActiveRatio(width, height, &trueratio); + swrenderer::R_SWRSetWindow(setblocks, width, height, height, WidescreenRatio); viewactive = savedviewactive; swrenderer::r_swtruecolor = savedoutputformat; } diff --git a/src/polyrenderer/poly_renderer.h b/src/polyrenderer/poly_renderer.h index 368872d97..75e192e9c 100644 --- a/src/polyrenderer/poly_renderer.h +++ b/src/polyrenderer/poly_renderer.h @@ -38,8 +38,8 @@ class DCanvas; class PolyRenderer { public: + void RenderView(player_t *player); void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines); - void RenderActorView(AActor *actor, bool dontmaplines); void RenderRemainingPlayerSprites(); static PolyRenderer *Instance(); @@ -52,6 +52,7 @@ public: bool DontMapLines = false; private: + void RenderActorView(AActor *actor, bool dontmaplines); void ClearBuffers(); void SetSceneViewport(); void SetupPerspectiveMatrix(); diff --git a/src/r_renderer.h b/src/r_renderer.h index d8f54ec5b..54e6d9dac 100644 --- a/src/r_renderer.h +++ b/src/r_renderer.h @@ -55,7 +55,6 @@ struct FRenderer virtual void OnModeSet () {} virtual void ClearBuffer(int color) = 0; virtual void Init() = 0; - virtual void SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio) {} virtual void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) = 0; virtual sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel) = 0; virtual void SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) {} diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 03ba0756f..29119754b 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -201,8 +201,6 @@ void R_SetViewSize (int blocks) void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, bool renderingToCanvas) { - float trueratio; - if (windowSize >= 11) { viewwidth = fullWidth; @@ -224,11 +222,10 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, b if (renderingToCanvas) { WidescreenRatio = fullWidth / (float)fullHeight; - trueratio = WidescreenRatio; } else { - WidescreenRatio = ActiveRatio(fullWidth, fullHeight, &trueratio); + WidescreenRatio = ActiveRatio(fullWidth, fullHeight); } DrawFSHUD = (windowSize == 11); @@ -258,7 +255,6 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, b if (fov > 170.) fov = 170.; } FocalTangent = tan(fov.Radians() / 2); - Renderer->SetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio); } //========================================================================== diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index 907b77051..85131c975 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -178,45 +178,11 @@ void FSoftwareRenderer::Precache(BYTE *texhitlist, TMap &act void FSoftwareRenderer::RenderView(player_t *player) { if (r_polyrenderer) - { - bool saved_swtruecolor = r_swtruecolor; - r_swtruecolor = screen->IsBgra(); - - PolyRenderer::Instance()->RenderActorView(player->mo, false); - - // Apply special colormap if the target cannot do it - if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) - { - R_BeginDrawerCommands(); - DrawerCommandQueue::QueueCommand(realfixedcolormap, screen); - R_EndDrawerCommands(); - } - - r_swtruecolor = saved_swtruecolor; - - FCanvasTextureInfo::UpdateAll(); - } + PolyRenderer::Instance()->RenderView(player); else - { - if (r_swtruecolor != screen->IsBgra()) - { - r_swtruecolor = screen->IsBgra(); - R_InitColumnDrawers(); - } + RenderScene::Instance()->RenderView(player); - R_BeginDrawerCommands(); - RenderScene::Instance()->RenderActorView(player->mo); - - // Apply special colormap if the target cannot do it - if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) - { - DrawerCommandQueue::QueueCommand(realfixedcolormap, screen); - } - - R_EndDrawerCommands(); - - FCanvasTextureInfo::UpdateAll(); - } + FCanvasTextureInfo::UpdateAll(); } void FSoftwareRenderer::RemapVoxels() @@ -292,11 +258,6 @@ void FSoftwareRenderer::ClearBuffer(int color) } } -void FSoftwareRenderer::SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio) -{ - R_SWRSetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio); -} - void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) { BYTE *Pixels = r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels(); diff --git a/src/swrenderer/r_swrenderer.h b/src/swrenderer/r_swrenderer.h index d116a1a95..5b2a6eedc 100644 --- a/src/swrenderer/r_swrenderer.h +++ b/src/swrenderer/r_swrenderer.h @@ -33,7 +33,6 @@ struct FSoftwareRenderer : public FRenderer void OnModeSet () override; void ClearBuffer(int color) override; void Init() override; - void SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio) override; void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) override; sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel) override; diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp index c9bfcb8bc..77b0edf14 100644 --- a/src/swrenderer/scene/r_scene.cpp +++ b/src/swrenderer/scene/r_scene.cpp @@ -30,6 +30,7 @@ #include "g_level.h" #include "p_effect.h" #include "po_man.h" +#include "st_stuff.h" #include "r_data/r_interpolate.h" #include "swrenderer/scene/r_scene.h" #include "swrenderer/scene/r_viewport.h" @@ -43,6 +44,7 @@ #include "swrenderer/segments/r_portalsegment.h" #include "swrenderer/plane/r_visibleplanelist.h" #include "swrenderer/drawers/r_draw.h" +#include "swrenderer/drawers/r_draw_rgba.h" #include "swrenderer/drawers/r_thread.h" #include "swrenderer/r_memory.h" @@ -58,6 +60,34 @@ namespace swrenderer return &instance; } + void RenderScene::RenderView(player_t *player) + { + int width = SCREENWIDTH; + int height = SCREENHEIGHT; + int stHeight = ST_Y; + float trueratio; + ActiveRatio(width, height, &trueratio); + R_SWRSetWindow(setblocks, width, height, stHeight, trueratio); + + if (r_swtruecolor != screen->IsBgra()) + { + r_swtruecolor = screen->IsBgra(); + R_InitColumnDrawers(); + } + + R_BeginDrawerCommands(); + + RenderActorView(player->mo); + + // Apply special colormap if the target cannot do it + if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D)) + { + DrawerCommandQueue::QueueCommand(realfixedcolormap, screen); + } + + R_EndDrawerCommands(); + } + void RenderScene::RenderActorView(AActor *actor, bool dontmaplines) { WallCycles.Reset(); @@ -165,6 +195,8 @@ namespace swrenderer bRenderingToCanvas = true; R_SetWindow(12, width, height, height, true); + R_SWRSetWindow(12, width, height, height, WidescreenRatio); + viewwindowx = x; viewwindowy = y; viewactive = true; @@ -175,7 +207,11 @@ namespace swrenderer RenderTarget = screen; bRenderingToCanvas = false; + R_ExecuteSetViewSize(); + float trueratio; + ActiveRatio(width, height, &trueratio); + R_SWRSetWindow(setblocks, width, height, height, WidescreenRatio); screen->Lock(true); R_SetupBuffer(); screen->Unlock(); diff --git a/src/swrenderer/scene/r_scene.h b/src/swrenderer/scene/r_scene.h index 1ad345890..843283813 100644 --- a/src/swrenderer/scene/r_scene.h +++ b/src/swrenderer/scene/r_scene.h @@ -33,6 +33,7 @@ namespace swrenderer void Deinit(); void RenderActorView(AActor *actor, bool dontmaplines = false); + void RenderView(player_t *player); void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false); bool DontMapLines() const { return dontmaplines; }