- reworked canvas texture updater to avoid passing game data to the render backends.

These are now handled one level above using a callback to perform the actual rendering.
This commit is contained in:
Christoph Oelckers 2020-04-25 14:13:36 +02:00
commit 730d07fbf7
7 changed files with 37 additions and 21 deletions

View file

@ -261,7 +261,12 @@ sector_t *PolyFrameBuffer::RenderView(player_t *player)
{
Level->canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
{
RenderTextureView(camtex, camera, fov);
RenderTextureView(camtex, [=](IntRect &bounds)
{
FRenderViewpoint texvp;
float ratio = camtex->aspectRatio;
RenderViewpoint(texvp, camera, &bounds, fov, ratio, ratio, false, false);
});
});
}
NoInterpolateView = saved_niv;
@ -285,7 +290,7 @@ sector_t *PolyFrameBuffer::RenderView(player_t *player)
}
void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
void PolyFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect &)> renderFunc)
{
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
auto BaseLayer = static_cast<PolyHardwareTexture*>(tex->GetHardwareTexture(0, 0));
@ -300,8 +305,7 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
bounds.width = std::min(tex->GetWidth(), image->GetWidth());
bounds.height = std::min(tex->GetHeight(), image->GetHeight());
FRenderViewpoint texvp;
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
renderFunc(bounds);
FlushDrawCommands();
DrawerThreads::WaitForWorkers();