libSDL2pp  0.16.0
C++11 bindings/wrapper for SDL2
Public Member Functions | Friends | List of all members
SDL2pp::Texture::LockHandle Class Reference

SDL2pp::Texture lock. More...

#include <SDL2pp/Texture.hh>

Public Member Functions

 LockHandle ()
 Create no-op lock. More...
 
 ~LockHandle ()
 Destructor. More...
 
 LockHandle (LockHandle &&other) noexcept
 Move constructor. More...
 
LockHandleoperator= (LockHandle &&other) noexcept
 Move assignment operator. More...
 
 LockHandle (const LockHandle &other)=delete
 Deleted copy constructor. More...
 
LockHandleoperator= (const LockHandle &other)=delete
 Deleted assignment operator. More...
 
void * GetPixels () const
 Get pointer to raw pixel data of locked region. More...
 
int GetPitch () const
 Get pitch of locked pixel data. More...
 

Friends

class Texture
 

Detailed Description

SDL2pp::Texture lock.

Textures with SDL_TEXTUREACCESS_STREAMING access mode may be locked, which provides (writeonly) access to their raw pixel data. This may be used to update texture contents.

This class represents the lock and controls its lifetime as the lock is released as soon as LockHandle is destroyed.

Usage example:

{
SDL2pp::Texture tex(SDL_PIXELFORMAT_RGB24,
SDL_TEXTUREACCESS_STREAMING,
256, 256);
{
// Lock the whole texture
SDL2pp::Texture::LockHandle lock = tex.Lock();
unsigned char* start = static_cast<unsigned char*>(lock.GetPixels());
// note that we use lock.GetPitch(), not tex.GetWidth() here
// as texture may have different dimensions in memory
unsigned char* end = start + tex.GetHeight() * lock.GetPitch();
// fill the texture white
std::fill(start, end, 255);
}
// At this point lock is released
}

Constructor & Destructor Documentation

◆ LockHandle() [1/3]

SDL2pp::Texture::LockHandle::LockHandle ( )

Create no-op lock.

This may be initialized with real lock later via move assignment

◆ ~LockHandle()

SDL2pp::Texture::LockHandle::~LockHandle ( )

Destructor.

Releases the lock

See also
http://wiki.libsdl.org/SDL_UnlockTexture

◆ LockHandle() [2/3]

SDL2pp::Texture::LockHandle::LockHandle ( Texture::LockHandle &&  other)
noexcept

Move constructor.

Parameters
[in]otherSDL2pp::Texture::LockHandle to move data from

◆ LockHandle() [3/3]

SDL2pp::Texture::LockHandle::LockHandle ( const LockHandle other)
delete

Deleted copy constructor.

This class is not copyable

Member Function Documentation

◆ GetPitch()

int SDL2pp::Texture::LockHandle::GetPitch ( ) const

Get pitch of locked pixel data.

Returns
Number of bytes in a row of pixel data, including padding between lines

◆ GetPixels()

void * SDL2pp::Texture::LockHandle::GetPixels ( ) const

Get pointer to raw pixel data of locked region.

Returns
Pointer to raw pixel data of locked region

◆ operator=() [1/2]

Texture::LockHandle & SDL2pp::Texture::LockHandle::operator= ( Texture::LockHandle &&  other)
noexcept

Move assignment operator.

Parameters
[in]otherSDL2pp::Texture::LockHandle to move data from
Returns
Reference to self

◆ operator=() [2/2]

LockHandle& SDL2pp::Texture::LockHandle::operator= ( const LockHandle other)
delete

Deleted assignment operator.

This class is not copyable


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