Hello Everybody !
I'm new to Allegro Programming (and programming in general ) and i get an error i don't even know the meaning of
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).
There are no compilation errors.
The TTF file "Roboto-Bold.ttf" is in the program folder.
When i use "al_create_builtin_font" instead of "al_load_ttf_font" it works perfectly.
At runtime, the debug console displays "It Works" and creates the display before crashing.
The crash message displayed in the console is:
File: C:/dev/allegro_winpkg/universal/allegro/addons/font/text.c, Line 79
Please, can someone tell me what messes everything up ?
2 hours i've been trying to solve this without success
Thank you very much !!!
After "al_laod_ttf_font" font pointer is null, so it means it doesn't find the font, but i double checked and the ttf file is in the exe folder...
Any ideas ?
I found the problem, but its still really really weird:
I use code::blocks, and when i run the program from code::blocks, it crashes.
But, when i run the program directly from the .exe file in the bin/debug folder of my project... IT WORKS !
I actually have no idea what caused this bug tho, and i would be interested if someone had an idea
Short answer - check the current working directory.
Long answer - change the directory to the one where your executable is, and THEN load your font.
Thank you very much !
Its weird the working directory isnt the good one by default...
Have a good day ^^
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.
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;