gre.load_resource( pool_name, resource_name, [pool parameters] )
This function will force the loading of a resource, such as an image or font, into the Storyboard application. This can be used in order to avoid load time delays that may be incurred as resources are lazy loaded into the application.
This call can only be made from the main Lua action execution thread.
Parameters:
pool_name The name of the resource pool: image
or font
resource_name The name of the resource that is to be loaded
The optional parameters vary depending on the pool being specified may not be required:
image pool:
w The width to cache the image at
h The height to cache the image at
background Whether or not to load the image asynchronously the 'background'. Asynchronous loading
capabilities are determined by the hardware rendering capabilities of the system and
may require serialization with the main rendering thread for a complete load to occur.
font pool:
size The point size of the font to load (required)
antialias A flag indicating if anti aliasing is to be used
These options should be passed as a table as the third parameter to ensure that the loader receives the
appropriate values.
On completion of a 'background' loaded resource, the following event is sent:
gre.resource_loaded 1s0 resource
Example:
-- Call this to pre-load the image and font into the cache function on_app_init(mapargs) -- Call this to pre-load a font at a 24pt size local opt = {} opt.size = 24 gre.load_resource("font", "fonts/DejaVu.ttf", opt) -- Call this to pre-load the image unscaled gre.load_resource("image", "images/tree.jpg") -- Call this to pre-load the image and scale it to 100x100 local opt = {} opt.w = 100 opt.h = 100 gre.load_resource("image", "images/scaledtree.jpg", opt) -- Call this to pre-load the image and scale it to 100x100 asynchronously local opt = {} opt.w = 100 opt.h = 100 opt.background = 1 gre.load_resource("image", "images/scaledtreebg.jpg", opt) end