Remove SetWindow from FRenderer interface

This commit is contained in:
Magnus Norddahl 2017-01-15 02:46:43 +01:00
parent 1e7015643d
commit 4c12ba740f
8 changed files with 77 additions and 50 deletions

View file

@ -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<ApplySpecialColormapRGBACommand>(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;
}

View file

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

View file

@ -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) {}

View file

@ -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);
}
//==========================================================================

View file

@ -178,45 +178,11 @@ void FSoftwareRenderer::Precache(BYTE *texhitlist, TMap<PClassActor*, bool> &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<ApplySpecialColormapRGBACommand>(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<ApplySpecialColormapRGBACommand>(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();

View file

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

View file

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

View file

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