cpp-sdl2
C++ header-only SDL2 wrapper
sdl::Texture::Lock Class Reference

Lock object that permit to access pixels directly on texture. More...

#include <texture.hpp>

Public Member Functions

Pixel at (Vec2i const &pos) const
 Get pixel at given location on texture. More...
 
Pixel at (size_t x, size_t y) const
 Get pixel at given location on texture. More...
 
Pixel operator[] (Vec2i const &pos) const
 Get pixel at location with operator[]. More...
 
 ~Lock ()
 Automatically unlock texture. More...
 

Private Member Functions

 Lock (SDL_Texture *texture, SDL_Rect const *rect)
 private ctor to create a lock. Lock are created by Texture class More...
 

Private Attributes

SDL_Texture * texture_
 pointer to raw texure More...
 
void * pixels_
 pointer to pixel array More...
 
int pitch_
 Pixel pitch. More...
 
SDL_PixelFormat * format_
 Pixel format. More...
 

Friends

class Texture
 

Detailed Description

Lock object that permit to access pixels directly on texture.

Definition at line 21 of file texture.hpp.

Constructor & Destructor Documentation

◆ ~Lock()

sdl::Texture::Lock::~Lock ( )
inline

Automatically unlock texture.

Definition at line 40 of file texture.hpp.

References format_, and texture_.

◆ Lock()

sdl::Texture::Lock::Lock ( SDL_Texture *  texture,
SDL_Rect const *  rect 
)
inlineprivate

private ctor to create a lock. Lock are created by Texture class

Definition at line 48 of file texture.hpp.

References format_, pitch_, pixels_, and texture_.

Member Function Documentation

◆ at() [1/2]

Pixel sdl::Texture::Lock::at ( Vec2i const &  pos) const
inline

Get pixel at given location on texture.

Definition at line 27 of file texture.hpp.

References at().

Referenced by at(), and operator[]().

◆ at() [2/2]

Pixel sdl::Texture::Lock::at ( size_t  x,
size_t  y 
) const
inline

Get pixel at given location on texture.

Definition at line 29 of file texture.hpp.

References format_, pitch_, and pixels_.

◆ operator[]()

Pixel sdl::Texture::Lock::operator[] ( Vec2i const &  pos) const
inline

Get pixel at location with operator[].

Definition at line 37 of file texture.hpp.

References at().

Friends And Related Function Documentation

◆ Texture

friend class Texture
friend

Definition at line 23 of file texture.hpp.

Referenced by sdl::Texture::operator=(), and sdl::Texture::Texture().

Member Data Documentation

◆ format_

SDL_PixelFormat* sdl::Texture::Lock::format_
private

Pixel format.

Definition at line 69 of file texture.hpp.

Referenced by at(), Lock(), and ~Lock().

◆ pitch_

int sdl::Texture::Lock::pitch_
private

Pixel pitch.

Definition at line 67 of file texture.hpp.

Referenced by at(), and Lock().

◆ pixels_

void* sdl::Texture::Lock::pixels_
private

pointer to pixel array

Definition at line 65 of file texture.hpp.

Referenced by at(), and Lock().

◆ texture_


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