From a05500148232f2059d674a047bc48c1d7142a9c9 Mon Sep 17 00:00:00 2001 From: frank Date: Mon, 14 Aug 2023 16:30:38 -0400 Subject: [PATCH] add method to clear texture list to sprite class, add comments explaining model class's private member vars --- src/Model.hpp | 9 +++++++++ src/Sprite.hpp | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Model.hpp b/src/Model.hpp index 6cfb744..1506385 100644 --- a/src/Model.hpp +++ b/src/Model.hpp @@ -40,8 +40,17 @@ namespace sb private: + /* When a texture is copied, it copies its shared pointer to its ID that identifies the texture memory on the GPU. Therefore, when + * this object is copied, its textures are copied with reference to the same GPU memory preserved. */ std::vector _textures; + + /* The attributes are associated with vertex data copied on the GPU. Shared pointers are used to store the attributes, so that if a + * copy of this object is made, each attributes in the copied object will point to its originally constructed attributes object, preserving + * the association with the vertex data on the GPU. */ std::map> _attributes; + + /* The model keeps a single transformation matrix. Specific types of transformation, like scale, translate, etc, can be combined into this + * transformation. */ glm::mat4 _transformation {1.0f}; public: diff --git a/src/Sprite.hpp b/src/Sprite.hpp index fb2d9f3..68f8928 100644 --- a/src/Sprite.hpp +++ b/src/Sprite.hpp @@ -149,14 +149,20 @@ namespace sb /*! * Get a constant reference to the texture attached to the sprite's plane object at the object's current texture index. - * - * @param index index of texture to get */ const sb::Texture& texture() const { return plane.texture(_texture_index); } + /*! + * Remove all textures from the sprite object's plane. + */ + void clear_textures() + { + plane.textures() = {}; + } + /*! * @param index set the object's texture index * @return constant reference to the texture at the given index