writepixelfast problems
Blitz3D Forums/Blitz3D Beginners Area/writepixelfast problems
| ||
[CODE] For particle.particles = Each particles ; draw particles col = particle\red Shl 16 ; convert to pixel colour col = col+particle\green Shl 8 col = col+particle\blue LockBuffer WritePixelFast(particle\x#,particle\y#,col) UnlockBuffer If particle\debris_size > 1 LockBuffer WritePixelFast(particle\x#+1.0,particle\y#,col) WritePixelFast(particle\x#,particle\y#+1.0,col) WritePixelFast(particle\x#+1.0,particle\y#+1.0,col) UnlockBuffer If particle\debris_size > 2 LockBuffer WritePixelFast(particle\x#+2.0,particle\y#,col) WritePixelFast(particle\x#+2.0,particle\y#+1.0,col) WritePixelFast(particle\x#,particle\y#+2.0,col) WritePixelFast(particle\x#+1.0,particle\y#+2.0,col) WritePixelFast(particle\x#+2.0,particle\y#+2.0,col) UnlockBuffer EndIf EndIf Next [/CODE] Why does this code crash? :( |
| ||
You don't specify what buffers to lock and unlock, at least that's a problem. [edit] Ooops, just checked the docs, that was ok, sorry. |
| ||
Duh! Forgot to allow for the width of the particle - it was writing outside the screen boundary. It works now. |
| ||
You only need to lock/unlock the buffer once, outside the loop. YAN |
| ||
Thanks Yan - I tried that before editing my code - which wasn't the problem anyway. |
| ||
I know. Just a general tip. :o) YAN |