Skip to content

Commit fe484f4

Browse files
committed
examples: Add Allegro 5 example
1 parent 15d71a6 commit fe484f4

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'' Allegro5 example, based on the Allegro5 documentation
2+
3+
#include "allegro5/allegro.bi"
4+
#include "allegro5/allegro_font.bi"
5+
#include "allegro5/allegro_ttf.bi"
6+
7+
var TTF_FONT = exepath() + "/../SDL/data/Vera.ttf"
8+
9+
al_init()
10+
al_init_font_addon()
11+
al_init_ttf_addon()
12+
13+
var display = al_create_display(640, 480)
14+
if display = NULL then
15+
print "al_create_display() failed"
16+
end 1
17+
end if
18+
19+
var font = al_load_ttf_font(TTF_FONT, 24, 0)
20+
if font = NULL then
21+
print "al_load_ttf_font() failed"
22+
end 1
23+
end if
24+
25+
var eventqueue = al_create_event_queue()
26+
al_install_keyboard()
27+
al_register_event_source(eventqueue, al_get_display_event_source(display))
28+
al_register_event_source(eventqueue, al_get_keyboard_event_source())
29+
30+
do
31+
al_clear_to_color(al_map_rgb(0,0,255))
32+
al_draw_text(font, al_map_rgb(255,255,255), 100, 100, 0, "Hello!")
33+
al_draw_text(font, al_map_rgb(0,255,0), 100, 200, 0, "Press any key to exit.")
34+
35+
al_flip_display()
36+
37+
dim event as ALLEGRO_EVENT
38+
al_wait_for_event(eventqueue, @event)
39+
40+
select case event.type
41+
case ALLEGRO_EVENT_KEY_DOWN, ALLEGRO_EVENT_DISPLAY_CLOSE
42+
exit do
43+
end select
44+
loop
45+
46+
al_destroy_event_queue(eventqueue)
47+
al_destroy_display(display)

0 commit comments

Comments
 (0)