I have a problem which I dont know how to solve.
I have some 2d-data that is created dynamically by some process. From that data, I create an image and I want to draw the Image. The data is changing over time and with the data change, the presented image should change as well.
What I did so far is:
*1 create an IImage using the video driver:
this->myImage = this->device->getVideoDriver()->createImage(irr::video::ECF_A8R8G8B8, irr::core::dimension2d<irr::u32>(width, height));
*2 fill the image with values:
this->myImage->setPixel(x, y, irr::video::SColor(255, value, value, value));
*3 put the image into a texture:
this->myTexture = this->device->getVideoDriver()->addTexture("Name", this->myImage);
*4 use draw2DImage (in a different class) to draw the image:
if(this->myTexture) driver->draw2DImage(this->myTexture, targetRectangle, rect<s32>(dimension2d<s32>(0,0), this->myTexture->getSize()), 0, 0, false);
If I change the IImage pixel values using step 2 later, the changed values dont show in the texture. So there is the problem. Is there an easy way of telling the texture: "hey, the image has changed. Get the new values now!"? Also, is there a more efficient way of changing the pixel values other than by creating so many SColor objects?
If thats not possible, I would have to create a new texture for each image change. But what happens to the old texture objects? I dont want my memory being polluted with old texture objects. Since I have to use "addTexture", I cant use drop() to destroy the old texture. Also on a related note: is it possible to give each new texture the same name as the last one?