Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » al_font_load_bitmap_font() fails

This thread is locked; no one can reply to it. rss feed Print
al_font_load_bitmap_font() fails
Matthew Leverton
Supreme Loser
January 1999
avatar

I got Speed ported to Allegro 5 (Windows Binary). But when playing it on another computer, it doesn't work. It exits immediately due to the font not being loaded.

I stripped my main routine down and the following code fails:

1int main(int argc, char *argv[])
2{
3 ALLEGRO_DISPLAY *display;
4 
5 al_init();
6 
7 al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE | ALLEGRO_OPENGL);
8 display = al_create_display(640, 480);
9 
10 al_set_window_title("SPEED");
11 
12 /* set up everything else */
13 al_iio_init();
14 al_font_init();
15 
16 font = al_font_load_bitmap_font("font.tga", NULL);
17 if (!font)
18 {
19 al_rest(10);
20 exit(1);
21 }
22 
23 al_destroy_display(display);
24 
25 return 0;
26}
27 
28END_OF_MAIN();

It works on my computer I'm developing on but fails on my laptop and Virtual PC. I'm static linking everything, including the VC runtime. Dependency viewer shows no unresolved dependencies.

I tried absolute paths and relative paths and it fails just the same.

Is there a bug here, or am I missing something stupid?

Trent Gamblin
Member #261
April 2000
avatar

I had the same problem on my laptop with this game. Did you try running it when compiled with debug libs? For me that pointed out that it was asserting before loading the font and the reason was that I didn't have proper OpenGL drivers installed. I had 1.1 and A5 requires 1.2. That was displayed in the allegro.log as Driver: Microsoft.

Matthew Leverton
Supreme Loser
January 1999
avatar

Okay... that's odd. Why does it let me create a display but then fail to load a font? It seems like it should not create a window if that's the case.

But you are right. When I use the D3D driver, it works.

Milan Mimica
Member #3,877
September 2003
avatar

I figured that Allegro is fine here. It lets you create the OpenGL display so that you can use OpenGL 1.1 yourself if you really want to (you should always check OpenGL version anyway). However, al_create_bitmap() will fail for non-memory bitmaps because it requires OpenGL 1.2 (maybe even higher).
al_font_load_bitmap_font() should check return values and return NULL.
Also, the limitation should be documented.

Matthew Leverton
Supreme Loser
January 1999
avatar

My Dell laptop has Mobile IntelĀ® 945GM graphics, which supports 100% of OpenGL 1.4, and some other miscellaneous features. So yes, it should be noted that using the OpenGL driver on Windows is pretty much worthless.

Milan Mimica
Member #3,877
September 2003
avatar

No, OpenGL 1.4 should really be enough. Can you post the allegro.log?

Matthew Leverton
Supreme Loser
January 1999
avatar

Here's part of it:

Quote:

...

wgl-win INFO: OpenGL Version: 1.1.0
wgl-win INFO: Vendor: Microsoft Corporation
wgl-win INFO: Renderer: GDI Generic

...

ogl_bitmap: glTexImage2D for format 18, size 1024x256 failed

I assume that's the relevant portion.

Why the "GDI Generic" ... Shouldn't that say Intel 945GM, as the OpenGL Extension Viewer program reports?

Edit:

Quote:

wgl-win INFO: Decoding visual no. 9...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated [sic]: no
wgl-win INFO: Doublebuffer: yes
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a0, 32 bit
wgl-win INFO: Depth buffer: 32 bits

wgl-win INFO: select_pixel_format(): Chose visual no. 9

By hardcoding this one, it works:

Quote:

wgl-win INFO: Decoding visual no. 6...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: yes
wgl-win INFO: Doublebuffer: yes
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a8, 32 bit
wgl-win INFO: Depth buffer: 24 bits

Milan Mimica
Member #3,877
September 2003
avatar

Yap, It chose the generic MS driver, not the Intel's one. Find the line printed by TRACE(PREFIX_I "Accelarated: %s\n", pf->rmethod ? "yes" : "no"); The code gives priority to visuals that claim to be accelerated. If none of them claims to be accelerated how can we tell which is the good one?

EDIT: heh

Matthew Leverton
Supreme Loser
January 1999
avatar

If you see my edit, it skips accelerated ones.

What it doesn't like is "_al_pixel_format_fits"

