commit 4ef36e37221e1c67d148f70385df568bd06e9cc0
parent c7ea652cf06af91592b058656262b2ed610b361b
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Sun, 26 Sep 2010 01:48:44 +0200
Premier bloc affiché à l'écran.
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -3,18 +3,23 @@
#include <SDL/SDL.h>
#include "erreurs.h"
+#define PROFONDEUR 24
+
SDL_Surface* init() {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
die("Erreur lors de l'initialisation de SDL :");
}
SDL_Surface* fenetre;
- fenetre = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE);
+ fenetre = SDL_SetVideoMode(640, 480, PROFONDEUR, 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, 0, 0, 0));
+ SDL_Flip(fenetre);
+
return fenetre;
}
@@ -26,10 +31,16 @@ void quit() {
int main(int argc, char** argv) {
SDL_Surface* fenetre = init();
- SDL_FillRect(fenetre, NULL, SDL_MapRGB(fenetre->format, 255, 0, 128));
+ SDL_Surface* bloc = SDL_CreateRGBSurface(SDL_HWSURFACE, 11, 11, PROFONDEUR, 0, 0, 0, 0);
+ SDL_FillRect(bloc, NULL, SDL_MapRGB(fenetre->format, 255, 255, 255));
+ SDL_Rect position = {0,0};
+
+ SDL_BlitSurface(bloc, NULL, fenetre, &position);
SDL_Flip(fenetre);
while (1);
+ SDL_FreeSurface(bloc);
+
quit();
}