Reputation: 6798
I don't think I am the first one to think about this ... but would it be possible to write a STL allocator that manages VRAM/Buffer Objects(BO) in OpenGL?
As a result of this Question I currently use vectors to write to and read from BOs.
Additionally i use some templating to map BOs as almost anything i like. Like this:
TypedBufferObject<someKindOfStruct> tbo = getTBO();
someKindOfStruct* mapPtr = tbo.map(GL_READ_WRITE);
This works quite well ... but isn't really safe when it comes to the number of elements that map contains.
Has someone implemented a BO-based allocator for STL? And (if not) would it actually be possible?
Upvotes: 0
Views: 611
Reputation: 224069
This article by Matt Austern is the classic reference for creating your own allocator. Allocator have their nooks and crannies, but when you know them writing your own isn't really all that hard.
Upvotes: 1