|
Problem loading non-bitmaps using physfs |
auamidium
Member #9,630
March 2008
|
I basically have the same problem as this guy, Bitmaps load correctly using but in technoid_font stays NULL. The files do exist, I know the paths are correct because the bitmap was properly loaded from in the .zip file. I just don't know what I am doing wrong with the font file. It loaded properly from a normal folder before I started using physfs. Thanks! It'll be open source if I ever finish it. |
Trent Gamblin
Member #261
April 2000
|
You're using the wrong function to load a ttf aren't you? It's al_load_ttf_font.
|
auamidium
Member #9,630
March 2008
|
Oooops, my bad. I was not copying and pasting. But I am actually using al_load_ttf_font() It works fine if I comment out all the physfs stuff and just load from in folder, but I want to use physfs because I have hundreds of resource files. It'll be open source if I ever finish it. |
Trent Gamblin
Member #261
April 2000
|
The guy in the other thread said he solved it by Quote: EDIT: Okay, I solved it. I removed ALL the libraries I was linking and re-added them in and I think I added in libphysfs.a instead of libphysfs.dll.a by accident. not sure about the difference, I assume one is a statically linked lib. =/
|
auamidium
Member #9,630
March 2008
|
I am linking "allegro_physfs-5.0.0-RC4-mt.dll", which I assume is the correct file? 1//...
2
3#include <allegro5/allegro.h>
4#include <allegro5/allegro_image.h>
5#include <allegro5/allegro_font.h>
6#include <allegro5/allegro_ttf.h>
7#include <physfs.h>
8#include <allegro5/allegro_physfs.h>
9
10// ...
11
12ALLEGRO_BITMAP *title_screen_bitmap = NULL;
13
14ALLEGRO_FONT *technoid_font = NULL;
15ALLEGRO_FONT *technoid_font_small = NULL;
16
17//...
18
19int main(int argc, char **argv)
20{
21 //...
22 if(!al_init())
23 {
24 cout << "failed to initalize allegro!" << endl;
25 return -1;
26 }
27
28 Cout_Debug_Version_Data();
29
30 if(!al_init_image_addon())
31 {
32 cout << "failed to iniitalize allegro image" << endl;
33 return -1;
34 }
35
36 ALLEGRO_DISPLAY *display = NULL;
37 display = al_create_display(SCREEN_W, SCREEN_H);
38 if(!display)
39 {
40 cout << "failed to create display!" << endl;
41 return -1;
42 }
43
44 if(!PHYSFS_init(argv[0]))
45 {
46 cout << "failed PHYSFS init" << endl;
47 return -1;
48 }
49
50 if(PHYSFS_mount("resources.zip", "/", 1) == 0)
51 {
52 cout << "Could not find resources.zip" << endl;
53 return -1;
54 }
55
56 al_set_physfs_file_interface();
57 al_init_font_addon();
58 al_init_ttf_addon();
59
60 // init other stuff...
61
62 //...
63
64 title_screen_bitmap = al_load_bitmap("title_screen_bitmap.bmp");
65 if(title_screen_bitmap == NULL)
66 {
67 cout << "problems" << endl;
68
69 } // works fine, no problems
70
71 technoid_font = al_load_ttf_font("TECHNOID.ttf",60,0);
72 technoid_font_small = al_load_ttf_font("TECHNOID.ttf",30,0);
73
74 if(technoid_font == NULL || technoid_font_small == NULL)
75 {
76 cout << "text loading failed" << endl;
77 return -1;
78 } //couts text loading fail and quits
79
80// Everything else
81
82}
Edit: I changed to technoid_font_small = al_load_ttf_font("TECHNOIDS.ttf",30,0); and it works. Is it that I cannot load the same file twice? Thanks though. It'll be open source if I ever finish it. |
Neil Walker
Member #210
April 2000
|
I don't really know A5, but does al_filename_exists return true? [edit]ah, well scrap my reply I never saw your update. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Edgar Reynaldo
Major Reynaldo
May 2007
|
auamidium said: Edit: I changed to technoid_font_small = al_load_ttf_font("TECHNOIDS.ttf",30,0); and it works. Is it that I cannot load the same file twice? Thanks though. Maybe 60 just isn't supported for that font? I don't know how Allegro handles sizes that aren't in the 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 |
Arthur Kalliokoski
Second in Command
February 2005
|
Edgar Reynaldo said: Maybe 60 just isn't supported for that font? I don't know how Allegro handles sizes that aren't in the font. TTF fonts are drawn using math functions, they don't really have a minimum or maximum size. I learned this a http://www.allegro.cc/forums/thread/604975/881025 OTOH, I hung the entire box fiddling with an insanely huge font (don't remember the size) and after I rebooted the log files said there had been a crash in the video driver. They all watch too much MSNBC... they get ideas. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
auamidium said:
technoid_font = al_load_font("technoid.ttf",60,0); The two calls are different - one has an a 's' and one doesn't, so it was the file name giving you problems, not the font size. 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 |
Matthew Leverton
Supreme Loser
January 1999
|
He's saying that if he tries to load the same font file twice with different sizes, it fails. If he creates two copies of the font within the same zip file with different names, then he can load them both. If that is really happening, then it sounds like a bug with Allegro. It should be easy for somebody to reproduce. |
|