hello,
I wonder when to use SDL_LockSurface, and what is the purpose to do
this.
I never used this function and my programs works.
Thanks in advance for your help,
PH.
hello,
I wonder when to use SDL_LockSurface, and what is the purpose to do
this.
I never used this function and my programs works.
Thanks in advance for your help,
PH.
“PH-Neutre” a ?crit dans le message news:
3965B4B9.7511E5D0 at cybercable.tm.fr…
hello,
I wonder when to use SDL_LockSurface, and what is the purpose to do
this.
I never used this function and my programs works.Thanks in advance for your help,
When you want to access directly to the pixels of your surface
(with surface->pixels)
the surface will need to be locked if it is in video memory (in directdraw,
don’t know about other systems)
so lock is not useful when your are working with system memory surface
(windowed, etc…)
or when you use only Blits.
Gautier - www.tlk.fr
I wonder when to use SDL_LockSurface, and what is the purpose to do
this.
I never used this function and my programs works.
Use the macro SDL_MUSTLOCK(surface) to determine if locking is required.
For unaccelerated software surfaces, it’s usually not, which may be why it
has worked for you so far.
Thus write:
if(SDL_MUSTLOCK(surface))
SDL_LockSurface(surface);
/* access the pixel data directly here */
if(SDL_MUSTLOCK(surface))
SDL_UnlockSurface(surface);
Locking is required when you access the pixel data pointed to by
surface->pixels directly, including when calling SDL_SaveBMP.
You should not lock the surface when using any of SDL’s other functions
on it (SDL_BlitSurface, SDL_UpdateRect etc).
(To the SDL developers: There is room in the flags for another flag
(SDL_LOCKED), which would make surface locks idempotent. To make the locks
recursive, we can add a counter instead. Is the refcount ever used?)