PDA

View Full Version : CreateOverlayEntity - problem with loading during game



KWilk
04-14-2011, 10:35 AM
Hello!

I have problem with loading resources.
At the loading screen I load all resources (CreateOverlayEntity)
but during the game play in first usage there is a frame rate lag, just like the resources has been loaded at this time.
Is there possible to load all graphic to memory? Something like :

CreateOverlayEntity(... , bool LoadToMemoryNow = false);

Seth
04-14-2011, 10:49 AM
I'm not sure I completely understand the question but you do have complete control over when resources are loaded.

Inside CreateOverlayEntity it creates an OverlayRenderComponent, inside that, it uses GetResourceManager()->GetSurfaceAnim(fileName) to get the image.

By using the ResourceManager it is automatically globally cached, and the instance is shared by anyone who requests it this way.

So, you can request an image at the start of the program (or anywhere) to pre-cache it: (just ignore what it returns as you don't really need it yet)


GetResourceManager()->GetSurfaceAnim("media/mycrap.rttex");

Use GetResourceManager()->KillAllResources() to uncache everything between levels.

Or use DestroyUnusedTextures(); it will intelligently destroy all images that don't appear to be in use by components.

Yogi
04-14-2011, 05:15 PM
I had the same problem. Thank you for solution.