简体   繁体   中英

Allegro 5 Load Data File

I am using Allegro 5 library. I want to load font from dat file. In Allegro's previous versions, there is useful methods for this. For example "load_datafile", load_dat_font. How can I do this in Allegro 5?

The closest direct thing Allegro 5 has is the physfs addon. Useful links:

With it you can load (for example) a Zip archive as a folder. So instead of using a datafile, you can use a Zip file.

See the manual for an example. In short, it looks like:

PHYSFS_init(argv[0]);
PHYSFS_addToSearchPath("data/foo.zip", 1);
// ...
al_set_physfs_file_interface();

Then future calls to al_load_bitmap() (etc) will look inside that zip file.

If you want to do anything other than that, you will need to write your own custom file interface. It's not terribly difficult, but I think you might as well use a Zip file.

Allegro 5 doesn't have datafiles at all. So you can't.

If you have something you want to load, then you will have to actually load it using either regular fileIO or Allegro 5's fileIO functions. Either way, you'll have to do the grunt work yourself.

Allegro 5 is lower-level than prior versions. Which means it has fewer convenience functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM