Blitz3D+ Command Reference

FreeBrush brush

Parameters

brush - brush handle

Description

Frees a brush.

Painting copies the brush's properties into the surface or entity, so freeing a brush does not change anything you have already painted with it - it just releases the brush object itself. A typical loader creates a brush, paints a batch of things, then frees it straight away.

After FreeBrush the handle is invalid: using it in any brush command is an error. Set your variable to 0 as a reminder. Note that textures referenced by the brush are shared objects - free those separately with FreeTexture when nothing else uses them.

See also: CreateBrush, LoadBrush, FreeTexture, PaintMesh.

Example

; FreeBrush Example
; -----------------

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

camera=CreateCamera()

light=CreateLight()
RotateEntity light,45,45,0

; A crate to paint. A brush is a 'paint recipe' applied with PaintEntity.
crate=CreateCube()
PositionEntity crate,0,0,5

; Paint the crate green...
brush=CreateBrush(0,255,0)
PaintEntity crate,brush

; ...then free the brush. The paint has already been copied onto the
; crate, so the crate stays green - the recipe itself is no longer needed.
FreeBrush brush

While Not KeyDown(1)

    TurnEntity crate,0,1,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrows: camera   Esc: exit"
    Text 0,20,"FreeBrush released the brush - the painted crate keeps its colour"

    Flip

Wend

End

Index