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

Class that represet a renderer texture. More...

#include <texture.hpp>

Classes

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

Public Member Functions

 Texture (SDL_Texture *t)
 Construct texture from C SDL_Texture object. More...
 
SDL_Texture * ptr () const
 Get SDL_Texture pointer from texture. More...
 
 Texture (SDL_Renderer *render, Uint32 format, SDL_TextureAccess access, int w, int h)
 Create texture. More...
 
 Texture ()=default
 Default constructor for empty texture object. More...
 
 Texture (SDL_Renderer *render, Uint32 format, SDL_TextureAccess access, Vec2i size)
 Create texture. More...
 
 Texture (SDL_Renderer *render, Surface const &surface)
 Create texture from surface. More...
 
 Texture (SDL_Renderer *render, std::string const &filename)
 Create texture from file. More...
 
 Texture (Texture &&other) noexcept
 Move texture into this one. More...
 
Textureoperator= (Texture &&other) noexcept
 Move texture into this one. More...
 
 Texture (Texture const &)=delete
 Non copiable. More...
 
Textureoperator= (Texture const &)=delete
 Non copiable. More...
 
 ~Texture ()
 Destroy texture when it's not in use anymore. More...
 
void set_blendmode (SDL_BlendMode const &bm) const
 Set texture blend mode. More...
 
SDL_BlendMode blendmode () const
 Get texture blend mode. More...
 
void set_colormod (Color const &color) const
 Set colormod. More...
 
void set_colormod (Uint8 r, Uint8 g, Uint8 b) const
 Set colormod. More...
 
Color colormod () const
 Get colormod. More...
 
void set_alphamod (Uint8 alpha) const
 Set alphamod. More...
 
Uint8 alphamod () const
 Set alphamod. More...
 
