Mail Archives: djgpp/1999/10/26/18:37:34
On Tue, 26 Oct 1999 21:32:30 +0200,
"Lasse Hassing" <lazer_hassing AT yahoo DOT com> wrote:
> I'm having problem blitting to a mem. bitmap
> Please help
>
> Source:
> // --------------------------------------------------------------
> #include <stdlib.h>
> #include <stdio.h>
> #include <allegro.h>
>
> BITMAP *FlukkiB;
> PALETTE MyPal;
> RLE_SPRITE *Flukki;
> int Fx;
> int Fy;
>
> file://BackBuffer
Micro$oft Outhouse Express has a problem with C comments that start
with // and are not followed by space.
//backbuffer
becomes
file://backbuffer
but
// backbuffer
works fine.
> BITMAP *back_buffer;
>
> void DoBlit(void);
> void BlitTimer(void);
>
> int main() {
> FlukkiB = load_pcx("flukki.pcx", MyPal);
> // snip
> allegro_init();
> set_color_depth(32);
Wrong! You're loading a bitmap before setting the default color depth.
Before a call to set_color_depth(), Allegro assumes you're using 8
bits per pixel.
> // Create 'Flukki'
> Flukki = get_rle_sprite(FlukkiB);
>
> back_buffer = create_bitmap(320, 240);
> clear(back_buffer);
>
> Fx = 10;
> Fy = 190;
>
> install_int(BlitTimer, 1000);
>
> for(;;)
> {
> if (key[KEY_ESC])
> break; }
>
> destroy_bitmap(back_buffer);
>
> return 0;
> }
>
> void DoBlit(void)
> {
> draw_rle_sprite(back_buffer, Flukki, Fx, Fy);
> }
>
> void BlitTimer(void)
> {
> DoBlit();
> }
> END_OF_FUNCTION(BlitTimer);
Should you really be blitting in a timer loop? This may also be your
problem. You aren't locking the variables you're using. You definitely
aren't locking your bitmap. (Can you?)
The interrupt handler should set a flag that a timer event has
happened, and the main loop should pick this up and blit the sprite.
> If I replace :
> draw_rle_sprite(back_buffer, Flukki, Fx, Fy);
> With:
> draw_rle_sprite(screen, Flukki, Fx, Fy);
> It work fine.
>
> Why?
screen is (under DOS only) a locked bitmap.
--
Damian Yerrick
Mail me from the link on my web site:
Pinocchio's Brother <http://yerricde.tripod.com/>
- Raw text -