Blitz3D+ Command Reference

GraphicsBuffer ( )

Parameters

None.

Description

Returns the buffer that drawing commands currently target.

This is whatever SetBuffer last selected - the front buffer, the back buffer, or an image's buffer. Useful for save-and-restore: a function that draws somewhere else temporarily can grab GraphicsBuffer(), do its work, then SetBuffer the old value back so the rest of the frame draws where it expects to.

See also: SetBuffer, BackBuffer, FrontBuffer, ImageBuffer.

Example

; GraphicsBuffer Example
; ----------------------

Graphics 640,480,0,2
SetBuffer BackBuffer()

x#=100
vx#=4

While Not KeyDown(1)

    Cls

    ; A bouncing ball so the scene is alive
    x=x+vx
    If x<0 Or x>600 Then vx=-vx
    Color 0,255,128
    Oval x,220,40,40,1

    ; GraphicsBuffer returns the buffer drawing currently targets
    buf=GraphicsBuffer()

    Color 255,255,255
    Text 0,0,"Esc: exit"
    Text 0,20,"GraphicsBuffer() = "+buf
    If buf=BackBuffer() Then
        Text 0,40,"...which matches BackBuffer() - as chosen by SetBuffer"
    EndIf

    Flip

Wend

End

Index