Path: utzoo!utgpu!utfyzx!oscvax!jan From: jan@oscvax.UUCP (Jan Sven Trabandt) Newsgroups: comp.sys.amiga Subject: Re: Bobs and Double Buffering Message-ID: <593@oscvax.UUCP> Date: Wed, 2-Mar-88 14:45:17 EST References: <8259@eleazar.Dartmouth.EDU> Reply-To: jan@oscvax.UUCP (Jan Sven Trabandt) Distribution: comp.sys.amiga Organization: Ontario Science Centre, Toronto Lines: 69 Summary: In article <8259@eleazar.Dartmouth.EDU> obie@eleazar.Dartmouth.EDU (Timothy D. Notestein) writes: >[...] >This is all that the RKM says is necessary for bob double-buffering. > >Is there something that I'm missing? Do i HAVE to have the Rastport set up >for double-buffering, or anything like that? Do I have to add the bob twice? >(I notice that it's documented that if double-buffering, you may have to > remove it twice, but it doesn't mention AddBob()) > >Is there some maintainence that has to be done by my program everytime I >move a bob or something? > Yes, you HAVE to double-buffer the rastport if you are double-buffering the bobs (*all* of them) and you want the double-buffering to work properly. I just spent some time playing around with this last week. What you have to do, after setting up all the double-buffering: - do AddBob *once* for your double-buffered bob repeat the following until motion complete: - do your SortGList and DrawGList into the offscreen rastport (#2) - swap displayed and offscreen rastports (#1 <==> #2) - alter the coordinates of your moving bobs, etc. - do a SortGList and DrawGlist on the now-offscreen rastport (#1) - swap displayed and offscreen rastports (#2 <==> #1) Now your bobs have moved smoothly (by one incremental amount) When you do a DrawGList with double-buffered bobs, the background of the rastport being drawn into is saved into the SaveBuffer, the DBufPacket.BufBuffer, alternating between the two buffers with each DrawGList. Thus, if you double-buffer the rastport, a DrawGList into alternating rastport bitmaps will keep the backgrounds in *each* rastport bitmap saved and restored separately. >Symptoms: The display comes up okay, but when I drag an icon around, >it's leaving bits and pieces of itself behind. As well, if part of one >icon passes under another (sorry, when I say icon, I DO mean bob), then >I get a kind of double-flickering affect, kind of.. (NOW YOU SEE IT, NOW >YOU DON'T). But, I also don't notice any movements being at ALL smoother. > If you don't double-buffer the rastport but do double-buffer the bos, you effectively: save the background into SaveBuffer, draw the bob, save the "background" which contains part of the bob you just drew (assuming you moved your bob by a small amount) into DBufPacket.BufBuffer, draw the bob in the new location while restoring/saving SaveBuffer (this save will again contain part of the bob you just drew), then restore the DBufPacket.BufBuffer which has part of the bob you drew back in the beginning, etc. This is why it leaves bits and pieces of itself behind. Also, to completely remove the double-buffered bob from both rastport bitmaps, you will have to do 2 DrawGList's (one on each rastport) After that, the BOBNIX flag in the vsprite flags field should be set, which tells you that it's ok to free or reuse the bob (only one call to RemBob necessary, since you only did one AddBob). Hope this clears things up a bit, Jan Sven. -------------------------------------------------------- -"Are you, besides Neysa, perchance a virgin?" -"No." -"Well, that's over-rated anyways." ( paraphrased from 'Split Infinity', by Piers Anthony) Mind like parachute - function only when open! Jan (Jan, from Amsterdam) no-hyphen Sven Trabandt ...!{allegro,ihnp4,decvax,pyramid}!utzoo!oscvax!jan