|
Problem compiling "A4 code" using A5 |
xtheunknown0
Member #13,772
November 2011
|
Hello, I "updated" the A4 code from a book to the point where running yielded on Lucid Lynx. So I went to the Allegro wiki for how to compile programs in 5.x.x and pasted But then my console "blew up" with: Package allegro-5.0 was not found in the pkg-config search path. Why doesn't my code compile? TIA, |
Matthew Leverton
Supreme Loser
January 1999
|
xtheunknown0 said: Package allegro-5.0 was not found in the pkg-config search path. |
xtheunknown0
Member #13,772
November 2011
|
Apparently, no help. I can give you a screenshot of this: |
Matthew Leverton
Supreme Loser
January 1999
|
Have you installed Allegro 5? Does the pc file exist in that location? Note that many of the errors are references to Allegro 4 functions, so even when you get Allegro 5 working it still won't compile. |
xtheunknown0
Member #13,772
November 2011
|
I think it's because I deleted the allegro-5.0 directory that svn created. One thing that I can't apparently "fix" on my own is getpixel(). What is the "equivalent" in A5? I know that the answer to that may be pretty big, so I'll also ask: is it where for simple games (a main.c and a header) you declare a "screen" in the header and initialise it somewhere in main.c then start using it other functions? and how do I set up a screen? BTW, so why was a "screen" argument removed from graphics primitives functions? I thought I could get away with using al_draw_[shape] functions but I need a "screen" for collision detection via getpixel... |
Edgar Reynaldo
Major Reynaldo
May 2007
|
The drawing target (which will also be used with al_get_pixel) in Allegro 5 is part of a stored state. You set it with al_set_target_bitmap and then just call drawing functions as necessary, and they will all draw to the most recent drawing target that you have set with that function. There is no 'screen' in A5, but semantically, the backbuffer is similar. You draw everything you want to display to it, and then call al_flip_display. Also, you will probably want to rework your collision detection, because reading from video memory is slow (if you read from the backbuffer, or another video bitmap). Depends on how many pixels you need to read though. 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 |
xtheunknown0
Member #13,772
November 2011
|
I've got the code to the point where it compiles but it aborts due to loading a font. foo: /home/blah/allegro-5.0/addons/font/text.c:73: al_draw_ustr: Assertion `font' failed. Why is this? TIA, |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Did you call al_init_font_addon and al_init_ttf_addon before loading your font? Also, did you check to make sure the font returned by al_load_ttf_font returned a non-zero value? You may have a problem with the current working directory being different than the one your executable is expecting. 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 |
xtheunknown0
Member #13,772
November 2011
|
That is indeed the problem (returning zero). What do I do about it? TIA, |
xtheunknown0
Member #13,772
November 2011
|
I think what wasn't clear from the start was the significance of having to load a font (, whereas my A4 book doesn't need to). Following from that is having an idea where A5 hunts for files. So I read parts of the manual and I try Now DejaVuSans.ttf is in my Documents/ where tankwar.c is (as well), so why is !font still "true"? TIA, |
Matthew Leverton
Supreme Loser
January 1999
|
It doesn't look anywhere for a font file, except for the exact spot you tell it to. Your code does nothing but tries to load "DejaVuSans.ttf" from the current working directory. Your call to al_get_standard_path() is meaningless. Read Edgar's link and follow the instructions. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
xtheunknown0 said: So I read parts of the manual and I try printf("%s\n", al_path_cstr(al_get_standard_path(ALLEGRO_RESOURCES_PATH), '/')); font = al_load_ttf_font("DejaVuSans.ttf", 72, 0);
Now DejaVuSans.ttf is in my Allegro doesn't search from anywhere except from the current working directory. That might not be the same as what is returned by al_get_standard_path(ALLEGRO_RESOURCES_PATH). To be sure, you have to set the current working directory yourself like the wiki showed you : ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_append_path_component(path, "resources"); al_change_directory(al_path_cstr(path, '/')); // change the working directory al_destroy_path(path);
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 |
Thomas Fjellstrom
Member #476
June 2000
|
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_append_path_component(path, "resources"); al_change_directory(al_path_cstr(path, '/')); // change the working directory al_destroy_path(path); I suppose that is the simplest way. I don't know why but the way I think of first is: ALLEGRO_PATH *res_path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_append_path_component(res_path, "resources"); ALLEGRO_PATH *file_path = al_clone_path(res_path); al_set_path_filename(file_path, 'filename.ext'); ALLEGRO_FONT *font = al_load_font(al_path_cstr(file_path, '/')); al_destroy_path(file_path); In the end its the same, and the first is easier. -- |
xtheunknown0
Member #13,772
November 2011
|
Well, I think I've tried - please tell me if I haven't: ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); I still have the same problem, and there is now a resources/ (storing the ttf) in Documents/ What is it that I do not get? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Is your executable file in the Documents folder? If so, it should work. If it still does not work, link to the debugging version of allegro. Then your program will produce a file called allegro.log and you can look at it for clues as to why the font didn't load. You're sure you initialized both the font addon and the ttf addon before loading? Code goes in <code>code goes here...</code> tags. 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 |
Thomas Fjellstrom
Member #476
June 2000
|
OH right, RESOURCES is actually the exe path on windows I think. You want ALLEGRO_USER_DOCUMENTS_PATH for your "My Documents" folder. ALLEGRO_RESOURCES_PATH is actually the full path to the directory your executable is in. So if you use that, you put your data in the same dir as the exe. -- |
xtheunknown0
Member #13,772
November 2011
|
How do I create an allegro.log? Sorry for being a nuisance. |
Matthew Leverton
Supreme Loser
January 1999
|
xtheunknown0 said: What is it that I do not get? al_change_directory(al_path_cstr(path, '/')); // change the working directory printf("The path: %s\n", al_path_cstr(path, '/')); Is the TTF there in that path that is displayed in your console window? xtheunknown0 said: How do I create an allegro.log? You have to link with the Allegro debug library and define something like ALLEGRO_DEBUG. But that's really not necessary. Debugging is simple: start with the obvious or simple and continue on until you find the problem. There are only a few reasons why it would fail:
9 out of 9 times you'll get the problem figured out after the first and second points are corrected. |
xtheunknown0
Member #13,772
November 2011
|
I believe I've tried the first two - I'm not sure how to help myself now. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
The code in the link you just posted is clearly missing a call to al_init_ttf_addon before you 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 |
|