From a6052168340f9831c766f76a3ec7b94da38da78a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 4 Mar 2026 16:53:58 +0000 Subject: Replace basic glVertexArray with a specific class ready for helpers --- lib/glArrays.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/glArrays.h') diff --git a/lib/glArrays.h b/lib/glArrays.h index 48bd577..e949ccd 100644 --- a/lib/glArrays.h +++ b/lib/glArrays.h @@ -119,8 +119,6 @@ struct glManagedArray : public std::array { }; // NOLINTBEGIN(readability-identifier-naming) -template using glVertexArrays = glManagedArray; -using glVertexArray = glManagedSingle; template using glBuffers = glManagedArray; using glBuffer = glManagedSingle; template using glFrameBuffers = glManagedArray; -- cgit v1.3 From 182f823116458ad357823f4cc56638980aafa0f6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 6 Mar 2026 14:11:38 +0000 Subject: Replace generic glBuffer type alias with a full implementation Adds wrappers for DSA storage and data uploads. --- gfx/gl/glBuffer.h | 27 +++++++++++++++++++++++++++ gfx/models/mesh.h | 1 + lib/glArrays.cpp | 14 -------------- lib/glArrays.h | 2 -- lib/glContainer.h | 2 +- 5 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 gfx/gl/glBuffer.h delete mode 100644 lib/glArrays.cpp (limited to 'lib/glArrays.h') 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(data.size() * sizeof(decltype(*data.data()))), data.data(), flags); + } + + void + data(const std::ranges::contiguous_range auto & data, GLenum flags) + { + glNamedBufferData( + name, static_cast(data.size() * sizeof(decltype(*data.data()))), data.data(), flags); + } + }; +} + +// NOLINTBEGIN(readability-identifier-naming) +template using glBuffers = glManagedArray; +using glBuffer = glManagedSingle; +// 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 #include diff --git a/lib/glArrays.cpp b/lib/glArrays.cpp deleted file mode 100644 index cb12f91..0000000 --- a/lib/glArrays.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "glArrays.h" -#include - -// Specialisations (glBuffer is an example of the typedef) -static_assert(std::is_nothrow_default_constructible_v); -static_assert(!std::is_trivially_default_constructible_v); -static_assert(std::is_nothrow_destructible_v); -static_assert(!std::is_trivially_destructible_v); -static_assert(std::is_default_constructible_v); -static_assert(!std::is_copy_constructible_v); -static_assert(!std::is_copy_assignable_v); -static_assert(std::is_nothrow_move_constructible_v); -static_assert(std::is_nothrow_move_assignable_v); -static_assert(sizeof(glBuffer) == sizeof(GLuint)); diff --git a/lib/glArrays.h b/lib/glArrays.h index e949ccd..1cf2fbf 100644 --- a/lib/glArrays.h +++ b/lib/glArrays.h @@ -119,8 +119,6 @@ struct glManagedArray : public std::array { }; // NOLINTBEGIN(readability-identifier-naming) -template using glBuffers = glManagedArray; -using glBuffer = glManagedSingle; template using glFrameBuffers = glManagedArray; using glFrameBuffer = glManagedSingle; template diff --git a/lib/glContainer.h b/lib/glContainer.h index 4119ef5..45f1030 100644 --- a/lib/glContainer.h +++ b/lib/glContainer.h @@ -1,6 +1,6 @@ #pragma once -#include "glArrays.h" +#include "gfx/gl/glBuffer.h" #include #include #include -- cgit v1.3