Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to make your game assets on a single file?  (Read 3993 times)

0 Members and 1 Guest are viewing this topic.

magneonx

  • Full Member
  • ***
  • Posts: 141
    • MSN Messenger - magnumneon04@hotmail.com
    • View Profile
How to make your game assets on a single file?
« 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!!!

cpolymeris

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • Email
Re: How to make your game assets on a single file?
« Reply #1 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).

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: How to make your game assets on a single file?
« Reply #2 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

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: How to make your game assets on a single file?
« Reply #3 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.
« Last Edit: July 08, 2013, 03:39:18 am by FRex »
Back to C++ gamedev with SFML in May 2023

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: How to make your game assets on a single file?
« Reply #4 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
SFML / OS X developer

 

anything