|
SDL3pp
A slim C++ wrapper for SDL3
|
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. More... | |
| TextureLock (const TextureLock &other)=delete | |
| Copy constructor. | |
| constexpr | TextureLock (TextureLock &&other) noexcept |
| Move constructor. | |
| ~TextureLock () | |
| Unlock a texture, uploading the changes to video memory, if needed. More... | |
| TextureLock & | operator= (const TextureLock &other)=delete |
| TextureLock & | operator= (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. More... | |
| TextureRef | get () |
| Get the reference to locked resource. | |
| void | release () |
| Releases the lock without unlocking. | |
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 Texture.Unlock() to unlock the pixels and apply any changes.
| texture | the texture to lock for access, which was created with TEXTUREACCESS_STREAMING. |
| rect | an Rect structure representing the area to lock for access; nullptr to lock the entire texture. |
| pixels | this is filled in with a pointer to the locked pixels, appropriately offset by the locked area. |
| pitch | this is filled in with the pitch of the locked pixels; the pitch is the length of one row in bytes. |
TEXTUREACCESS_STREAMING; call GetError() for more information.
|
inline |
Warning: Please note that Texture.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.