[SDL] Reading and writing Data to/from Surface

Jacek Wojdel wojdel at kbs.twi.tudelft.nl
Mon Nov 11 05:23:01 PST 2002


On Fri, Nov 08, 2002 at 09:02:07AM +0100, mista.tapas at gmx.net wrote:
> > for rotation you will always need to work with 2 surfaces, the original
> > and 
> > the one where the algorithm is writing the rotationed image ... (otherwise
> > 
> > during the rotation the algorithm would overwrite original pixels that are
> > 
> > still needed) So at least a scratch surface is needed ... (which could be 
> > later blitted back to the original screen or directly to the framebuffer)
> 
> I use two buffers. Sorry if tat wasnt clear. I have the Map-image in  a
> Surface, and The Rotation-algorithm reads from this buffer and writes into the
> screen surface, which is then updatet by SDL_Flip() (if that was the name of
> the function that flips the doublebuffer)..
> 
> Some other person mentioned that this is computationally heave, since the
> pixels in the Map Image get accessed on a pretty much random basis (at least it
> seems so to the compiler).. I can understand that point.. But there must be
> some computational tricks. I remember Demos from the 486 and 386 days which
> did some amazing full screen rotating and zooming and blending at 320x200..
> 
> I`m prettty much puzzled how they achieved that...

OK, so somebody already mentioned a shear-trick, if you're interested in how
it looks like you can fetch:

http://www.kbs.twi.tudelft.nl/People/Staff/J.C.Wojdel/roto_test.tgz

The program loads an image and pseudo-rotates it using combinations of
horizontal and vertical shears (skews). Just move your mouse around to see
it. On small rotations (only 2 skews) I get arount 45fps on P3/933. For
rotations up to 90degrees (5 skews) it drops down to 30fps.
The program will work only in 32bps (see lines 109 and 118, where the
pointers should be cast depending on the pixeldepth), because I was too lazy
to do it properly (you should make depth switch in the beginning of the
function and repeat the loops with different casts; you don't want to make
switch within the loop).
Is it faster than yours ?
Regards,
	Jacek
-- 
+-------------------------------------+
|from: J.C.Wojdel                     |
|      J.C.Wojdel at cs.tudelft.nl       |
+-------------------------------------+




More information about the SDL mailing list