adbrown85 / gloop

Lightweight C++ wrapper for OpenGL
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Add BufferLayout utility #36

Closed adbrown85 closed 12 years ago

adbrown85 commented 12 years ago

Since our wrapper for buffer objects will be very general and lightweight, as opposed to having specialized implementations for each use of a buffer, e.g. VertexBufferObject, we may want to have a utility to keep track of what's in a buffer. You would give it a number of regions, where a region is a essentially a name, data type, and count, and then it would compute the stride and offset of those regions for you. If the counts for all of the regions were the same, the layout could be set to interleaved, which would change the offsets.

BufferRegion
 + name() : string
 + type() : GLenum
 + normalized() : bool
 + count() : GLuint

BufferLayout
 + region(BufferRegion)
 + regions() : range<BufferRegion>
 + region(name : string)
 + stride() : GLuint
 + offset(name : string)
adbrown85 commented 12 years ago

Maybe want to have BufferLayout be immutable, like this...

BufferLayout
 + BufferLayout(regions : range<BufferRegion>, interleaved : bool)
 + interleaved() : bool
 + names() : range<string>
 + offset(name : string) : GLuint
 + type(name : string) : GLenum
 + normalized(name : string) : bool
 + stride() : GLuint

If the interleaved argument to the constructor was false, BufferLayout would have to throw an exception if the counts of the regions weren't the same. Considering it would have to throw one for the same reason on the interleaved setter in the mutable version, there's not really a big different though.

adbrown85 commented 12 years ago

Probably just implement it using std::vector first, then can investigate using boost::range later.