libSDL2pp
C++ bindings/wrapper for SDL2
|
Image stored in the graphics card memory that can be used for fast drawing. More...
#include <SDL2pp/Texture.hh>
Classes | |
class | LockHandle |
SDL2pp::Texture lock. More... | |
Public Member Functions | |
Texture (SDL_Texture *texture) | |
Construct from existing SDL_Texture structure. | |
Texture (Renderer &renderer, Uint32 format, int access, int w, int h) | |
Create empty texture. | |
Texture (Renderer &renderer, RWops &rwops) | |
Create texture loading it via RWops. | |
Texture (Renderer &renderer, const std::string &filename) | |
Create texture loading it from file. | |
Texture (Renderer &renderer, const Surface &surface) | |
Create texture from surface. | |
virtual | ~Texture () |
Destructor. | |
Texture (Texture &&other) noexcept | |
Move constructor. | |
Texture & | operator= (Texture &&other) noexcept |
Move assignment. | |
Texture (const Texture &other)=delete | |
Deleted copy constructor. | |
Texture & | operator= (const Texture &other)=delete |
Deleted assignment operator. | |
SDL_Texture * | Get () const |
Get pointer to managed SDL_Texture structure. | |
Texture & | Update (const Optional< Rect > &rect, const void *pixels, int pitch) |
Update the given texture rectangle with new pixel data. | |
Texture & | Update (const Optional< Rect > &rect, Surface &surface) |
Update the given texture rectangle with new pixel data taken from surface. | |
Texture & | Update (const Optional< Rect > &rect, Surface &&surface) |
Update the given texture rectangle with new pixel data taken from surface. | |
Texture & | UpdateYUV (const Optional< Rect > &rect, const Uint8 *yplane, int ypitch, const Uint8 *uplane, int upitch, const Uint8 *vplane, int vpitch) |
Update the given texture rectangle with new pixel data. | |
Texture & | SetBlendMode (SDL_BlendMode blendMode=SDL_BLENDMODE_NONE) |
Set the blend mode for a texture, used by SDL2pp::Renderer::Copy. | |
Texture & | SetAlphaMod (Uint8 alpha=255) |
Set an additional alpha value multiplied into render copy operations. | |
Texture & | SetColorMod (Uint8 r=255, Uint8 g=255, Uint8 b=255) |
Set an additional color value multiplied into render copy operations. | |
Texture & | SetColorAndAlphaMod (const Color &color=Color{255, 255, 255, SDL_ALPHA_OPAQUE}) |
Set an additional color value multiplied into render copy operations. | |
LockHandle | Lock (const Optional< Rect > &rect=NullOpt) |
Lock texture for write-only pixel access. | |
Uint32 | GetFormat () const |
Get texture format. | |
int | GetAccess () const |
Get texture access mode. | |
int | GetWidth () const |
Get texture image width. | |
int | GetHeight () const |
Get texture image height. | |
Point | GetSize () const |
Get texture image size. | |
Uint8 | GetAlphaMod () const |
Get the additional alpha value multiplied into render copy operations. | |
SDL_BlendMode | GetBlendMode () const |
Get the blend mode used for texture copy operations. | |
void | GetColorMod (Uint8 &r, Uint8 &g, Uint8 &b) const |
Get the additional color value multiplied into render copy operations. | |
Color | GetColorAndAlphaMod () const |
Get the additional color value multiplied into render copy operations. | |
Image stored in the graphics card memory that can be used for fast drawing.
|
explicit |
Construct from existing SDL_Texture structure.
[in] | texture | Existing SDL_Texture to manage |
SDL2pp::Texture::Texture | ( | Renderer & | renderer, |
Uint32 | format, | ||
int | access, | ||
int | w, | ||
int | h | ||
) |
Create empty texture.
[in] | renderer | Rendering context to create texture for |
[in] | format | One of the enumerated values in SDL_PixelFormatEnum |
[in] | access | One of the enumerated values in SDL_TextureAccess |
[in] | w | Width of the texture in pixels |
[in] | h | Height of the texture in pixels |
SDL2pp::Exception |
Create texture loading it via RWops.
[in] | renderer | Rendering context to create texture for |
[in] | rwops | RWops used to access an image file |
SDL2pp::Exception |
SDL2pp::Texture::Texture | ( | Renderer & | renderer, |
const std::string & | filename | ||
) |
Create texture loading it from file.
[in] | renderer | Rendering context to create texture for |
[in] | filename | Path to an image file |
SDL2pp::Exception |
Create texture from surface.
[in] | renderer | Rendering context to create texture for |
[in] | surface | Surface containing pixel data used to fill the texture |
SDL2pp::Exception |
|
virtual |
Destructor.
|
noexcept |
Move constructor.
[in] | other | SDL2pp::Texture object to move data from |
|
delete |
Deleted copy constructor.
This class is not copyable
SDL_Texture * SDL2pp::Texture::Get | ( | ) | const |
Get pointer to managed SDL_Texture structure.
int SDL2pp::Texture::GetAccess | ( | ) | const |
Uint8 SDL2pp::Texture::GetAlphaMod | ( | ) | const |
Get the additional alpha value multiplied into render copy operations.
SDL2pp::Exception |
SDL_BlendMode SDL2pp::Texture::GetBlendMode | ( | ) | const |
Get the blend mode used for texture copy operations.
SDL2pp::Exception |
Color SDL2pp::Texture::GetColorAndAlphaMod | ( | ) | const |
Get the additional color value multiplied into render copy operations.
SDL2pp::Exception |
void SDL2pp::Texture::GetColorMod | ( | Uint8 & | r, |
Uint8 & | g, | ||
Uint8 & | b | ||
) | const |
Get the additional color value multiplied into render copy operations.
[out] | r | Variable to be filled in with the current red color value |
[out] | g | Variable to be filled in with the current green color value |
[out] | b | Variable to be filled in with the current blue color value |
SDL2pp::Exception |
Uint32 SDL2pp::Texture::GetFormat | ( | ) | const |
int SDL2pp::Texture::GetHeight | ( | ) | const |
Point SDL2pp::Texture::GetSize | ( | ) | const |
Get texture image size.
SDL2pp::Exception |
int SDL2pp::Texture::GetWidth | ( | ) | const |
Texture::LockHandle SDL2pp::Texture::Lock | ( | const Optional< Rect > & | rect = NullOpt | ) |
Lock texture for write-only pixel access.
[in] | rect | Rect representing area to lock for access (NullOpt to lock entire texture) |
SDL2pp::Exception |
Deleted assignment operator.
This class is not copyable
Move assignment.
[in] | other | SDL2pp::Texture object to move data from |
Texture & SDL2pp::Texture::SetAlphaMod | ( | Uint8 | alpha = 255 | ) |
Set an additional alpha value multiplied into render copy operations.
[in] | alpha | Source alpha value multiplied into copy operations |
SDL2pp::Exception |
Texture & SDL2pp::Texture::SetBlendMode | ( | SDL_BlendMode | blendMode = SDL_BLENDMODE_NONE | ) |
Set the blend mode for a texture, used by SDL2pp::Renderer::Copy.
[in] | blendMode | SDL_BlendMode to use for texture blending |
SDL2pp::Exception |
Texture & SDL2pp::Texture::SetColorAndAlphaMod | ( | const Color & | color = Color{255, 255, 255, SDL_ALPHA_OPAQUE} | ) |
Set an additional color value multiplied into render copy operations.
[in] | color | Color to be used when multiplied into render copy operations |
SDL2pp::Exception |
Texture & SDL2pp::Texture::SetColorMod | ( | Uint8 | r = 255 , |
Uint8 | g = 255 , |
||
Uint8 | b = 255 |
||
) |
Set an additional color value multiplied into render copy operations.
[in] | r | Red color value multiplied into copy operations |
[in] | g | Green color value multiplied into copy operations |
[in] | b | Blue color value multiplied into copy operations |
SDL2pp::Exception |
Update the given texture rectangle with new pixel data.
[in] | rect | Rect representing the area to update, or NullOpt to update the entire texture |
[in] | pixels | Raw pixel data |
[in] | pitch | Number of bytes in a row of pixel data, including padding between lines |
SDL2pp::Exception |
Update the given texture rectangle with new pixel data taken from surface.
[in] | rect | Rect representing the area to update, or NullOpt to update the entire texture |
[in] | surface | Surface to take pixel data from |
SDL2pp::Exception |
Update the given texture rectangle with new pixel data taken from surface.
[in] | rect | Rect representing the area to update, or NullOpt to update the entire texture |
[in] | surface | Surface to take pixel data from |
SDL2pp::Exception |
Texture & SDL2pp::Texture::UpdateYUV | ( | const Optional< Rect > & | rect, |
const Uint8 * | yplane, | ||
int | ypitch, | ||
const Uint8 * | uplane, | ||
int | upitch, | ||
const Uint8 * | vplane, | ||
int | vpitch | ||
) |
Update the given texture rectangle with new pixel data.
[in] | rect | Rect representing the area to update, or NullOpt to update the entire texture |
[in] | yplane | Raw pixel data for the Y plane |
[in] | ypitch | Number of bytes between rows of pixel data for the Y plane |
[in] | uplane | Raw pixel data for the U plane |
[in] | upitch | Number of bytes between rows of pixel data for the U plane |
[in] | vplane | Raw pixel data for the V plane |
[in] | vpitch | Number of bytes between rows of pixel data for the V plane |
SDL2pp::Exception |