extract the render-to-texture functionality to a separate programme