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
|
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL, *lignes[256] = {NULL};
SDL_Rect position;
int i = 0;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(256, 640, 32, SDL_HWSURFACE);
for (i = 0 ; i <= 255 ; i++)
lignes[i] = SDL_CreateRGBSurface(SDL_HWSURFACE, 1 ,640, 32, 0, 0, 0, 0);
SDL_WM_SetCaption("Mon dégradé en SDL !", NULL);
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
for (i = 0 ; i <= 255 ; i++)
{
position.x = i;
position.y = 0;
SDL_FillRect(lignes[i], NULL, SDL_MapRGB(ecran->format, i, i, i));
SDL_BlitSurface(lignes[i], NULL, ecran, &position);
}
SDL_Flip(ecran);
pause();
for (i = 0 ; i <= 255 ; i++)
SDL_FreeSurface(lignes[i]);
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager