Fix render to texture

This commit is contained in:
Magnus Norddahl 2019-12-08 01:39:17 +01:00
commit fdb93309fe
7 changed files with 43 additions and 23 deletions

View file

@ -97,6 +97,7 @@ void PolyFrameBuffer::CheckCanvas()
{
if (!mCanvas || mCanvas->GetWidth() != GetWidth() || mCanvas->GetHeight() != GetHeight())
{
FlushDrawCommands();
DrawerThreads::WaitForWorkers();
mCanvas.reset(new DCanvas(0, 0, true));
@ -104,7 +105,7 @@ void PolyFrameBuffer::CheckCanvas()
mDepthStencil.reset();
mDepthStencil.reset(new PolyDepthStencil(GetWidth(), GetHeight()));
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil());
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil(), true);
}
}
@ -342,7 +343,7 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
int height = mat->TextureHeight();
DCanvas *image = BaseLayer->GetImage(tex, 0, 0);
PolyDepthStencil *depthStencil = BaseLayer->GetDepthStencil(tex);
mRenderState->SetRenderTarget(image, depthStencil);
mRenderState->SetRenderTarget(image, depthStencil, false);
IntRect bounds;
bounds.left = bounds.top = 0;
@ -352,8 +353,9 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
FRenderViewpoint texvp;
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
FlushDrawCommands();
DrawerThreads::WaitForWorkers();
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil());
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil(), true);
tex->SetUpdated(true);
}