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

Locks a Texture for access to its pixels.

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

Public Member Functions

constexpr TextureLock ()=default
 Creates an empty lock.
 
constexpr TextureLock (TextureLock &&other)
 Move constructor.
 
 TextureLock (TextureRef texture, OptionalRef< const SDL_Rect > rect)
 Lock a portion of the texture for write-only pixel access.
 
 ~TextureLock ()
 Destructor.
 
void Unlock ()
 Unlock a texture, uploading the changes to video memory, if needed.
 
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.
 

Constructor & Destructor Documentation

◆ TextureLock()

SDL::TextureLock::TextureLock ( TextureRef  texture,
OptionalRef< const SDL_Rect >  rect 
)
inline

As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level.

You must use TextureLock.Unlock() to unlock the pixels and apply any changes.

Parameters
texturethe texture to lock for access, which was created with TEXTUREACCESS_STREAMING.
rectan Rect structure representing the area to lock for access; nullptr to lock the entire texture.
Exceptions
Erroron failure.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
TextureLock.Unlock

◆ ~TextureLock()

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

Member Function Documentation

◆ Unlock()

void SDL::TextureLock::Unlock ( )
inline

Warning: Please note that TextureRef.Lock() is intended to be write-only; it will not guarantee the previous contents of the texture will be provided. You must fully initialize any area of a texture that you lock before unlocking it, as the pixels might otherwise be uninitialized memory.

Which is to say: locking and immediately unlocking a texture can result in corrupted textures, depending on the renderer in use.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
TextureRef.Lock

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