summaryrefslogtreecommitdiff
path: root/lib/glBuffers.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-01-01 16:44:19 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-01-01 16:44:19 +0000
commit7c03d93c367b842c464dca30e121bc4c20547c36 (patch)
tree6df340dc3b0bd16f6ced2a051a68fc8a3c67a08c /lib/glBuffers.h
parentFirst iteration with font/text support (diff)
downloadilt-7c03d93c367b842c464dca30e121bc4c20547c36.tar.bz2
ilt-7c03d93c367b842c464dca30e121bc4c20547c36.tar.xz
ilt-7c03d93c367b842c464dca30e121bc4c20547c36.zip
Generic solution for glGen/glDel arrays, then tidy-up the uses
Diffstat (limited to 'lib/glBuffers.h')
-rw-r--r--lib/glBuffers.h64
1 files changed, 0 insertions, 64 deletions
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 <GL/glew.h>
-#include <algorithm> // IWYU pragma: keep
-#include <array>
-#include <cstddef>
-#include <special_members.hpp>
-
-class glBuffersBase {
-protected:
- static void gen(GLsizei, GLuint *);
- static void del(GLsizei, const GLuint *);
-};
-
-template<size_t N> 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<GLuint, N> ids {};
-};
-
-template<size_t N> glBuffers<N>::glBuffers(glBuffers<N> && src) noexcept : ids {src.ids}
-{
- std::fill(src.ids.begin(), src.ids.end(), -1);
-}
-
-template<size_t N>
-glBuffers<N> &
-glBuffers<N>::operator=(glBuffers<N> && src) noexcept
-{
- ids = src.ids;
- std::fill(src.ids.begin(), src.ids.end(), -1);
- return *this;
-}
-
-using glBuffer = glBuffers<1>;
-
-#endif