Go to main content

man pages section 3: Library Interfaces and Headers

Exit Print View

Updated: Thursday, June 13, 2019
 
 

SDL_LockSurface (3)

Name

SDL_LockSurface - Lock a surface for directly access.

Synopsis

#include "SDL.h"

int SDL_LockSurface(SDL_Surface *surface);

Description

SDL_LockSurface(3)             SDL API Reference            SDL_LockSurface(3)



NAME
       SDL_LockSurface - Lock a surface for directly access.

SYNOPSIS
       #include "SDL.h"

       int SDL_LockSurface(SDL_Surface *surface);

DESCRIPTION
       SDL_LockSurface  sets  up  a surface for directly accessing the pixels.
       Between calls to SDL_LockSurface and SDL_UnlockSurface, you  can  write
       to and read from surface->pixels, using the pixel format stored in sur-
       face->format. Once you are done accessing the surface, you  should  use
       SDL_UnlockSurface to release it.

       Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates to
       0, then you can read and write to the surface  at  any  time,  and  the
       pixel format of the surface will not change.

       No operating system or library calls should be made between lock/unlock
       pairs, as critical system locks may be held during this time.

       It should be noted, that since SDL 1.1.8 surface locks  are  recursive.
       This  means  that  you can lock a surface multiple times, but each lock
       must have a match unlock.

           .
           .
           SDL_LockSurface( surface );
           .
           /* Surface is locked */
           /* Direct pixel access on surface here */
           .
           SDL_LockSurface( surface );
           .
           /* More direct pixel access on surface */
           .
           SDL_UnlockSurface( surface );
           /* Surface is still locked */
           /* Note: Is versions < 1.1.8, the surface would have been */
           /* no longer locked at this stage                         */
           .
           SDL_UnlockSurface( surface );
           /* Surface is now unlocked */
           .
           .

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


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+------------------+
       |ATTRIBUTE TYPE | ATTRIBUTE VALUE  |
       +---------------+------------------+
       |Availability   | library/sdl      |
       +---------------+------------------+
       |Stability      | Volatile         |
       +---------------+------------------+
SEE ALSO
       SDL_UnlockSurface



NOTES
       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source       was        downloaded        from         https://www.lib-
       sdl.org/release/SDL-1.2.15.tar.gz

       Further information about this software can be found on the open source
       community website at https://www.libsdl.org/.



SDL                         Tue 11 Sep 2001, 23:01          SDL_LockSurface(3)