-1

I am trying to load a bitmap with allegro 5.0.10

ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
al_set_path_filename(path, "Bitmap.bmp");

al_init_image_addon();
ALLEGRO_BITMAP *bmp = al_load_bitmap(al_path_cstr(path, '/'));
if (!bmp) {
    fprintf(stderr, "No Background.bmp in this directory...");
    return -2;
}

al_draw_bitmap(bmp, 0, 0, 0);

Once i tried to run the program in debug mode, i get this error:

Assertion failed!

Program: c:\allegro\bin\allegro-5.0.10-monolith-md-debug.dll
File: allegro-git\src\system.c
Line: 336

Expression: active_sysdrv

...

How do i fix this?

junyi00
  • 792
  • 3
  • 8
  • 28

2 Answers2

0

You need to initialize allegro by calling al_init(). Very few Allegro functions can be called before doing that.

Matthew
  • 47,584
  • 11
  • 86
  • 98
0

@junyi00, you need to make sure that you call al_init() before trying to load any resources. In your code above, make sure al_init() is already called before calling al_get_standard_path(ALLEGRO_RESOURCES_PATH), al_set_path_filename(path, "Bitmap.bmp"), al_load_bitmap(al_path_cstr(path, '/')) and basically all the Allegro functions from there. No other Allegro functions can be called before this function except one or two. See http://manpages.ubuntu.com/manpages/artful/en/man3/al_init.3alleg5.html and http://manpages.ubuntu.com/manpages/zesty/en/man3/al_install_system.3alleg5.html These are links to the al_init() and al_install_system() Allegro function manual pages

Mumasaba
  • 1
  • 1