Map buffer data as shared_ptr<T[]>

This commit is contained in:
Nikita Lisitsa 2021-03-13 14:30:11 +03:00
parent 0a367b8ab4
commit 9baa91b7e3

View file

@ -55,13 +55,13 @@ namespace psemek::gfx
}
template <typename T>
std::shared_ptr<T> map()
std::shared_ptr<T[]> map()
{
if (auto p = mapped_.lock())
return std::static_pointer_cast<T>(p);
return std::static_pointer_cast<T[]>(p);
bind();
std::shared_ptr<T> p(reinterpret_cast<T *>(gl::MapBuffer(gl::ARRAY_BUFFER, gl::WRITE_ONLY)), [this](T *){
std::shared_ptr<T[]> p(reinterpret_cast<T *>(gl::MapBuffer(gl::ARRAY_BUFFER, gl::WRITE_ONLY)), [this](T *){
bind();
gl::UnmapBuffer(gl::ARRAY_BUFFER);
});