private DX11IndexedGeometry QuadTextured() { DX11IndexedGeometry geom = new DX11IndexedGeometry(this.device); float sx = 1.0f; float sy = 1.0f; Pos4Tex2Vertex[] vertices = new Pos4Tex2Vertex[] { new Pos4Tex2Vertex() { Position = new Vector4(-sx, sy, 0.0f, 1.0f), TexCoords = new Vector2(0, 0) }, new Pos4Tex2Vertex() { Position = new Vector4(sx, sy, 0.0f, 1.0f), TexCoords = new Vector2(1, 0) }, new Pos4Tex2Vertex() { Position = new Vector4(-sx, -sy, 0.0f, 1.0f), TexCoords = new Vector2(0, 1) }, new Pos4Tex2Vertex() { Position = new Vector4(sx, -sy, 0.0f, 1.0f), TexCoords = new Vector2(1, 1) }, }; int[] indices = new int[] { 0, 1, 3, 3, 2, 0 }; geom.VertexBuffer = DX11VertexBuffer.CreateImmutable(device, vertices);; geom.IndexBuffer = DX11IndexBuffer.CreateImmutable(device, indices); geom.InputLayout = Pos4Tex2Vertex.Layout; geom.VertexBuffer.InputLayout = geom.InputLayout; geom.Topology = PrimitiveTopology.TriangleList; geom.HasBoundingBox = true; geom.BoundingBox = new BoundingBox(new Vector3(-sx, -sy, 0.0f), new Vector3(sx, sy, 0.0f)); return(geom); }
private DX11IndexedGeometry QuadTextured() { DX11IndexedGeometry geom = new DX11IndexedGeometry(this.context); DataStream ds = new DataStream(4 * Pos4Tex2Vertex.VertexSize, true, true); ds.Position = 0; float sx = 1.0f; float sy = 1.0f; Pos4Tex2Vertex v = new Pos4Tex2Vertex(); v.Position = new Vector4(-sx, sy, 0.0f, 1.0f); v.TexCoords = new Vector2(0, 0); ds.Write <Pos4Tex2Vertex>(v); v.Position = new Vector4(sx, sy, 0.0f, 1.0f); v.TexCoords = new Vector2(1, 0); ds.Write <Pos4Tex2Vertex>(v); v.Position = new Vector4(-sx, -sy, 0.0f, 1.0f); v.TexCoords = new Vector2(0, 1); ds.Write <Pos4Tex2Vertex>(v); v.Position = new Vector4(sx, -sy, 0.0f, 1.0f); v.TexCoords = new Vector2(1, 1); ds.Write <Pos4Tex2Vertex>(v); ds.Position = 0; var vertices = 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(24, true, true); indexstream.WriteRange(new int[] { 0, 1, 3, 3, 2, 0 }); indexstream.Position = 0; geom.VertexBuffer = vertices; geom.IndexBuffer = new DX11IndexBuffer(context, indexstream, false, true); geom.InputLayout = Pos4Tex2Vertex.Layout; geom.Topology = PrimitiveTopology.TriangleList; geom.VerticesCount = 4; geom.VertexSize = Pos4Tex2Vertex.VertexSize; geom.HasBoundingBox = true; geom.BoundingBox = new BoundingBox(new Vector3(-sx, -sy, 0.0f), new Vector3(sx, sy, 0.0f)); return(geom); }
private DX11IndexedGeometry QuadTextured() { DX11IndexedGeometry geom = new DX11IndexedGeometry(this.context); DataStream ds = new DataStream(4 * Pos4Tex2Vertex.VertexSize, true, true); ds.Position = 0; float sx = 1.0f; float sy = 1.0f; Pos4Tex2Vertex v = new Pos4Tex2Vertex(); v.Position = new Vector4(-sx, sy, 0.0f, 1.0f); v.TexCoords = new Vector2(0, 0); ds.Write<Pos4Tex2Vertex>(v); v.Position = new Vector4(sx, sy, 0.0f, 1.0f); v.TexCoords = new Vector2(1, 0); ds.Write<Pos4Tex2Vertex>(v); v.Position = new Vector4(-sx, -sy, 0.0f, 1.0f); v.TexCoords = new Vector2(0, 1); ds.Write<Pos4Tex2Vertex>(v); v.Position = new Vector4(sx, -sy, 0.0f, 1.0f); v.TexCoords = new Vector2(1, 1); ds.Write<Pos4Tex2Vertex>(v); ds.Position = 0; var vertices = 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(24, true, true); indexstream.WriteRange(new int[] { 0, 1, 3, 3, 2, 0 }); indexstream.Position = 0; geom.VertexBuffer = vertices; geom.IndexBuffer = new DX11IndexBuffer(context, indexstream, false, true); geom.InputLayout = Pos4Tex2Vertex.Layout; geom.Topology = PrimitiveTopology.TriangleList; geom.VerticesCount = 4; geom.VertexSize = Pos4Tex2Vertex.VertexSize; geom.HasBoundingBox = true; geom.BoundingBox = new BoundingBox(new Vector3(-sx, -sy, 0.0f), new Vector3(sx, sy, 0.0f)); return geom; }