Draw UTextureRenderTarget2D in Viewport

Hi everyone,

I have a UTextureRenderTarget2D that is updated every tick and I would like to draw it to the main game window. How would that be done in C++?

I already tried getting the UGameViewportClient with
CameraViewportClient = GetWorld()->GetGameViewport(), then getting the FSceneViewport with
CameraViewport = CameraViewportClient->GetGameViewport(). Then in my render thread I access my UTextureRenderTarget2D CaptureRenderTarget:

auto RenderResource = static_cast<const FTextureRenderTarget2DResource *>(CaptureRenderTarget->Resource);
FTexture2DRHIRef& Texture = (FTexture2DRHIRef&)RenderResource->GetRenderTargetTexture();
CameraViewport->SetRenderTargetTextureRenderThread(Texture);

My code compiles, the game runs, but the TextureRenderTarget2D is not drawn to the game window.

I’ve been through the forum and couldn’t find a solution for that exact problem, but I hope there is one.

Best regards
Robert