Change the ManualResourceLoader for texture?

Problems building or running the engine, queries about how to use features etc.
Post Reply
zone1
Gnoblar
Posts: 7
Joined: Wed Jan 29, 2014 4:09 am

Change the ManualResourceLoader for texture?

Post by zone1 »

I'm creating textures dynamically so they require manual resource loaders. It worked fine till I changed my code a bit. Because of the change, I have to replace the ManualResourceLoader object I pass in the Texture's constructor, but it seems this is not possible in the current Ogre API. Maybe I have overlooked something? I'm using ogre 1.9.0.

You might ask, why would anyone need to change the ManualResourceLoader object. I have an STL vector of some type, and each object in this vector has a dynamically created texture. For example:
std::vector<TexOwner*> textures; // It's called differently in the real code but that doesn't matter.
textures.push_back(new TexOwner()); // Inside the TexOwner I create Textures as new Texture(...., this) - passing the this pointer as the ManualResourceLoader.

This worked, till I changed TexOwner* (a pointer) to TexOwner (not pointer :p), because it is not really useful to have a vector of pointers in my situation. (Since c++11 you can have move constructors of objects so there's way less data duplicating involved.) The problem is, that each texture had a TexOwner as its ManualResourceLoader, but these TexOwners are moved now, so their pointer changes as the vector is resized.

Of course there are infinite ways to work around this problem, but it would be better if I wouldn't have to.
Post Reply