The Battle for Wesnoth  1.17.4+dev
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
texture Class Reference

Wrapper class to encapsulate creation and management of an SDL_Texture. More...

#include <texture.hpp>

Classes

struct  info
 Small wrapper that queries metadata about the provided texture. More...
 

Public Member Functions

 texture ()
 Default ctor. More...
 
 texture (const texture &)=default
 
 texture (SDL_Texture *txt)
 Assigns the given texture to this one. More...
 
 texture (const surface &surf)
 Construct a texture from a surface. More...
 
 texture (int w, int h, SDL_TextureAccess access)
 Construct a texture of the specified size and access type. More...
 
const info get_info () const
 Queries metadata about the texture, such as its dimensions. More...
 
void reset ()
 Releases ownership of the managed texture and resets the ptr to null. More...
 
void reset (int w, int h, SDL_TextureAccess access)
 Releases ownership of the managed texture and creates a new one. More...
 
void assign (SDL_Texture *t)
 Replaces ownership of the managed texture with the given one. More...
 
textureoperator= (const texture &t)=default
 
textureoperator= (texture &&t)
 Move assignment. More...
 
 operator SDL_Texture * () const
 
bool null () const
 

Private Member Functions

void finalize ()
 

Private Attributes

std::shared_ptr< SDL_Texture > texture_
 

Detailed Description

Wrapper class to encapsulate creation and management of an SDL_Texture.

Supports free creation and creation from a surface.

Definition at line 27 of file texture.hpp.

Constructor & Destructor Documentation

◆ texture() [1/5]

texture::texture ( )

Default ctor.

Texture will be a nullptr.

Definition at line 40 of file texture.cpp.

◆ texture() [2/5]

texture::texture ( const texture )
default

◆ texture() [3/5]

texture::texture ( SDL_Texture *  txt)
explicit

Assigns the given texture to this one.

Definition at line 45 of file texture.cpp.

References finalize().

◆ texture() [4/5]

texture::texture ( const surface surf)
explicit

Construct a texture from a surface.

Definition at line 51 of file texture.cpp.

References ERR_SDL, CVideo::get_renderer(), CVideo::get_singleton(), and texture_.

◆ texture() [5/5]

texture::texture ( int  w,
int  h,
SDL_TextureAccess  access 
)

Construct a texture of the specified size and access type.

Definition at line 65 of file texture.cpp.

References reset().

Member Function Documentation

◆ assign()

void texture::assign ( SDL_Texture *  t)

Replaces ownership of the managed texture with the given one.

Definition at line 101 of file texture.cpp.

References texture_.

Referenced by get_info().

◆ finalize()

void texture::finalize ( )
private

Definition at line 71 of file texture.cpp.

References set_texture_blend_mode().

Referenced by null(), reset(), and texture().

◆ get_info()

const info texture::get_info ( ) const
inline

Queries metadata about the texture, such as its dimensions.

Definition at line 56 of file texture.hpp.

References assign(), texture::info::info(), operator=(), reset(), and t.

Referenced by render_target_setter::render_target_setter().

◆ null()

bool texture::null ( ) const
inline

Definition at line 80 of file texture.hpp.

References finalize(), and texture_.

◆ operator SDL_Texture *()

texture::operator SDL_Texture * ( ) const
inline

Definition at line 75 of file texture.hpp.

References texture_.

◆ operator=() [1/2]

texture& texture::operator= ( const texture t)
default

Referenced by get_info().

◆ operator=() [2/2]

texture & texture::operator= ( texture &&  t)

Move assignment.

Releases ownership of the managed texture from the passed object.

Definition at line 106 of file texture.cpp.

References t, and texture_.

◆ reset() [1/2]

void texture::reset ( )

Releases ownership of the managed texture and resets the ptr to null.

Definition at line 76 of file texture.cpp.

References texture_.

Referenced by get_info(), reset(), and texture().

◆ reset() [2/2]

void texture::reset ( int  w,
int  h,
SDL_TextureAccess  access 
)

Releases ownership of the managed texture and creates a new one.

Definition at line 83 of file texture.cpp.

References ERR_SDL, finalize(), CVideo::get_renderer(), CVideo::get_singleton(), reset(), and texture_.

Member Data Documentation

◆ texture_

std::shared_ptr<SDL_Texture> texture::texture_
private

Definition at line 88 of file texture.hpp.

Referenced by assign(), null(), operator SDL_Texture *(), operator=(), reset(), and texture().


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