10 , format(Color::Format)
16 if (tex) SDL_DestroyTexture(tex);
19 Texture::Texture(Texture &&other)
24 Texture &Texture::operator =(Texture &&other) {
25 Texture temp(std::move(other));
36 : tex(SDL_CreateTexture(c, f, u, s.x, s.y))
45 : tex(IMG_LoadTexture(c, file))
48 SDL_QueryTexture(tex, &format, nullptr, &size.x, &size.y);
52 void Texture::Swap(Texture &other) {
53 std::swap(tex, other.tex);
54 std::swap(format, other.format);
55 std::swap(size, other.size);
59 void Texture::SetColors(const Color *values) {
60 if (format == Color::Format) {
61 SDL_UpdateTexture(tex, nullptr, values, Size().x * sizeof(Color));
63 // TODO: implement for non-Color pixel formats
68 void Texture::Fill(SDL_Renderer *canv) {
69 SDL_RenderCopy(canv, tex, nullptr, nullptr);
72 void Texture::Fill(SDL_Renderer *canv, Rect<int> clip) {
73 SDL_RenderCopy(canv, tex, &clip, nullptr);
76 void Texture::Copy(SDL_Renderer *canv, Vector<int> to) {
77 Copy(canv, Rect<int>(to, Size()));
80 void Texture::Copy(SDL_Renderer *canv, Rect<int> to) {
81 SDL_RenderCopy(canv, tex, nullptr, &to);
84 void Texture::Copy(SDL_Renderer *canv, Rect<int> clip, Vector<int> to) {
85 Copy(canv, clip, Rect<int>(to, clip.Size()));
88 void Texture::Copy(SDL_Renderer *canv, Rect<int> clip, Rect<int> to) {
89 SDL_RenderCopy(canv, tex, &clip, &to);