SFML community forums

Help => General => Topic started by: magneonx on July 07, 2013, 04:23:31 am

Title: How to make your game assets on a single file?
Post by: magneonx on July 07, 2013, 04:23:31 am
Hello! I just notice on some games like Torchlight II, they have their game files on .PAK. I want the same thing too, because I don't like my .pngs scattered on a folder. How can I make it like that?

Is SFML capable of loading those resource say on a compress file??? Of course, this could make the game load a lot longer but I just want my game folder spick and span. At least though its irrelevant at some times.

Thanks!!!
Title: Re: How to make your game assets on a single file?
Post by: cpolymeris on July 07, 2013, 05:28:27 am
AFAIK, sfml does not provide the functionality to read from packed or compressed files, but it can read from stream. So you would just need to find a library (e.g. zlib) to open the data files and pipe it to the sfml readers. Ideally, this would be optional, so you can have your "scattered pngs" during development and then ship packed files.

Regarding speed, if the compression algorithm is not too complicated, the load times can actually be faster if the data is compressed, and all together (less seek time).
Title: Re: How to make your game assets on a single file?
Post by: fallahn on July 07, 2013, 08:09:24 am
Take a look at physfs which is a library for opening pak and zip files. I believe there is also sample code on the wiki to demonstrate using it with sfml
Title: Re: How to make your game assets on a single file?
Post by: FRex on July 08, 2013, 03:36:37 am
Just download physics and write own stream(like 20 lines, also ready stealable version is on wiki).
http://icculus.org/physfs/
It handles zip, 7zip, few game specific asset container types and real filesystem uniformly with ability to make one file cover another one, decompression on the fly, directory iterating, checking if file exist and uses the best encoding ever(utf8) for it's path, it has just single C header and like 20 functions to know and it's zlib, just like SFML. It doesn't really have to make loading longer, unless you pack it with 7zip and take ultra compression ratio or something else very silly the disc io and gpu texture loading will always just dominate over the actual decompression and processing of whatever is there.
Title: Re: How to make your game assets on a single file?
Post by: Hiura on July 08, 2013, 07:46:33 am
I don't know what it is worth, but there is this entry in the wiki: https://github.com/SFML/SFML/wiki/Source%3A-SFML-PhysFS

And this one, fby FRex: https://github.com/SFML/SFML/wiki/Source%3A-PhysicsFS-Input-Stream