aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mglpp/graphics/Texture.hpp1
-rw-r--r--src/graphics/Texture.cpp15
2 files changed, 16 insertions, 0 deletions
diff --git a/include/mglpp/graphics/Texture.hpp b/include/mglpp/graphics/Texture.hpp
index 5ef94a0..906818c 100644
--- a/include/mglpp/graphics/Texture.hpp
+++ b/include/mglpp/graphics/Texture.hpp
@@ -18,6 +18,7 @@ namespace mgl {
Texture();
Texture(Texture &&other);
+ Texture& operator=(Texture &&other);
~Texture();
static Texture reference(mgl_texture ref);
diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp
index 794c563..86c4ac0 100644
--- a/src/graphics/Texture.cpp
+++ b/src/graphics/Texture.cpp
@@ -9,7 +9,22 @@ namespace mgl {
Texture::Texture(Texture &&other) {
memcpy(&texture, &other.texture, sizeof(mgl_texture));
+ owned = other.owned;
+
+ other.texture.id = 0;
+ other.owned = false;
+ }
+
+ Texture& Texture::operator=(Texture &&other) {
+ if(owned)
+ mgl_texture_unload(&texture);
+
+ memcpy(&texture, &other.texture, sizeof(mgl_texture));
+ owned = other.owned;
+
other.texture.id = 0;
+ other.owned = false;
+ return *this;
}
Texture::~Texture() {