#ifndef _FUS_SDL_UTIL_H_ #define _FUS_SDL_UTIL_H_ #include #include #include #define ERR_INFO() fprintf(stderr, "%s:%s:%i: ", \ __FILE__, __func__, __LINE__) #define RET_IF_SDL_NZ(x) { \ if((x) != 0){ \ ERR_INFO(); \ fprintf(stderr, "SDL error: %s\n", SDL_GetError()); \ return 2;}} #define RET_IF_SDL_NULL(x) { \ if((x) == NULL){ \ ERR_INFO(); \ fprintf(stderr, "SDL error: %s\n", SDL_GetError()); \ return 2;}} #define RET_NULL_IF_SDL_NZ(x) { \ if((x) != 0){ \ ERR_INFO(); \ fprintf(stderr, "SDL error: %s\n", SDL_GetError()); \ return NULL;}} #define RET_NULL_IF_SDL_NULL(x) { \ if((x) == NULL){ \ ERR_INFO(); \ fprintf(stderr, "SDL error: %s\n", SDL_GetError()); \ return NULL;}} void interpolate_color(SDL_Color *c, Uint8 r, Uint8 g, Uint8 b, int t, int t_max); void palette_printf(SDL_Palette *pal); SDL_Surface *surface8_create(int w, int h, bool use_rle, bool use_colorkey, SDL_Palette *pal); SDL_Surface *surface32_create(int w, int h, bool use_rle, bool use_colorkey); Uint8 *surface8_get_pixel_ptr(SDL_Surface *surface, int x, int y); Uint32 *surface32_get_pixel_ptr(SDL_Surface *surface, int x, int y); #endif