Manage mapped memory (glMapBuffer) with std::vector

前端 未结 1 530
南方客
南方客 2021-01-21 20:48

it occurred to me that it would be a good idea to manage a range of mapped memory (from glMapBuffer) with a std::vector.

// map data to ptr
T* dataPtr = (T*)glMa         


        
相关标签:
1条回答
  • 2021-01-21 21:11

    No, and for good reason. This code would never work. For example, you could alter the MapBuffer and break the size/capacity values inside the vector. You could push into the vector and cause an access violation/segmentation fault. You could cause a resize, destroying the buffer. And, fundamentally, if it's already within a contiguous array, what's the benefit? You could roll a custom container for fixed length arrays, I guess.

    Especially! if you already have a pair of pointers to act like iterators.

    0 讨论(0)
提交回复
热议问题