I have made a c++ wrapper for an allegro bitmap. I create an AguiBitmap as a global variable for testing, then later I say,
bitmap = AguiBitmap("somepath");
after allegro has been initialized.
However, when I close the application, it crashes in the bitmap's destructor. If I do al_destroy_bitmap(0); its fine, but there cant be anything wrong with my bitmap pointer because I use it to render.
AguiBitmap::~AguiBitmap()
{
        al_destroy_bitmap(nativeBitmapPtr); 
}
AguiBitmap::AguiBitmap()
{
    nativeBitmapPtr = 0;
    width = 0;
    height = 0;
}
AguiBitmap::AguiBitmap( char *filename )
{
    if(!filename)
    {
        nativeBitmapPtr = 0;
        return;
    }
    nativeBitmapPtr = al_load_bitmap(filename);
    if(nativeBitmapPtr)
    {
        width = al_get_bitmap_width(nativeBitmapPtr);
        height = al_get_bitmap_height(nativeBitmapPtr);
    }
    else
    {
        width = 0;
        height = 0;
    }
}
AguiBitmap::AguiBitmap( std::string filename )
{
    AguiBitmap((char*)filename.c_str());
}
ALLEGRO_BITMAP* AguiBitmap::getBitmap() const
{
    return nativeBitmapPtr;
}
int AguiBitmap::getWidth() const
{
    return width;
}
int AguiBitmap::getHeight() const
{
    return height;
}
Thanks
 
     
     
    