I am learning SDL from a tutorial on youtube and one lesson is displaying bitmaps, I types in the code in code::blocks but it only displays the image when I am about to close it.
Here is my code.
Code:#include <SDL/SDL.h> SDL_Surface *buffer = 0; SDL_Surface *bitmap = 0; int main(int argc, char *argv[]){ SDL_Init(SDL_INIT_VIDEO); buffer = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); bool run = true; SDL_Event event; bitmap = SDL_LoadBMP("smile.bmp"); if(bitmap == 0){ return -1; } SDL_Rect pos; pos.x = 0; pos.y = 0; while(run){ while(SDL_PollEvent(&event)){ if(event.type == SDL_QUIT) { run = false; } } } SDL_BlitSurface(bitmap, 0, buffer, &pos); SDL_Flip(buffer); SDL_Quit(); return(0); }



LinkBack URL
About LinkBacks


