Advertisement
Guest User

Untitled

a guest
Oct 31st, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. /* Découper une texture en frames. */
  2. void cuttingTexture(SDL_Texture *texture, SDL_Rect *src, int wFrame, int hFrame)
  3. {
  4.     int i = 0;
  5.     int x, y, w, h;
  6.     SDL_QueryTexture(texture, NULL, NULL, &w, &h);
  7.     int frameNumber = ((w * h)/(wFrame * hFrame)) *2;
  8.  
  9.     if((src = SDL_malloc(sizeof(SDL_Rect) * frameNumber)) == NULL)
  10.     {
  11.         fprintf(stderr, "Erreur lors de l'allocation dynamique de src.");
  12.         cleanUp(renderer, window);
  13.         exit(EXIT_FAILURE);
  14.     }
  15.  
  16.     for(x = 0 ; x < w ; x += wFrame)
  17.     {
  18.         for(y = 0 ; y < h ; y += hFrame)
  19.         {
  20.             src[i].x = x;
  21.             src[i].y = y;
  22.             src[i].w = wFrame;
  23.             src[i].h = hFrame;
  24.  
  25.             i++;
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement