public static DX11IndexedGeometry CreateFrom <T>(DxDevice device, T[] vertices, int[] indices, InputElement[] layout) where T : struct { DX11IndexedGeometry geom = new DX11IndexedGeometry(device); geom.VertexBuffer = DX11VertexBuffer.CreateImmutable <T>(device, vertices); geom.IndexBuffer = DX11IndexBuffer.CreateImmutable(device, indices); geom.InputLayout = layout; geom.Topology = PrimitiveTopology.TriangleList; geom.HasBoundingBox = false; return(geom); }
public DX11IndexedGeometry(DX11IndexedGeometry owner) { this.ownsvbo = false; this.ownsido = false; this.device = owner.device; this.drawer = owner.drawer; this.IndexBuffer = owner.IndexBuffer; this.InputLayout = owner.InputLayout; this.Topology = owner.Topology; this.VertexBuffer = owner.VertexBuffer; }
public DX11IndexedGeometry(DX11IndexedGeometry owner) { this.ownsvbo = false; this.ownsido = false; this.context = owner.context; this.drawer = owner.drawer; this.IndexBuffer = owner.IndexBuffer; this.InputLayout = owner.InputLayout; this.Topology = owner.Topology; this.VertexBuffer = owner.VertexBuffer; this.VertexSize = owner.VertexSize; this.VerticesCount = owner.VerticesCount; }
public static DX11IndexedGeometry CreateFrom <T>(DX11RenderContext context, T[] vertices, int[] indices, InputElement[] layout) where T : struct { int vertexsize = Marshal.SizeOf(typeof(T)); DX11IndexedGeometry geom = new DX11IndexedGeometry(context); DataStream ds = new DataStream(vertices.Length * vertexsize, true, true); ds.Position = 0; ds.WriteRange(vertices); ds.Position = 0; var vbuffer = new SlimDX.Direct3D11.Buffer(context.Device, ds, new BufferDescription() { BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, SizeInBytes = (int)ds.Length, Usage = ResourceUsage.Default }); ds.Dispose(); var indexstream = new DataStream(indices.Length * 4, true, true); indexstream.WriteRange(indices); indexstream.Position = 0; geom.VertexBuffer = vbuffer; geom.IndexBuffer = new DX11IndexBuffer(context, indexstream, false, true); geom.InputLayout = layout; geom.Topology = PrimitiveTopology.TriangleList; geom.VerticesCount = vertices.Length; geom.VertexSize = vertexsize; geom.HasBoundingBox = false; // geom.BoundingBox = new BoundingBox(new Vector3(-radius), new Vector3(radius)); return(geom); }