From a2ac8b537a61fb7a7be1a3e08635ffc88e17d966 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 18 Nov 2021 06:48:50 +0100 Subject: Disable copy constructors for opengl resource items --- src/graphics/Texture.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/graphics/Texture.cpp') 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 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 }; } -- cgit v1.2.3