summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-27 21:47:41 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-27 21:47:41 +0000
commite0ac130808d9bed5443115ee91e9cccda713ae3c (patch)
treedad2b2cbe2bc8bf5560f4859880549472f808671 /lib
parentRemove the static texture cache (diff)
parentRender text in N draw calls (diff)
downloadilt-e0ac130808d9bed5443115ee91e9cccda713ae3c.tar.bz2
ilt-e0ac130808d9bed5443115ee91e9cccda713ae3c.tar.xz
ilt-e0ac130808d9bed5443115ee91e9cccda713ae3c.zip
Merge branch 'text2'
Diffstat (limited to 'lib')
-rw-r--r--lib/cache.cpp1
-rw-r--r--lib/cache.h39
-rw-r--r--lib/glContainer.h6
-rw-r--r--lib/gl_traits.h8
4 files changed, 14 insertions, 40 deletions
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 <functional>
-#include <map>
-#include <memory>
-#include <tuple>
-
-template<typename Obj, typename... KeyParts> class Cache {
-public:
- using Ptr = std::shared_ptr<Obj>;
- using Key = std::tuple<KeyParts...>;
-
- 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<Obj>(keyparts...);
- }
-
-private:
- std::map<Key, Ptr, std::less<>> cached;
-};
-
-// IWYU pragma: no_forward_declare Cache
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<template<typename, typename...> typename C> explicit glContainer(const C<T> & src)
+ {
+ reserve(src.size());
+ std::copy(src.begin(), src.end(), std::back_inserter(*this));
+ }
+
DEFAULT_MOVE_NO_COPY(glContainer);
[[nodiscard]] iterator
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<glm::uint32> : public gl_traits_integer {
template<typename T, std::size_t S> struct gl_traits<std::array<T, S>> : public gl_traits<T> {
static constexpr GLint size {S * gl_traits<T>::size};
+ static constexpr auto vertexAttribFunc {
+ [](GLuint index, GLint, GLenum type, GLsizei stride, const void * pointer) -> GLuint {
+ const auto base = static_cast<const T *>(pointer);
+ for (GLuint e = 0; e < S; e++) {
+ glVertexAttribPointer(index + e, gl_traits<T>::size, type, GL_FALSE, stride, base + e);
+ }
+ return S;
+ }};
};
template<glm::length_t L, typename T, glm::qualifier Q> struct gl_traits<glm::vec<L, T, Q>> : public gl_traits<T> {