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 64 65 66 67 68 69 70
| //
//* main.c
//* test4
//
//* Created by Benoit Castagnetto on 10/02/2016.
//* Copyright © 2016 Benoit Castagnetto. All rights reserved.
//
*
#include <stdio.h>
#include <stdlib.h>
#include <SDL2_ttf/SDL_ttf.h>
#include <SDL2_image/SDL_image.h>
#include <SDL2/SDL.h>
*
int main (int argc, char** argv)
{
*****
****SDL_Window *ecran = NULL, *texte = NULL, *fond = NULL;
****SDL_Rect position;
****SDL_Event event;
****TTF_Font *police = NULL;
****SDL_Color couleurNoire = {0, 0, 0};
****int continuer = 1;
*****
****SDL_Init(SDL_INIT_VIDEO);
****TTF_Init();
*****
//*** ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
//*** SDL_WM_SetCaption("Gestion du texte avec SDL_ttf", NULL);
*
****ecran = SDL_CreateWindow("test", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
*
*****
//*** fond = IMG_Load("moraira.jpg");
*****
****/* Chargement de la police */
****police = TTF_OpenFont("Arial", 65);
****/* Écriture du texte dans la SDL_Surface texte en mode Blended (optimal) */
****texte = TTF_RenderText_Blended(police, "Salut les Zér0s !", couleurNoire);
*
****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));
*********
********position.x = 0;
********position.y = 0;
********SDL_BlitSurface(fond, NULL, ecran, &position); /* Blit du fond */
*********
********position.x = 60;
********position.y = 370;
********SDL_BlitSurface(texte, NULL, ecran, &position); /* Blit du texte */
********SDL_Flip(ecran);
****}
*****
****TTF_CloseFont(police);
****TTF_Quit();
*****
****SDL_FreeSurface(texte);
****SDL_Quit();
*****
****return EXIT_SUCCESS;
} |
Partager