ok the second tutorial, in the wiki it says SDL_Flip(); but it needs to be SDL_Flip(screen);
also, i made this
Code:
#include "SDL/SDL.h"
int main(int argc, char* argv[])
{
// start sdl
SDL_Init(SDL_INIT_EVERYTHING);
// load an image
SDL_Surface* loaded_image = NULL;
loaded_image = SDL_LoadBMP("MyImage.bmp");
// convert it to the right format
SDL_Surface* compatible_image = NULL;
compatible_image = SDL_DisplayFormat(loaded_image);
SDL_FreeSurface(loaded_image);
// set up the screen
const int SCREEN_WIDTH = 800;
const int SCREEN_HEIGHT = 600;
const int SCREEN_BPP = 32;
SDL_Surface* screen = NULL;
screen = SDL_SetVideoMode( SCREEN_WIDTH,
SCREEN_HEIGHT,
SCREEN_BPP,
SDL_SWSURFACE);
// put image on screen
SDL_Rect position;
position.x = 0;
position.y = 0;
SDL_BlitSurface( compatible_image,
NULL,
screen,
&position);
SDL_Flip(screen);
//Wait 2 seconds
SDL_Delay( 2000 );
// Destroy remaining surfaces
SDL_FreeSurface( compatible_image );
// quit sdl
SDL_Quit();
return 0;
}
and it compiles but it just displays a black window. my image is NOT displayed. why is this? the image is in the same directory as the binary
Bookmarks