Quote:

wgl-win INFO: get_available_pixel_formats_old(): Got 42 visuals.
wgl-win INFO: Decoding visual no. 1...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: yes
wgl-win INFO: Doublebuffer: no
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a8, 32 bit
wgl-win INFO: Depth buffer: 0 bits
--
wgl-win INFO: Decoding visual no. 2...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: yes
wgl-win INFO: Doublebuffer: yes
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a8, 32 bit
wgl-win INFO: Depth buffer: 0 bits
--
wgl-win INFO: Decoding visual no. 3...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: yes
wgl-win INFO: Doublebuffer: no
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a8, 32 bit
wgl-win INFO: Depth buffer: 16 bits
--
wgl-win INFO: Decoding visual no. 4...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: yes
wgl-win INFO: Doublebuffer: yes
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a8, 32 bit
wgl-win INFO: Depth buffer: 16 bits
--
wgl-win INFO: Decoding visual no. 5...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: yes
wgl-win INFO: Doublebuffer: no
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a8, 32 bit
wgl-win INFO: Depth buffer: 24 bits
--
wgl-win INFO: Decoding visual no. 6...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: yes
wgl-win INFO: Doublebuffer: yes
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a8, 32 bit
wgl-win INFO: Depth buffer: 24 bits
--
wgl-win INFO: Decoding visual no. 7...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: no
wgl-win INFO: Doublebuffer: no
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a0, 32 bit
wgl-win INFO: Depth buffer: 32 bits
--
wgl-win INFO: Decoding visual no. 8...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: no
wgl-win INFO: Doublebuffer: no
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a0, 32 bit
wgl-win INFO: Depth buffer: 16 bits
--
wgl-win INFO: Decoding visual no. 9...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: no
wgl-win INFO: Doublebuffer: yes
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a0, 32 bit
wgl-win INFO: Depth buffer: 32 bits
--
wgl-win INFO: Decoding visual no. 10...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: no
wgl-win INFO: Doublebuffer: yes
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a0, 32 bit
wgl-win INFO: Depth buffer: 16 bits
--
wgl-win INFO: Decoding visual no. 19...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: no
wgl-win INFO: Doublebuffer: no
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a0, 24 bit
wgl-win INFO: Depth buffer: 32 bits
--
wgl-win INFO: Decoding visual no. 20...
wgl-win INFO: Decoding:
wgl-win INFO: Accelarated: no
wgl-win INFO: Doublebuffer: no
wgl-win INFO: Swap method: undefined
wgl-win INFO: Color format: r8 g8 b8 a0, 24 bit
wgl-win INFO: Depth buffer: 16 bits
--
wgl-win INFO: i: 1 rmethod: 1 db: 0 !want_sb: 1 format_fits: 0 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 2 rmethod: 1 db: 1 !want_sb: 1 format_fits: 0 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 3 rmethod: 1 db: 0 !want_sb: 1 format_fits: 0 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 4 rmethod: 1 db: 1 !want_sb: 1 format_fits: 0 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 5 rmethod: 1 db: 0 !want_sb: 1 format_fits: 0 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 6 rmethod: 1 db: 1 !want_sb: 1 format_fits: 0 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 7 rmethod: 0 db: 0 !want_sb: 1 format_fits: 1 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 8 rmethod: 0 db: 0 !want_sb: 1 format_fits: 1 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 9 rmethod: 0 db: 1 !want_sb: 1 format_fits: 1 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 10 rmethod: 0 db: 1 !want_sb: 1 format_fits: 1 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 19 rmethod: 0 db: 0 !want_sb: 1 format_fits: 1 fc: 0 fd: 0 smpb: 0
wgl-win INFO: i: 20 rmethod: 0 db: 0 !want_sb: 1 format_fits: 1 fc: 0 fd: 0 smpb: 0

wgl-win INFO: -1 9

Milan Mimica
Member #3,877
September 2003
avatar

Ah I see, this is not new either. Default pixel format is ALLEGRO_PIXEL_FORMAT_ANY_NO_ALPHA, while all your accelerated visuals would fit in ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA. I am going to fix this by introducing ALLEGRO_PIXEL_FORMAT_ANY.
So calling al_set_new_display_flags(ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA) prior to al_create_display() would make it work correctly.

Go to: