I've noticed that after you call al_set_physfs_file_interface, then all calls to al_open_video no longer will accept the filename being on a path. The file will have to be in the root of the exe or if inside an archive has to be at the root level. All the other resources seem to not be affected by this behavior.
I have all game resources in a folder called data:
[data]
...[bitmaps]
...[videos]
my.exe
I load images such as: data/bitmaps/image.png. But I am unable to do the same for video after al_set_physfs_file_interface call.
Having the it structured this way, I can zip the data folder up to data.dat and everything will continue to work without having to change any path. Just video seems to have a different behavior.
Any ideas?
Thanks
your best bet is to step into al_load_video and debug it yourself. Step into the allegro loading functions and see which function is being used to actually load the file. It probably calls al_fopen, so you can set a break point there.
You can enable logging by calling al_set_config_value(al_get_system_config(), "trace", "level", "debug") before al_init, which will create a log file (`allegro.log`) in your current directory. There, the video addon should dump some useful information.
Hi, thanks for the replies. I'm using Delphi. Everything else that I've tried (bitmaps, samples and streams) all seem to work as expected. It just video that will not accept a path in filename after physfs is enabled. At this point, only a filename and must be in root. I know some c/c++ but my primary language is Delphi.
I have a project that I'm working so I had to get this working. In the meantime I implemented my own management for zip archives. Hopefully it will be good enough. Even if video had al_open_videof that accepted a ALLEGRO_FILE interface it would have been easier to make something else work, but nope.
Hopefully what I got now will work well enough for this project.
Update:
I went in and enabled the log file and it shows:
video W ogv.c:1184 ogv_open_video [ 8.13665] Failed to open data\video\presents.ogv.
Which is this section of code:
filename = al_path_cstr(video->filename, ALLEGRO_NATIVE_PATH_SEP); fp = al_fopen(filename, "rb"); if (!fp) { ALLEGRO_WARN("Failed to open %s.\n", filename); return false; }
Docs says that al_fopen will use physfs_open after its enabled. All the other loading routines (bitmap, sample, streams) seem to work fine.
What happens when you change the path separator to a forward slash? I
Actually, I do use forward slashes in code (that was a copy/paste from the log). Its very weird. Can't seem to get a handle on why its even an issue.
@drezgames
If I was you, to investigate this further, I would try to enumerate the current directory's contents after mounting the archive file. If some files don't appear in the results (ie. some contents are missing, or simply not reported as being present), then that's definitely a bug in allegro or physfs.
Mount the archive, and then try :
ALLEGRO_FS_ENTRY* root = al_create_fs_entry("./"); bool open = al_open_directory(root); if (open) { ALLEGRO_FS_ENTRY* e = 0; while ((e = al_read_directory(root))) { printf("Found '%s'!\n" , al_get_fs_entry_name(e)); al_destroy_fs_entry(e); } al_close_directory(root); }