Duncan Palmer
Duncan Palmer

Reputation: 2913

C++ Allegro - Bitmap turns up black?

Hey guys im making a c++ game and im trying to load a bitmap onto my game screen but when I do the image doesn't come up, only a black sqaure as showen below:

enter image description here

Im am currently using the following code:

BITMAP *buffer = create_bitmap( 640, 480 );

BITMAP *player = NULL;
player  = load_bitmap("player.bmp", NULL);

Then inside my game loop:

    rectfill(buffer, 0, 0,
              640, 480,
                   makecol( 255, 0, 0 )
                    );

    masked_blit(player, buffer, 0, 0, 100, 100, 32, 32);
    blit(buffer, screen, 0, 0, 0, 0, 640, 480 );
    clear_bitmap( player );
    clear_bitmap( buffer );   

I thought I was doing everything right but maybe not.

Any help is appreciated. Also if you need any more info just ask.

Upvotes: 2

Views: 214

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473567

clear_bitmap( player );

You cleared the bitmap you just loaded. Unless you intend to reload it again, the data it stored was destroyed.

Upvotes: 3

Related Questions