From 6231f9ecdea59454c3cad6e3bd1ad6a1d723ec72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sun, 26 Sep 2010 01:33:47 +0200 Subject: [PATCH] Dessin d'une couleur, factorisation du code d'erreur. --- main.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index d4a3b57..c6cc573 100644 --- a/main.c +++ b/main.c @@ -2,16 +2,29 @@ #include #include +#define die(msg) {\ + fprintf(stderr, msg "\n"); \ + fprintf(stderr, " %s\n", SDL_GetError()); \ + exit(EXIT_FAILURE); \ +} + int main(int argc, char** argv) { if (SDL_Init(SDL_INIT_VIDEO) != 0) { - fprintf(stderr, "Erreur à l'initialisation de SDL :"); - fprintf(stderr, " %s", SDL_GetError()); - exit(EXIT_FAILURE); + die("Erreur lors de l'initialisation de SDL :"); } - SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE); + SDL_Surface* fenetre; + fenetre = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE); + if (fenetre == NULL) { + die("Erreur lors de la création de la fenêtre."); + } SDL_WM_SetCaption("Lew", "lew.png"); + SDL_FillRect(fenetre, NULL, SDL_MapRGB(fenetre->format, 255, 0, 128)); + SDL_Flip(fenetre); + + while (1); + SDL_Quit(); return EXIT_SUCCESS; }