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:
| 1 | int 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 | |
| 28 | END_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?
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.
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.
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.
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.
No, OpenGL 1.4 should really be enough. Can you post the allegro.log?
Here's part of it:
...
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:
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:
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
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
If you see my edit, it skips accelerated ones.
What it doesn't like is "_al_pixel_format_fits"
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
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.