public void SetDataWithElementCountAndVertexStride(bool dynamic, int elementCount, int vertexStride, Type expectedExceptionType) { var vertexBuffer = (dynamic) ? new DynamicVertexBuffer(gd, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None) : new VertexBuffer(gd, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None); var savedDataBytes = ArrayUtil.ConvertFrom(savedData); if (expectedExceptionType != null) { Assert.Throws(expectedExceptionType, () => vertexBuffer.SetData(0, savedDataBytes, 0, elementCount, vertexStride)); } else { vertexBuffer.SetData(0, savedDataBytes, 0, elementCount, vertexStride); var readDataBytes = new byte[savedDataBytes.Length]; vertexBuffer.GetData(0, readDataBytes, 0, elementCount, vertexStride); Assert.AreEqual( savedDataBytes.Take(elementCount).ToArray(), readDataBytes.Take(elementCount).ToArray()); } vertexBuffer.Dispose(); }
public void SetDataWithElementCount(bool dynamic, int startIndex, int elementCount, bool shouldSucceed, Type expectedExceptionType) { var vertexBuffer = (dynamic) ? new DynamicVertexBuffer(gd, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None) : new VertexBuffer(gd, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None); var savedDataBytes = ArrayUtil.ConvertFrom(savedData); if (!shouldSucceed) { Assert.Throws(expectedExceptionType, () => vertexBuffer.SetData(savedDataBytes, startIndex, elementCount)); } else { vertexBuffer.SetData(savedDataBytes, startIndex, elementCount); var readDataBytes = new byte[savedDataBytes.Length]; vertexBuffer.GetData(readDataBytes, startIndex, elementCount); Assert.AreEqual( savedDataBytes.Skip(startIndex).Take(elementCount).ToArray(), readDataBytes.Skip(startIndex).Take(elementCount).ToArray()); } vertexBuffer.Dispose(); }
public void SetDataWithElementCountAndVertexStride(bool dynamic, int elementCount, int vertexStride, bool shouldSucceed, Type expectedExceptionType) { Game.DrawWith += (sender, e) => { var vertexBuffer = (dynamic) ? new DynamicVertexBuffer(Game.GraphicsDevice, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None) : new VertexBuffer(Game.GraphicsDevice, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None); var savedDataBytes = ArrayUtil.ConvertFrom(savedData); if (!shouldSucceed) { Assert.Throws(expectedExceptionType, () => vertexBuffer.SetData(0, savedDataBytes, 0, elementCount, vertexStride)); } else { vertexBuffer.SetData(0, savedDataBytes, 0, elementCount, vertexStride); var readDataBytes = new byte[savedDataBytes.Length]; vertexBuffer.GetData(0, readDataBytes, 0, elementCount, vertexStride); Assert.AreEqual( savedDataBytes.Take(elementCount).ToArray(), readDataBytes.Take(elementCount).ToArray()); } }; Game.Run(); }
public void ShouldSetAndGetDataBytes(bool dynamic) { Game.DrawWith += (sender, e) => { var vertexBuffer = (dynamic) ? new DynamicVertexBuffer(Game.GraphicsDevice, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None) : new VertexBuffer(Game.GraphicsDevice, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None); var savedDataBytes = ArrayUtil.ConvertFrom(savedData); vertexBuffer.SetData(savedDataBytes); var readData = new VertexPositionTexture[4]; vertexBuffer.GetData(readData, 0, 4); Assert.AreEqual(savedData, readData); }; Game.Run(); }
public void ShouldSetAndGetDataBytes(bool dynamic) { var vertexBuffer = (dynamic) ? new DynamicVertexBuffer(gd, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None) : new VertexBuffer(gd, typeof(VertexPositionTexture), savedData.Length, BufferUsage.None); var savedDataBytes = ArrayUtil.ConvertFrom(savedData); vertexBuffer.SetData(savedDataBytes); if (dynamic) { var dynamicVertexBuffer = vertexBuffer as DynamicVertexBuffer; dynamicVertexBuffer.SetData(savedDataBytes, 0, savedDataBytes.Length, SetDataOptions.None); } var readData = new VertexPositionTexture[4]; vertexBuffer.GetData(readData, 0, 4); Assert.AreEqual(savedData, readData); vertexBuffer.Dispose(); }