Change RenderTarget global to be an internal swrenderer variable

This commit is contained in:
Magnus Norddahl 2017-01-15 03:19:03 +01:00
parent aaee6e333f
commit f9175561bb
10 changed files with 42 additions and 26 deletions

View file

@ -694,8 +694,6 @@ void D_Display ()
} }
} }
RenderTarget = screen;
// change the view size if needed // change the view size if needed
if (setsizeneeded && StatusBar != NULL) if (setsizeneeded && StatusBar != NULL)
{ {

View file

@ -53,6 +53,8 @@ void PolyRenderer::RenderView(player_t *player)
{ {
using namespace swrenderer; using namespace swrenderer;
swrenderer::RenderTarget = screen;
bool saved_swtruecolor = r_swtruecolor; bool saved_swtruecolor = r_swtruecolor;
r_swtruecolor = screen->IsBgra(); r_swtruecolor = screen->IsBgra();
@ -82,7 +84,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
const bool savedoutputformat = swrenderer::r_swtruecolor; const bool savedoutputformat = swrenderer::r_swtruecolor;
viewwidth = width; viewwidth = width;
RenderTarget = canvas; swrenderer::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); swrenderer::R_SWRSetWindow(12, width, height, height, WidescreenRatio);
@ -97,7 +99,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
canvas->Unlock(); canvas->Unlock();
RenderTarget = screen; swrenderer::RenderTarget = screen;
swrenderer::bRenderingToCanvas = false; swrenderer::bRenderingToCanvas = false;
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
float trueratio; float trueratio;
@ -153,8 +155,8 @@ void PolyRenderer::RenderRemainingPlayerSprites()
void PolyRenderer::ClearBuffers() void PolyRenderer::ClearBuffers()
{ {
PolyVertexBuffer::Clear(); PolyVertexBuffer::Clear();
PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0); PolyStencilBuffer::Instance()->Clear(swrenderer::RenderTarget->GetWidth(), swrenderer::RenderTarget->GetHeight(), 0);
PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight()); PolySubsectorGBuffer::Instance()->Resize(swrenderer::RenderTarget->GetPitch(), swrenderer::RenderTarget->GetHeight());
NextStencilValue = 0; NextStencilValue = 0;
SeenLinePortals.clear(); SeenLinePortals.clear();
SeenMirrors.clear(); SeenMirrors.clear();
@ -162,6 +164,8 @@ void PolyRenderer::ClearBuffers()
void PolyRenderer::SetSceneViewport() void PolyRenderer::SetSceneViewport()
{ {
using namespace swrenderer;
if (RenderTarget == screen) // Rendering to screen if (RenderTarget == screen) // Rendering to screen
{ {
int height; int height;

View file

@ -165,12 +165,12 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
double texturemid = (BaseYCenter - sy) * tex->Scale.Y + tex->TopOffset; double texturemid = (BaseYCenter - sy) * tex->Scale.Y + tex->TopOffset;
// Adjust PSprite for fullscreen views // Adjust PSprite for fullscreen views
if (camera->player && (RenderTarget != screen || viewheight == RenderTarget->GetHeight() || (RenderTarget->GetWidth() > (BaseXCenter * 2) && !st_scale))) if (camera->player && (swrenderer::RenderTarget != screen || viewheight == swrenderer::RenderTarget->GetHeight() || (swrenderer::RenderTarget->GetWidth() > (BaseXCenter * 2) && !st_scale)))
{ {
AWeapon *weapon = dyn_cast<AWeapon>(sprite->GetCaller()); AWeapon *weapon = dyn_cast<AWeapon>(sprite->GetCaller());
if (weapon != nullptr && weapon->YAdjust != 0) if (weapon != nullptr && weapon->YAdjust != 0)
{ {
if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) if (swrenderer::RenderTarget != screen || viewheight == swrenderer::RenderTarget->GetHeight())
{ {
texturemid -= weapon->YAdjust; texturemid -= weapon->YAdjust;
} }
@ -338,7 +338,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
// Check for hardware-assisted 2D. If it's available, and this sprite is not // Check for hardware-assisted 2D. If it's available, and this sprite is not
// fuzzy, don't draw it until after the switch to 2D mode. // fuzzy, don't draw it until after the switch to 2D mode.
if (!noaccel && RenderTarget == screen && (DFrameBuffer *)screen->Accel2D) if (!noaccel && swrenderer::RenderTarget == screen && (DFrameBuffer *)screen->Accel2D)
{ {
FRenderStyle style = visstyle.RenderStyle; FRenderStyle style = visstyle.RenderStyle;
style.CheckFuzz(); style.CheckFuzz();

View file

@ -100,8 +100,6 @@ CUSTOM_CVAR(Float, r_quakeintensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
else if (self > 1.f) self = 1.f; else if (self > 1.f) self = 1.f;
} }
DCanvas *RenderTarget; // [RH] canvas to render to
int viewwindowx; int viewwindowx;
int viewwindowy; int viewwindowy;
@ -908,7 +906,7 @@ void R_SetupFrame (AActor *actor)
validcount++; validcount++;
if (RenderTarget == screen && r_clearbuffer != 0) if (r_clearbuffer != 0)
{ {
int color; int color;
int hom = r_clearbuffer; int hom = r_clearbuffer;

View file

@ -12,8 +12,6 @@ class FSerializer;
// There a 0-31, i.e. 32 LUT in the COLORMAP lump. // There a 0-31, i.e. 32 LUT in the COLORMAP lump.
#define NUMCOLORMAPS 32 #define NUMCOLORMAPS 32
extern DCanvas *RenderTarget;
extern DVector3 ViewPos; extern DVector3 ViewPos;
extern DVector3 ViewActorPos; extern DVector3 ViewActorPos;
extern DAngle ViewAngle; extern DAngle ViewAngle;

View file

@ -244,18 +244,7 @@ void FSoftwareRenderer::OnModeSet ()
void FSoftwareRenderer::ClearBuffer(int color) void FSoftwareRenderer::ClearBuffer(int color)
{ {
if (!r_swtruecolor) RenderScene::Instance()->SetClearColor(color);
{
memset(RenderTarget->GetBuffer(), color, RenderTarget->GetPitch() * RenderTarget->GetHeight());
}
else
{
uint32_t bgracolor = GPalette.BaseColors[color].d;
int size = RenderTarget->GetPitch() * RenderTarget->GetHeight();
uint32_t *dest = (uint32_t *)RenderTarget->GetBuffer();
for (int i = 0; i < size; i++)
dest[i] = bgracolor;
}
} }
void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov)

View file

@ -49,6 +49,7 @@
#include "swrenderer/r_memory.h" #include "swrenderer/r_memory.h"
EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Bool, r_shadercolormaps)
EXTERN_CVAR(Int, r_clearbuffer)
namespace swrenderer namespace swrenderer
{ {
@ -60,8 +61,15 @@ namespace swrenderer
return &instance; return &instance;
} }
void RenderScene::SetClearColor(int color)
{
clearcolor = color;
}
void RenderScene::RenderView(player_t *player) void RenderScene::RenderView(player_t *player)
{ {
RenderTarget = screen;
int width = SCREENWIDTH; int width = SCREENWIDTH;
int height = SCREENHEIGHT; int height = SCREENHEIGHT;
int stHeight = ST_Y; int stHeight = ST_Y;
@ -75,6 +83,22 @@ namespace swrenderer
R_InitColumnDrawers(); R_InitColumnDrawers();
} }
if (r_clearbuffer != 0)
{
if (!r_swtruecolor)
{
memset(RenderTarget->GetBuffer(), clearcolor, RenderTarget->GetPitch() * RenderTarget->GetHeight());
}
else
{
uint32_t bgracolor = GPalette.BaseColors[clearcolor].d;
int size = RenderTarget->GetPitch() * RenderTarget->GetHeight();
uint32_t *dest = (uint32_t *)RenderTarget->GetBuffer();
for (int i = 0; i < size; i++)
dest[i] = bgracolor;
}
}
R_BeginDrawerCommands(); R_BeginDrawerCommands();
RenderActorView(player->mo); RenderActorView(player->mo);

View file

@ -32,6 +32,8 @@ namespace swrenderer
void ScreenResized(); void ScreenResized();
void Deinit(); void Deinit();
void SetClearColor(int color);
void RenderActorView(AActor *actor, bool dontmaplines = false); void RenderActorView(AActor *actor, bool dontmaplines = false);
void RenderView(player_t *player); 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);
@ -40,5 +42,6 @@ namespace swrenderer
private: private:
bool dontmaplines = false; bool dontmaplines = false;
int clearcolor = 0;
}; };
} }

View file

@ -44,6 +44,7 @@ namespace swrenderer
double FocalLengthX; double FocalLengthX;
double FocalLengthY; double FocalLengthY;
DCanvas *RenderTarget;
bool bRenderingToCanvas; bool bRenderingToCanvas;
double globaluclip, globaldclip; double globaluclip, globaldclip;
double CenterX, CenterY; double CenterX, CenterY;

View file

@ -18,6 +18,7 @@
namespace swrenderer namespace swrenderer
{ {
extern DCanvas *RenderTarget;
extern bool bRenderingToCanvas; extern bool bRenderingToCanvas;
extern fixed_t viewingrangerecip; extern fixed_t viewingrangerecip;
extern double FocalLengthX; extern double FocalLengthX;