summaryrefslogtreecommitdiff
path: root/src/xSDL.c
blob: 3ee36cb1777b19601a60dda8070479827c187e3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
** xSDL.c for  in /home/gayot_o/prog/minesweeper/src
** 
** Made by olivier gayot
** Login   <gayot_o@epitech.net>
** 
** Started on  Wed Apr 25 23:40:24 2012 olivier gayot
** Last update Wed Apr 25 23:40:24 2012 olivier gayot
*/

#include	"minesweeper.h"

int	xSDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect,
    SDL_Surface *dest, SDL_Rect *dstrect) {
  int	ret;
  if (dest != scr)
    ret = SDL_BlitSurface(src, srcrect, dest, dstrect);
  else
  {
    if (SDL_mutexP(mutex) == -1)
      fprintf(stderr, "Error during SDL_mutexP: %s\n", SDL_GetError());
    ret = SDL_BlitSurface(src, srcrect, dest, dstrect);
    if (SDL_mutexV(mutex) == -1)
      fprintf(stderr, "Error during SDL_mutexV: %s\n", SDL_GetError());
  }
  return (ret);
}

void	xSDL_Flip(SDL_Surface *surf) {
  if (surf == scr)
    SDL_mutexP(mutex);
  SDL_Flip(surf);
  if (surf == scr)
    SDL_mutexV(mutex);
}