|
Sprite loading problem |
auliszek
Member #12,875
May 2011
|
Hi I was searching for the answer in many places but nobody could help me yet. like this: 1al_init();
2 ALLEGRO_DISPLAY *display = al_create_display(640, 480);
3 al_set_window_title(display, "Allegro 5");
4 al_clear_to_color(al_map_rgba(0, 0, 0, 255));
5 // koniec inicjalizacji okna - jest ok.
6
7 if(!al_init_image_addon())
8 return -1;
9
10 if(!al_filename_exists("D:/C++/Allegro_drawing/Allegro_drawing/sprite.bmp"))
11 return -4;
12
13 if(!al_is_system_installed())
14 return -5;
15
16 ALLEGRO_BITMAP *img = al_load_bitmap("sprite.bmp");
17 if(!img)
18 return -2;
Sprite is in the internal directory named like the project (as you can see). It always ends returning -2. I included needed header files. |
weapon_S
Member #7,859
October 2006
|
"D:/C++/Allegro_drawing/Allegro_drawing/sprite.bmp" != "sprite.bmp" |
auliszek
Member #12,875
May 2011
|
Windows xp home It is not equal in theory, but it is also the directory where main.cpp is. When i load font this way it works. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
If you use a relative path like sprite.bmp, then you have to run the program from the same directory as sprite.bmp, or the same directory as your program, if they're the same. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
torhu
Member #2,727
September 2002
|
You can set the current directory to where the executable is like this, if that's where your data is: ALLEGRO_PATH appdir = al_get_standard_path(ALLEGRO_RESOURCES_PATH, ALLEGRO_NATIVE_PATH_SEP); if (!appdir) return -6; if (!al_change_directory(al_path_cstr(appdir))) return -7; al_destroy_path(appdir); If that doesn't work, maybe the BMP file is an a weird format? |
auliszek
Member #12,875
May 2011
|
But when i do sth like: |
LennyLen
Member #5,313
December 2004
|
As Torhu mentioned, the BMP file could be in a wrong format. Try loading/saving it with MS Paint, and see if the problem persists.
|
auliszek
Member #12,875
May 2011
|
Yeah, this totally worked |
Audric
Member #907
January 2001
|
According to this thread, somebody had similar problem with a 32bit BMP, 24bit was fine. (edit: From looking at the source, the load routine will only accept some very specific R G B bitmasks... for 32bit, only ARGB order is accepted.) |
Arthur Kalliokoski
Second in Command
February 2005
|
Photoshop should be able to save to .png or possibly .tga. They all watch too much MSNBC... they get ideas. |
auliszek
Member #12,875
May 2011
|
Thanks guyz |
|