summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2026-03-12 01:15:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2026-03-12 01:15:26 +0000
commit6d9d393ae60bfc6b2625a5540cd60ffed478aa13 (patch)
treebfb184ff995f03c998129e79f786208586fa9360 /gfx/gl
parentReuse vertex array objects for common structures with DSA (diff)
downloadilt-6d9d393ae60bfc6b2625a5540cd60ffed478aa13.tar.bz2
ilt-6d9d393ae60bfc6b2625a5540cd60ffed478aa13.tar.xz
ilt-6d9d393ae60bfc6b2625a5540cd60ffed478aa13.zip
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.
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/glVertexArray.h24
1 files changed, 22 insertions, 2 deletions
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<typename glAllocated>
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<GLuint>;
}
{
using T = typename glAllocated::value_type;
- glVertexArrayVertexBuffer(name, binding, buffer.bufferName(), 0, sizeof(T));
+ useBuffer(binding, buffer.bufferName(), sizeof(T), offset);
+ }
+
+ template<typename V>
+ void
+ useBuffer(GLuint binding, GLuint bufferName, auto V::* mbr) const
+ {
+ useBuffer(binding, bufferName, sizeof(V), VertexArrayConfigurator::MP {mbr});
+ }
+
+ template<typename V>
+ 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);
}
};
}