SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::SurfaceLock Struct Reference

Locks a Surface. More...

Inheritance diagram for SDL::SurfaceLock:
Inheritance graph
[legend]

Public Member Functions

constexpr SurfaceLock ()=default
 Creates an empty lock.
 
constexpr SurfaceLock (SurfaceLock &&other)
 Move constructor.
 
 SurfaceLock (SurfaceRef surface)
 Set up a surface for directly accessing the pixels.
 
 ~SurfaceLock ()
 Destructor.
 
void Unlock ()
 Release a surface after directly accessing the pixels.
 
void reset ()
 Same as Unlock(), just for uniformity.
 
- Public Member Functions inherited from SDL::LockBase< SurfaceRef >
constexpr LockBase ()=default
 Default ctor.
 
 LockBase (const LockBase &other)=delete
 
 LockBase (LockBase &&other)
 Move ctor.
 
constexpr ~LockBase ()
 Dtor.
 
LockBaseoperator= (LockBase other)
 Move assignment.
 
- Public Member Functions inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
RESOURCE release ()
 Returns reference and reset this.
 
- Public Member Functions inherited from SDL::ResourcePtrBase< RESOURCE >
constexpr operator bool () const
 Check if not null.
 
constexpr bool operator== (const ResourcePtrBase &other) const
 Comparison.
 
constexpr bool operator== (std::nullptr_t) const
 Comparison.
 
constexpr bool operator== (std::nullopt_t) const
 Comparison.
 
constexpr reference operator* () const
 Gets reference.
 
constexpr const referenceoperator-> () const
 Gets addressable reference.
 
constexpr referenceoperator-> ()
 Gets addressable reference.
 
reference get () const
 Get reference.
 

Additional Inherited Members

- Public Types inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
using deleter = DELETER
 The deleter type.
 
- Public Types inherited from SDL::ResourcePtrBase< RESOURCE >
using reference = RESOURCE
 The reference resource type.
 
using value_type = typename reference::value_type
 The raw resource type.
 
- Protected Member Functions inherited from SDL::LockBase< SurfaceRef >
constexpr LockBase (SurfaceRef &&resource)
 Constructs initializing member.
 
- Protected Member Functions inherited from SDL::ResourceOwnerBase< RESOURCE, DELETER >
constexpr ResourceOwnerBase (base::value_type value={}, DELETER deleter={})
 Constructs from raw type.
 
void free ()
 Frees resource.
 
- Protected Member Functions inherited from SDL::ResourcePtrBase< RESOURCE >
constexpr ResourcePtrBase (value_type value={})
 Constructs from raw type.
 
referenceget ()
 Get reference.
 

Detailed Description

Only really necessary if Surface.MustLock() returns t

Constructor & Destructor Documentation

◆ SurfaceLock()

SDL::SurfaceLock::SurfaceLock ( SurfaceRef  surface)
inline

Between calls to SurfaceRef.Lock() / SurfaceLock.Unlock(), you can write to and read from surface->pixels, using the pixel format stored in surface->format. Once you are done accessing the surface, you should use SurfaceLock.Unlock() 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.

Parameters
surfacethe Surface structure to be locked.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe. The locking referred to by this function is making the pixels available for direct access, not thread-safe locking.
Since
This function is available since SDL 3.2.0.
See also
SDL_MUSTLOCK
SurfaceLock.Unlock

◆ ~SurfaceLock()

SDL::SurfaceLock::~SurfaceLock ( )
inline
See also
Unlock()

Member Function Documentation

◆ Unlock()

void SDL::SurfaceLock::Unlock ( )
inline
Thread safety:
This function is not thread safe. The locking referred to by this function is making the pixels available for direct access, not thread-safe locking.
Since
This function is available since SDL 3.2.0.
See also
SurfaceRef.Lock

The documentation for this struct was generated from the following file: