diff options
| author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-03-06 14:11:38 +0000 |
|---|---|---|
| committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-03-06 14:11:38 +0000 |
| commit | 182f823116458ad357823f4cc56638980aafa0f6 (patch) | |
| tree | b6937e27e6d2875d8242e40645929f12138712c4 /gfx | |
| parent | Define SequentialCollection in terms of contiguous_range (diff) | |
| download | ilt-182f823116458ad357823f4cc56638980aafa0f6.tar.bz2 ilt-182f823116458ad357823f4cc56638980aafa0f6.tar.xz ilt-182f823116458ad357823f4cc56638980aafa0f6.zip | |
Replace generic glBuffer type alias with a full implementation
Adds wrappers for DSA storage and data uploads.
Diffstat (limited to 'gfx')
| -rw-r--r-- | gfx/gl/glBuffer.h | 27 | ||||
| -rw-r--r-- | gfx/models/mesh.h | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/gfx/gl/glBuffer.h b/gfx/gl/glBuffer.h new file mode 100644 index 0000000..f43c223 --- /dev/null +++ b/gfx/gl/glBuffer.h @@ -0,0 +1,27 @@ +#pragma once + +#include "glArrays.h" + +namespace Impl { + // NOLINTNEXTLINE(readability-identifier-naming) + struct glBuffer : Detail::glNamed { + void + storage(const std::ranges::contiguous_range auto & data, GLenum flags) + { + glNamedBufferStorage( + name, static_cast<GLsizeiptr>(data.size() * sizeof(decltype(*data.data()))), data.data(), flags); + } + + void + data(const std::ranges::contiguous_range auto & data, GLenum flags) + { + glNamedBufferData( + name, static_cast<GLsizeiptr>(data.size() * sizeof(decltype(*data.data()))), data.data(), flags); + } + }; +} + +// NOLINTBEGIN(readability-identifier-naming) +template<size_t N> using glBuffers = glManagedArray<Impl::glBuffer, N, &glCreateBuffers, &glDeleteBuffers>; +using glBuffer = glManagedSingle<Impl::glBuffer, &glCreateBuffers, &glDeleteBuffers>; +// NOLINTEND(readability-identifier-naming) diff --git a/gfx/models/mesh.h b/gfx/models/mesh.h index d6ac171..4135a30 100644 --- a/gfx/models/mesh.h +++ b/gfx/models/mesh.h @@ -1,6 +1,7 @@ #pragma once #include "config/types.h" +#include "gfx/gl/glBuffer.h" #include "gfx/gl/vertexArrayObject.h" #include <gfx/gl/glVertexArray.h> #include <glad/gl.h> |
