Runtime loading of resources

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

Post Reply
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Runtime loading of resources

Post by Rado1 »

It would be nice to allow dynamic runtime loading of bitmaps, meshes, sounds, etc. There can be several possibilities how to do it. A simple solution would be to have the string property Path of BitmapFromFile, MeshImport, SampleImport and Music.

As the first step, the Path is set, then, RefreshContent component is called.

Example:

Code: Select all

MyBitmapFromFile.Path = "./picture1.jpg";
@RefreshContent(Component: MyBitmapFromFile); // or refresh the whole enclosing bitmap
Advanced feature: accessing files on Android devices. For instance, pictures in gallery.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado,

This has actually been discussed a couple of times in the past. Here are some quotes from back in 2009 ..
Kjell wrote:Correct me if I'm wrong ( Ville ), but I believe one of the reasons ZGE builds such small exe's is that it doesn't include importers for file formats such as bmp, 3ds and wav. Instead, files are converted into the "native" engine formats when they are imported by the Editor.
Ville wrote:One of the early design decisions about the ZGE-engine was to minimize the number of files needed to redistribute the games. There are several reasons:

- No external dependencies to other files in runtime. If you have the exe then it will work. My opinion is that single file distributions are elegant.
- No external dependencies to other files also in designer. The whole project is in the zgeproj-file.
- Whole program including data can be compressed with exe-compressors
- And as Kjell mentions, no file format parsers are needed in runtime. When you import 3ds, bitmaps and audio into ZGE it is converted to a simple internal format. Having 3ds/jpg/bmp/tga/mp3 parsers built into the runtime would significantly increase runtime size and complexity.

Having said the above, I would imagine that when we start expanding the scripting-functions with functionality it would be very useful to add some kind of "loadTexture('setse.tga');" function. So I won't rule it out totally but it won't happen in short-term.
Anyway, you can already do this by scripting your own parser and using the File component. I've posted a ( outdated .. because we have xptr now ) example here.

K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Kjell you have a good memory and probably better knowledge of ZGE history than myself :)

Since we included the excellent and very small NanoJpg library in the runtime we could allow dynamic loading of jpg-images.

Anyway the first step is to allow any file access (using File component) on Android because right now it isn't implemented. And to implement external library too so that BASS library etc can be used.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi guys,

It's probably worth noting that progressive JPEGs aren't supported by NanoJPEG / ZGE, so not every JPEG will work.

Also, ZGE doesn't have any folder / file scanning at the moment, so you have to know the full path ( including filename ) of any files you want to load dynamically beforehand.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Thank you all for answers. In my next project on Android I just wanted to browse image gallery (eg. /sdcard/DCIM/Camera) and loading pictures from it to ZGE's Bitmap to be used as textures (or to display them in another way). As far as I understand, you recommend to use an external library. Do you have any idea which library to use, or should I write my own?
Post Reply