Hello,
I stumbled upon a problem: Let's say I want to emit Vertices that define different sets of attributes to the renderer - what would be the appropriate way to do this?
Imagine a sequence of gl-commands like

Code :
// vertex0
glColor...
...
glNormal...
glVertex...   
 
// vertex1
glNormal...
glVertex...
 
// vertex2
glVertex...

Defining an array to me only seems possible for the vertex-attribute and could not be emitted via glDrawElements. To minimize the data-flow to the graphics adaptor this could be transformed to

Code :
/* Define a vertex array */
glEnable ... VERTEX_ARRAY
 
// vertex0
glColor...
glNormal...
glArrayElement...
 
//vertex1
glNormal
glArrayElement...
 
//vertex2
glArrayElement...
which would allow for reuse of the vertex-(point)-data via an index, but not for the additional attributes present in vertices 0 and 1. Of course arrays for the additional attributes could be defined but, as I read the documentation a construct like

Code :
 
//vertex0
glEnable.. VERTEX
glEnable.. COLOR
glEnable.. NORMAl
glArrayElement...
 
//vertex1
glDisable...COLOR
glArrayElement...
 
//vertex2
glDisable... NORMAL
glArrayElement
is not allowed. Am I missing the right functionality to accomplish emitting vertices with different sets of attributes to the renderer without having to send (possible identical data) over the data-bus more than once?


To be more precise: I have model-data stored in a compact form like this
Code :
/* Vertex-Attribute-Values are simple vector-structures (sequences of floats) */
{
  Vector0 = { x,y,z,w },
  Vector1...
}
 
/* Vertices are defined as a bitmask indicating the attributes present followed by indices into the vertex-attribut-value-array */
{
  POINT_BIT+NORMAL_BIT+COLOR_BIT, IndexOfNormalVectorX, IndexOfColor,...,
  POINT_BIT+NORMAL_BIT, IndexOfNormal, IndexOfVertex...
  POINT_BIT, IndexOfVertex
}
 
/* Triangles are defined by offsets into the vertex array */
{
  OffsetOfVertex0, OffsetOfVertex1, OffsetOfVertex2
}
The question that led to the question posted at the beginning was how to efficiently emit such data.

Thanks for ideas