From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro sprite scaling : the fastest? Date: Wed, 28 May 1997 21:25:38 +0100 Organization: None Distribution: world Message-ID: References: <01bc6af5$49b40e80$e83663c3 AT default> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 38 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Thomas Harte writes: > Being ray casting, naturally I am rendering the display via scaled >slithers. What I want to know is - are there faster algorithms than the >Allegro 'stretch_blit', bearing in mind I am using slithers (effectively >sprites 1 pixel across by some other amount down, A single-pixel sliver is just about the worst case scenario for a general purpose stretching algorithm like the code in Allegro. The stretch_blit() function scales the image along both axis, which is gross overcomplication for a ray-casting engine: writing a specialised routine should give a dramatic speed improvement. The Allegro stretching code uses a very obscure technique: it contains a little code generator that constructs a bit of machine code for scaling one line of the sprite, and then calls it once for each horizontal line that needs to be copied. Generating the stretcher function takes rather longer than just doing everything directly, so the worst case is with very wide, short shapes. It will work best with fairly large, approximately rectangular regions, or ones that are taller than they are wide, but your situation of a single pixel width is taking things to extremes: you don't need a 2d stretcher at all! One trouble with drawing vertical lines, as someone already mentioned, is that it does bad things to the cache performance. One way to get around this is to draw the entire image rotated by 90 degrees, so you will be tracing horizontal lines both on the screen and through your texture maps. Then write a specialised blit-to-screen that flips it back to being the right way up: this is going to slow the blit down a bit, but if you are using mode-X and copy it as a series of vertical lines (horizontal in the memory image, vertical down the screen), it will fit nicely into the planar video memory organisation. I don't know for a fact whether any games have used this technique, but in theory it ought to work quite well :-) -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ Beauty is a French phonetic corruption of a short cloth neck ornament.