#pragma once #include #include namespace mln { namespace gfx { class VertexBufferResource { protected: VertexBufferResource() noexcept = default; public: virtual ~VertexBufferResource() noexcept = default; }; using UniqueVertexBufferResource = std::unique_ptr; // This class has a template argument that we use to specify the vertex type. It // is not used by the implementation, but serves type checking purposes during // build time. template class VertexBuffer { public: VertexBuffer(const std::size_t elements_, UniqueVertexBufferResource&& resource_) : elements(elements_), resource(std::move(resource_)) {} std::size_t elements; template T& getResource() const { assert(resource); return static_cast(*resource); } protected: UniqueVertexBufferResource resource; }; } // namespace gfx } // namespace mln