Do you know a fast way to scroll a window?(2d using directdraw). I'm writing a small multiplayer version of the popular nibbles game, but i have performance problems scrolling the screen, so i'm asking you if there's a DD optimized function to scroll, or some tricks to avoid repaint whole screen every frame... Thanks
Posted on 2001-02-14 13:53:00 by *mi*
Yes you have to use a buffer, lets say a DX surface that you recalculate only when a "scroll" is happening. If the screen is still (ie no scrolling) you just blit the whole surface on the video backbuffer. This will be VERY fast if this buffer surface is in video memory, and medium if its in system memory. Anyway you will get a speed bust by NOT recalculating this buffer at every frame. There is one more optimization that can be done to that: you can preload a margin around that surface (add a border to it) and then when a scroll take place just shift the starting of the source rectangle and Blit, then based on the direction of the scroll update just the required border (left, top,down,right ...whatever is needed)... Depending on the size of the border (an the memory it uses) you can postpone the border update at a more desirable time... this way you can do "pixel scrolling" even if your map is somehow made of tiles :) Using ASM routines you are on the safe side even with the first method...because of great speed ...but the again more speed never hurt somebody... did it? :D This message was edited by BogdanOntanu, on 2/14/2001 4:38:49 PM
Posted on 2001-02-14 16:33:00 by BogdanOntanu