Beispiel #1
0
        public static DX11VertexBuffer CreateImmutable <T>(DxDevice device, DataStream initial) where T : struct
        {
            int vertexSize          = Marshal.SizeOf(typeof(T));
            int verticesCount       = (int)initial.Length / vertexSize;
            DX11VertexBuffer result = CreateImmutable(device, verticesCount, vertexSize, initial);

            return(result);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public static DX11VertexBuffer CreateImmutable <T>(DxDevice device, T[] initial) where T : struct
        {
            int vertexSize    = Marshal.SizeOf(typeof(T));
            int verticesCount = initial.Length;

            DataStream ds = new DataStream(vertexSize * verticesCount, true, true);

            ds.WriteRange <T>(initial);
            ds.Position = 0;
            DX11VertexBuffer result = CreateImmutable(device, verticesCount, vertexSize, ds);

            ds.Dispose();
            return(result);
        }
Beispiel #4
0
        public static DX11VertexBuffer CreateImmutable <T>(DxDevice device, int elementCount, int stride, T[] initial) where T : struct
        {
            int vertexSize    = stride;
            int verticesCount = elementCount;

            DataStream ds = new DataStream(vertexSize * verticesCount, true, true);

            ds.WriteRange <T>(initial);
            ds.Position = 0;
            DX11VertexBuffer result = CreateImmutable(device, verticesCount, vertexSize, ds);

            ds.Dispose();
            return(result);
        }
Beispiel #5
0
        public static DX11VertexBuffer CreateFromRawBuffer(DxDevice device, int verticesCount, int vertexSize, DX11RawBuffer buffer)
        {
            if (!buffer.Description.BindFlags.HasFlag(BindFlags.VertexBuffer))
            {
                throw new ArgumentException("Raw Buffer does not have Vertex Buffer Bind flag");
            }

            DX11VertexBuffer vbo = new DX11VertexBuffer(device);

            vbo.Buffer        = buffer.Buffer;
            vbo.desc          = buffer.Description;
            vbo.VertexSize    = vertexSize;
            vbo.VerticesCount = verticesCount;

            return(vbo);
        }
Beispiel #6
0
        private void UpdateVertexLayouts()
        {
            List <VertexBufferBinding> newbinding = new List <VertexBufferBinding>();
            List <InputElement>        newlayout  = new List <InputElement>();

            for (int i = 0; i < vertexBuffers.Count; i++)
            {
                DX11VertexBuffer    vb    = vertexBuffers[i];
                VertexBufferBinding vbind = new VertexBufferBinding(vb.Buffer, vb.VertexSize, 0);
                newbinding.Add(vbind);

                foreach (InputElement elem in vb.InputLayout)
                {
                    InputElement newelem = elem;
                    newelem.Slot = i;
                    newlayout.Add(newelem);
                }
            }

            this.InputLayout = newlayout.ToArray();
            this.binding     = newbinding.ToArray();
        }
 public void Unlock(DX11VertexBuffer target)
 {
     this.vbopool.UnLock(target);
 }
Beispiel #8
0
 public void AddVertexBuffer(DX11VertexBuffer buffer)
 {
     this.vertexBuffers.Add(buffer);
 }