void set_coloralphamod (Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
 Set coloralphamod. More...
 
void set_coloralphamod (Color const &c) const
 Set coloralphamod. More...
 
Color coloralphamod () const
 Get coloralphamod. More...
 
Uint32 format () const
 Get texture format. More...
 
int access () const
 Access texture. More...
 
Vec2i size () const
 Get texture size. More...
 
Lock lock ()
 lock texture for direct access to content More...
 
Lock lock (Rect const &rect)
 lock texture rect More...
 

Private Attributes

SDL_Texture * texture_ = nullptr
 

Detailed Description

Class that represet a renderer texture.

Definition at line 17 of file texture.hpp.

Constructor & Destructor Documentation

◆ Texture() [1/8]

sdl::Texture::Texture ( SDL_Texture *  t)
inlineexplicit

Construct texture from C SDL_Texture object.

Definition at line 73 of file texture.hpp.

◆ Texture() [2/8]

sdl::Texture::Texture ( SDL_Renderer *  render,
Uint32  format,
SDL_TextureAccess  access,
int  w,
int  h 
)
inline

Create texture.

Definition at line 79 of file texture.hpp.

References sdl::Texture::Lock::Texture, and sdl::Texture::Lock::texture_.

◆ Texture() [3/8]

sdl::Texture::Texture ( )
default

Default constructor for empty texture object.

◆ Texture() [4/8]

sdl::Texture::Texture ( SDL_Renderer *  render,
Uint32  format,
SDL_TextureAccess  access,
Vec2i  size 
)
inline

Create texture.

Definition at line 89 of file texture.hpp.

References access(), and format().

◆ Texture() [5/8]

sdl::Texture::Texture ( SDL_Renderer *  render,
Surface const &  surface 
)
inline

Create texture from surface.

Definition at line 95 of file texture.hpp.

References sdl::Surface::ptr(), and sdl::Texture::Lock::texture_.

◆ Texture() [6/8]

sdl::Texture::Texture ( SDL_Renderer *  render,
std::string const &  filename 
)
inline

Create texture from file.

Definition at line 102 of file texture.hpp.

◆ Texture() [7/8]

sdl::Texture::Texture ( Texture &&  other)
inlinenoexcept

Move texture into this one.

Definition at line 107 of file texture.hpp.

◆ Texture() [8/8]

sdl::Texture::Texture ( Texture const &  )
delete

Non copiable.

◆ ~Texture()

sdl::Texture::~Texture ( )
inline

Destroy texture when it's not in use anymore.

Definition at line 128 of file texture.hpp.

References sdl::Texture::Lock::texture_.

Member Function Documentation

◆ access()

int sdl::Texture::access ( ) const
inline

Access texture.

Definition at line 205 of file texture.hpp.

References sdl::simd::a, and sdl::Texture::Lock::texture_.

Referenced by Texture().

◆ alphamod()

Uint8 sdl::Texture::alphamod ( ) const
inline

Set alphamod.

Definition at line 167 of file texture.hpp.

References sdl::Texture::Lock::texture_.

Referenced by coloralphamod().

◆ blendmode()

SDL_BlendMode sdl::Texture::blendmode ( ) const
inline

Get texture blend mode.

Definition at line 136 of file texture.hpp.

References sdl::Texture::Lock::texture_.

◆ coloralphamod()

Color sdl::Texture::coloralphamod ( ) const
inline

Get coloralphamod.

Definition at line 188 of file texture.hpp.

References alphamod(), and colormod().

◆ colormod()

Color sdl::Texture::colormod ( ) const
inline

Get colormod.

Definition at line 153 of file texture.hpp.

References sdl::Texture::Lock::texture_.

Referenced by coloralphamod().

◆ format()

Uint32 sdl::Texture::format ( ) const
inline

Get texture format.

Definition at line 196 of file texture.hpp.

References sdl::Texture::Lock::texture_.

Referenced by Texture().

◆ lock() [1/2]

Lock sdl::Texture::lock ( )
inline

lock texture for direct access to content

Definition at line 223 of file texture.hpp.

References sdl::Texture::Lock::texture_.

◆ lock() [2/2]

Lock sdl::Texture::lock ( Rect const &  rect)
inline

lock texture rect

Definition at line 226 of file texture.hpp.

References sdl::Texture::Lock::texture_.

◆ operator=() [1/2]

Texture& sdl::Texture::operator= ( Texture &&  other)
inlinenoexcept

Move texture into this one.

Definition at line 110 of file texture.hpp.

References sdl::Texture::Lock::Texture, and sdl::Texture::Lock::texture_.

◆ operator=() [2/2]

Texture& sdl::Texture::operator= ( Texture const &  )
delete

Non copiable.

◆ ptr()

SDL_Texture* sdl::Texture::ptr ( ) const
inline

Get SDL_Texture pointer from texture.

Definition at line 76 of file texture.hpp.

References sdl::Texture::Lock::texture_.

◆ set_alphamod()

void sdl::Texture::set_alphamod ( Uint8  alpha) const
inline

Set alphamod.

Definition at line 162 of file texture.hpp.

References sdl::Texture::Lock::texture_.

Referenced by set_coloralphamod().

◆ set_blendmode()

void sdl::Texture::set_blendmode ( SDL_BlendMode const &  bm) const
inline

Set texture blend mode.

Definition at line 131 of file texture.hpp.

References sdl::Texture::Lock::texture_.

◆ set_coloralphamod() [1/2]

void sdl::Texture::set_coloralphamod ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
) const
inline

Set coloralphamod.

Definition at line 176 of file texture.hpp.

References set_alphamod(), and set_colormod().

◆ set_coloralphamod() [2/2]

void sdl::Texture::set_coloralphamod ( Color const &  c) const
inline

Set coloralphamod.

Definition at line 182 of file texture.hpp.

References set_alphamod(), and set_colormod().

◆ set_colormod() [1/2]

void sdl::Texture::set_colormod ( Color const &  color) const
inline

Set colormod.

Definition at line 144 of file texture.hpp.

References set_colormod().

Referenced by set_coloralphamod(), and set_colormod().

◆ set_colormod() [2/2]

void sdl::Texture::set_colormod ( Uint8  r,
Uint8  g,
Uint8  b 
) const
inline

Set colormod.

Definition at line 146 of file texture.hpp.

References sdl::Texture::Lock::texture_.

◆ size()

Vec2i sdl::Texture::size ( ) const
inline

Get texture size.

Definition at line 214 of file texture.hpp.

References sdl::Texture::Lock::texture_.

Member Data Documentation

◆ texture_

SDL_Texture* sdl::Texture::texture_ = nullptr
private

Definition at line 229 of file texture.hpp.


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