Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Lyoko-Jeremie/d110539a5e87460f6f774ebc3737afda to your computer and use it in GitHub Desktop.
Save Lyoko-Jeremie/d110539a5e87460f6f774ebc3737afda to your computer and use it in GitHub Desktop.
OGRE save render window to image file
// from https://forums.ogre3d.org/viewtopic.php?t=67447
void HDRCtrl::OnBnClickedSaverender()
{
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual(
"MainRenderTarget",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TextureType::TEX_TYPE_2D,
m_w,
m_h,
m_d,
0,
Ogre::PixelFormat::PF_R8G8B8,
Ogre::TextureUsage::TU_RENDERTARGET);
Ogre::RenderTexture *renderTexture = tex->getBuffer()->getRenderTarget();
renderTexture->addViewport(m_camera);
int count = renderTexture->getNumViewports();
renderTexture->getViewport(0)->setClearEveryFrame(true);
renderTexture->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
renderTexture->getViewport(0)->setOverlaysEnabled(false);
renderTexture->update();
// Now save the contents
renderTexture->writeContentsToFile("./RoomRender.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment