trouble with SDL_LoadBMP - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: trouble with SDL_LoadBMP (/thread-6773.html)
trouble with SDL_LoadBMP - -Rice- - Sep 5, 2003 08:42 AM
I am having trouble with SDL_LoadBMP function. It is copied straight from Jonh Halls book (thank you John for allowing this in a pdf format for public consumption). Example 4-3 on page 84 (book) or 102 (pdf) is returning error stating "Couldn't open test-image.bmp".
what I am doing:
-creating the SDL application in project builder (SDL Application option)
-adding the source code from the book. I copied this out of acrobat so there should be no typo mistakes.
-add the file test-image.bmp via pb's project->add files... menu. Checking copy items into destination group's folder (if needed) button.
-build. here I get the error annotated above.
other sdl projects compile fine up to this point, but no idea. I have tested this at home and at work and fails both places. Home is compiled on an iMac G3 333 w/ 168 mb ram, and at work on a 350 Blue white G3 w/192 mb ram. Both are running OS X10.2.6 and pb 2.0.1 SDL is version 1.2.6 at work and 1.2.5 at home
trouble with SDL_LoadBMP - IBethune - Sep 5, 2003 11:27 AM
OK I don't know the exact book you are talking about but here are a few things about loading images.
You need to be sure of where the image file is. If you have added it to your project it will likely have been added in the Bundle Resources section (look in the Targets section of PB).
In that case the path you need to use to open the image is
because the file loader starts looking in the same folder as your .app but the image is stored inside the .app itself.
I think this will work.
BTW If you're wanting to load lots of images, and also ones that aren't BMP, the SDL_image framework is great.
trouble with SDL_LoadBMP - hams - Sep 5, 2003 11:30 AM
if you are using the 'open' or 'fopen' interfaces, then you
need to put your bmp file in the same directory as the
application bundle. (don't add it to the Resources folder
for the project).
That probably means going into the build folder and putting
the image there.
in order to access the image inside to application bundle,
you would need to get a reference to the mainBundle and
then get the path for the Resources directory. Then you can
use that path plus filename to open the file.
trouble with SDL_LoadBMP - -Rice- - Sep 5, 2003 12:39 PM
THAT WORKED!!!! Thank you both for the replies. My bad on not posting the url for John Halls book. This is it below:
funny thing though, I can get to that page in safari, but on this computer (OS 9), I can not.
Good book, though. Again, thank you both for the help.
trouble with SDL_LoadBMP - OneSadCookie - Sep 5, 2003 04:17 PM
There's a FAQ about this stuff: