View Full Version : problems blitting a picture to the screen
petr6534
2004.10.18, 06:46 PM
When I try to blit a .bmp picture to the screen, just a black screen shows up.
I've used SDL_LoadBMP(), SDL_BlitSurface(), and SDL_UpdateRect(), but it doesn't work. Any tips?
PowerMacX
2004.10.18, 09:10 PM
Post the relevant part of your code...
petr6534
2004.10.18, 10:06 PM
My error tells me that it can't open the file.
Here's the code...
SDL_Surface *image;
image = SDL_LoadBMP("one.bmp");
if (image == NULL)
{
fprintf(stderr, "Couldn't load %s: %s\n", "one.bmp", SDL_GetError());
}
SDL_BlitSurface(image, NULL, screen, NULL);
SDL_Flip(screen);
SDL_FreeSurface(image);
PowerMacX
2004.10.20, 07:01 PM
Is the file one.bmp in the same folder as your app? (The "build" folder, if you used Xcode).
SDL sets the default directory to the same folder as your app package, not to the Resources folder inside it (Check SDLMain.m if you want to change that)
petr6534
2004.10.20, 08:18 PM
It worked! Thanks very much!
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.