My idea is to use a boost mpl to define vertex formats with argument unrolling tricks, generating code objects for vertex access and rendering, so the only runtime decision made is following the function pointer to the generated implementation of submitVertexList in the VertexDef class v-table.
So that way you can define your vertex format like so:
Recursive instantiation of an inline member function using a selector class can be used to hard code the submitVertexList function for each VertexDef instantiation in compile time. VertexDef inherits AbstractVertexDef, so the resulting type is an interface for doing vertex format specific things to a list of vertices with that type. You could then supply your own type for vertex data:
And voila! That would be interpreted correctly by the above VertexDef. It is also possible that an output vertex type be generated by VertexDef instantiation, like VertexDef::VertexType.
Of course, the issue with generating an actual VertexType class from the VertexDef template in boost is that it would require a lot of manual template specialization to select the type for each attribute in the vertex format, because real variadic lists only exist in C++11, and not boost mpl.
Would you be interested in looking it over and trying it if I wrote this up in a branch called, say, flexible_vertex_formats?
My idea is to use a boost mpl to define vertex formats with argument unrolling tricks, generating code objects for vertex access and rendering, so the only runtime decision made is following the function pointer to the generated implementation of submitVertexList in the VertexDef class v-table.
So that way you can define your vertex format like so:
Recursive instantiation of an inline member function using a selector class can be used to hard code the submitVertexList function for each VertexDef instantiation in compile time. VertexDef inherits AbstractVertexDef, so the resulting type is an interface for doing vertex format specific things to a list of vertices with that type. You could then supply your own type for vertex data:
Then assign a VertexDef to a GeometryFactory
And voila! That would be interpreted correctly by the above VertexDef. It is also possible that an output vertex type be generated by VertexDef instantiation, like VertexDef::VertexType.
Of course, the issue with generating an actual VertexType class from the VertexDef template in boost is that it would require a lot of manual template specialization to select the type for each attribute in the vertex format, because real variadic lists only exist in C++11, and not boost mpl.
Would you be interested in looking it over and trying it if I wrote this up in a branch called, say, flexible_vertex_formats?