News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

"Single buffering" via swapscreen repetition

Started by bmorris, April 05, 2013, 07:01:24 AM

Previous topic - Next topic

bmorris

When I translated Creeping Angels from DarkBasic to PlayBasic, the biggest challenge was converting from a one-screen to a double-buffering regime; I ended up putting all the disparate display functions into one big function, controlled through its arguments. Happily, the new version works just as well as the old.

It occurred to me recently that I could've bypassed this in the following simple way: by calling swapscreen before as well as after every (disparate) gfx/text command block, thereby totally ignoring one of the two screens.

What do you think about this strategy? It feels to me like "missing the point" of double buffering, but in the context of games with simple, turn-based gfx, I can't see anything fundamentally wrong with it.

kevin

#1
 DB is also double buffered, except they render  2D to a 'mock up' screen and overlay it.  

Here's a rough approximation.  And you don't have to flip the buffers multiple times.

PlayBASIC Code: [Select]
   global Screen=NewImage(GetSurfaceWidth(),GetSurfaceHeight())
rendertoimage Screen

Show()

print "some Stuff"

Show()

print "some Stuff"
print "some Stuff"
print "some Stuff"

Show()

waitkey




Psub Show()
oldsurface=getsurface()

rendertoscreen
drawImage Screen,0,0,false

rendertoimage oldsurface
EndPsub






bmorris

I see. Thanks for filling me in on this - although, alas, in my future programming I'll probably adhere to standard double buffering.