+#include "Texture.h"
+
+
+namespace gworm {
+
+Texture::Texture()
+: tex(nullptr)
+, format(Color::Format)
+, size(0, 0) {
+
+}
+
+Texture::~Texture() {
+ if (tex) SDL_DestroyTexture(tex);
+}
+
+Texture::Texture(Texture &&other)
+: Texture() {
+ Swap(other);
+}
+
+Texture &Texture::operator =(Texture &&other) {
+ Texture temp(std::move(other));
+ Swap(temp);
+ return *this;
+}
+
+
+Texture::Texture(
+ SDL_Renderer *c,
+ Uint32 f,
+ int u,
+ Vector<int> s)
+: tex(SDL_CreateTexture(c, f, u, s.x, s.y))
+, format(f)
+, size(s) {
+
+}
+
+
+void Texture::Swap(Texture &other) {
+ std::swap(tex, other.tex);
+ std::swap(format, other.format);
+ std::swap(size, other.size);
+}
+
+
+void Texture::SetColors(const Color *values) {
+ if (format == Color::Format) {
+ SDL_UpdateTexture(tex, nullptr, values, Size().x * sizeof(Color));
+ } else {
+ // TODO: implement for non-Color pixel formats
+ }
+}
+
+
+void Texture::Fill(SDL_Renderer *canv) {
+ SDL_RenderCopy(canv, tex, nullptr, nullptr);
+}
+
+void Texture::Copy(SDL_Renderer *canv, Vector<int> to) {
+ Copy(canv, Rect<int>(to, Size()));
+}
+
+void Texture::Copy(SDL_Renderer *canv, Rect<int> to) {
+ SDL_RenderCopy(canv, tex, nullptr, &to);
+}
+
+}