Blitz3D+ Command Reference

FrontBuffer ( )

Parameters

None.

Description

Returns a handle to the front buffer - the part of the display the player sees.

Anything drawn to the front buffer appears on screen straight away, with no Flip needed. That sounds convenient, but each drawing command shows up the moment it runs, so animation drawn here flickers as the player watches the frame being assembled. That is why games draw to the back buffer and Flip instead - see BackBuffer for the standard pattern.

The front buffer is still useful when you just want something on screen with no loop at all: a quick debug plot, a loading message, a one-off test sketch. After Graphics, the front buffer is already the draw target, so Plot and Text work immediately. The Print, Write and Input commands always print to the front buffer, whatever the current draw target.

Like BackBuffer, the handle changes with the display - fetch it fresh after each Graphics call.

See also: BackBuffer, SetBuffer, Flip, Print.

Example

; FrontBuffer Example
; -------------------

Graphics 640,480,0,2

SeedRnd MilliSecs()

; Show the instructions once via the back buffer and Flip
SetBuffer BackBuffer()
Cls
Text 0,0,"Hold the left mouse button to spray paint   Esc: exit"
Text 0,20,"Everything below is drawn straight to FrontBuffer() - no Flip needed"
Flip

; From now on draw straight to the VISIBLE front buffer
SetBuffer FrontBuffer()

While Not KeyDown(1)

    ; Each star appears the instant it is drawn
    Color Rand(100,255),Rand(100,255),Rand(100,255)
    Plot Rand(0,639),Rand(50,479)

    ; Spray paint under the mouse pointer
    If MouseDown(1) Then
        Color Rand(255),Rand(100,255),0
        Oval MouseX()+Rand(-15,15),MouseY()+Rand(-15,15),4,4,1
    EndIf

    ; Small delay so the drawing is watchable
    Delay 5

Wend

End

Index