![]() |
|
TTF Loading Failing |
mumu1000
Member #16,842
April 2018
|
Hello Everybody ! I Just want to make a "Hello World" test program, everything works fine, until i try to load a ttf font (it worked with the builtin font). 1
2#include <iostream>
3#include <string>
4#include "allegro.h"
5#include "allegro_color.h"
6#include "allegro_font.h"
7#include "allegro_ttf.h"
8
9int main(int argc, char **argv)
10{
11 bool allegroIsWorking = al_init();
12 bool alfontIsWorking = al_init_font_addon();
13 bool alTTFIsWorking = al_init_ttf_addon();
14 if(allegroIsWorking && alfontIsWorking && alTTFIsWorking)
15 {
16 cout << "It Works\n";
17 }
18 ALLEGRO_DISPLAY * Ecran = al_create_display(1000,500);
19 ALLEGRO_FONT * font = al_load_ttf_font("Roboto-Bold.ttf",70,0);
20 al_clear_to_color(al_map_rgb(0,0,0));
21 al_draw_text(font,al_map_rgb(255,255,255), 2,2,0,"Hello world");
22 al_flip_display();
23
24
25 return 0;
26}
There are no compilation errors. Assertion failed! Program: C:\Users\PathToMyProgam\program.exe Expression: font Please, can someone tell me what messes everything up ? Thank you very much !!! Edit: Edit Edit: I use code::blocks, and when i run the program from code::blocks, it crashes. I actually have no idea what caused this bug tho, and i would be interested if someone had an idea |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Short answer - check the current working directory. Long answer - change the directory to the one where your executable is, and THEN load your font. 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 |
mumu1000
Member #16,842
April 2018
|
Thank you very much ! Have a good day ^^ |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
The working directory is where ever you ran the program from. There's a setting in CB that lets you change the executable's current working directory. {"name":"611416","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/a\/ea1a752635f9cb273e082b13c8ff3b99.png","w":877,"h":747,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/a\/ea1a752635f9cb273e082b13c8ff3b99"} However, that doesn't stop users running your program outside of CB. For that you need to fix the current working directory. You can do this pretty easily with Allegro 5. ALLEGRO_PATH* p = al_get_standard_path(ALLEGRO_EXENAME_PATH); al_change_directory(al_path_cstr(p) , ALLEGRO_NATIVE_PATH_SEP); al_destroy_path(p); p = 0;
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 |
|