diff options
author | Ludovic Pouzenc <lpouzenc@gmail.com> | 2013-07-17 15:50:28 +0200 |
---|---|---|
committer | Ludovic Pouzenc <lpouzenc@gmail.com> | 2013-07-17 15:50:28 +0200 |
commit | 5cdd053de62373920422400200d1d9f79f6f3d0b (patch) | |
tree | 010910c0620672a89660d64f3cc17a4b2c748b73 /src/sandbox | |
parent | 25df857bd3a0f5fe4a4917e1e1488f22675a0574 (diff) | |
download | mplemmings-5cdd053de62373920422400200d1d9f79f6f3d0b.tar.gz mplemmings-5cdd053de62373920422400200d1d9f79f6f3d0b.tar.bz2 mplemmings-5cdd053de62373920422400200d1d9f79f6f3d0b.zip |
Debut ajout changement des ressources. Ajout de checks dans le parser
(limites sur INT). Factorisation de la macro mpl_check macro dans utils.h
Diffstat (limited to 'src/sandbox')
-rw-r--r-- | src/sandbox/sprite.c | 9 | ||||
-rw-r--r-- | src/sandbox/sprite_gif.c | 24 |
2 files changed, 3 insertions, 30 deletions
diff --git a/src/sandbox/sprite.c b/src/sandbox/sprite.c index 7aafccf..57c6f06 100644 --- a/src/sandbox/sprite.c +++ b/src/sandbox/sprite.c @@ -3,6 +3,7 @@ #error "This code is only for SDL 2+. No backward compatibility with previous SDL versions, sorry." #endif +#include "utils.h" #define MPL_WINDOW_TITLE __FILE__ #define MPL_WINDOW_WIDTH 640 @@ -83,14 +84,6 @@ int main(int argc, char *argv[]) { } -#define mpl_check(expr, fail_code, priority, ...) \ - if (! (expr)) { \ - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,priority,__VA_ARGS__); \ - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,priority, \ - "-> last SDL error : %s\n", SDL_GetError()); \ - fail_code; \ - } - void my_SDL_init_or_die(char title[], SDL_Rect win_pos, Uint32 init_flags, Uint32 win_flags, Uint32 rend_flags, SDL_Window **win, SDL_Renderer **rend, SDL_RendererInfo *rend_info, SDL_Rect *viewport) { int res, i; diff --git a/src/sandbox/sprite_gif.c b/src/sandbox/sprite_gif.c index eb7f58a..28c57aa 100644 --- a/src/sandbox/sprite_gif.c +++ b/src/sandbox/sprite_gif.c @@ -5,6 +5,7 @@ #error "This code is only for SDL 2+. No backward compatibility with previous SDL versions, sorry." #endif +#include "utils.h" #define MPL_WINDOW_TITLE __FILE__ #define MPL_WINDOW_WIDTH 640 @@ -85,14 +86,6 @@ int main(int argc, char *argv[]) { } -#define mpl_check(expr, fail_code, priority, ...) \ - if (! (expr)) { \ - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,priority,__VA_ARGS__); \ - SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,priority, \ - "-> last SDL error : %s\n", SDL_GetError()); \ - fail_code; \ - } - void my_SDL_init_or_die(char title[], SDL_Rect win_pos, Uint32 init_flags, Uint32 win_flags, Uint32 rend_flags, SDL_Window **win, SDL_Renderer **rend, SDL_RendererInfo *rend_info, SDL_Rect *viewport) { int res, i; @@ -188,21 +181,7 @@ SDL_Texture * my_sdl_load_texture(SDL_Renderer *rend, char *giffilepath, SDL_Rec SDL_LOG_PRIORITY_WARN, "my_sdl_load_texture(rend, \"%s\") failed",giffilepath ); -/* mpl_check( - s->format->BitsPerPixel==24, - {SDL_FreeSurface(s); return NULL;}, - SDL_LOG_PRIORITY_WARN, - "my_sdl_load_texture(rend, \"%s\") : BitsPerPixel == %i",bmpfilepath,s->format->BitsPerPixel - ); - res=SDL_SetColorKey(s, SDL_TRUE, MPL_COLOR_KEY); - mpl_check( - res==0, - {SDL_FreeSurface(s); return NULL;}, - SDL_LOG_PRIORITY_WARN, - "my_sdl_load_texture(rend, \"%s\") : can't set colorkey %x",bmpfilepath,MPL_COLOR_KEY - ); -*/ t = SDL_CreateTextureFromSurface(rend, s); mpl_check( t, @@ -219,3 +198,4 @@ SDL_Texture * my_sdl_load_texture(SDL_Renderer *rend, char *giffilepath, SDL_Rec SDL_FreeSurface(s); return t; } + |