It is currently Fri May 24, 2013 8:15 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Padding bytes in 2DDrawing Buffer
PostPosted: Wed Apr 18, 2012 2:52 am 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 932
Location: New York
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:
; 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...


Top
 Profile  
 
 Post subject: Re: Padding bytes in 2DDrawing Buffer
PostPosted: Wed Apr 18, 2012 5:39 am 
Offline
Addict
Addict
User avatar

Joined: Sat Aug 15, 2009 6:59 pm
Posts: 1024
It is save. Are you sure you set the depth correctly? Thr number normaly represents the depth in bits not in bytes.


Top
 Profile  
 
 Post subject: Re: Padding bytes in 2DDrawing Buffer
PostPosted: Thu Apr 19, 2012 5:00 am 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 932
Location: New York
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye