displaying bitmap in sdl-xcode plz help

Hi I am trying to display an image saying hello world and i wrote all the right code, and it just displays a black window.. What could be wrong what could i be doing wrong I am putting hello world in the directory for the project so what should i do so it shows the image? here is the code (btw this is sdl-c++) and using xcode


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "SDL/SDL.h"

int main( int argc, char* args[] )
{
    //The images
    SDL_Surface* hello = NULL;
    SDL_Surface* screen = NULL;
    
    //Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );
    
    //Set up screen
    screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
    
    //Load image
    hello = SDL_LoadBMP( "hello.bmp" );
    
    //Apply image to screen
    SDL_BlitSurface( hello, NULL, screen, NULL );
    
    //Update Screen
    SDL_Flip( screen );
    
    //Pause
    SDL_Delay( 2000 );
    
    //Free the loaded image
    SDL_FreeSurface( hello );
    
    //Quit SDL
    SDL_Quit();
    
    return 0;
}


thx in advance!
Last edited on
bump
check to see if hello is null. If it is, the bmp failed to load. Most likely because you put your bmp in the wrong directory.
Hi disch. Yes, the bmp is failing to load. Maybe I did put it in the wrong directory which one would I put it in? How would I do so? I am sooo confused I thought I just put it in the same folder as my xcode project. already-waiting-your-reply, Michael :)
Are you on Windows?

If yes, you can do this:

1
2
3
4
5
6
7
8
9
10
11
12
#include <windows.h> // <- temporary, remove this after this test is done

int main()
{
  /* temporary, remove this after your test is done */
  char buffer[MAX_PATH];
  GetCurrentDirectoryA(MAX_PATH,buffer)
  MessageBoxA(NULL,buffer,"",MB_OK);
  /* end of temporary crap */

  /* the rest of your program */
}


That'll pop up a little window telling you exactly which directory the .bmp needs to be put in.
disch. tysm for replies i solved by specyfying the complete path. I super appreciate everything :)
Topic archived. No new replies allowed.