mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 16:41:22 +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;
|
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;
|
||||||
|
if (Viewpoint.camera)
|
||||||
|
{
|
||||||
|
savedflags = Viewpoint.camera->renderflags;
|
||||||
|
|
||||||
// Never draw the player unless in chasecam mode
|
// Never draw the player unless in chasecam mode
|
||||||
if (!Viewpoint.showviewer)
|
if (!Viewpoint.showviewer)
|
||||||
Viewpoint.camera->renderflags |= RF_INVISIBLE;
|
Viewpoint.camera->renderflags |= RF_INVISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
ScreenTriangle::FuzzStart = (ScreenTriangle::FuzzStart + 14) % FUZZTABLE;
|
ScreenTriangle::FuzzStart = (ScreenTriangle::FuzzStart + 14) % FUZZTABLE;
|
||||||
|
|
||||||
|
@ -147,6 +163,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
||||||
Scene.RenderTranslucent(&mainViewpoint);
|
Scene.RenderTranslucent(&mainViewpoint);
|
||||||
PlayerSprites.Render(Threads.MainThread());
|
PlayerSprites.Render(Threads.MainThread());
|
||||||
|
|
||||||
|
if (Viewpoint.camera)
|
||||||
Viewpoint.camera->renderflags = savedflags;
|
Viewpoint.camera->renderflags = savedflags;
|
||||||
interpolator.RestoreInterpolations ();
|
interpolator.RestoreInterpolations ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue