Guard BindBuffer/BufferData calls for empty arrays

- Issue MatterHackers/MCCentral#3843
Crash when model is floating above plate with no supports
This commit is contained in:
John Lewin 2018-07-12 12:07:33 -07:00
parent 79804f354b
commit 18fd48d562

View file

@ -49,6 +49,8 @@ namespace MatterHackers.GCodeVisualizer
// Set vertex data
myVertexLength = colorData.Length;
if (myVertexLength > 0)
{
GL.BindBuffer(BufferTarget.ArrayBuffer, myVertexId);
unsafe
{
@ -57,9 +59,12 @@ namespace MatterHackers.GCodeVisualizer
GL.BufferData(BufferTarget.ArrayBuffer, colorData.Length * ColorVertexData.Stride, (IntPtr)dataPointer, BufferUsageHint.StaticDraw);
}
}
}
// Set index data
myIndexLength = indexData.Length;
if (myIndexLength > 0)
{
GL.BindBuffer(BufferTarget.ElementArrayBuffer, myIndexId);
unsafe
{
@ -69,6 +74,7 @@ namespace MatterHackers.GCodeVisualizer
}
}
}
}
public void renderRange(int offset, int count)
{