SDL_LockSurface

hy,

i wonder in wich case SDL_LockSurface would fail.

would it fail if lock is unnecessary ?
(i mean if SDL_MUSTLOCK(surface) evaluates to 0 ?)

if it fail could i know why with SDL_GetError() ?

thanks for any help…

Lloyd Dupont wrote:

i wonder in wich case SDL_LockSurface would fail.

would it fail if lock is unnecessary ?
(i mean if SDL_MUSTLOCK(surface) evaluates to 0 ?)

if it fail could i know why with SDL_GetError() ?

if you have a hardware surface, and the system cannot
unlock the surface at the current time (for example, the
video hardware is busy blitting to it). also, on windows,
directx can “lose” your hardware surfaces. in that event
the surface is definitely gone, and there’s no way you
could lock it.

it is safe to call SDL_LockSurface, even if it is
unneeded. and SDL also smartly handles multiple calls
to LockSurface (just be sure to match with the same
number of Unlocks).

i’m not sure if SDL_GetError will give you the specific
reason the lock failed, but i’ve found the error message
is very helpful.

Pete Shinners wrote:

Lloyd Dupont wrote:

i wonder in wich case SDL_LockSurface would fail.

thanks it is very clear and helpfull…