Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Découper une texture en frames. */
- void cuttingTexture(SDL_Texture *texture, SDL_Rect *src, int wFrame, int hFrame)
- {
- int i = 0;
- int x, y, w, h;
- SDL_QueryTexture(texture, NULL, NULL, &w, &h);
- int frameNumber = ((w * h)/(wFrame * hFrame)) *2;
- if((src = SDL_malloc(sizeof(SDL_Rect) * frameNumber)) == NULL)
- {
- fprintf(stderr, "Erreur lors de l'allocation dynamique de src.");
- cleanUp(renderer, window);
- exit(EXIT_FAILURE);
- }
- for(x = 0 ; x < w ; x += wFrame)
- {
- for(y = 0 ; y < h ; y += hFrame)
- {
- src[i].x = x;
- src[i].y = y;
- src[i].w = wFrame;
- src[i].h = hFrame;
- i++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement