/// <summary> /// Construct an SubArrayBuffer from a <see cref="ArrayBufferItemAttribute"/>. /// </summary> /// <param name="arrayItemType"> /// A <see cref="Type"/> describing the vertex array buffer item type. /// </param> public ArraySection(ArrayBufferObjectBase arrayBuffer, Type arrayItemType) : base(GetArrayType(arrayItemType)) { if (arrayBuffer == null) throw new ArgumentNullException("arrayBuffer"); _ArrayBuffer = arrayBuffer; }
/// <summary> /// Test <see cref="ArrayBufferObject.Create(uint)"/>. /// </summary> private void CreateArray_Core() { Array testArray = CreateTestArray(); ArrayBufferObjectBase arrayBufferRef = null; using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { ConstructionDefaulValues(arrayBuffer); // Create client memory Assert.IsFalse(arrayBuffer.Exists(_Context)); arrayBuffer.Create(testArray); // Still not existing Assert.IsFalse(arrayBuffer.Exists(_Context)); // ItemCount reflect client buffer size Assert.AreEqual((uint)testArray.Length, arrayBuffer.ItemCount); // Actually define GPU buffer arrayBuffer.Create(_Context); // Now exists Assert.IsTrue(arrayBuffer.Exists(_Context)); // ItemCount reflect the GPU buffer size Assert.AreEqual((uint)testArray.Length, arrayBuffer.ItemCount); // Test after disposition arrayBufferRef = arrayBuffer; } if (arrayBufferRef != null) { DispositionDefaulValues(arrayBufferRef); } }
/// <summary> /// Test <see cref="ArrayBufferObject.Create(GraphicsContext, Array)"/>. /// </summary> private void CreateCtxArray_Core() { ArrayBufferObjectBase arrayBufferRef = null; using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { ConstructionDefaulValues(arrayBuffer); // Create GPU memory Assert.IsFalse(arrayBuffer.Exists(_Context)); arrayBuffer.Create(_Context, new float[16]); // Now exists Assert.IsTrue(arrayBuffer.Exists(_Context)); // ItemCount reflect the GPU buffer size Assert.AreEqual(16, arrayBuffer.ItemCount); // We should be able to issue a new buffer arrayBuffer.Create(_Context, new float[32]); Assert.IsTrue(arrayBuffer.Exists(_Context)); // ItemCount reflect the GPU buffer size Assert.AreEqual(32, arrayBuffer.ItemCount); // ItemCount reflect the GPU buffer size Assert.AreEqual(32 * arrayBuffer.ItemSize, arrayBuffer.BufferSize); // Test after disposition arrayBufferRef = arrayBuffer; } if (arrayBufferRef != null) { DispositionDefaulValues(arrayBufferRef); } }
public void CreateCtxArray_Exception2() { _Context.MakeCurrent(false); using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { arrayBuffer.Create(_Context, 0); } }
public InterleavedSection(ArrayBufferObjectBase arrayBuffer, InterleavedSectionBase otherSection) { _ParentArray = arrayBuffer; ItemType = otherSection.ItemType; Normalized = otherSection.Normalized; Offset = otherSection.Offset; Stride = otherSection.Stride; }
/// <summary> /// /// </summary> /// <param name="arrayBuffer"></param> /// <param name="sectionIndex"></param> public ArrayAttachment(ArrayBufferObjectBase arrayBuffer, uint sectionIndex) { if (arrayBuffer == null) throw new ArgumentNullException("arrayBuffer"); ArrayBuffer = arrayBuffer; ArrayBuffer.IncRef(); ArraySectionIndex = sectionIndex; }
private void VertexArrayBufferValues(VertexArrayObject vertexArray, string attributeSemantic, ArrayBufferObjectBase arrayBuffer, uint arraySectionIndex) { VertexArrayObject.VertexArray vertexArrayBuffer = vertexArray.GetVertexArray(attributeSemantic); Assert.IsFalse(arrayBuffer.IsDisposed); Assert.IsNotNull(vertexArrayBuffer); Assert.AreSame(arrayBuffer, vertexArrayBuffer.ArrayBuffer); Assert.AreEqual(arraySectionIndex, vertexArrayBuffer.ArraySectionIndex); }
/// <summary> /// Construct an InstancedVertexArray for enabling instanced vertex attribute. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> which defines a vertex array buffer. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the section of <paramref name="arrayBuffer"/>. /// </param> /// <param name="divisor"> /// A <see cref="UInt32"/> that specify the number of instances that will pass between updates of the generic attribute. /// </param> public InstancedVertexArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, uint divisor) : base(arrayBuffer, sectionIndex) { if (divisor == 0) { throw new ArgumentException("invalid value", "divisor"); } Divisor = divisor; }
/// <summary> /// /// </summary> /// <param name="arrayBuffer"></param> /// <param name="sectionIndex"></param> public ArrayAttachment(ArrayBufferObjectBase arrayBuffer, uint sectionIndex) { if (arrayBuffer == null) { throw new ArgumentNullException("arrayBuffer"); } ArrayBuffer = arrayBuffer; ArrayBuffer.IncRef(); ArraySectionIndex = sectionIndex; }
/// <summary> /// Construct an VertexArray for enabling vertex attribute. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> which defines a vertex array buffer. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the section of <paramref name="arrayBuffer"/>. /// </param> public VertexArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex) { if (arrayBuffer != null && arrayBuffer.ItemCount == 0) throw new ArgumentException("zero items", "arrayBuffer"); if (arrayBuffer != null && sectionIndex >= arrayBuffer.ArraySectionsCount) throw new ArgumentOutOfRangeException("out of bounds", "sectionIndex"); ArrayBuffer = arrayBuffer; if (ArrayBuffer != null) ArrayBuffer.IncRef(); ArraySectionIndex = sectionIndex; }
private FeedbackBufferObject CreateFeedbackBuffer(ArrayBufferObjectBase interleavedArrayBuffer) { FeedbackBufferObject newtonFeedbackBuffer = new FeedbackBufferObject(); newtonFeedbackBuffer.AttachArray(0, interleavedArrayBuffer, 0); newtonFeedbackBuffer.AttachArray(1, interleavedArrayBuffer, 1); newtonFeedbackBuffer.AttachArray(2, interleavedArrayBuffer, 2); newtonFeedbackBuffer.AttachArray(3, interleavedArrayBuffer, 3); newtonFeedbackBuffer.EnableRasterizer = true; return(newtonFeedbackBuffer); }
/// <summary> /// Set an array buffer to a shader attribute. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="attributeName"> /// A <see cref="String"/> that specify the name of the attribute variable. /// </param> /// <param name="blockName"> /// A <see cref="String"/> that specify the name of the attribute block encolosing <paramref name="semantic"/>. It /// can be null. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid input name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, string attributeName, string blockName) { if (String.IsNullOrEmpty(attributeName)) { throw new ArgumentException("invalid name", "attributeName"); } // Set vertex array SetVertexArray(new VertexArray(arrayBuffer, sectionIndex), attributeName, blockName); // Compute the actual vertex array length UpdateVertexArrayLength(); }
/// <summary> /// Link an array buffer to an attribute of this vertex array. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="attributeName"> /// A <see cref="String"/> that specify the name of the attribute variable. /// </param> /// <param name="blockName"> /// A <see cref="String"/> that specify the name of the attribute block encolosing <paramref name="semantic"/>. It /// can be null. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid input name. /// </exception> public void SetInstancedArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, uint divisor, string attributeName, string blockName) { if (Gl.CurrentExtensions.InstancedArrays == false) { throw new InvalidOperationException("instanced arrays not support by current implementation"); } if (String.IsNullOrEmpty(attributeName)) { throw new ArgumentException("invalid name", "attributeName"); } // Set vertex array SetVertexArray(new InstancedVertexArray(arrayBuffer, sectionIndex, divisor), attributeName, blockName); // Note: instanced vertex arrays do not contribute to vertex array length. Do not update vertex arrays length }
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(); } } }
/// <summary> /// Construct an VertexArray for enabling vertex attribute. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> which defines a vertex array buffer. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the section of <paramref name="arrayBuffer"/>. /// </param> public VertexArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex) { if (arrayBuffer != null && arrayBuffer.ItemCount == 0) { throw new ArgumentException("zero items", "arrayBuffer"); } if (arrayBuffer != null && sectionIndex >= arrayBuffer.ArraySectionsCount) { throw new ArgumentOutOfRangeException("out of bounds", "sectionIndex"); } ArrayBuffer = arrayBuffer; if (ArrayBuffer != null) { ArrayBuffer.IncRef(); } ArraySectionIndex = sectionIndex; }
private VertexArrayObject CreateVertexArray(NewtonVertex[] array, out ArrayBufferObjectBase interleavedArrayBuffer) { VertexArrayObject newtonVertexArray = new VertexArrayObject(); ArrayBufferObjectInterleaved newtonVertexArrayBuffer = new ArrayBufferObjectInterleaved(typeof(NewtonVertex), BufferObjectHint.DynamicGpuDraw); if (array != null) newtonVertexArrayBuffer.Create(array); else newtonVertexArrayBuffer.Create(VertexCount); newtonVertexArray.SetArray(newtonVertexArrayBuffer, 0, VertexArraySemantic.Position); newtonVertexArray.SetArray(newtonVertexArrayBuffer, 1, VertexArraySemantic.Speed); newtonVertexArray.SetArray(newtonVertexArrayBuffer, 2, VertexArraySemantic.Acceleration); newtonVertexArray.SetArray(newtonVertexArrayBuffer, 3, VertexArraySemantic.Mass); newtonVertexArray.SetElementArray(PrimitiveType.Points); interleavedArrayBuffer = newtonVertexArrayBuffer; return (newtonVertexArray); }
/// <summary> /// Test <see cref="ArrayBufferObject.Create(GraphicsContext, uint)"/>. /// </summary> private void CreateCtxCount_Core() { const uint TestItemCount = 16; ArrayBufferObjectBase arrayBufferRef = null; using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { ConstructionDefaulValues(arrayBuffer); // Create GPU memory Assert.IsFalse(arrayBuffer.Exists(_Context)); arrayBuffer.Create(_Context, TestItemCount); // Now exists Assert.IsTrue(arrayBuffer.Exists(_Context)); // ItemCount reflect the GPU buffer size Assert.AreEqual(TestItemCount, arrayBuffer.ItemCount); // ClientItemCount can be 0 (client buffer disposed) or ItemCount Assert.IsTrue(arrayBuffer.ClientItemCount == 0 || arrayBuffer.ClientItemCount == arrayBuffer.ItemCount); // We should be able to issue a new buffer arrayBuffer.Create(_Context, TestItemCount * 2); Assert.IsTrue(arrayBuffer.Exists(_Context)); // ItemCount reflect the GPU buffer size Assert.AreEqual(TestItemCount * 2, arrayBuffer.ItemCount); // ClientItemCount can be 0 (client buffer disposed) or ItemCount Assert.IsTrue(arrayBuffer.ClientItemCount == 0 || arrayBuffer.ClientItemCount == arrayBuffer.ItemCount); // Test after disposition arrayBufferRef = arrayBuffer; } if (arrayBufferRef != null) { Assert.AreEqual(0, arrayBufferRef.ItemCount); Assert.AreEqual(0, arrayBufferRef.ClientItemCount); } }
private VertexArrayObject CreateVertexArray(NewtonVertex[] array, out ArrayBufferObjectBase interleavedArrayBuffer) { VertexArrayObject newtonVertexArray = new VertexArrayObject(); ArrayBufferObjectInterleaved newtonVertexArrayBuffer = new ArrayBufferObjectInterleaved(typeof(NewtonVertex), BufferObjectHint.DynamicGpuDraw); if (array != null) { newtonVertexArrayBuffer.Create(array); } else { newtonVertexArrayBuffer.Create(VertexCount); } newtonVertexArray.SetArray(newtonVertexArrayBuffer, 0, VertexArraySemantic.Position); newtonVertexArray.SetArray(newtonVertexArrayBuffer, 1, VertexArraySemantic.Speed); newtonVertexArray.SetArray(newtonVertexArrayBuffer, 2, VertexArraySemantic.Acceleration); newtonVertexArray.SetArray(newtonVertexArrayBuffer, 3, VertexArraySemantic.Mass); newtonVertexArray.SetElementArray(PrimitiveType.Points); interleavedArrayBuffer = newtonVertexArrayBuffer; return(newtonVertexArray); }
/// <summary> /// Automatically computes bounding box for the specified vertex arrays. /// </summary> /// <param name="vertexArrayObject"> /// /// </param> /// <returns> /// It returns the <see cref="IBoundingVolume"/> for <paramref name="vertexArrayObject"/>, if possible. /// </returns> private static IBoundingVolume ComputeBoundingVolume(VertexArrayObject vertexArrayObject) { if (vertexArrayObject == null) { throw new ArgumentNullException("vertexArrayObject"); } VertexArrayObject.IVertexArray vertexArray = vertexArrayObject.GetVertexArray(VertexArraySemantic.Position); if (vertexArray == null) { return(null); } ArrayBufferObjectBase positionArray = vertexArray.Array; Type positionArrayType = positionArray.GetType(); if (positionArrayType == typeof(ArrayBufferObject <Vertex4f>)) { ArrayBufferObject <Vertex4f> positionArray4f = (ArrayBufferObject <Vertex4f>)positionArray; Vertex4f min = Vertex4f.Maximum, max = Vertex4f.Minimum; positionArray4f.MinMax(out min, out max); return(new BoundingBox((Vertex3f)min, (Vertex3f)max)); } else if (positionArrayType == typeof(ArrayBufferObject <Vertex3f>)) { ArrayBufferObject <Vertex3f> positionArray3f = (ArrayBufferObject <Vertex3f>)positionArray; Vertex3f min = Vertex3f.Maximum, max = Vertex3f.Minimum; positionArray3f.MinMax(out min, out max); return(new BoundingBox(min, max)); } else { return(null); } }
public void AttachArray(uint varyingLocation, ArrayBufferObjectBase arrayBuffer, uint sectionIndex) { _AttachedArrays[varyingLocation] = new ArrayAttachment(arrayBuffer, sectionIndex); }
public void AttachArray(uint varyingLocation, ArrayBufferObjectBase arrayBuffer) { AttachArray(varyingLocation, arrayBuffer, 0); }
/// <summary> /// Set an array buffer to this vertex array. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="semantic"> /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name. /// </exception> public void SetInstancedArray(ArrayBufferObjectBase arrayBuffer, uint divisor, string semantic) { SetInstancedArray(arrayBuffer, 0, divisor, semantic, SemanticBlockName); }
/// <summary> /// Test <see cref="ArrayBufferObject.Create(uint)"/>. /// </summary> private void CreateCount_Core() { const uint TestItemCount = 16; ArrayBufferObjectBase arrayBufferRef = null; using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { ConstructionDefaulValues(arrayBuffer); // Create client buffer Assert.IsFalse(arrayBuffer.Exists(_Context)); arrayBuffer.Create(TestItemCount); // Still not existing Assert.IsFalse(arrayBuffer.Exists(_Context)); // ItemCount reflect client buffer size Assert.AreEqual(TestItemCount, arrayBuffer.ItemCount); Assert.AreEqual(TestItemCount, arrayBuffer.ClientItemCount); // Actually define GPU buffer arrayBuffer.Create(_Context); // Now exists Assert.IsTrue(arrayBuffer.Exists(_Context)); // ItemCount reflect the GPU buffer size Assert.AreEqual(TestItemCount, arrayBuffer.ItemCount); // ClientItemCount can be 0 (client buffer disposed) or ItemCount Assert.IsTrue(arrayBuffer.ClientItemCount == 0 || arrayBuffer.ClientItemCount == arrayBuffer.ItemCount); // Define a new client buffer, different from previous arrayBuffer.Create(TestItemCount * 2); // Still exists Assert.IsTrue(arrayBuffer.Exists(_Context)); // GPU buffer item count hasn't changed Assert.AreEqual(TestItemCount, arrayBuffer.ItemCount); // Client buffer item count respect the last request Assert.AreEqual(TestItemCount * 2, arrayBuffer.ClientItemCount); // Actually update GPU buffer uint prevObjectName = arrayBuffer.ObjectName; arrayBuffer.Create(_Context); // Still exists Assert.IsTrue(arrayBuffer.Exists(_Context)); // No new object has been created Assert.AreEqual(prevObjectName, arrayBuffer.ObjectName); // GPU buffer item count has been updated Assert.AreEqual(TestItemCount * 2, arrayBuffer.ItemCount); // ClientItemCount can be 0 (client buffer disposed) or ItemCount Assert.IsTrue(arrayBuffer.ClientItemCount == 0 || arrayBuffer.ClientItemCount == arrayBuffer.ItemCount); // Test after disposition arrayBufferRef = arrayBuffer; } if (arrayBufferRef != null) { DispositionDefaulValues(arrayBufferRef); } }
/// <summary> /// Set an array buffer to a shader attribute. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="semantic"> /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, string semantic) { SetArray(arrayBuffer, 0, semantic, SemanticBlockName); }
/// <summary> /// Set an array buffer to this vertex array. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="inputName"> /// A <see cref="String"/> that specify the name of the input variable. /// </param> /// <param name="blockName"> /// A <see cref="String"/> that specify the name of the input block encolosing <paramref name="inputName"/>. It /// can be null. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="inputName"/> is null or is not a valid input name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, string inputName, string blockName) { SetArray(arrayBuffer, 0, inputName, blockName); }
/// <summary> /// Set an array buffer to this vertex array. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="semantic"> /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, string semantic) { SetArray(arrayBuffer, sectionIndex, semantic, SemanticBlockName); }
public void CreateCtxArray_Exception3() { using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { arrayBuffer.Create(_Context, 0); } }
/// <summary> /// Set an array buffer to this vertex array. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="semantic"> /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, string semantic) { SetArray(arrayBuffer, 0, semantic, SemanticBlockName); }
public void CreateCtxArray_Exception1() { using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { arrayBuffer.Create((GraphicsContext)null, 0); } }
/// <summary> /// Test for default values after construction. /// </summary> /// <param name="arrayBuffer"></param> private void DispositionDefaulValues(ArrayBufferObjectBase arrayBuffer) { Assert.AreEqual(0, arrayBuffer.ItemCount); Assert.AreEqual(0, arrayBuffer.ClientItemCount); }
/// <summary> /// Set an array buffer to a shader attribute. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="inputName"> /// A <see cref="String"/> that specify the name of the input variable. /// </param> /// <param name="blockName"> /// A <see cref="String"/> that specify the name of the input block encolosing <paramref name="inputName"/>. It /// can be null. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="inputName"/> is null or is not a valid input name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, string inputName, string blockName) { SetArray(arrayBuffer, 0, inputName, blockName); }
/// <summary> /// Set an array buffer to a shader attribute. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="semantic"> /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, string semantic) { SetArray(arrayBuffer, sectionIndex, semantic, SemanticBlockName); }
/// <summary> /// Link an array buffer to an attribute of this vertex array. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="attributeName"> /// A <see cref="String"/> that specify the name of the attribute variable. /// </param> /// <param name="blockName"> /// A <see cref="String"/> that specify the name of the attribute block encolosing <paramref name="semantic"/>. It /// can be null. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="semantic"/> is null or is not a valid input name. /// </exception> public void SetArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, string attributeName, string blockName) { if (String.IsNullOrEmpty(attributeName)) throw new ArgumentException("invalid name", "attributeName"); VertexArray vertexArray, previousVertexArray; // Dispose previous vertex array if (_VertexArrays.TryGetValue(attributeName, out previousVertexArray)) previousVertexArray.Dispose(); // Map buffer object with attribute name _VertexArrays[attributeName] = vertexArray = new VertexArray(arrayBuffer, sectionIndex); // Map buffer object with input name including block name also if (blockName != null) { // Attribute referenced in block attributeName = String.Format("{0}.{1}", blockName, attributeName); // Dispose previous vertex array if (_VertexArrays.TryGetValue(attributeName, out previousVertexArray)) previousVertexArray.Dispose(); // Map buffer object with attribute name _VertexArrays[attributeName] = vertexArray; } // Compute the actual vertex array length UpdateVertexArrayLength(); // Update vertex arrays _VertexArrayDirty = true; }
/// <summary> /// Set an array buffer to this vertex array. /// </summary> /// <param name="arrayBuffer"> /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array. /// </param> /// <param name="sectionIndex"> /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index. /// </param> /// <param name="inputName"> /// A <see cref="String"/> that specify the name of the input variable. /// </param> /// <param name="blockName"> /// A <see cref="String"/> that specify the name of the input block encolosing <paramref name="inputName"/>. It /// can be null. /// </param> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="arrayBuffer"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// Exception throw if <paramref name="arrayBuffer"/> has no items. /// </exception> /// <exception cref="ArgumentException"> /// Exception thrown if <paramref name="inputName"/> is null or is not a valid input name. /// </exception> public void SetInstancedArray(ArrayBufferObjectBase arrayBuffer, uint divisor, string inputName, string blockName) { SetInstancedArray(arrayBuffer, 0, divisor, inputName, blockName); }
private FeedbackBufferObject CreateFeedbackBuffer(ArrayBufferObjectBase interleavedArrayBuffer) { FeedbackBufferObject newtonFeedbackBuffer = new FeedbackBufferObject(); newtonFeedbackBuffer.AttachArray(0, interleavedArrayBuffer, 0); newtonFeedbackBuffer.AttachArray(1, interleavedArrayBuffer, 1); newtonFeedbackBuffer.AttachArray(2, interleavedArrayBuffer, 2); newtonFeedbackBuffer.AttachArray(3, interleavedArrayBuffer, 3); newtonFeedbackBuffer.EnableRasterizer = true; return (newtonFeedbackBuffer); }
public void CreateCount_Exception1() { using (ArrayBufferObjectBase arrayBuffer = CreateInstance()) { arrayBuffer.Create(0); } }