delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/20/23:11:05

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro Dirty Rectangles question.
Date: Sat, 16 Aug 1997 15:05:40 GMT
Organization: [posted via] Easynet Group PLC
Lines: 38
Message-ID: <33f5bc84.29886373@news.easynet.co.uk>
References: <33F3908D DOT 16DF AT sentex DOT net>
NNTP-Posting-Host: foot.easynet.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Thu, 14 Aug 1997 16:11:09 -0700, Temujin <temujin AT sentex DOT net>
wrote:

>I'm muddling through the demo.c that comes with Allegro to figure out
>how to do dirty trangles (mainly because it flys compared to the other
>screen updating techniques in SVGA modes).  What I was wondering is
>this, is there a piece of code or like some sample code that uses dirty
>triangles to move around like 2 bmp/sprites on the screen?  Just
>something basic like that so it would be just a matter of duplicating it
>many times to get more objects.
>To me atleast the dirty triagle stuff is a little strange mainly because
>I'm use to doing the old double buffer method.

The basic idea is much the same as double buffering -- you draw all
the objects to a memory bitmap (probably by erasing them and
redrawing, rather than drawing the entire scene from scratch each
frame, but this depends on the situation in hand), and as you draw
objects you create a bounding box and add it to a list of such boxes. 

Then, when you've made all the changes for the current frame, you
vsync() and immediately blit the rectangles whose locations you stored
earlier to the screen bitmap. Finally you free the rectangle list and
start again. It can help a lot in terms of flicker
reduction/elimination if you copy the rectangles in order of
increasing Y coordinate.

Allegro's demo provides a reasonable example of this, although the
code is somewhat poorly laid out. It might help if you make a backup
copy of it, and then delete all the code not related to dirty
rectangles. Things might look clearer then.

When I get around to writing the example programs for Allegro Vivace
they should be a good place to learn this sort of technique; however,
at present, I think there's only a brief description of the theory
there.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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