diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp index 416fa7efb..da506602c 100644 --- a/src/swrenderer/line/r_line.cpp +++ b/src/swrenderer/line/r_line.cpp @@ -638,7 +638,7 @@ namespace swrenderer linedef = curline->linedef; // mark the segment as visible for auto map - if (!r_dontmaplines) linedef->flags |= ML_MAPPED; + if (!RenderScene::Instance()->DontMapLines()) linedef->flags |= ML_MAPPED; midtexture = toptexture = bottomtexture = 0; diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index d1397f10b..a315385a3 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -93,7 +93,7 @@ void FSoftwareRenderer::Init() gl_ParseDefs(); r_swtruecolor = screen->IsBgra(); - R_InitRenderer(); + RenderScene::Instance()->Init(); } //========================================================================== @@ -224,7 +224,7 @@ void FSoftwareRenderer::RenderView(player_t *player) } R_BeginDrawerCommands(); - R_RenderActorView (player->mo); + RenderScene::Instance()->RenderActorView(player->mo); // [RH] Let cameras draw onto textures that were visible this frame. FCanvasTextureInfo::UpdateAll (); @@ -268,7 +268,7 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi if (r_polyrenderer) PolyRenderer::Instance()->RenderViewToCanvas(player->mo, pic, 0, 0, width, height, true); else - R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height); + RenderScene::Instance()->RenderViewToCanvas (player->mo, pic, 0, 0, width, height); screen->GetFlashedPalette (palette); M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch()); pic->Unlock (); @@ -323,7 +323,7 @@ bool FSoftwareRenderer::RequireGLNodes() void FSoftwareRenderer::OnModeSet () { - R_MultiresInit (); + RenderScene::Instance()->ScreenResized(); RenderTarget = screen; screen->Lock (true); @@ -413,7 +413,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin if (r_polyrenderer) PolyRenderer::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); else - R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); + RenderScene::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate); R_SetFOV (savedfov); if (Canvas->IsBgra()) diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp index 50e20be72..75946f367 100644 --- a/src/swrenderer/scene/r_scene.cpp +++ b/src/swrenderer/scene/r_scene.cpp @@ -51,9 +51,14 @@ EXTERN_CVAR(Bool, r_shadercolormaps) namespace swrenderer { cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles; - bool r_dontmaplines; + + RenderScene *RenderScene::Instance() + { + static RenderScene instance; + return &instance; + } - void R_RenderActorView(AActor *actor, bool dontmaplines) + void RenderScene::RenderActorView(AActor *actor, bool dontmaplines) { WallCycles.Reset(); PlaneCycles.Reset(); @@ -85,7 +90,7 @@ namespace swrenderer RenderPortal::Instance()->SetMainPortal(); - r_dontmaplines = dontmaplines; + this->dontmaplines = dontmaplines; // [RH] Hack to make windows into underwater areas possible RenderOpaquePass::Instance()->ResetFakingUnderwater(); @@ -138,7 +143,7 @@ namespace swrenderer } } - void R_RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) + void RenderScene::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines) { const bool savedviewactive = viewactive; const bool savedoutputformat = r_swtruecolor; @@ -160,7 +165,7 @@ namespace swrenderer viewwindowy = y; viewactive = true; - R_RenderActorView(actor, dontmaplines); + RenderActorView(actor, dontmaplines); R_EndDrawerCommands(); @@ -180,14 +185,14 @@ namespace swrenderer } } - void R_MultiresInit() + void RenderScene::ScreenResized() { VisiblePlaneList::Instance()->Init(); } - void R_InitRenderer() + void RenderScene::Init() { - atterm(R_ShutdownRenderer); + atterm([]() { RenderScene::Instance()->Deinit(); }); // viewwidth / viewheight are set by the defaults fillshort(zeroarray, MAXWIDTH, 0); @@ -195,7 +200,7 @@ namespace swrenderer R_InitColumnDrawers(); } - void R_ShutdownRenderer() + void RenderScene::Deinit() { RenderTranslucentPass::Deinit(); VisiblePlaneList::Instance()->Deinit(); diff --git a/src/swrenderer/scene/r_scene.h b/src/swrenderer/scene/r_scene.h index 5b5a951bc..1ad345890 100644 --- a/src/swrenderer/scene/r_scene.h +++ b/src/swrenderer/scene/r_scene.h @@ -22,13 +22,22 @@ extern cycle_t FrameCycles; namespace swrenderer { extern cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles; + + class RenderScene + { + public: + static RenderScene *Instance(); - extern bool r_dontmaplines; + void Init(); + void ScreenResized(); + void Deinit(); + + void RenderActorView(AActor *actor, bool dontmaplines = false); + void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false); + + bool DontMapLines() const { return dontmaplines; } - void R_RenderActorView(AActor *actor, bool dontmaplines = false); - void R_RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false); - - void R_InitRenderer(); - void R_MultiresInit(); - void R_ShutdownRenderer(); + private: + bool dontmaplines = false; + }; } diff --git a/src/swrenderer/scene/r_viewport.h b/src/swrenderer/scene/r_viewport.h index 2fa32988e..6638a8592 100644 --- a/src/swrenderer/scene/r_viewport.h +++ b/src/swrenderer/scene/r_viewport.h @@ -37,5 +37,4 @@ namespace swrenderer void R_InitTextureMapping(); void R_SetupBuffer(); void R_SetupFreelook(); - void R_InitRenderer(); }