Original Post
Hello! Im pretty new to SDL, i was able to get an image loaded but for some reason it is flashing constantly. I tried adding "SDL_DisplayFormat()","SDL_UpdateRect()" and changing some other things that i thought would fix it but nothing. I also tried changing the flags, i tried to set the video mode fullscreen, window, SWSURFACE, HWSURFACE,etc.
#include "SDL/SDL.h"
int main( int argc, char* args[] )
{
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
SDL_Surface *screen = NULL;
SDL_Surface *pic = NULL;
SDL_Surface *newPic = NULL;
SDL_Rect dstRect;
int done =0;
while(done == 0)
{
//Event initialization
SDL_Event event;
//loops program
while ( SDL_PollEvent(&event) )
{
//x button ends program
if ( event.type == SDL_QUIT )
{
done = 1;
}
if ( event.type == SDL_KEYDOWN )
{ //esc key ends program
if ( event.key.keysym.sym == SDLK_ESCAPE )
{
done = 1;
}
}
}
//set video mode
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_FULLSCREEN|SDL_HWSURFACE);
//load image
pic = SDL_LoadBMP("zeldaBMP.bmp");
newPic = SDL_DisplayFormat( pic );
dstRect.y = 80;
dstRect.x = 80;
//blit image
SDL_BlitSurface(newPic,NULL,screen,&dstRect);
SDL_UpdateRect(screen,0,0,screen->w,screen->h);
SDL_Flip(screen);
//Set the window caption
SDL_WM_SetCaption( "Hello World", NULL );
}
//Quit SDL
atexit(SDL_Quit);
return 0;
}