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
| #include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h> /* Ne pas oublier l'include ! */
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL;
SDL_Event event;
TTF_Font *police = NULL; /* Stockera les informations de police */
int continuer = 1;
SDL_Init(SDL_INIT_VIDEO);
TTF_Init(); /* Initialisation (peut être avant ou après SDL_Init) */
ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Gestion du texte avec SDL_ttf", NULL);
police = TTF_OpenFont("angelina.ttf", 65); /* Ouverture de la police au début */
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
}
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
SDL_Flip(ecran);
}
TTF_CloseFont(police); /* Fermeture de la police avant TTF_Quit */
TTF_Quit(); /* Arrêt de SDL_ttf (peut être avant ou après SDL_Quit, peu importe) */
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager