/// <summary> /// Get an element from this mapped BufferObject. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> used for mapping this BufferObject. /// </param> /// <param name="offset"> /// A <see cref="Int64"/> that specify the offset applied to the mapped BufferObject to get the stored /// value, in bytes. /// </param> /// <returns> /// It returns a <see cref="Vertex3f"/>, read from the mapped BufferObject at the specified offset. /// </returns> /// <exception cref="InvalidOperationException"> /// Exception thrown if this BufferObject is not mapped (<see cref="IsMapped"/>). /// </exception> public Vertex3f Get(GraphicsContext ctx, UInt64 offset) { unsafe { byte * bufferPtr = (byte *)MappedBuffer.ToPointer(); Vertex3f *bufferItemPtr = (Vertex3f *)(bufferPtr + offset); return(bufferItemPtr[0]); } }
/// <summary> /// Set an element to this mapped BufferObject. /// </summary> /// <param name="value"> /// A <see cref="Vertex3f"/> that specify the mapped BufferObject element. /// </param> /// <param name="offset"> /// A <see cref="UInt64"/> that specify the offset applied to the mapped BufferObject where <paramref name="value"/> /// is stored. This value is expressed in basic machine units (bytes). /// </param> /// <exception cref="InvalidOperationException"> /// Exception thrown if this BufferObject is not mapped (<see cref="IsMapped"/>). /// </exception> public void Set(Vertex3f value, UInt64 offset) { if (IsMapped == false) { throw new InvalidOperationException("not mapped"); } unsafe { byte * bufferPtr = (byte *)MappedBuffer.ToPointer(); Vertex3f *bufferItemPtr = (Vertex3f *)(bufferPtr + offset); bufferItemPtr[0] = value; } }