10 #include <SDL_render.h> 48 Lock(SDL_Texture* texture, SDL_Rect
const* rect) :
texture_{texture}
56 SDL_QueryTexture(
texture_, &f,
nullptr,
nullptr,
nullptr);
80 :
Texture{SDL_CreateTexture(render, format, access, w, h)}
96 :
Texture{SDL_CreateTextureFromSurface(render, surface.
ptr())}
116 other.texture_ =
nullptr;
133 if (SDL_SetTextureBlendMode(
texture_, bm) != 0)
throw Exception{
"SDL_SetTextureBlendMode"};
139 if (SDL_GetTextureBlendMode(
texture_, &bm) != 0)
throw Exception{
"SDL_GetTextureBlendMode"};
148 if (SDL_SetTextureColorMod(
texture_, r, g, b) != 0)
149 throw Exception{
"SDL_SetTextureColorMod"};
156 if (SDL_GetTextureColorMod(
texture_, &c.r, &c.g, &c.b) != 0)
157 throw Exception{
"SDL_SetTextureColorMod"};
164 if (SDL_SetTextureAlphaMod(
texture_, alpha) != 0)
throw Exception{
"SDL_SetTextureAlphaMod"};
170 if (SDL_GetTextureAlphaMod(
texture_, &alpha) != 0)
171 throw Exception{
"SDL_GetTextureAlphaMod"};
199 if (SDL_QueryTexture(
texture_, &f,
nullptr,
nullptr,
nullptr) != 0)
208 if (SDL_QueryTexture(
texture_,
nullptr, &a,
nullptr,
nullptr) != 0)
217 if (SDL_QueryTexture(
texture_,
nullptr,
nullptr, &s.x, &s.y) != 0)
SDL_Texture * ptr() const
Get SDL_Texture pointer from texture.
void set_colormod(Color const &color) const
Set colormod.
Texture(SDL_Renderer *render, Surface const &surface)
Create texture from surface.
sdl::Rect, C++ wrapping of SDL_Rect
void set_alphamod(Uint8 alpha) const
Set alphamod.
Generic templated 2D vector class.
Texture(SDL_Renderer *render, Uint32 format, SDL_TextureAccess access, Vec2i size)
Create texture.
Color colormod() const
Get colormod.
void * pixels_
pointer to pixel array
Lock(SDL_Texture *texture, SDL_Rect const *rect)
private ctor to create a lock. Lock are created by Texture class
int access() const
Access texture.
Color coloralphamod() const
Get coloralphamod.
~Texture()
Destroy texture when it's not in use anymore.
Pixel operator[](Vec2i const &pos) const
Get pixel at location with operator[].
Uint32 format() const
Get texture format.
Class that represet a renderer texture.
SDL_Texture * texture_
pointer to raw texure
Texture(SDL_Renderer *render, Uint32 format, SDL_TextureAccess access, int w, int h)
Create texture.
SDL_PixelFormat * format_
Pixel format.
C++ wrapping around the SDL_Color structure.
Pixel at(size_t x, size_t y) const
Get pixel at given location on texture.
Define to deactivate exception support.
Texture & operator=(Texture &&other) noexcept
Move texture into this one.
Vec2i size() const
Get texture size.
void set_coloralphamod(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
Set coloralphamod.
Lock object that permit to access pixels directly on texture.
Represent a 4 channel pixel.
Lock lock(Rect const &rect)
lock texture rect
Texture(SDL_Texture *t)
Construct texture from C SDL_Texture object.
~Lock()
Automatically unlock texture.
SDL_Surface * ptr() const
Get C SDL_Surface object.
Uint8 alphamod() const
Set alphamod.
Represent an SDL_Surface.
void set_coloralphamod(Color const &c) const
Set coloralphamod.
Pixel at(Vec2i const &pos) const
Get pixel at given location on texture.
Texture(SDL_Renderer *render, std::string const &filename)
Create texture from file.
SDL_BlendMode blendmode() const
Get texture blend mode.
void set_blendmode(SDL_BlendMode const &bm) const
Set texture blend mode.
Define to deactivate exception support.
Texture(Texture &&other) noexcept
Move texture into this one.
Lock lock()
lock texture for direct access to content
void set_colormod(Uint8 r, Uint8 g, Uint8 b) const
Set colormod.