Framing Buffer Tile Scrolling Algorithm
From GPWiki
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. For a discussion of basic tile scrolling techniques, please refer to this Smooth Scrolling Tiles tutorial (Visual Basic). The tutorial below assumes a basic knowledge of tiling methodology. When coding a tile based game, the efficiency of your tiling algorithm can have a great effect on your frame rate. As a general rule of thumb, the fewer the blits, the better. One large blit is preferable to many small blits. For this reason, it is wise to employ an algorithm which renders the scene to special buffers which are semi-permanent. For example: Imagine your tiled scene is stationary. Using this technique, the tiles that make up the scene are rendered once to a single buffer, which I will call the Main Surface. The Main Surface is then used to update the backbuffer each frame. This results in one blit per frame, and very fast performance! The only downside to this technique is memory usage. The Main Surface will take up as much video memory as the backbuffer itself, though most modern video cards can accomodate this easily. Things get a little trickier when your scene is scrolling, however. The Main Surface is no longer sufficient for rendering the scene on its own. Enter the framing buffers:
![]()
When the scroll is complete, and the Top Buffer is entirely in view, all of the framing buffers and the Main Surface must be re-rendered from constituent tiles, giving us the new scene:
An implementation of this technique can be found in this RPG Demo source code (Visual Basic).
|







