示例#1
0
        /// <summary>
        /// Constructs a texture from a matrix of color data structures that can be applied to rendered 3D objects.
        /// </summary>
        /// <param name="window">A reference to the Direct3D-capable window in which this texture will be rendered.</param>
        /// <param name="image">A matrix of RGBA color vectors with 32 bits of data per channel.</param>
        public Texture(Window3D window, Color4[,] image)
            : this(window)
        {
            int[] szImage = image.Size();
            int byteSize = SizeOf(image);

            ImageBuffer = Tag(new DataStream(byteSize, true, true));
            foreach (Color4 color in image) { ImageBuffer.Write(color); }

            Image = Tag(new Texture2D
            (
                Device3D,
                CreateTextureDescription(szImage[0], szImage[1], Formats.Float4),
                new DataRectangle(ImageBuffer.DataPointer, szImage[1] * SizeOf<Color4>())
            ));
            SRV = Tag(new ShaderResourceView(Device3D, Image));
        }