Support access bits in gfx::buffer::map

This commit is contained in:
Nikita Lisitsa 2023-09-17 20:19:36 +03:00
parent 6e366cea16
commit 27a9c9ee7b

View file

@ -154,13 +154,13 @@ namespace psemek::gfx
} }
template <typename T> template <typename T>
std::shared_ptr<T[]> map() std::shared_ptr<T[]> map(GLbitfield access)
{ {
if (auto p = mapped_.lock()) if (auto p = mapped_.lock())
return std::static_pointer_cast<T[]>(p); return std::static_pointer_cast<T[]>(p);
bind(); bind();
std::shared_ptr<T[]> p(reinterpret_cast<T *>(gl::MapBufferRange(Target, 0, size_, gl::MAP_WRITE_BIT)), [this](T *){ std::shared_ptr<T[]> p(reinterpret_cast<T *>(gl::MapBufferRange(Target, 0, size_, access)), [this](T *){
bind(); bind();
gl::UnmapBuffer(Target); gl::UnmapBuffer(Target);
}); });