From c403a71564def731f4d3b80d6ff63f08aa3c7ea3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 11 Mar 2026 20:45:05 +0000 Subject: Reuse vertex array objects for common structures with DSA Slashes the number of VAOs required and the amount of setup required. --- game/terrain.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'game/terrain.h') diff --git a/game/terrain.h b/game/terrain.h index 1a63296..f1170f2 100644 --- a/game/terrain.h +++ b/game/terrain.h @@ -13,7 +13,7 @@ class Terrain : public GeoData, public WorldObject, public Renderable { public: template explicit Terrain(P &&... params) : GeoData {std::forward

(params)...} { - generateMeshes(); + initialise(); } void render(const SceneShader & shader, const Frustum &) const override; @@ -29,15 +29,17 @@ public: void generateMeshes(); private: + void initialise(); void afterChange() override; struct SurfaceArrayBuffer { - glVertexArray vertexArray; glBuffer indicesBuffer; GLsizei count; AxisAlignedBoundingBox aabb; }; + glVertexArray vertexArray; + struct SurfaceKey { const Surface * surface; GlobalPosition2D basePosition; -- cgit v1.3