aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Texture.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-18 06:48:50 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 06:48:50 +0100
commita2ac8b537a61fb7a7be1a3e08635ffc88e17d966 (patch)
treeb7594e7d1cff0abaecdd8e96ef0ad90bce8f1098 /src/graphics/Texture.cpp
parent3f8099b9b5c64e912a2ca227a9e3b2ce774f5ff3 (diff)
Disable copy constructors for opengl resource items
Diffstat (limited to 'src/graphics/Texture.cpp')
-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 };
}