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
| #include <SDL.h>
#include <SDL_ttf.h>
int main(int argc, char* args[])
{
SDL_Window *fenetre = NULL;
SDL_Renderer *Rendu = NULL;
SDL_Init(SDL_INIT_VIDEO);
fenetre = SDL_CreateWindow("Jeu alignement", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 768, SDL_SWSURFACE);
Rendu = SDL_CreateRenderer(fenetre, -1, SDL_RENDERER_ACCELERATED);
TTF_Init();
SDL_Surface *texte = NULL, *ecran = NULL;
TTF_Font *Police = TTF_OpenFont("..//Font//times.ttf", 24);
SDL_Color couleur = { 255,255,255 };
texte = TTF_RenderText_Blended(Police, "ok gg sa marche bien", couleur);
SDL_Rect img = { 0,0,300,150 };
ecran = SDL_GetWindowSurface(fenetre);
SDL_BlitSurface(texte, NULL, ecran, &img);
SDL_UpdateWindowSurface(fenetre);
SDL_Event event;
bool exec = false;
while (!exec)
{
SDL_WaitEvent(&event);
if (event.key.keysym.sym == SDLK_r)
exec = true;
}
TTF_CloseFont(Police);
TTF_Quit();
SDL_FreeSurface(texte);
SDL_Quit();
return 0;
} |
Partager