LockBuffer/UnlockBuffer! Slow or fast?

Blitz3D Forums/Blitz3D Programming/LockBuffer/UnlockBuffer! Slow or fast?

ChrML(Posted 2003) [#1]
Are those commands alone slow or fast?
I mean, so if I'm using those commands about 20 times each mainloop, would I experience any slowdowns because of that?
Now I mean the command themselves, not what I can do with them!


fredborg(Posted 2003) [#2]
They are plenty fast, if you do not abuse them.
;Bad usage
;This is slow
For x = 0 to 200
LockBuffer BackBuffer()
WritePixelFast x,0,-1,BackBuffer()
UnlockBuffer BackBuffer()
Next

; Good usage
; This is fast
LockBuffer BackBuffer()
For x = 0 to 200
WritePixelFast x,0,-1,BackBuffer()
Next
UnlockBuffer BackBuffer()



ChrML(Posted 2003) [#3]
Ah, I see, cuz I thought of simplifying the commands for my GUI package, but Locking and Unlocking for every command there, but ok, I'll just write in the manual which commands that uses locked, and which uses unlocked then. Thanks for help :).


Beaker(Posted 2003) [#4]
You could test it. But, I would say they are slow. 20 times a mainloop won't be a problem though.

You can get a little more speed out of them by storing the buffer in a variable (eg. buff=BackBuffer() ) at program start.