From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: Error blitting to bitmap Organization: Pin Eight Software Message-ID: References: <7v4vor$fev$1 AT news DOT inet DOT tele DOT dk> X-Newsreader: Forte Agent 1.6/32.525 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 97 X-Trace: 9/2nmKxIUIKauj8ptfJ4GPlNVlDMLhL2pPBGyTqSU++QAAyCkZvOABeq++Dhc5tTyEC2EZKnLTcQ!ZSythP2QCi+jtsNZAEjOUFQliJnGHTW0UwnQ70o90C334buZF9QsNsbESNBiByB8mQ== X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Tue, 26 Oct 1999 21:22:50 GMT Distribution: world Date: Tue, 26 Oct 1999 21:22:50 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Tue, 26 Oct 1999 21:32:30 +0200, "Lasse Hassing" wrote: > I'm having problem blitting to a mem. bitmap > Please help > > Source: > // -------------------------------------------------------------- > #include > #include > #include > > 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