I'm using Ogre 1.10, I have a dynamic texture assigned to a material that I need to update its buffer with a new image every few seconds. How can I transfer pixel data from an image to my dynamic texture?
I've created a manual texture like:
// Create the texture Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "dyn_texture", // name Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, // type 256, 256, // width & height 0, // number of mipmaps Ogre::PF_BYTE_BGRA, // pixel format Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
And on my update function I have the image that I want to transfer:
Ogre::Image img; img.load(basename.toStdString(), "resources"); //Copy pixels from img to texture //??
I've already tried doing:
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer(); pixelBuffer->blitFromMemory(img.getPixelBox());
works but it's quite slow, gui freezes when updating like that.