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 "gl/data/gl_data.h"
#include "d_net.h" #include "d_net.h"
#include "po_man.h" #include "po_man.h"
#include "st_stuff.h"
#include "swrenderer/scene/r_scene.h" #include "swrenderer/scene/r_scene.h"
#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_viewport.h"
#include "swrenderer/scene/r_light.h" #include "swrenderer/scene/r_light.h"
#include "swrenderer/drawers/r_draw_rgba.h"
EXTERN_CVAR(Bool, r_shadercolormaps)
EXTERN_CVAR(Int, screenblocks) EXTERN_CVAR(Int, screenblocks)
void InitGLRMapinfoData(); void InitGLRMapinfoData();
extern bool r_showviewer; extern bool r_showviewer;
@ -46,6 +49,33 @@ PolyRenderer *PolyRenderer::Instance()
return &scene; 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) void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines)
{ {
const bool savedviewactive = viewactive; const bool savedviewactive = viewactive;
@ -55,6 +85,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
RenderTarget = canvas; RenderTarget = canvas;
swrenderer::bRenderingToCanvas = true; swrenderer::bRenderingToCanvas = true;
R_SetWindow(12, width, height, height, true); R_SetWindow(12, width, height, height, true);
swrenderer::R_SWRSetWindow(12, width, height, height, WidescreenRatio);
viewwindowx = x; viewwindowx = x;
viewwindowy = y; viewwindowy = y;
viewactive = true; viewactive = true;
@ -69,6 +100,9 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
RenderTarget = screen; RenderTarget = screen;
swrenderer::bRenderingToCanvas = false; swrenderer::bRenderingToCanvas = false;
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
float trueratio;
ActiveRatio(width, height, &trueratio);
swrenderer::R_SWRSetWindow(setblocks, width, height, height, WidescreenRatio);
viewactive = savedviewactive; viewactive = savedviewactive;
swrenderer::r_swtruecolor = savedoutputformat; swrenderer::r_swtruecolor = savedoutputformat;
} }

View file

@ -38,8 +38,8 @@ class DCanvas;
class PolyRenderer class PolyRenderer
{ {
public: public:
void RenderView(player_t *player);
void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines); void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines);
void RenderActorView(AActor *actor, bool dontmaplines);
void RenderRemainingPlayerSprites(); void RenderRemainingPlayerSprites();
static PolyRenderer *Instance(); static PolyRenderer *Instance();
@ -52,6 +52,7 @@ public:
bool DontMapLines = false; bool DontMapLines = false;
private: private:
void RenderActorView(AActor *actor, bool dontmaplines);
void ClearBuffers(); void ClearBuffers();
void SetSceneViewport(); void SetSceneViewport();
void SetupPerspectiveMatrix(); void SetupPerspectiveMatrix();

View file

@ -55,7 +55,6 @@ struct FRenderer
virtual void OnModeSet () {} virtual void OnModeSet () {}
virtual void ClearBuffer(int color) = 0; virtual void ClearBuffer(int color) = 0;
virtual void Init() = 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 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 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) {} 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) void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, bool renderingToCanvas)
{ {
float trueratio;
if (windowSize >= 11) if (windowSize >= 11)
{ {
viewwidth = fullWidth; viewwidth = fullWidth;
@ -224,11 +222,10 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, b
if (renderingToCanvas) if (renderingToCanvas)
{ {
WidescreenRatio = fullWidth / (float)fullHeight; WidescreenRatio = fullWidth / (float)fullHeight;
trueratio = WidescreenRatio;
} }
else else
{ {
WidescreenRatio = ActiveRatio(fullWidth, fullHeight, &trueratio); WidescreenRatio = ActiveRatio(fullWidth, fullHeight);
} }
DrawFSHUD = (windowSize == 11); DrawFSHUD = (windowSize == 11);
@ -258,7 +255,6 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, b
if (fov > 170.) fov = 170.; if (fov > 170.) fov = 170.;
} }
FocalTangent = tan(fov.Radians() / 2); 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) void FSoftwareRenderer::RenderView(player_t *player)
{ {
if (r_polyrenderer) if (r_polyrenderer)
{ PolyRenderer::Instance()->RenderView(player);
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();
}
else else
{ RenderScene::Instance()->RenderView(player);
if (r_swtruecolor != screen->IsBgra())
{
r_swtruecolor = screen->IsBgra();
R_InitColumnDrawers();
}
R_BeginDrawerCommands(); FCanvasTextureInfo::UpdateAll();
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();
}
} }
void FSoftwareRenderer::RemapVoxels() 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) void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov)
{ {
BYTE *Pixels = r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels(); BYTE *Pixels = r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels();

View file

@ -33,7 +33,6 @@ struct FSoftwareRenderer : public FRenderer
void OnModeSet () override; void OnModeSet () override;
void ClearBuffer(int color) override; void ClearBuffer(int color) override;
void Init() 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; void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) override;
sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel) 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 "g_level.h"
#include "p_effect.h" #include "p_effect.h"
#include "po_man.h" #include "po_man.h"
#include "st_stuff.h"
#include "r_data/r_interpolate.h" #include "r_data/r_interpolate.h"
#include "swrenderer/scene/r_scene.h" #include "swrenderer/scene/r_scene.h"
#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_viewport.h"
@ -43,6 +44,7 @@
#include "swrenderer/segments/r_portalsegment.h" #include "swrenderer/segments/r_portalsegment.h"
#include "swrenderer/plane/r_visibleplanelist.h" #include "swrenderer/plane/r_visibleplanelist.h"
#include "swrenderer/drawers/r_draw.h" #include "swrenderer/drawers/r_draw.h"
#include "swrenderer/drawers/r_draw_rgba.h"
#include "swrenderer/drawers/r_thread.h" #include "swrenderer/drawers/r_thread.h"
#include "swrenderer/r_memory.h" #include "swrenderer/r_memory.h"
@ -58,6 +60,34 @@ namespace swrenderer
return &instance; 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) void RenderScene::RenderActorView(AActor *actor, bool dontmaplines)
{ {
WallCycles.Reset(); WallCycles.Reset();
@ -165,6 +195,8 @@ namespace swrenderer
bRenderingToCanvas = true; bRenderingToCanvas = true;
R_SetWindow(12, width, height, height, true); R_SetWindow(12, width, height, height, true);
R_SWRSetWindow(12, width, height, height, WidescreenRatio);
viewwindowx = x; viewwindowx = x;
viewwindowy = y; viewwindowy = y;
viewactive = true; viewactive = true;
@ -175,7 +207,11 @@ namespace swrenderer
RenderTarget = screen; RenderTarget = screen;
bRenderingToCanvas = false; bRenderingToCanvas = false;
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
float trueratio;
ActiveRatio(width, height, &trueratio);
R_SWRSetWindow(setblocks, width, height, height, WidescreenRatio);
screen->Lock(true); screen->Lock(true);
R_SetupBuffer(); R_SetupBuffer();
screen->Unlock(); screen->Unlock();

View file

@ -33,6 +33,7 @@ namespace swrenderer
void Deinit(); void Deinit();
void RenderActorView(AActor *actor, bool dontmaplines = false); 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); void RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false);
bool DontMapLines() const { return dontmaplines; } bool DontMapLines() const { return dontmaplines; }