Allegro バージョン 5.0 の概要
◆ Ubuntu での操作手順例
sudo apt -y update sudo apt -y install flac libflac++-dev libflac-dev sudo apt -y install libdump sudo apt -y install libvorbis-dev sudo apt -y install libogg-dev sudo apt -y install libxxf86dga-dev oss4-dev x11proto-xf86dga-dev
cd /tmp tar -xvzof allegro-5.0.8.tar.gz cd allegro-5.0.8
次の手順でオプションを確認
cmake . make
※ cmake のあとには半角スペースと、半角のピリオド
sudo make install
ftp://ftp.pucmg.br/Computacao/Mais_Utilizados/Programacao_Software/C_-_C++/CodeBlocks/allegro/allegro/examples/ex_ttf.c
#define ALLEGRO_STATICLINK #include<stdio.h> #include<allegro.h> #include<allegro_ttf.h> #include<allegro_primitives.h> static ALLEGRO_FONT *font24; int doit() { al_draw_textf(font24, al_map_rgb(128, 100, 20), 50, 50, ALLEGRO_ALIGN_CENTRE, "hoge"); return 0; } int main() { /* you should always do this at the start of Allegro programs */ if(!al_init()) { return -1; } /* set up the keyboard handler */ al_install_keyboard(); /* set up the mouse handler */ al_install_mouse(); /* set up fonts */ al_init_font_addon(); al_init_ttf_addon(); /* set a graphics mode sized 800x640 */ ALLEGRO_DISPLAY *display = NULL; display = al_create_display(800, 640); if(!display) { return -1; } /* load font */ font24 = al_load_font("/usr/share/fonts/truetype/freefont/FreeSans.ttf",24,0); al_clear_to_color(al_map_rgb(0,0,0)); // clears the screen to the selected color doit(); ALLEGRO_EVENT_QUEUE *EventQueue; ALLEGRO_EVENT Event; bool Exit = false; EventQueue = al_create_event_queue(); al_register_event_source(EventQueue, al_get_display_event_source(display)); al_register_event_source(EventQueue, al_get_keyboard_event_source()); al_register_event_source(EventQueue, al_get_mouse_event_source()); while(Exit == false) { al_flip_display(); al_wait_for_event(EventQueue, &Event); if(Event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { Exit = true; } } al_destroy_display(display); return 0; }
次の手順でコンパイル
g++ hoge.cc -I/usr/local/include/allegro5 -L/usr/local/lib -lallegro -lallegro_font -lallegro_ttf -lm
次の手順で実行
./a.out