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 63 64 65 66 67 68
|
#include <stdio.h>
#include "SDL.h"
#include "SDL_image.h"
int main(int argc, char *argv[])
{
Uint32 initflags = SDL_INIT_VIDEO;
SDL_Surface *screen, *image, *Sauvegarde;
Uint8 video_bpp = 32;
Uint32 videoflags = SDL_HWSURFACE;
int done;
SDL_Event event;
SDL_Rect position;
position.x = 200;
position.y = 0;
SDL_Init(initflags);
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255)); // Ecran en blanc
image = IMG_Load("/Users/Lucas/Desktop/images/fond.png"); // On charge l' image.
SDL_LockSurface(image);
Sauvegarde = SDL_CreateRGBSurfaceFrom(image->pixels, image->w, image->h, image->format->BitsPerPixel, image->pitch, 0, 0, 0, 0);
SDL_UnlockSurface(image);
SDL_BlitSurface(Sauvegarde, NULL, screen, &position);
SDL_BlitSurface(image, NULL, screen, NULL); // On blitt l' image dans le coin superieur gauche.
SDL_Flip(screen);
done = 0;
while ( !done ) {
while ( SDL_PollEvent(&event) ) {
switch (event.type) {
case SDL_MOUSEMOTION:
break;
case SDL_MOUSEBUTTONDOWN:
break;
case SDL_KEYDOWN:
/* Any keypress quits the app... */
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
}
SDL_FreeSurface(image);
SDL_FreeSurface(Sauvegarde);
SDL_Quit();
return(0);
} |
Partager