SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL::TextureLock Class Reference

Lock a portion of the texture for write-only pixel access. More...

Public Member Functions

 TextureLock (TextureRef resource, OptionalRef< const RectRaw > rect, void **pixels, int *pitch)
 Lock a portion of the texture for write-only pixel access.
 TextureLock (const TextureLock &other)=delete
 Copy constructor.
 TextureLock (TextureLock &&other) noexcept
 Move constructor.
 ~TextureLock ()
 Unlock a texture, uploading the changes to video memory, if needed.
TextureLockoperator= (const TextureLock &other)=delete
TextureLockoperator= (TextureLock &&other) noexcept
 Assignment operator.
constexpr operator bool () const
 True if not locked.
void reset ()
 Unlock a texture, uploading the changes to video memory, if needed.
TextureRef resource () const
 Get the reference to locked resource.
void release ()
 Releases the lock without unlocking.

Detailed Description

Lock a portion of the texture for write-only pixel access.

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 UnlockTexture() to unlock the pixels and apply any changes.

Since
This function is available since SDL 3.2.0.
See also
LockTextureToSurface
UnlockTexture

Constructor & Destructor Documentation

◆ ~TextureLock()

SDL::TextureLock::~TextureLock ( )
inline

Unlock a texture, uploading the changes to video memory, if needed.

Warning: Please note that LockTexture() 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
LockTexture

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