Dessin d'une couleur, factorisation du code d'erreur.

This commit is contained in:
Georges Dupéron 2010-09-26 01:33:47 +02:00
parent 51e2cfe93a
commit 6231f9ecde

21
main.c
View File

@ -2,16 +2,29 @@
#include <stdio.h>
#include <SDL/SDL.h>
#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;
}