Custom GameViewportClient: Render off-screen

This code is for off screen rendering in editor mode. I want to do it in game mode. How to do?