Skip to content

LockBuffer

Narta Xaymar Dirks edited this page Oct 28, 2026 · 5 revisions

Blitz3DBlitzPlusBlitzBasic

LockBuffer

LockBuffer:Void buffer:Int32=0
Parameter Mode Type Default Description
buffer In Int32 0 The buffer to lock. Defaults to the current buffer.

Description

Makes a copy of the pixels of a buffer that ReadPixelFast and WritePixelFast can use quickly. What the program writes reaches the buffer when UnlockBuffer is called, so do not forget it. Do not use the other drawing commands while a buffer is locked.

Differences

  • Up to 8 buffers can be locked at the same time.
  • The lock works on a copy: drawing commands and ReadPixel do not see what was written until the buffer is unlocked, and when pixels were written, the whole copy replaces the buffer on unlocking, which discards anything that drawing commands drew meanwhile.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Cls
LockBuffer BackBuffer()
For y = 0 To 239
	For x = 0 To 319
		WritePixelFast x, y, ((x * 255 / 319) Shl 16) Or ((y * 255 / 239) Shl 8) Or 128
	Next
Next
UnlockBuffer BackBuffer()
Flip
WaitKey

Media

LockBuffer

Related Commands

BackBuffer, BufferDirty, FrontBuffer, GraphicsBuffer, LoadBuffer, SaveBuffer, SetBuffer, UnlockBuffer

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally