My program opens, without returning -1, or showing the image, and I was wonderng why this happens.
here is my code
Code:#include <SDL/SDL.h> #include <SDL/SDL_image.h> SDL_Surface *buffer = 0; SDL_Surface *man = 0; void draw_surface(SDL_Surface* sur, int x, int y){ SDL_Rect pos; pos.x = x; pos.y = y; SDL_BlitSurface(sur, 0, buffer, &pos); } SDL_Surface *draw_img(const char *filename){ SDL_Surface *img = IMG_Load(filename); if(man != 0){ SDL_SetColorKey(img, SDL_SRCCOLORKEY, 0xFFFF00); } return(img); } int main(int argc, char *argv[]){ SDL_Init(SDL_INIT_VIDEO); buffer = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); man = draw_img("person.png"); if(man == 0){ return -1; } bool run = true; SDL_Event event; while(run){ while(SDL_PollEvent(&event)){ if(event.type == SDL_QUIT){ run = false; } } draw_surface(man, 0, 0); } SDL_FreeSurface(man); SDL_Quit(); return 1; }



LinkBack URL
About LinkBacks


