1SDL_LockSurface(3)             SDL API Reference            SDL_LockSurface(3)
2
3
4

NAME

6       SDL_LockSurface - Lock a surface for directly access.
7

SYNOPSIS

9       #include "SDL.h"
10
11       int SDL_LockSurface(SDL_Surface *surface);
12

DESCRIPTION

14       SDL_LockSurface  sets  up  a surface for directly accessing the pixels.
15       Between calls to SDL_LockSurface and SDL_UnlockSurface, you  can  write
16       to and read from surface->pixels, using the pixel format stored in sur‐
17       face->format. Once you are done accessing the surface, you  should  use
18       SDL_UnlockSurface to release it.
19
20       Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates to
21       0, then you can read and write to the surface  at  any  time,  and  the
22       pixel format of the surface will not change.
23
24       No operating system or library calls should be made between lock/unlock
25       pairs, as critical system locks may be held during this time.
26
27       It should be noted, that since SDL 1.1.8 surface locks  are  recursive.
28       This  means  that  you can lock a surface multiple times, but each lock
29       must have a match unlock.
30
31           .
32           .
33           SDL_LockSurface( surface );
34           .
35           /* Surface is locked */
36           /* Direct pixel access on surface here */
37           .
38           SDL_LockSurface( surface );
39           .
40           /* More direct pixel access on surface */
41           .
42           SDL_UnlockSurface( surface );
43           /* Surface is still locked */
44           /* Note: Is versions < 1.1.8, the surface would have been */
45           /* no longer locked at this stage                         */
46           .
47           SDL_UnlockSurface( surface );
48           /* Surface is now unlocked */
49           .
50           .
51

RETURN VALUE

53       SDL_LockSurface returns 0, or -1 if the surface couldn't be locked.
54

SEE ALSO

56       SDL_UnlockSurface
57
58
59
60SDL                         Tue 11 Sep 2001, 23:01          SDL_LockSurface(3)
Impressum