|
Need ./ when loading images with PhysFS? |
jmasterx
Member #11,410
October 2009
|
I'm using PhysFS like this: if (!PHYSFS_init(m_args[0].c_str())) { throw Exception("Allegro PHYSFS failed to initialize"); } if (!PHYSFS_addToSearchPath("resource.dat", 1)) { throw Exception("Allegro PHYSFS failed to open resource file"); } al_set_physfs_file_interface();
I basically do this: Right now, the problem seems to be that my images are only getting loaded if I append ./ to their path. I'm on Windows. The paths are normally resources/sprites/toad.png I load them in like this: Sprite::Sprite( const std::string& fileName ) : m_bitmap(NULL),m_width(0),m_height(0) { m_bitmap = al_load_bitmap(fileName.c_str()); if(!m_bitmap) { throw Exception("CGE Allegro 5 failed to load image " + fileName); } m_width = al_get_bitmap_width(m_bitmap); m_height = al_get_bitmap_height(m_bitmap); } Is it normal that I have to add ./ to images but not files that I open with al_fopen? Thanks Agui GUI API -> https://github.com/jmasterx/Agui |
torhu
Member #2,727
September 2002
|
jmasterx said: Right now, the problem seems to be that my images are only getting loaded if I append ./ to their path. I'm on Windows. The paths are normally resources/sprites/toad.png I probably can't help you anyway, but I think you need to proof read your problem description |
jmasterx
Member #11,410
October 2009
|
Fixed. Agui GUI API -> https://github.com/jmasterx/Agui |
Arthur Kalliokoski
Second in Command
February 2005
|
IIRC, certain file extensions get added to the PATH or something so you can type in "toad.png" into the command line and windows will fire up a paint program or something. In that case, you might need the ./ to specify THIS file RIGHT HERE! They all watch too much MSNBC... they get ideas. |
Trent Gamblin
Member #261
April 2000
|
No. It should work without ./ . Are you sure you don't have the images in the wrong place in the archive and the old images still there under that path in the real filesystem?
|
jmasterx
Member #11,410
October 2009
|
Well it seems ascii 13 was being appended to my filenames. All is fixed now. Thanks Agui GUI API -> https://github.com/jmasterx/Agui |
Neil Roy
Member #2,229
April 2002
|
This is what I have... I have a quality flag where the game selects one of two files with low and high quality versions of the same graphics and sound. I have my graphics, sound etc... all stored in their own folders inside the zip file and access with "gfx/Pacman01.png" etc. Works fine. PHYSFS_init(NULL); if(quality) { if(!PHYSFS_mount("Deluxe_Pacman_2_High.pak", "/", 1)) { a5_error(AT, display.screen, "PHSYFS_init() failed."); exit(1); } } else { if(!PHYSFS_mount("Deluxe_Pacman_2_Low.pak", "/", 1)) { a5_error(AT, display.screen, "PHSYFS_init() failed."); exit(1); } } al_set_physfs_file_interface();
--- |
|