Skip to content

Taking a Screenshot

Steven Sell edited this page Jun 14, 2016 · 5 revisions

Taking a screenshot involves three short steps:

  1. Retrieve Camera to Capture

     auto camera = OcularCameras->getMainCamera();
    
  2. Refresh the Camera's Render Texture

     auto renderTexture = camera->getRenderTexture();
     renderTexture->refresh();
    
  3. Save the Render Texture to a File

     OcularResources->saveResource(renderTexture, File("screenshot.png"));
    

All together:

auto camera = OcularCameras->getMainCamera();

if(camera)
{
    auto renderTexture = camera->getRenderTexture();

    if(renderTexture)
    {
        renderTexture->refresh();
        OcularResources->saveResource(renderTexture, File("screenshot.png"));
    }
}