summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/glContainer.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/glContainer.h b/lib/glContainer.h
index e5f53e2..ce88916 100644
--- a/lib/glContainer.h
+++ b/lib/glContainer.h
@@ -136,6 +136,22 @@ public:
return size_;
}
+ void
+ at(size_type pos, const T & value)
+ {
+ if (pos >= size()) {
+ throw std::out_of_range {__FUNCTION__};
+ }
+ if (data_.data()) {
+ data_[pos] = value;
+ }
+ else {
+ glBindBuffer(GL_ARRAY_BUFFER, buffer_);
+ glBufferSubData(GL_ARRAY_BUFFER, static_cast<GLintptr>(pos * sizeof(T)), sizeof(value), &value);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ }
+ }
+
[[nodiscard]] reference_type
at(size_type pos)
{