From 7c6ad616ae0d8c2bb83c9ad6473b5581a6bd7526 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 31 Dec 2021 12:31:13 +0000 Subject: Allow glBuffers and glVertexArrays to be moved --- lib/glBuffers.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/glBuffers.h') diff --git a/lib/glBuffers.h b/lib/glBuffers.h index e91293c..e2c09df 100644 --- a/lib/glBuffers.h +++ b/lib/glBuffers.h @@ -2,6 +2,7 @@ #define GLBUFFERS_H #include +#include // IWYU pragma: keep #include #include #include @@ -25,7 +26,7 @@ public: } NO_COPY(glBuffers); - NO_MOVE(glBuffers); + CUSTOM_MOVE(glBuffers); // NOLINTNEXTLINE(hicpp-explicit-conversions) operator GLuint() const @@ -43,6 +44,21 @@ public: private: std::array ids {}; }; + +template glBuffers::glBuffers(glBuffers && src) noexcept : ids {src.ids} +{ + std::fill(src.ids.begin(), src.ids.end(), -1); +} + +template +glBuffers & +glBuffers::operator=(glBuffers && src) noexcept +{ + ids = src.ids; + std::fill(src.ids.begin(), src.ids.end(), -1); + return *this; +} + using glBuffer = glBuffers<1>; #endif -- cgit v1.2.3