- Online Community Forums » Programming Questions » preloaded resources

This thread is locked; no one can reply to it. rss feed Print
preloaded resources
Member #14,368
June 2012

I'm using Allegro 5.1.2 and have all resources embedded in exe through zip.
On application start I unpack archive and get files one by one already loaded in memory.
So there is simple question I didn't found answer to (on site, wiki or forums):
Can allegro use that already preloaded data for resources somehow? Maybe through ALLEGRO_FILE_INTERFACE???
thx in advance;)

Arthur Kalliokoski
Second in Command
February 2005

Do you have the examples? Check out ex_memfile.c.

Also in the manual:

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Member #14,368
June 2012

Oh, thank you, that's just what I was needed:)
Wondering about why I didn't find it by myself...

Member #7,827
October 2006

You can also skip the manual unpacking step and mount the archive directly with PhysFS (using PHYSFS_mountMemory) and then use the standard Allegro loading functions via the PhysFS addon.

PHYSFS_mountMemory(zip_data_ptr, zip_data_length, NULL, ".zip", NULL, 0);
al_load_bitmap("blah.bmp") // Will try loading from the zip file first

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Member #14,368
June 2012

"You can also skip the manual unpacking step and mount the archive directly with PhysFS (using PHYSFS_mountMemory [])"

Yep, I saw this function on physfs manual, but it is now only in unstable version of physfs 2.1.0.
I've tried out the function, but there was many strange run-time errors and I rolled back to 2.0.2.

Now I'm using minizip from zlib distribution and "Justin Fletcher very simple implementation of a memory access method for the ioapi code (" from here
and that all works perfectly!

P.S. sorry for my english

Go to: