Load images GPU

Hi guys,

For my game I have been working with very large spritesheets (fullHD) and it’s memory and CPU consumption is becoming a concern. I can’t afford to preload all the images with the project.xml file.

I would like to know if it is possible to load the images during runtime, and to store them on the GPU’s memory, freeing a lot of precious RAM. Has anyone tried to do that?

Best regards,
Fabio

Are you talking about html5 target? I believe that native targets don’t do preloading of assets.

On html5, you can load your images asynchronously with openfl.display.Loader.

I’m not sure OpenFL currently supports releasing images loaded into main memory.

http://www.openfl.org/documentation/api/openfl/display/Loader.html

It seems it doesn’t. Looks like OpenFL implementation always holds images loaded into main memory. You may need to look for another library, or you should modify OpenFL by yourself if you really need that, unfortunately.

You will end up consuming twice as much memory as original image, since the same image will be uploaded to the GPU.

As far as I know there is possible to add embed=“false” into assets tag in the project.xml file (but no info about it on [that][1] page ). Not embedded assets not should be loaded on application start and you can load them when you want by Assets.loadBitmapData(), Assets.loadText() and etc.

If you need to unload any asset, you need to kill all reference (and also call dispose() for bimap data objects ) on it and remove it from Assets.cache - it contains AssetCache object that allows to you to clear all or to remove particular asset by its id.

Also I checked now that for flash target assets are included into swf regardless of exist embed="false" or not.

Calling @singmajesty !

Thank you very much for the quick replies @vroad and @T1mL3arn. I think that my question is more related to the second answer @vroad gave.

I am already using embed=“false” on my project.xml , the problem is that I want to free memory from the loaded images and send them to the GPU. I am seing this method from BitmapData.hx, getTexture. Matbe I can use it to get the GL_TEXTURE and then dispose the Bitmap. However, I don’t really know how to use OpenGL and OpenFL toghether. Do you guys happen to know a good resource to study this?