#include <stdio.h>
#include <string.h>
#include <allegro.h>
// Definiciones
#define WIDTH 320
#define HEIGHT 200
#define DEPTH 8
// Version (major.minor)
#define VERSION_MAJOR 1
#define VERSION_MINOR 00
int main(void)
{
int i;
char temp[80];
if(install_allegro(SYSTEM_AUTODETECT, &errno, atexit)){
allegro_message(" Error inicializando el sistema \n%s\n", allegro_error);
allegro_exit();
}
if(install_keyboard()){
allegro_message(" Error inicializando teclado de Allegro \n%s\n", allegro_error);
allegro_exit();
}
// Colocamos titulo de la ventana, version y subversion
strcpy(temp,"");
sprintf(temp,"Allegro Leccion 03-Salida de texto 2003 v%d.%d", VERSION_MAJOR, VERSION_MINOR);
set_window_title(temp);
set_color_depth(DEPTH);
set_color_conversion(COLORCONV_TOTAL);
if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, WIDTH, HEIGHT, WIDTH, HEIGHT)<0){
allegro_message("Modo grafico no detectado \n%s\n", allegro_error);
allegro_exit();
}
for (i = 0; i < 100; i += 10) {
text_mode_ex(i / 10 + 1);
textout(screen, font, "Salida de texto, fondo coloreado", i, i, 0);
}
for (i = 0; i < 50; i += 10) {
text_mode(i / 10 + 2);
textout_centre(screen, font, "Texto Centrado", SCREEN_W/2, 5+i, 0);
}
text_mode(-1);
rectfill(screen, 0, 105, SCREEN_W - 1, SCREEN_H - 1, 16);
for (i = 0; i < 100; i += 10)
textout(screen, font, "Salida de texto, fondo transparente", i, 105 + i, i / 10 + 1);
for (i = 0; i < 50; i += 10)
textout_centre(screen, font, "Texto Centrado", SCREEN_W/2, 110+i, i/10+1);
readkey();
return 0;
}
END_OF_MAIN();