Maxime BOUCHER wrote:
You're right, it 's not that hard.
Actually, indices are stored in a "VertexIndices IntArray".
Whereas they are directly stored in the PrimitiveSet for a DrawElement.

If someone knows why there are these several types for PrimitiveSets, and 
especially this difference between DrawArrayLengths and DrawElementUthing, I 
would be very very pleased to know (for culture).

DrawArrays is for non-indexed rendering. Each element of each vertex attribute array (vertices, normals, colors, texture coords) is used in order (0,1,2,...).

DrawArrayLengths is for non-indexed rendering of variable-length primitives (line strips, line loops, triangle strips, triangle fans, quad strips, and polygons). In addition to the attribute arrays, there is a "lengths" array specified that determines how long each primitive will be.

DrawElementsUByte, DrawElementsUShort, and DrawElementsUInt are for indexed rendering. Instead of using the vertex attribute arrays in order (0,1,2,...), the DrawElements* primitive set includes an index array that specifies which element of each array should be used for each vertex in the primitive. The main use for this is in dense meshes, where any given vertex is shared among several primitives.

If you want to understand these better look up glDrawArrays() and glDrawElements() in the OpenGL Red Book. Note that osg::DrawArrayLengths is just a convenience layer on top of glDrawArrays().

Also, don't confuse the indexed rendering aspect of the DrawElements primitive sets with index arrays. The index arrays (set by setVertexIndices(), setNormalIndices(), etc) should not be used in most cases, as they force OSG to drop down to immediate mode rendering (using glBegin() and glEnd()), which is much slower than the above methods.

--"J"

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to