|
Weird issue with font, can anybody help? |
Xyphon
Member #16,627
January 2017
|
Hey, here is my current code firstly: 1#include <allegro5/allegro.h>
2#include <allegro5/allegro_font.h>
3#include <allegro5/allegro_ttf.h>
4#include <stdio.h>
5
6int main(int argc, char **argv) {
7 ALLEGRO_DISPLAY *display = NULL;
8 ALLEGRO_EVENT_QUEUE *event_queue = NULL;
9 ALLEGRO_FONT *myfont = NULL;
10 al_init();
11
12 al_init_font_addon();
13 al_init_ttf_addon();
14 al_install_keyboard();
15
16 display = al_create_display(640, 480);
17 myfont = al_load_ttf_font("pirulen.ttf", 72, 0);
18 event_queue = al_create_event_queue();
19 al_register_event_source(event_queue, al_get_display_event_source(display));
20 al_register_event_source(event_queue, al_get_keyboard_event_source());
21 al_clear_to_color(al_map_rgb(255, 255, 255));
22 al_flip_display();
23 while (1)
24 {
25 ALLEGRO_EVENT ev;
26 ALLEGRO_TIMEOUT timeout;
27 al_init_timeout(&timeout, 0.06);
28
29 bool get_event = al_wait_for_event_until(event_queue, &ev, &timeout);
30
31 if (get_event && ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
32 break;
33 }
34 else if (get_event && ev.type == ALLEGRO_EVENT_KEY_DOWN) {
35 int code = ev.keyboard.keycode;
36 al_draw_text(myfont, al_map_rgb(0, 0, 0), 320, 240, ALLEGRO_ALIGN_CENTRE, "Button pressed!");
37 }
38
39 al_clear_to_color(al_map_rgb(255, 255, 255));
40 al_flip_display();
41 }
42 al_destroy_display(display);
43 al_destroy_event_queue(event_queue);
44 return 0;
45}
For some reason, I keep getting errors saying unresolved external symbol for By the way, I'm using Visual Studio 2015. Thanks in advance |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You have to link the font and ttf addons. If you're using Nuget, you need to tick the check box for those two libraries for linking. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Xyphon
Member #16,627
January 2017
|
Thank you! Problem solved. |
|