problems blitting a picture to the screen

petr6534
Unregistered
 
Post: #1
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?
Quote this message in a reply
Moderator
Posts: 770
Joined: 2003.04
Post: #2
Post the relevant part of your code...
Quote this message in a reply
petr6534
Unregistered
 
Post: #3
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);
Quote this message in a reply
Moderator
Posts: 770
Joined: 2003.04
Post: #4
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)
Quote this message in a reply
petr6534
Unregistered
 
Post: #5
It worked! Thanks very much!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL full screen mode leaves garbage on screen when exiting app Malarkey 5 4,932 Nov 19, 2008 12:51 PM
Last Post: Malarkey
  picture before app ? imaumac 4 2,530 Nov 1, 2008 07:37 AM
Last Post: imaumac
  picture for some seconds imaumac 3 1,985 Oct 23, 2008 09:28 PM
Last Post: kodex
  SDL Blitting KidTsunami 5 6,639 May 8, 2008 08:17 AM
Last Post: leRiCl
  NSGL full screen problems Josh 2 2,990 Jan 19, 2005 04:02 AM
Last Post: Josh