1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include < stdlib.h>
#include < stdio.h>
#include < SDL/SDL.h>
#include < SDL/SDL_image.h>
void pause();
// -------------------------------------
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL, *imageDeFond = NULL, *sapin = NULL;
SDL_Rect positionFond, positionSapin;
positionFond.x = 0;
positionFond.y = 0;
positionSapin.x = 500;
positionSapin.y = 260;
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetIcon(IMG_Load("sdl_icone.bmp"), NULL);
ecran = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);
SDL_WM_SetCaption("Chargement d'images en SDL", NULL);
imageDeFond = IMG_Load("lac_en_montagne.bmp");
SDL_BlitSurface(imageDeFond, NULL, ecran, &positionFond);
/* Chargement d'un PNG avec IMG_Load
Celui-ci est automatiquement rendu transparent car les informations de
transparence sont codées à l'intérieur du fichier PNG */
sapin = IMG_Load("sapin.png");
SDL_BlitSurface(sapin, NULL, ecran, &positionSapin);
SDL_Flip(ecran);
pause();
SDL_FreeSurface(imageDeFond);
SDL_FreeSurface(sapin);
SDL_Quit();
return EXIT_SUCCESS;
}
// -------------------------------------
void pause()
{
int continuer = 1;
SDL_Event event;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
}
}
}
// ------------------------------------- |
Partager