﻿#include <allegro5\allegro.h>
#include <allegro5\allegro_native_dialog.h>

#include <allegro5\allegro_font.h>
#include <allegro5\allegro_ttf.h>


void erreur(const char*txt)
{
ALLEGRO_DISPLAY *display;

    display = al_is_system_installed() ? al_get_current_display() : NULL;
    al_show_native_message_box( display, "Erreur", txt ,NULL, NULL, 0);
    exit(EXIT_FAILURE);
}


int main()
{
ALLEGRO_DISPLAY*display;

	if(!al_init())
		erreur("init allegro");

	display=al_create_display(800,600);
	if (!display)
		erreur("create display");

	al_init_font_addon();
	al_init_ttf_addon();

	ALLEGRO_FONT*arial24 = al_load_ttf_font("arial.ttf", 24, 0);
	ALLEGRO_FONT*arial36 = al_load_ttf_font("arial.ttf", 36, 0);
	ALLEGRO_FONT*arial18 = al_load_ttf_font("arial.ttf", 18, 0);
	if(!arial24||!arial36||!arial18)
		erreur("load fontes");

	int scrx = al_get_display_width(display);
	int scry = al_get_display_height(display);

	
	al_draw_text(	arial24,al_map_rgb(255, 0, 255),	50, 50,	0,	"Salut 24 point : éàùàâêï");
	al_draw_text(arial36, al_map_rgb(255, 127, 127), scrx / 2, scry / 2, ALLEGRO_ALIGN_CENTRE, "centre et 36 point");
	al_draw_text(arial18, al_map_rgb(15, 240, 18), scrx-10, scry-200, ALLEGRO_ALIGN_RIGHT, "aligne à droite et 18 point");

	al_draw_textf(arial18, al_map_rgb(255, 255, 255), scrx/2, scry-100, ALLEGRO_ALIGN_CENTRE,
		"TEXT formaté: largeur et hauteur écran = %i / %i" , scrx, scry);

	al_flip_display();

	al_rest(5.0);

	al_destroy_font(arial18);
	al_destroy_font(arial24);
	al_destroy_font(arial36);
	al_destroy_display(display);

	return 0;

}

