public void SetArraySectionByBlock() { ArrayBufferObjectBase arrayBuffer1 = null, arrayBuffer2 = null, arrayBuffer3 = null; try { arrayBuffer1 = new ArrayBufferObject(VertexBaseType.Float, 3, BufferObjectHint.StaticCpuDraw); arrayBuffer1.Create(16); arrayBuffer2 = new ArrayBufferObjectInterleaved(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw); arrayBuffer2.Create(16); arrayBuffer3 = new ArrayBufferObjectPacked(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw); arrayBuffer3.Create(16); using (VertexArrayObject vertexArray = new VertexArrayObject()) { // Set array buffers to different attributes Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer1, 0, "attribute1", null); }); VertexArrayBufferValues(vertexArray, "attribute1", null, arrayBuffer1, 0); Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer2, 0, "attribute2", null); }); VertexArrayBufferValues(vertexArray, "attribute2", null, arrayBuffer2, 0); Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer2, 1, "attribute3", null); }); VertexArrayBufferValues(vertexArray, "attribute3", null, arrayBuffer2, 1); Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer3, 2, "attribute4", null); }); VertexArrayBufferValues(vertexArray, "attribute4", null, arrayBuffer3, 2); } Assert.IsTrue(arrayBuffer1.IsDisposed); Assert.IsTrue(arrayBuffer2.IsDisposed); Assert.IsTrue(arrayBuffer3.IsDisposed); } finally { if (arrayBuffer1 != null && !arrayBuffer1.IsDisposed) { arrayBuffer1.Dispose(); } if (arrayBuffer2 != null && !arrayBuffer2.IsDisposed) { arrayBuffer2.Dispose(); } if (arrayBuffer3 != null && !arrayBuffer3.IsDisposed) { arrayBuffer3.Dispose(); } } }
public void SetArraySectionByBlock() { ArrayBufferObjectBase arrayBuffer1 = null, arrayBuffer2 = null, arrayBuffer3 = null; try { arrayBuffer1 = new ArrayBufferObject(VertexBaseType.Float, 3, BufferObjectHint.StaticCpuDraw); arrayBuffer1.Create(16); arrayBuffer2 = new ArrayBufferObjectInterleaved(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw); arrayBuffer2.Create(16); arrayBuffer3 = new ArrayBufferObjectPacked(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw); arrayBuffer3.Create(16); using (VertexArrayObject vertexArray = new VertexArrayObject()) { // Set array buffers to different attributes Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer1, 0, "attribute1", null); }); VertexArrayBufferValues(vertexArray, "attribute1", null, arrayBuffer1, 0); Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer2, 0, "attribute2", null); }); VertexArrayBufferValues(vertexArray, "attribute2", null, arrayBuffer2, 0); Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer2, 1, "attribute3", null); }); VertexArrayBufferValues(vertexArray, "attribute3", null, arrayBuffer2, 1); Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer3, 2, "attribute4", null); }); VertexArrayBufferValues(vertexArray, "attribute4", null, arrayBuffer3, 2); } Assert.IsTrue(arrayBuffer1.IsDisposed); Assert.IsTrue(arrayBuffer2.IsDisposed); Assert.IsTrue(arrayBuffer3.IsDisposed); } finally { if (arrayBuffer1 != null && !arrayBuffer1.IsDisposed) arrayBuffer1.Dispose(); if (arrayBuffer2 != null && !arrayBuffer2.IsDisposed) arrayBuffer2.Dispose(); if (arrayBuffer3 != null && !arrayBuffer3.IsDisposed) arrayBuffer3.Dispose(); } }