From 7c03d93c367b842c464dca30e121bc4c20547c36 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 1 Jan 2022 16:44:19 +0000 Subject: Generic solution for glGen/glDel arrays, then tidy-up the uses --- lib/glBuffers.h | 64 --------------------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 lib/glBuffers.h (limited to 'lib/glBuffers.h') diff --git a/lib/glBuffers.h b/lib/glBuffers.h deleted file mode 100644 index e2c09df..0000000 --- a/lib/glBuffers.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef GLBUFFERS_H -#define GLBUFFERS_H - -#include -#include // IWYU pragma: keep -#include -#include -#include - -class glBuffersBase { -protected: - static void gen(GLsizei, GLuint *); - static void del(GLsizei, const GLuint *); -}; - -template class glBuffers : glBuffersBase { -public: - glBuffers() - { - gen(N, ids.data()); - } - - ~glBuffers() - { - del(N, ids.data()); - } - - NO_COPY(glBuffers); - CUSTOM_MOVE(glBuffers); - - // NOLINTNEXTLINE(hicpp-explicit-conversions) - operator GLuint() const - { - static_assert(N == 1, "Implicit cast only if N == 1"); - return ids.front(); - } - - auto - operator[](size_t n) const - { - return ids[n]; - } - -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