public IndexBufferPtr GetIndex() { using (var buffer = new OneIndexBuffer <uint>(DrawMode.Triangles, BufferUsage.StaticDraw)) { buffer.Alloc(this.index.Length); unsafe { uint *array = (uint *)buffer.FirstElement(); for (int i = 0; i < this.index.Length; i++) { array[i] = this.index[i]; } } return(buffer.GetBufferPtr() as IndexBufferPtr); } }
public IndexBufferPtr GetIndex() { using (var indexBuffer = new OneIndexBuffer <uint>(DrawMode.TriangleStrip, BufferUsage.StaticDraw)) { indexBuffer.Alloc(indexes.Length); unsafe { uint *indexArray = (uint *)indexBuffer.FirstElement(); for (int i = 0; i < indexes.Length; i++) { indexArray[i] = indexes[i]; } } return(indexBuffer.GetBufferPtr() as IndexBufferPtr); } }
public IndexBufferPtr GetIndex() { using (var buffer = new OneIndexBuffer <uint>( DrawMode.LineStrip, BufferUsage.StaticDraw)) { buffer.Alloc(model.Indexes.Length); unsafe { var array = (uint *)buffer.FirstElement(); for (int i = 0; i < model.Indexes.Length; i++) { array[i] = model.Indexes[i]; } } return(buffer.GetBufferPtr() as IndexBufferPtr); } }
public IndexBufferPtr GetIndexBufferRenderer() { using (var buffer = new OneIndexBuffer <uint>(DrawMode.Triangles, BufferUsage.StaticDraw)) { buffer.Alloc(faces.Count * 3); unsafe { uint *array = (uint *)buffer.FirstElement(); for (int i = 0; i < faces.Count; i++) { //TODO: 用ushort类型的IndexBuffer就会引发系统错误,为什么? //array[i * 3 + 0] = (ushort)(faces[i].Item1 - 1); //array[i * 3 + 1] = (ushort)(faces[i].Item2 - 1); //array[i * 3 + 2] = (ushort)(faces[i].Item3 - 1); array[i * 3 + 0] = (uint)(faces[i].Item1 - 1); array[i * 3 + 1] = (uint)(faces[i].Item2 - 1); array[i * 3 + 2] = (uint)(faces[i].Item3 - 1); } } return(buffer.GetBufferPtr() as IndexBufferPointerBase); } }