Premier bloc affiché à l'écran.
This commit is contained in:
parent
c7ea652cf0
commit
4ef36e3722
15
main.c
15
main.c
|
@ -3,18 +3,23 @@
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include "erreurs.h"
|
#include "erreurs.h"
|
||||||
|
|
||||||
|
#define PROFONDEUR 24
|
||||||
|
|
||||||
SDL_Surface* init() {
|
SDL_Surface* init() {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
die("Erreur lors de l'initialisation de SDL :");
|
die("Erreur lors de l'initialisation de SDL :");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface* fenetre;
|
SDL_Surface* fenetre;
|
||||||
fenetre = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE);
|
fenetre = SDL_SetVideoMode(640, 480, PROFONDEUR, SDL_HWSURFACE);
|
||||||
if (fenetre == NULL) {
|
if (fenetre == NULL) {
|
||||||
die("Erreur lors de la création de la fenêtre.");
|
die("Erreur lors de la création de la fenêtre.");
|
||||||
}
|
}
|
||||||
SDL_WM_SetCaption("Lew", "lew.png");
|
SDL_WM_SetCaption("Lew", "lew.png");
|
||||||
|
|
||||||
|
SDL_FillRect(fenetre, NULL, SDL_MapRGB(fenetre->format, 0, 0, 0));
|
||||||
|
SDL_Flip(fenetre);
|
||||||
|
|
||||||
return fenetre;
|
return fenetre;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +31,16 @@ void quit() {
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
SDL_Surface* fenetre = init();
|
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);
|
SDL_Flip(fenetre);
|
||||||
|
|
||||||
while (1);
|
while (1);
|
||||||
|
|
||||||
|
SDL_FreeSurface(bloc);
|
||||||
|
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user