Hello everyone,
I have a simple program that displays the text "hey" in a window.
#SelectExpand
1#include <allegro5/allegro5.h>
2#include <allegro5/allegro_font.h>
3#include <stdio.h>
4
5void must_init
(_Bool test,
const char *description
)
6{
7 if(test
) return;
8
9 fprintf(stderr,
"couldn't initialize %s\n", description
);
10 exit(1);
11}
12
13void main
(){
14 must_init
(al_init(),
"allegro");
15 must_init
(al_init_font_addon(),
"fonts");
16 ALLEGRO_DISPLAY* disp
= al_create_display(500,
500);
17 must_init
(disp,
"display");
18
19 ALLEGRO_EVENT event
;
20 ALLEGRO_EVENT_QUEUE *queue
=al_create_event_queue();
21 must_init
(queue,
"queue");
22 al_register_event_source(queue,
al_get_display_event_source(disp
));
23
24 ALLEGRO_FONT* font = al_create_builtin_font
();
25 must_init
(font,
"builitin font");
26
27 while(true){
28 al_clear_to_color(al_map_rgb(0,
0,
0));
29 al_draw_text(font,
al_map_rgb(255,
255,
255),
0,
0,
0,
"hey");
30 al_flip_display();
31 if(event.type
== ALLEGRO_EVENT_DISPLAY_CLOSE
){
32 return;
33 }
34 al_wait_for_event(queue,
&event
);
35
36 }
37}
Then I wanted to improve this program by making the window resizeable:
#SelectExpand
1#include <allegro5/allegro5.h>
2#include <allegro5/allegro_font.h>
3#include <stdio.h>
4
5void must_init
(_Bool test,
const char *description
)
6{
7 if(test
) return;
8
9 fprintf(stderr,
"couldn't initialize %s\n", description
);
10 exit(1);
11}
12
13void main
(){
14 must_init
(al_init(),
"allegro");
15 must_init
(al_init_font_addon(),
"fonts");
16 al_set_new_display_flags(ALLEGRO_RESIZABLE
|ALLEGRO_WINDOWED
);
17 ALLEGRO_DISPLAY* disp
= al_create_display(500,
500);
18 must_init
(disp,
"display");
19
20 ALLEGRO_EVENT event
;
21 ALLEGRO_EVENT_QUEUE *queue
=al_create_event_queue();
22 must_init
(queue,
"queue");
23 al_register_event_source(queue,
al_get_display_event_source(disp
));
24
25 ALLEGRO_FONT* font = al_create_builtin_font
();
26 must_init
(font,
"builitin font");
27
28 while(true){
29 al_acknowledge_resize(disp
);
30 al_clear_to_color(al_map_rgb(0,
0,
0));
31 al_draw_text(font,
al_map_rgb(255,
255,
255),
0,
0,
0,
"hey");
32 al_flip_display();
33 if(event.type
== ALLEGRO_EVENT_DISPLAY_CLOSE
){
34 return;
35 }
36 al_wait_for_event(queue,
&event
);
37
38 }
39}
When I run this program in linux everything works fine, but when I run it windows or wine I see no text.
Would somebody be so kind as to tell me why this error occures?