aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/Texture.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp
index f543c37..29c2eea 100644
--- a/src/graphics/Texture.cpp
+++ b/src/graphics/Texture.cpp
@@ -1,9 +1,15 @@
#include "../../include/mglpp/graphics/Texture.hpp"
#include "../../include/mglpp/graphics/Image.hpp"
+#include <string.h>
namespace mgl {
Texture::Texture() {
- texture.id = 0;
+ memset(&texture, 0, sizeof(mgl_texture));
+ }
+
+ Texture::Texture(Texture &&other) {
+ memcpy(&texture, &other.texture, sizeof(mgl_texture));
+ other.texture.id = 0;
}
Texture::~Texture() {
@@ -47,6 +53,13 @@ namespace mgl {
return mgl_texture_load_from_image(&texture, image.internal_image(), &texture_load_options) == 0;
}
+ void Texture::clear() {
+ if(owned)
+ mgl_texture_unload(&texture);
+ memset(&texture, 0, sizeof(mgl_texture));
+ owned = true;
+ }
+
vec2i Texture::get_size() const {
return { texture.width, texture.height };
}