Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest)
  2. {
  3.     // Exit early if image is not on dest at all
  4.     if (x + image->w < 0 || x >= dest->w || y + image->h < 0 || y >= dest->h)
  5.         return;
  6.  
  7.     // Set up a rectangle to draw to
  8.     SDL_Rect blitRect;
  9.  
  10.     blitRect.x = x;
  11.     blitRect.y = y;
  12.     blitRect.w = image->w;
  13.     blitRect.h = image->h;
  14.  
  15.     /* Blit onto the destination surface */
  16.     if (SDL_BlitSurface(image, NULL, dest, &blitRect) < 0)
  17.     {
  18.         printf("BlitSurface error: %s\n", SDL_GetError());
  19.         showErrorAndExit(2, "");
  20.     }
  21.  
  22.     // Only if it is to the screen, mark the region as damaged
  23.     if (dest == screen)
  24.         addBuffer(blitRect.x, blitRect.y, blitRect.w, blitRect.h);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement