-
September 23rd, 2012, 11:15 AM
#1
Why am I getting black screen? SDL-C++ issue. Please assist me :)
hello I am trying to open a screen with an image saying hello. It shows no errors on xcode, but when I run the program, the screen pops up black. It is just a black screen, and doesnt show the image saying hello. I heard that the solution is to put the image into the same directory, so I dragged it onto xcode. Still, it shows up black. I really would appreciate all help . Thanks. P.S Am i not putting it into the directory correctly? How do I put the image into the same directory as the project? thank you!!!
Code:
#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;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|