![]() |
|
OS X 10.5 problem |
dac118
Member #9,617
March 2008
|
I just installed the newest version of Allegro, but when I try to use bitmaps all I can use are examples, not my own. I fI use my own, I get a white square instead of a window, then it crashes. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
When you say newest version do you mean the newest stable version , the newest release of the WIP version , or SVN version, so on...? Post the version number of Allegro you downloaded. As for the code not working post what you're using that isn't working. 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 |
dac118
Member #9,617
March 2008
|
I'm using Allegro v4.2.2 The code that doesn't work is as follows: #include <Allegro/allegro.h> int main(int argc, const char *argv[]) 610 x 400 is the image size of picture.bmp |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
You can use code tags in the forum to display your code in a formatted window. It makes it easier to read. You can also edit your post. <code> Code goes here </code> If the code you posted is crashing, it's likely because you used a relative path name to load your "picture.bmp" file. The load_bitmap and create_bitmap functions will return NULL if they fail to load/create their bitmaps respectively and you should check for it. The directory that will be searched for the file is likely the directory the program was run from and if it is not there load_bitmap will fail. Try using the absolute path of the file and see if that will work. However , this will reduce portability if you use an absolute path. It's best to build up an absolute path to the file during runtime so the absolute path will be correct on every machine it's run on. BITMAP* pic = load_bitmap("picture.bmp" , NULL); if (!pic) {return 0;}// loading failed , quit / deallocate memory
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 |
dac118
Member #9,617
March 2008
|
I tried the direct path, but it still failed. I tried using Terminal to compile it, and when I ran it using ./a.out, after it crashes, it said: Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Don't use a semi-colon after END_OF_MAIN() , it's incorrect. Try compiling this and running it. If the graphics mode is set correctly the screen will appear red at the beginning of the program. Press a key and if the screen turns yellow the buffer was allocated correctly. Press another key and if the picture bitmap was loaded okay the screen will turn green. Press another key to attempt to display your picture. Be sure to replace picture.bmp with the absolute path of the file on your computer. Perhaps filename directory slashes are not being written correctly?
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 |
dac118
Member #9,617
March 2008
|
Got to yellow, then when I pressed a key, it crashed, without turning green. As for the slashes, I used "/". Could the problem have anything to do with the depth? |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Since the screen didn't turn green , then load_bitmap was returning NULL which means it failed. If you set a color depth and call set_gfx_mode then until you do it again any bitmaps you load with load_bitmap will be converted to the current color depth. I think the problem is just with the file path. Try something like this : char filepath_pic[] = "absolute/path.bmp"; fix_filename_slashes(filepath_pic); BITMAP* map = load_bitmap(filepath_pic , NULL); I'm not sure what MacOS X likes for slashes so maybe that will fix it. 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 |
dac118
Member #9,617
March 2008
|
It flashes red, then stays white, and then when I press a key, yellow. It doesn't crash, but stays yellow. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Well , that's really bizarre with the screen going white and all. Especially since there's no code in there to do that. Since I don't see any MacOS X builds on the allegro files page I assume you compiled Allegro yourself. Did you follow everything in the allegro\docs\build\macosx.txt file? What options did you pass to the compiler when you compiled your program and linked it? 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 |
dac118
Member #9,617
March 2008
|
I compiled the projects in Xcode, so I didn't have to pass any options. When I did compile the file in Terminal, I just typed "g++ -framework Allegro" and then the location. I did compile Allegro myself at first, but then I found an automatic installer and used that (it was v4.2.2). Neither installations worked on my own image. I don't known if this could be of the same cause, but when I just tried to use g++ to compile a C++ file, I got an error saying "expected unqualified-id before ‘using’" Maybe my gcc's broken. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
According to allegro/docs/build/macosx.txt in the "Using allegro from the command line" section it says to Quote:
You can also link against the Allegro framework, providing you previously gcc myfile.c -o myprogram `allegro-config --frameworks` Using backticks around "allegro-config -- frameworks". You can also find a list of linking options by using Quote: Run allegro-config without any arguments for a full list of options. Take another look over macosx.txt and see if there's something you missed. 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 |
dac118
Member #9,617
March 2008
|
I Reinstalled it, tried command line commands, and Xcode compilation, but it still crashes. When I switched to using a .cpp for the main, it still didn't work, but the debugger reported: "EXC_BAD_ACCESS:" |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Are you using the right allegro-config options? Since I'm not a MacOS X user myself , I'm not entirely sure what's going on. 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 |
dac118
Member #9,617
March 2008
|
I just used the 'gcc myfile.c -o myprogram `allegro-config --frameworks`' with my file's name. As for the installer log, I'm not sure where it's at. It can't be a location problem, though, because I put an image in the same folder as the lesson 4 image. The lesson 4 image works, but the second I use my own, it doesn't. I adjusted the sizes, but still, it crashes. Oddly enough, When I try "g++ lesson4.cpp -o myprogram `allegro-config --frameworks`" (using lesson 4 image), it crashes. |
Peter Hull
Member #1,136
March 2001
|
To me this looks more like something is unusual about your bitmap, given that the lesson 4 bitmap doesn't crash and your bitmap does. Can you attach that bitmap for us to have a look at? Pete
|
dac118
Member #9,617
March 2008
|
It's not very detailed, but… |
Peter Hull
Member #1,136
March 2001
|
I think you might have found a bug in Allegro, but on the other hand I can't believe this has never been seen before. I did some tracing with gdb and it fails here What tool did you use to create your bitmap? Pete
|
dac118
Member #9,617
March 2008
|
AppleWorks for OSX, but I saved it using Preview. |
Peter Hull
Member #1,136
March 2001
|
Just to check I'm right, can you try with this bitmap? (works for me) What I did was used convert from ImageMagick to 'fix' it This bug doesn't seem to be OS X specific. Pete
|
dac118
Member #9,617
March 2008
|
It worked with the bitmap. Does this mean I just have to download ImageMagick and fix my bitmaps before adding them to the file? |
Ron Novy
Member #6,982
March 2006
![]() |
That image you linked doesn't show up in Explorer, but it does show a white box in FireFox. I just think it's funny how Apple always finds those little known and rarely implemented features created by Microsoft and then implements them to make Microsoft look stupid. ---- |
Peter Hull
Member #1,136
March 2001
|
Ron: I'll bet Bill G has his head in his hands right now!! dac118: Depends if you're going to make all your bitmaps in AppleWorks and save them with preview. Anyway there will be a patch to Allegro coming along soon, which will fix this. You can check, but ImageMagick might already be installed (I can't remember if it was or if I installed it myself) Pete
|
dac118
Member #9,617
March 2008
|
Thanks for all the help, now everything works! Although I do have one more question: how would I handle text input (i.e strings) using cin >> or something else? |
|