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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL_ttf.h>
#include <SDL_image.h>
#define FENETRE_LARGEUR 500
#define FENETRE_HAUTEUR 500
int main(int argc,char *argv[])
{
TTF_Font *police = NULL;
SDL_Color coleurNoir = {0,0,0};
int i=0,j,continuer = 1;
SDL_Event event;
SDL_Rect position;
SDL_Surface *ecran = NULL, *zozor = NULL;
if(SDL_Init(SDL_INIT_VIDEO) == -1)
{
fprintf(stderr,"ERREUR DE L'INITIALISATION DE LA SDL : %s\n",SDL_GetError());
exit(EXIT_FAILURE);
}
if(TTF_Init() == -1)
{
fprintf(stderr,"ERREUR DE L'INITIALISATION DE LA SDL : %s\n",SDL_GetError());
exit(EXIT_FAILURE);
}
ecran = SDL_SetVideoMode(FENETRE_LARGEUR, FENETRE_HAUTEUR, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE);
if(ecran == NULL)
{
fprintf(stderr,"ERREUR DE L'INITIALISATION DE LA SDL : %s\n",SDL_GetError());
exit(EXIT_FAILURE);
}
police = TTF_OpenFont("ARIALBD.TTF",64);
if(police == NULL)
{
fprintf(stderr,"ERREUR LOAD POLICE : %s\n",TTF_GetError());
exit(EXIT_FAILURE);
}
zozor = TTF_RenderText_Blended(police,"salut tout le monde",coleurNoir);
while(continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
}
SDL_FillRect(ecran,NULL,SDL_MapRGB(ecran->format,0,0,255));
position.x = 0;
position.y = 0;
if(SDL_BlitSurface(zozor,NULL,ecran,&position) == -1)
{
exit(EXIT_FAILURE);
}
SDL_Flip(ecran);
}
TTF_CloseFont(police);
TTF_Quit();
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager