Padding bytes in 2DDrawing Buffer
Posted: Wed Apr 18, 2012 2:52 am
When writing directly to a screen's drawing buffer, I know that each horizontal line may have extra non-visible "padding" bytes after the end - that is what DrawingBufferPitch() is useful for.
But should I avoid writing into these padding bytes? Or is it perfectly safe?
For a very simple example, would this be a safe (although strange) way to clear a screen?
I ask because I've had some IMA crashes around code which directly writes to the buffer. As far as I can tell, I am correctly writing to either the visible bytes or the padding bytes, nowhere else...
But should I avoid writing into these padding bytes? Or is it perfectly safe?
For a very simple example, would this be a safe (although strange) way to clear a screen?
Code: Select all
; example:
; ScreenWidth = 640
; ScreenHeight = 480
; ScreenDepth = 4 (bytes)
If StartDrawing(ScreenOutput())
FillMemory(DrawingBuffer(), DrawingBufferPitch() * ScreenHeight, Color, #PB_Long)
EndIf