I have a mesh consisting of facets with variable vertex count. So I want to draw them separately with multiple MultiDrawElements. It appears though that using the function to access facets beyond the first one fails. The program crashes without even an exception.
int numOfEdgeFacets = 2 * Slices; int numOfEdgeIndices = 3 * numOfEdgeFacets; int numOfTotalStackFacets = BB_ElementMesh.IndexArray.Length - 2 * numOfEdgeFacets;//Remove top-bottom edges int Bottom = new int[numOfEdgeFacets]; int body = new int[numOfTotalStackFacets]; int Top = new int[numOfEdgeFacets]; Array.ConstrainedCopy(BB_ElementMesh.IndexArray, 0, Bottom, 0, numOfEdgeFacets); Array.ConstrainedCopy(BB_ElementMesh.IndexArray, BB_ElementMesh.IndexArray.Length - numOfEdgeFacets, Top, 0, numOfEdgeFacets); Array.ConstrainedCopy(BB_ElementMesh.IndexArray, numOfEdgeFacets, body, 0, numOfTotalStackFacets); //First Draw the BottomPolygon GL.MultiDrawElements(BeginMode.Polygon, ref numOfEdgeFacets, DrawElementsType.UnsignedInt, Bottom, 1); //Draw the main body GL.MultiDrawElements(BeginMode.Polygon, ref numOfTotalStackFacets, DrawElementsType.UnsignedInt, body, 1); //Draw the Top GL.MultiDrawElements(BeginMode.Polygon, ref numOfEdgeFacets, DrawElementsType.UnsignedInt, Top, 1);
In the Code Above only the first call to MultiDrawElements succeeds. If I commend the first and the second calls (ending up with an identical to the first) the third crashes the program. The only difference I see between the first and the last array is that they reference different parts of the collective Element Array (IndexArray).
What could I be doing wrong, or is there another way to address my problem(drawing variable size facets)?
Thank you in advance.