/// <summary> /// Creates an index buffer reader on a stream. /// </summary> /// <param name="reader">The reader to use. It must point to the beginning of the index buffer.</param> /// <param name="format">The format of each index in the buffer.</param> public IndexBufferReader(BinaryReader reader, IndexBufferFormat format) { _reader = reader; _format = format; _baseOffset = _reader.BaseStream.Position; _indexSize = (format == IndexBufferFormat.UInt16) ? 2U : 4U; }
public void ResetTracking() { PrimitiveTopology.ResetTracking(); VertexBuffers.ResetTracking(); IndexBuffer.ResetTracking(); IndexBufferFormat.ResetTracking(); // InputElements.ResetTracking(); // reset nicht hier, weil in VertexShader gesetzt }
public void ClearState() { PrimitiveTopology.InitializeState(); VertexBuffers.InitializeState(); IndexBuffer.InitializeState(); IndexBufferFormat.InitializeState(); InputElements.InitializeState(); }
/// <summary> /// Creates an index buffer stream. /// </summary> /// <param name="stream">The base stream to use. It must point to the beginning of the index buffer.</param> /// <param name="format">The format of each index in the buffer.</param> public IndexBufferStream(Stream stream, IndexBufferFormat format) { _stream = stream; _reader = new BinaryReader(_stream); _writer = new BinaryWriter(_stream); _format = format; _baseOffset = _stream.Position; _indexSize = (format == IndexBufferFormat.UInt16) ? 2U : 4U; }
/// <summary> /// Binds an index buffer to the current mesh. /// </summary> /// <param name="indices">The indices to bind.</param> /// <param name="format">The primitive type to use.</param> /// <exception cref="System.InvalidOperationException">Cannot bind an index buffer if no mesh is active</exception> public void BindIndexBuffer(IEnumerable <ushort> indices, IndexBufferFormat format) { if (_currentMesh == null) { throw new InvalidOperationException("Cannot bind an index buffer if no mesh is active"); } _currentMesh.Indices = indices.ToArray(); _currentMesh.Mesh.IndexBufferType = (PrimitiveType)Enum.Parse(typeof(PrimitiveType), format.ToString()); }