// sync load of a texture, loads and returns after texture is fully loaded
Texture* pTex = resourceManager()->load("maka.png");
// we got the texture, use it
int w = pTex->width();
int h = pTex->height();
// do something with w and h
ResourceId myTextureId = 3493; // or we can use: resourceId("maka.png") to get the id
struct MyResObserver : public IResourceObserver
{
void onResourceLoaded(Resource* pRes)
{
Texture* pTex = dynamic_cast<Texture*>(pRes);
if (pTex && pTex->id() == myTextureId)
{
int w = pTex->width();
int h = pTex->height();
// use w and h
}
}
} myObserver;
///....................
void someClass::someInit()
{
// we add our observer into the manager's list
resourceManager()->addObserver(&myObserver);
// async loading, returns right away, the resource will be loaded later on
resourceManager()->load(myTextureId);
// or we could do: resourceManager()->load(someTextureId, &myObserver);
}
Any other ideas would be welcomed, thanks.