Padding bytes in 2DDrawing Buffer

Everything else that doesn't fall into one of the other PB categories.
User avatar
kenmo
Addict
Addict
Posts: 2083
Joined: Tue Dec 23, 2003 3:54 am

Padding bytes in 2DDrawing Buffer

Post by kenmo »

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?

Code: Select all

; example:
; ScreenWidth  = 640
; ScreenHeight = 480
; ScreenDepth  =   4 (bytes)

If StartDrawing(ScreenOutput())
  FillMemory(DrawingBuffer(), DrawingBufferPitch() * ScreenHeight, Color, #PB_Long)
EndIf
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...
Thorium
Addict
Addict
Posts: 1314
Joined: Sat Aug 15, 2009 6:59 pm

Re: Padding bytes in 2DDrawing Buffer

Post by Thorium »

It is save. Are you sure you set the depth correctly? Thr number normaly represents the depth in bits not in bytes.
User avatar
kenmo
Addict
Addict
Posts: 2083
Joined: Tue Dec 23, 2003 3:54 am

Re: Padding bytes in 2DDrawing Buffer

Post by kenmo »

Yes the depth is usually referred to as 32-bit, but I used a depth-in-bytes variable (typically = 4 or 2) for calculating memory block sizes... but I didn't really need to include that in my first post above.

I will keep investigating, and post again if I can reproduce the crashes or if I find it is my own bug.
Post Reply