29#ifndef NOMLIB_SDL2_TEXTURE_HEADERS
30#define NOMLIB_SDL2_TEXTURE_HEADERS
38#include "nomlib/config.hpp"
39#include "nomlib/math/Color4.hpp"
40#include "nomlib/math/Point2.hpp"
41#include "nomlib/math/Size2.hpp"
42#include "nomlib/math/Rect.hpp"
73 Static = SDL_TEXTUREACCESS_STATIC,
74 Streaming = SDL_TEXTUREACCESS_STREAMING,
75 RenderTarget = SDL_TEXTUREACCESS_TARGET
123 bool initialize(uint32 format, uint32 flags,
const Size2i& dims);
133 bool create(
const Image& source, uint32 pixel_format,
enum Texture::Access type );
135 const Point2i& position()
const;
146 const IntRect& bounds()
const;
157 enum Texture::Access
access (
void )
const;
159 void set_position(
const Point2i& pos);
180 int pitch (
void )
const;
182 void* pixels (
void )
const;
184 uint8 bytes_per_pixel (
void )
const;
186 uint32 pixel_format (
void )
const;
244 bool lock(
const IntRect& bounds);
266 bool load (
const std::string& filename,
267 bool use_cache =
false,
268 enum Texture::Access type = Access::Static
281 bool update_pixels(
const void* source, uint16 pitch,
const IntRect& bounds);
287 void draw(SDL_Renderer* target)
const;
302 void draw(SDL_Renderer* target,
const real64 angle)
const;
380 bool copy_pixels (
const void* source,
int pitch );
383 void set_scale_factor(
int factor);
385 std::shared_ptr<SDL_Texture> texture_;
Bitmap storage container.
const SDL_BlendMode blend_mode(void) const
Obtain the blending mode used for texture copies.
bool create(const Image &source)
Texture(void)
Default constructor.
bool set_colorkey(const Color4i &colorkey)
bool initialize(uint32 format, uint32 flags, const Size2i &dims)
enum Texture::Access access(void) const
Query texture access type.
void set_bounds(const IntRect &bounds)
Set bounding coordinates of the Texture.
bool initialize(uint32 format, uint32 flags, int width, int height)
Color4i colorkey_
Cached upon use of the set_colorkey method for use by external classes.
void set_size(const Size2i &size)
Set the width & height dimensions of the texture.
bool load(const std::string &filename, bool use_cache=false, enum Texture::Access type=Access::Static)
Texture(const Texture ©)
Copy constructor.
void draw(const RenderWindow &target, const real64 angle) const
bool lock()
Lock the entire bounds of the texture for write access to the pixel buffer.
bool set_blend_mode(const SDL_BlendMode blend)
Set a new blending mode for this texture.
int pitch_
Texture's pixel pitch; these are only available when a Texture is locked.
Texture * clone() const
Get a shallow-copy of the underlying stored texture.
void draw(SDL_Renderer *target, const real64 angle) const
void draw(const RenderWindow &target) const
Texture & operator=(const Texture &other)
Copy assignment operator.
const Color4i color_modulation(void) const
Obtain the additional color value multiplied into render copy operations.
bool set_color_modulation(const Color4i &color)
Set an additional color value multiplied into render copy operations.
static const Point2i maximum_size(void)
Obtain the largest nom::Texture size allowable by your graphics hardware.
uint8 bits_per_pixel(void) const
void * pixels_
Texture's pixels; these are only available when a Texture is locked.
bool update_pixels(const void *source, uint16 pitch, const IntRect &bounds)
Upload pixels to texture.
bool create(SDL_Texture *source)
SDL_Texture * texture() const
Get the underlying texture stored.
bool lock(const IntRect &bounds)
Lock a portion of the texture for write access to the pixel buffer.
bool valid() const
Is this object initialized – not nullptr?
uint8 alpha(void) const
Obtain the set color key for this image.
int scale_factor(enum ResizeAlgorithm scaling_algorithm) const
Return the scaling factor of the chosen algorithm.
bool locked() const
Query lock status of texture.
uint32 pixel(int x, int y)
Read a RGBA pixel from the video surface.
bool set_alpha(uint8 opacity)
Set an additional alpha value multiplied into render copy operations.
bool create(const Image &source, uint32 pixel_format, enum Texture::Access type)
const Color4i & colorkey(void) const
bool resize(enum ResizeAlgorithm scaling_algorithm)
Rescale the Texture with the chosen rescaling algorithm.
void draw(SDL_Renderer *target) const
ResizeAlgorithm
Available pixel rescaling algorithms.
const Size2i & size() const
Get the width & height dimensions of the texture.
~Texture(void)
Destructor.