www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/26/18:37:34

From: Damian Yerrick <DELCAPSyerricde AT pineight DOT 8mSOFTWARE DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Error blitting to bitmap
Organization: Pin Eight Software <http://yerricde.tripod.com/binaries/>
Message-ID: <VhgWOE7zDFlcOwovOssPAJI6kMWS@4ax.com>
References: <7v4vor$fev$1 AT news DOT inet DOT tele DOT dk>
X-Newsreader: Forte Agent 1.6/32.525
MIME-Version: 1.0
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" <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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019