J´ai fait un code simple, et bien, lorsque je "blitte" en dehors de ma boucle while, ça marche et à l´intérieur, ça ne marche pas ! Une solution ?
// Ce code fonctionne
- include <stdio.h>
- include <stdlib.h>
- include <SDL/SDL.h>
int main(int argc, char *argv[])
{
int continuer = 1;
SDL_Surface *ecran = NULL, *test = NULL;
SDL_Rect position;
position.x = 0;
position.y = -45;
SDL_Event event;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWS
URFACE | SDL_DOUBLEBUF);
test = SDL_CreateRGBSurface(SDL_HWSURFACE, 50, 50, 32, 0, 0, 0, 0);
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
SDL_FillRect(test, NULL, SDL_MapRGB(ecran->format, 255, 0, 0));
SDL_BlitSurface(test, NULL, ecran, &position);
SDL_Flip(ecran);
while(continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
}
// Je met d´habitude ici mes BlitSurface...
}
SDL_FreeSurface(test);
SDL_Quit();
return EXIT_SUCCESS;
}