Hello,
I wanted to know the meaning of “pitch” used in the setpixel function.
Also, why do we need to lock and unlock the surfaces?
Please help.
Regards,
Smitha.
Hello,
I wanted to know the meaning of “pitch” used in the setpixel function.
Also, why do we need to lock and unlock the surfaces?
Please help.
Regards,
Smitha.
Smitha Rathnam wrote:
Hello,
?
?I wanted to know the meaning of “pitch” used in the setpixel function.
Also, why do we need to lock and unlock the surfaces?
?
Please help.
?
Regards,
Smitha.
Pitch is a length in bytes of o single image row. It is important value because a length of a row is not always width * bytes_per_pixel due to various alignment memory requirements. When accessing pixel data pitch value should be always used to determine the distance between beginning of 2 subsequent rows.
Locking mechanism (aka mapping) is needed for 2 reasons:
That is why with hardware surfaces pixel pointer may be invalid until surface is locked and memory is mapped to local space.
So when modifying hw surface:
Hi.
SDL’s surface locking has nothing to do with multi-threading. If you want to
share surfaces between threads then you must take external precautions to
ensure consistent results.
Regards,
– Brian.On 23 June 2010 12:00, hardcoder wrote:
Locking mechanism (aka mapping) is needed for 2 reasons:
- Ensuring exclusive access to pixel data in multi-threaded environment.
- Telling the video driver that access to pixel is needed in local memory
space (especially when surface is stored in video memory).That is why with hardware surfaces pixel pointer may be invalid until
surface is locked and memory is mapped to local space.So when modifying hw surface: