|
|
| [Bug] [A5.1] Allegro crashes in fullscreen mode (rel. al_init_ttf_addon) |
|
Max Savenkov
Member #4,613
May 2004
|
I saw this reported already, but details were sketchy. Allegro crashes sometimes under Windows when using DirectX render in full-screen mode with non-desktop resolution. Crash seems to be related to TTF addon. Here's my reproduction code: 1 al_init();
2
3 al_set_new_bitmap_flags( ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR | ALLEGRO_MIPMAP | ALLEGRO_VIDEO_BITMAP );
4
5 al_set_new_display_flags( ALLEGRO_FULLSCREEN|ALLEGRO_DIRECT3D );
6 al_set_new_display_option( ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST );
7 al_set_new_display_option( ALLEGRO_COLOR_SIZE, 32, ALLEGRO_REQUIRE );
8
9 ALLEGRO_DISPLAY *d = al_create_display(1024, 768);
10 if ( !d ) return;
11
12 al_init_image_addon();
13 al_init_font_addon();
14 al_init_ttf_addon();
15
16 ALLEGRO_BITMAP *b = al_load_bitmap( "../Data/Sprites/defence_arrows.png" );
17
18 al_flip_display();
19
20 al_destroy_bitmap( b );
21 al_destroy_display( d );
Allegro (or rather DirectX) will crash in call from al_load_bitmap to here: 1static void d3d_do_upload(ALLEGRO_BITMAP *bmp, int x, int y, int width,
2 int height, bool sync_from_memory)
3{
4 ALLEGRO_BITMAP_EXTRA_D3D *d3d_bmp = get_extra(bmp);
5
6 if (sync_from_memory) {
7 d3d_sync_bitmap_texture(bmp, x, y, width, height);
8 }
9
10 if (_al_d3d_render_to_texture_supported()) {
11 if (d3d_bmp->display->device->UpdateTexture(
12 (IDirect3DBaseTexture9 *)d3d_bmp->system_texture,
13 (IDirect3DBaseTexture9 *)d3d_bmp->video_texture) != D3D_OK) {
14 ALLEGRO_ERROR("d3d_do_upload: Couldn't update texture.\n");
15 return;
16 }
17 }
18}
...on call to d3d_bmp->display->device->UpdateTexture on attempt to access invalid pointer. Bot input pointers seem to be valid at the first glance, so something deeper is corrupted. However, this will not happen, if I initialize ttf addon BEFORE creating display: 1 al_init();
2
3 al_set_new_bitmap_flags( ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR | ALLEGRO_MIPMAP | ALLEGRO_VIDEO_BITMAP );
4
5 al_set_new_display_flags( ALLEGRO_FULLSCREEN|ALLEGRO_DIRECT3D );
6 al_set_new_display_option( ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST );
7 al_set_new_display_option( ALLEGRO_COLOR_SIZE, 32, ALLEGRO_REQUIRE );
8
9 al_init_image_addon();
10 al_init_font_addon();
11 al_init_ttf_addon();
12
13 ALLEGRO_DISPLAY *d = al_create_display(1024, 768);
14 if ( !d ) return;
15
16 ALLEGRO_BITMAP *b = al_load_bitmap( "../Data/Sprites/defence_arrows.png" );
17
18 al_flip_display();
19
20 al_destroy_bitmap( b );
21 al_destroy_display( d );
This way, it always works. However, I could find no mention of this in docs, and also this does not happen if I either:
So I think it's a bug.
|
|
Trent Gamblin
Member #261
April 2000
|
This is al_init_ttf_addon, so to me it looks like something in Freetype itself: 1bool al_init_ttf_addon(void)
2{
3 if (ttf_inited) {
4 ALLEGRO_WARN("TTF addon already initialised.\n");
5 return true;
6 }
7
8 FT_Init_FreeType(&ft);
9 vt.font_height = ttf_font_height;
10 vt.font_ascent = ttf_font_ascent;
11 vt.font_descent = ttf_font_descent;
12 vt.char_length = ttf_char_length;
13 vt.text_length = ttf_text_length;
14 vt.render_char = ttf_render_char;
15 vt.render = ttf_render;
16 vt.destroy = ttf_destroy;
17 vt.get_text_dimensions = ttf_get_text_dimensions;
18 vt.get_font_ranges = ttf_get_font_ranges;
19
20 al_register_font_loader(".ttf", al_load_ttf_font);
21
22 /* Can't fail right now - in the future we might dynamically load
23 * the FreeType DLL here and/or initialize FreeType (which both
24 * could fail and would cause a false return).
25 */
26 ttf_inited = true;
27 return ttf_inited;
28}
|
|
Max Savenkov
Member #4,613
May 2004
|
I suspect race condition or some other synchronization problem somewhere. If I place a unneeded call to al_flip_display before addon initialization, code stop crashing: ALLEGRO_DISPLAY *d = al_create_display(1024, 768); al_flip_display(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); ALLEGRO_BITMAP *b = al_load_bitmap( "../Data/Sprites/defence_arrows.png" al_flip_display(); ); However, adding al_rest( 10.0 ) instead of al_flip_display do not help. I noticed that when I try to set non-desktop resolution in fullscreen mode, display creation takes a longer time. Maybe this crash has something to do with it.
|
|
|