- fix softpoly canvas drawing not restoring all globals properly

- add null pointer check on camera
This commit is contained in:
Magnus Norddahl 2018-04-15 16:05:29 +02:00
parent bb037635a8
commit 21c2d38342

View file

@ -62,11 +62,6 @@ void PolyRenderer::RenderView(player_t *player, DCanvas *target)
RenderTarget = target; RenderTarget = target;
RenderToCanvas = false; RenderToCanvas = false;
int width = SCREENWIDTH;
int height = SCREENHEIGHT;
float trueratio;
ActiveRatio(width, height, &trueratio);
//viewport->SetViewport(&Thread, width, height, trueratio);
RenderActorView(player->mo, false); RenderActorView(player->mo, false);
@ -78,24 +73,40 @@ void PolyRenderer::RenderView(player_t *player, DCanvas *target)
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; // Save a bunch of silly globals:
auto savedViewpoint = Viewpoint;
auto savedViewwindow = Viewwindow;
auto savedviewwindowx = viewwindowx;
auto savedviewwindowy = viewwindowy;
auto savedviewwidth = viewwidth;
auto savedviewheight = viewheight;
auto savedviewactive = viewactive;
auto savedRenderTarget = RenderTarget;
viewwidth = width; // Setup the view:
RenderTarget = canvas; RenderTarget = canvas;
RenderToCanvas = true; RenderToCanvas = true;
R_SetWindow(Viewpoint, Viewwindow, 12, width, height, height, true); R_SetWindow(Viewpoint, Viewwindow, 12, width, height, height, true);
//viewport->SetViewport(&Thread, width, height, Viewwindow.WidescreenRatio);
viewwindowx = x; viewwindowx = x;
viewwindowy = y; viewwindowy = y;
viewactive = true; viewactive = true;
// Render:
RenderActorView(actor, dontmaplines); RenderActorView(actor, dontmaplines);
Threads.MainThread()->FlushDrawQueue(); Threads.MainThread()->FlushDrawQueue();
DrawerThreads::WaitForWorkers(); DrawerThreads::WaitForWorkers();
RenderTarget = nullptr;
RenderToCanvas = false; RenderToCanvas = false;
// Restore silly globals:
Viewpoint = savedViewpoint;
Viewwindow = savedViewwindow;
viewwindowx = savedviewwindowx;
viewwindowy = savedviewwindowy;
viewwidth = savedviewwidth;
viewheight = savedviewheight;
viewactive = savedviewactive; viewactive = savedviewactive;
RenderTarget = savedRenderTarget;
} }
void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines) void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
@ -126,10 +137,15 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
PolyCameraLight::Instance()->SetCamera(Viewpoint, RenderTarget, actor); PolyCameraLight::Instance()->SetCamera(Viewpoint, RenderTarget, actor);
//Viewport->SetupFreelook(); //Viewport->SetupFreelook();
ActorRenderFlags savedflags = Viewpoint.camera->renderflags; ActorRenderFlags savedflags = 0;
// Never draw the player unless in chasecam mode if (Viewpoint.camera)
if (!Viewpoint.showviewer) {
Viewpoint.camera->renderflags |= RF_INVISIBLE; savedflags = Viewpoint.camera->renderflags;
// Never draw the player unless in chasecam mode
if (!Viewpoint.showviewer)
Viewpoint.camera->renderflags |= RF_INVISIBLE;
}
ScreenTriangle::FuzzStart = (ScreenTriangle::FuzzStart + 14) % FUZZTABLE; ScreenTriangle::FuzzStart = (ScreenTriangle::FuzzStart + 14) % FUZZTABLE;
@ -147,7 +163,8 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
Scene.RenderTranslucent(&mainViewpoint); Scene.RenderTranslucent(&mainViewpoint);
PlayerSprites.Render(Threads.MainThread()); PlayerSprites.Render(Threads.MainThread());
Viewpoint.camera->renderflags = savedflags; if (Viewpoint.camera)
Viewpoint.camera->renderflags = savedflags;
interpolator.RestoreInterpolations (); interpolator.RestoreInterpolations ();
NetUpdate(); NetUpdate();