From 91d180bec65cefbe271b54902f5c37839df9111e Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 23 Nov 2016 21:10:19 +0100 Subject: [PATCH] Fix render to texture --- src/r_poly.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/r_poly.cpp b/src/r_poly.cpp index 04e5becde..d51d01f9b 100644 --- a/src/r_poly.cpp +++ b/src/r_poly.cpp @@ -67,14 +67,21 @@ void RenderPolyScene::ClearBuffers() void RenderPolyScene::SetSceneViewport() { - int height; - if (screenblocks >= 10) - height = SCREENHEIGHT; - else - height = (screenblocks*SCREENHEIGHT / 10) & ~7; + if (RenderTarget == screen) // Rendering to screen + { + int height; + if (screenblocks >= 10) + height = SCREENHEIGHT; + else + height = (screenblocks*SCREENHEIGHT / 10) & ~7; - int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); - PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, RenderTarget); + int bottom = SCREENHEIGHT - (height + viewwindowy - ((height - viewheight) / 2)); + PolyTriangleDrawer::set_viewport(viewwindowx, SCREENHEIGHT - bottom - height, viewwidth, height, RenderTarget); + } + else // Rendering to camera texture + { + PolyTriangleDrawer::set_viewport(0, 0, RenderTarget->GetWidth(), RenderTarget->GetHeight(), RenderTarget); + } } void RenderPolyScene::SetupPerspectiveMatrix()