From 14d82ff67eab5d94b69fb38ea6a0bc634674245c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 26 Jan 2024 17:56:52 +0000 Subject: Remove the generic cache completely --- lib/cache.cpp | 1 - lib/cache.h | 39 --------------------------------------- 2 files changed, 40 deletions(-) delete mode 100644 lib/cache.cpp delete mode 100644 lib/cache.h (limited to 'lib') diff --git a/lib/cache.cpp b/lib/cache.cpp deleted file mode 100644 index 05b26b0..0000000 --- a/lib/cache.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "cache.h" diff --git a/lib/cache.h b/lib/cache.h deleted file mode 100644 index f5fd227..0000000 --- a/lib/cache.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include "special_members.h" -#include -#include -#include -#include - -template class Cache { -public: - using Ptr = std::shared_ptr; - using Key = std::tuple; - - Cache() = default; - virtual ~Cache() = default; - DEFAULT_MOVE(Cache); - NO_COPY(Cache); - - [[nodiscard]] Ptr - get(const KeyParts &... keyparts) - { - auto key = std::tie(keyparts...); - if (auto e = cached.find(key); e != cached.end()) { - return e->second; - } - return cached.emplace(key, construct(keyparts...)).first->second; - } - - [[nodiscard]] virtual Ptr - construct(const KeyParts &... keyparts) const - { - return std::make_shared(keyparts...); - } - -private: - std::map> cached; -}; - -// IWYU pragma: no_forward_declare Cache -- cgit v1.2.3 From d82541fcea40efadaef63fef5f4a76c3fea5defe Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Jan 2024 11:32:16 +0000 Subject: Support constructing a glContainer from a collection of the same type --- lib/glContainer.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/glContainer.h b/lib/glContainer.h index ce88916..2ccc1c2 100644 --- a/lib/glContainer.h +++ b/lib/glContainer.h @@ -38,6 +38,12 @@ public: clear(); } + template typename C> explicit glContainer(const C & src) + { + reserve(src.size()); + std::copy(src.begin(), src.end(), std::back_inserter(*this)); + } + DEFAULT_MOVE_NO_COPY(glContainer); [[nodiscard]] iterator -- cgit v1.2.3 From c00dacdb573d3e090a092e5725bb3eb7137d0098 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Jan 2024 21:37:59 +0000 Subject: Add traits vertex attrib func override for arrays Address limitation on size when specifying arrays of glm::vec --- lib/gl_traits.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/gl_traits.h b/lib/gl_traits.h index 14ac9d8..b3c6909 100644 --- a/lib/gl_traits.h +++ b/lib/gl_traits.h @@ -83,6 +83,14 @@ template<> struct gl_traits : public gl_traits_integer { template struct gl_traits> : public gl_traits { static constexpr GLint size {S * gl_traits::size}; + static constexpr auto vertexAttribFunc { + [](GLuint index, GLint, GLenum type, GLsizei stride, const void * pointer) -> GLuint { + const auto base = static_cast(pointer); + for (GLuint e = 0; e < S; e++) { + glVertexAttribPointer(index + e, gl_traits::size, type, GL_FALSE, stride, base + e); + } + return S; + }}; }; template struct gl_traits> : public gl_traits { -- cgit v1.2.3