From 6d9d393ae60bfc6b2625a5540cd60ffed478aa13 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 12 Mar 2026 01:15:26 +0000 Subject: Shared VAO for all 3 parts of RailVehicleClass Rearranges its LocationVertex to be 3 repeated Parts. Adds helpers to glvglVertexArray for useBuffer with various offsets. Render is then an iteration of the meshes and the location data at the nth offset. --- gfx/gl/glVertexArray.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'gfx/gl') diff --git a/gfx/gl/glVertexArray.h b/gfx/gl/glVertexArray.h index 6630b70..791f74f 100644 --- a/gfx/gl/glVertexArray.h +++ b/gfx/gl/glVertexArray.h @@ -125,13 +125,33 @@ namespace Impl { template void - useBuffer(GLuint binding, const glAllocated & buffer) const + useBuffer(GLuint binding, const glAllocated & buffer, GLsizei offset = 0) const requires requires { { buffer.bufferName() } -> std::same_as; } { using T = typename glAllocated::value_type; - glVertexArrayVertexBuffer(name, binding, buffer.bufferName(), 0, sizeof(T)); + useBuffer(binding, buffer.bufferName(), sizeof(T), offset); + } + + template + void + useBuffer(GLuint binding, GLuint bufferName, auto V::* mbr) const + { + useBuffer(binding, bufferName, sizeof(V), VertexArrayConfigurator::MP {mbr}); + } + + template + void + useBuffer(GLuint binding, GLuint bufferName, GLintptr offset = 0) const + { + useBuffer(binding, bufferName, sizeof(V), offset); + } + + void + useBuffer(GLuint binding, GLuint bufferName, GLsizei stride, GLintptr offset = 0) const + { + glVertexArrayVertexBuffer(name, binding, bufferName, offset, stride); } }; } -- cgit v1.3