[SDL] Fast Scrolling

Frank Ramsay fjramsay at erols.com
Sun Aug 15 14:47:38 PDT 1999



Prasanth Kumar wrote:
> 
> <snip>
> > The real way to implement a scroller is to adjust the display aperture
> > (portion of video memory which is being displayed) dynamically.  It's
> > a more fine-grained application of the process which allows double
> > buffering.
> >
> > Unfortunately, with modern video cards, the only API that I know of
> > that supports this is X11 DGA.  When in a window, you have to implement
> > scrolling with a full-window copy.  DirectX only supports page flipping.
> >
> > If someone knows better, please let me know!
> <snip>
> But this wont work with a parallax scroller would it?

after getting a lot of info from the 'faster way' thread I started I
found that
I can easily get 100 fps on my P2-450 (640x480x8bpp in a window) by NOT
redrawing the
entire buffer every time.
I'll try and explain how I would work it for a paralax scroller...
you build up several layers, each one is wider than the physical
display, say 4 times the width, then you blit from those to your real
back buffer.  This way you only have to re-draw the individual layers
from the game when your window goes out of scope... I didn't explain
well.
ok, lets try it this way

window on desktop
+-------------------+
|                   |
|                   |
|                   |
+-------------------+
background layer buffer
+---------+-------------------+---------------------------------------+
|         |                   |                                       |
|         |     background    |                                       |
|         |        view       |                                       |
+---------+-------------------+---------------------------------------+
Forground layer buffer
+-------------------------+-------------------+-----------------------+
|                         |                   |                       |
|                         |   forground view  |                       |
|                         |                   |                       |
+-------------------------+-------------------+-----------------------+
back buffer
+-------------------+
|                   |
|                   |
|                   |
+-------------------+

copy the background view portion of the background buffer to the back
buffer
then overlay that with the forground view portion of the forgroundlayer
buffer
then blit the back buffer to the display surface.

You only redraw the background or forground layers when the view onto
those layers goes outside what you already have pre-drawn.  This should
get you over 50fps on a 166 mhz machine.  The newest version of my iso
code
uses something similar to this and gets nearly 20fps on a P150 (640x480)
this is
up from 4.8 fps if I re-draw the entire display each time.

				-fjr



More information about the SDL mailing list