UnlockBuffer [buffer]
Parameters
| buffer (optional) - the buffer to unlock; the current buffer set with SetBuffer (default) |
Description
|
Unlocks a buffer locked with LockBuffer. Call it as soon as your ReadPixelFast/WritePixelFast work is done - it ends the direct-access stretch and makes the buffer safe for normal drawing commands again. Every LockBuffer should have a matching UnlockBuffer, on the same buffer. On the modern runtime this is instant (buffers live in main memory), but keep the pairing so the Fast pixel commands stay legal and the code still works on classic Blitz3D. See also: LockBuffer, ReadPixelFast, WritePixelFast, CopyPixelFast. |
Example
; UnlockBuffer Example ; -------------------- Graphics 640,480,0,2 SetBuffer BackBuffer() t#=0 While Not KeyDown(1) Cls t=t+4 ; Lock the buffer so the fast pixel commands are allowed LockBuffer BackBuffer() ; Write a plasma pattern pixel by pixel into a small panel For y=0 To 95 For x=0 To 127 v#=Sin(x*4+t)+Sin(y*5-t)+Sin((x+y)*3+t*2) r=128+v*42 g=128+Sin(v*60+t)*127 b=255-r WritePixelFast 256+x,192+y,$FF000000 Or (r Shl 16) Or (g Shl 8) Or b Next Next ; UnlockBuffer MUST run before any other drawing command - ; while locked, only the read/write pixel commands may be used UnlockBuffer BackBuffer() Color 255,255,255 Rect 255,191,130,98,0 Text 0,0,"Esc: exit" Text 0,20,"UnlockBuffer frees the buffer so Rect, Text and Flip work again" Flip Wend End
Index