0028276: Visualization, Graphic3d_ArrayOfPrimitives - fix usage of 16-bit indices
authorkgv <kgv@opencascade.com>
Fri, 23 Dec 2016 18:21:00 +0000 (21:21 +0300)
committerapn <apn@opencascade.com>
Thu, 29 Dec 2016 11:31:29 +0000 (14:31 +0300)
Graphic3d_ArrayOfPrimitives now check the amount of vertex data rather than amount of indices.

src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx
src/OpenGl/OpenGl_PrimitiveArray.cxx

index 6fe98f0..037c05f 100644 (file)
@@ -56,7 +56,7 @@ Graphic3d_ArrayOfPrimitives::Graphic3d_ArrayOfPrimitives (const Graphic3d_TypeOf
   if (theMaxEdges > 0)
   {
     myIndices = new Graphic3d_IndexBuffer (anAlloc);
-    if (theMaxEdges < Standard_Integer(USHRT_MAX))
+    if (theMaxVertexs < Standard_Integer(USHRT_MAX))
     {
       if (!myIndices->Init<unsigned short> (theMaxEdges))
       {
index 47c789c..811097d 100644 (file)
@@ -943,12 +943,13 @@ void OpenGl_PrimitiveArray::setDrawMode (const Graphic3d_TypeOfPrimitiveArray th
 Standard_Boolean OpenGl_PrimitiveArray::processIndices (const Handle(OpenGl_Context)& theContext) const
 {
   if (myIndices.IsNull()
+   || myAttribs.IsNull()
    || theContext->hasUintIndex)
   {
     return Standard_True;
   }
 
-  if (myIndices->NbElements > std::numeric_limits<GLushort>::max())
+  if (myAttribs->NbElements > std::numeric_limits<GLushort>::max())
   {
     Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (new NCollection_AlignedAllocator (16));
     if (!anAttribs->Init (myIndices->NbElements, myAttribs->AttributesArray(), myAttribs->NbAttributes))