Move r_scene into a class

This commit is contained in:
Magnus Norddahl 2017-01-14 02:25:02 +01:00
parent 1c4e0c6385
commit 5ea28897af
5 changed files with 36 additions and 23 deletions

View file

@ -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;

View file

@ -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())

View file

@ -51,9 +51,14 @@ EXTERN_CVAR(Bool, r_shadercolormaps)
namespace swrenderer
{
cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles;
bool r_dontmaplines;
void R_RenderActorView(AActor *actor, bool dontmaplines)
RenderScene *RenderScene::Instance()
{
static RenderScene instance;
return &instance;
}
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();

View file

@ -23,12 +23,21 @@ namespace swrenderer
{
extern cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles;
extern bool r_dontmaplines;
class RenderScene
{
public:
static RenderScene *Instance();
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 Init();
void ScreenResized();
void Deinit();
void R_InitRenderer();
void R_MultiresInit();
void R_ShutdownRenderer();
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; }
private:
bool dontmaplines = false;
};
}

View file

@ -37,5 +37,4 @@ namespace swrenderer
void R_InitTextureMapping();
void R_SetupBuffer();
void R_SetupFreelook();
void R_InitRenderer();
}