Buffer or Flip issue?

BlitzPlus Forums/BlitzPlus Programming/Buffer or Flip issue?

Markh999(Posted 2004) [#1]
This is as simple as it gets. Why doesn't the attached code plot a single white point on the screen until AFTER I press the escape key. I don't understand why I would need the FLIP command if the default is the front buffer.

Graphics 640,480,0,1
Plot 300,300
While Not KeyHit(1)
Wend


Cold Harbour(Posted 2004) [#2]
It's because in B+ you can't draw to the frontbuffer directly. If you try to draw to it it uses the backbuffer. Something like that.


Markh999(Posted 2004) [#3]
Thanks for the reply. So if I put SetBuffer FrontBuffer() just after the graphics staement and before the plot then should that work because it doesn't? I can't believe I'm strugglinlg on something so trivial !! Any help appreciated.


Floyd(Posted 2004) [#4]
BlitzPlus alway uses double buffering and you have no direct access to the front buffer.

Perhaps the FrontBuffer() function should not be in the language. But it is and it is always the same as BackBuffer().

Try displaying the values of FrontBuffer() and BackBuffer(). They are the same number.


monkeybot(Posted 2004) [#5]
yes it took me a while to suss that out,its basically so you can "build" screens and display in one blit,the documentation doesn't seem to explain it very well


Kaminari(Posted 2004) [#6]
I'm having a similar issue using BlitzPlus and trying to go through some programming examples in "Game Programming for Teens" I get similar results when I run the following code. I don't see any of the lines drawn until hitting th escape key. Some examples seem to run if I compile and exe and then run them from that. Is there a way to make these run correctly from the BlitzPlus ide?

;demo06-02.bb - Draws a bunch of random lines to screen.

;Initialize Graphics
Graphics 800,600
;Draw only to the front buffer
SetBuffer FrontBuffer()

;Draw only to the front buffer
SeedRnd(MilliSecs())

While (Not KeyDown(1))
;Set a random color
Color Rand(0,255),Rand(0,255),Rand(0,255)

;Draw a random line
Line Rand(0,800), Rand(0,600), Rand(0,800), Rand(0,600)

;Slow it down
Delay(25)
Wend


Kaminari(Posted 2004) [#7]
The "flip command before "wend" worked wonders. I may not have any problems after all. Sorry for the unecessary post.


Russell(Posted 2004) [#8]
If I remember correctly, there were a few commands missing from BlitzPlus's command set initially because they were 'obsolete'. Unfortunately, some people's Blitz 2D\3D code was then broken (it wouldn't compile under B+). Sooo, Mark added them back in for compatibility sake, but they work slightly differently. For example, the above mentioned backbuffer always used issue. Once you accept that the back buffer is the ONLY buffer you can write to (and that you will ALWAYS be using double buffering - not necessarily a bad thing), you'll be fine. True, I found some cases where writing to the front buffer was useful...but I've learned to be without it and honestly don't miss it.

Once you 'get it', it's all 'cake'. :)

Russell