summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-04-27 15:19:06 +0200
committerCarl Hetherington <cth@carlh.net>2025-04-28 02:31:15 +0200
commit807f3577bcea52a2f4d0bed394d3f430b9a80967 (patch)
tree6eaaeecc27a73cb3f01659174c98e9cfcfc44341
parent41407e264a9a9cb97ecc32bcef8c5ba9fa39108f (diff)
Add move constructor/operator to Texture.
-rw-r--r--src/wx/gl_util.cc28
-rw-r--r--src/wx/gl_util.h3
2 files changed, 31 insertions, 0 deletions
diff --git a/src/wx/gl_util.cc b/src/wx/gl_util.cc
index 87a75f749..8b66e4c05 100644
--- a/src/wx/gl_util.cc
+++ b/src/wx/gl_util.cc
@@ -81,6 +81,34 @@ Texture::Texture(GLint unpack_alignment, int unit)
}
+Texture::Texture(Texture&& other)
+ : _name(other._name)
+ , _unpack_alignment(other._unpack_alignment)
+ , _unit(other._unit)
+ , _size(std::move(other._size))
+{
+ other._name = 0;
+}
+
+
+Texture&
+Texture::operator=(Texture&& other)
+{
+ if (this == &other) {
+ return *this;
+ }
+
+ _name = other._name;
+ _unpack_alignment = other._unpack_alignment;
+ _unit = other._unit;
+ _size = std::move(other._size);
+
+ other._name = 0;
+
+ return *this;
+}
+
+
Texture::~Texture()
{
glDeleteTextures(1, &_name);
diff --git a/src/wx/gl_util.h b/src/wx/gl_util.h
index 3c8ba6dc5..20ea2883e 100644
--- a/src/wx/gl_util.h
+++ b/src/wx/gl_util.h
@@ -137,6 +137,9 @@ public:
Texture(Texture const&) = delete;
Texture& operator=(Texture const&) = delete;
+ Texture(Texture&&);
+ Texture& operator=(Texture&&);
+
void bind();
void set(std::shared_ptr<const Image> image, int component = 0);