mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- fix softpoly canvas drawing not restoring all globals properly
- add null pointer check on camera
This commit is contained in:
parent
bb037635a8
commit
21c2d38342
1 changed files with 31 additions and 14 deletions
|
@ -62,11 +62,6 @@ void PolyRenderer::RenderView(player_t *player, DCanvas *target)
|
|||
|
||||
RenderTarget = target;
|
||||
RenderToCanvas = false;
|
||||
int width = SCREENWIDTH;
|
||||
int height = SCREENHEIGHT;
|
||||
float trueratio;
|
||||
ActiveRatio(width, height, &trueratio);
|
||||
//viewport->SetViewport(&Thread, width, height, trueratio);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
RenderToCanvas = true;
|
||||
R_SetWindow(Viewpoint, Viewwindow, 12, width, height, height, true);
|
||||
//viewport->SetViewport(&Thread, width, height, Viewwindow.WidescreenRatio);
|
||||
viewwindowx = x;
|
||||
viewwindowy = y;
|
||||
viewactive = true;
|
||||
|
||||
// Render:
|
||||
RenderActorView(actor, dontmaplines);
|
||||
Threads.MainThread()->FlushDrawQueue();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
||||
RenderTarget = nullptr;
|
||||
RenderToCanvas = false;
|
||||
|
||||
// Restore silly globals:
|
||||
Viewpoint = savedViewpoint;
|
||||
Viewwindow = savedViewwindow;
|
||||
viewwindowx = savedviewwindowx;
|
||||
viewwindowy = savedviewwindowy;
|
||||
viewwidth = savedviewwidth;
|
||||
viewheight = savedviewheight;
|
||||
viewactive = savedviewactive;
|
||||
RenderTarget = savedRenderTarget;
|
||||
}
|
||||
|
||||
void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
||||
|
@ -126,10 +137,15 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
|||
PolyCameraLight::Instance()->SetCamera(Viewpoint, RenderTarget, actor);
|
||||
//Viewport->SetupFreelook();
|
||||
|
||||
ActorRenderFlags savedflags = Viewpoint.camera->renderflags;
|
||||
// Never draw the player unless in chasecam mode
|
||||
if (!Viewpoint.showviewer)
|
||||
Viewpoint.camera->renderflags |= RF_INVISIBLE;
|
||||
ActorRenderFlags savedflags = 0;
|
||||
if (Viewpoint.camera)
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -147,7 +163,8 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
|||
Scene.RenderTranslucent(&mainViewpoint);
|
||||
PlayerSprites.Render(Threads.MainThread());
|
||||
|
||||
Viewpoint.camera->renderflags = savedflags;
|
||||
if (Viewpoint.camera)
|
||||
Viewpoint.camera->renderflags = savedflags;
|
||||
interpolator.RestoreInterpolations ();
|
||||
|
||||
NetUpdate();
|
||||
|
|
Loading…
Reference in a new issue