dxLockBuffer(buffer%)

Parameters

buffer = any valid screen/image buffer (optional)

Description

After you use dxLockBuffer on a buffer, the only graphics commands you can use are the read/dxWrite pixel commands dxReadPixel, dxWritePixel, dxReadPixelFast, dxWritePixelFast, CopyPixelFast, and CopyPixel. You must dxUnLockBuffer before using other graphics commands or API calls, and you are advised to only keep the buffer locked for as long as it is needed.

The buffer parameter isn't required. If omitted, the default buffer set with dxSetBuffer will be used.

See the other commands for more information.

See also: LockedPitch, LockedFormat, LockedPixels, dxReadPixelFast, dxWritePixelFast, dxUnLockBuffer.

Example

; High Speed Graphics Commands

Graphics 640,480,16

; Draw a bunch of stuff on the screen
For t= 1 To 1000
dxColor dxRnd(255),dxRnd(255),dxRnd(255)
dxRect dxRnd(640),dxRnd(480),dxRnd(150),dxRnd(150),dxRnd(1)
Next

Delay 3000

; Copy the top half of the screen over the bottom half
; using fast pixels and locked buffers
For x = 1 To 640
For y = 1 To 240
dxLockBuffer dxFrontBuffer()
dxWritePixelFast x,y+241,dxReadPixelFast(x,y)
dxUnLockBuffer dxFrontBuffer()
Next
Next

Delay 3000

; Draw the left half of the screen over the right half
; using the slower direct pixel access
For x = 1 To 320
For y = 1 To 480
dxWritePixel x+320,y,dxReadPixel(x,y)
Next
Next

Index