I made a simple that loads and displays an image. at my house every thing worked ok. then when I bring it to school the image wont load(i have error checking after and it returns 1 if the file is still null.) it returns 1 every time. its the same source file and the image is the same and in the spot in the folder. why do you think it does this?
What size is the image? It may be too large for the school computer's GPU to be able to handle as a texture. If so, you can always try loading it as a memory bitmap rather than as a video bitmap.
How do I load it as a memory bitmap and whats the difference? I think I've heard of it but never used it before.
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
memory bitmaps are stored in normal RAM
video bitmaps are stored in RAM on the gfx card
Try explicitly stating the path in the load function, it could be a working folder issue, e.g. debug mode.
How do I load it as a memory bitmap and whats the difference?
Memory bitmaps are slower to use, but can be larger than the default video bitmaps.
Thus, you should try to load images as a regular video bitmap. If a large image fails to load, then you can load it as a memory bitmap instead. But you should detect that at run time, so that better computers will not use memory bitmaps when they could be using hardware accelerated ones.
I've tried using memory bitmaps, different sized images, different formats and typing out the complete path and still it wont load.
Post your code with image then.
Windows doesn't like to run your executable from the directory you think it should be, so when you try to use a relative path like you are, it will be relative to whatever windows has set as the current working directory, not the one you think it is.
First try using an abosolute path to your files, then play with the al_get_standard_path to locate your files.
What do i do with al_get_standard_path? al_get_standard_path(ALLEGRO_EXENAME_PATH);?
what would I do with this?
On Windows, make sure the data is stored relative to the exe
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_append_path_component(path, "Media"); al_set_path_filename(path, "foo.png"); // a hack, but this probably works in place of the 'append': // al_set_path_filename(path, "Media/foo.png"); al_load_bitmap(al_path_cstr(path, '/'));
The above code assumes the image is in a folder called 'Media' next to the executable. The documentation explains this clearly:
If you bundle data in a location relative to your executable, then you should use this path (ALLEGRO_RESOURCES_PATH) to locate that data.
Oh I see. Just curious why do you consider it a hack?
It's a hack, because you're abusing the structure a bit. An Allegro path is a vector of path components, eg: "usr", "share", "mygame". Then it has a filename: "img.png".
When you call al_path_cstr(), it joins them together with the delimiter you supply.
So if you add something like "foo/bar" via al_append_path_component() or al_set_path_filename(), you are putting two pieces together in a single slot of the vector.
It doesn't really matter in that when you call al_path_cstr() you'll get the same result. However, you cannot traverse each component individually now, since Allegro will treat your "combo" component as a single entity.
I doubt the functionality will ever change, so it should be safe to use.
Its crashing at path = al_get_standard_path. this must be the universe telling me that this just isn't going to work. Its probably has to do with some sort of restrictions on the computers. looks like I wont be able to show off my programs to people in my programming class because I cant even run the exe there because it just closes instantly from the images failing to load.
Make sure you are calling al_init() first.
I'll double check tomorrow. Its still a pain in the butt to have to do this especially if i have to load like 50 images. Is this standard or something special you do?
You can also do it this way:
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_change_directory(al_path_cstr(path), '/'); al_destroy_path(path); foo1 = al_load_bitmap("images/foo1.png"); foo2 = al_load_bitmap("images/foo2.png");
It looks like this will be useful to you: http://wiki.allegro.cc/index.php?title=Return_values
It still doesn't work after doing the thing with the paths.