SlimDX Direct3D11 设备创建

SlimDX Direct3D11 Device Creation

我的应用程序有问题(WinForms [我希望这不是问题,因为下面的 link 指的是 WPF]), 我所有的问题都与此处描述的相同:

Fast Video Display WPF

为了显示很多视频流,我以前用图片框工作,后来发现绘图很慢,fps 也变低了。

我听取了使用 Direct3D11 的建议,但是 我在构造函数中遇到了问题:

Texture2D tex = new Texture2D(Device, texDesc);

如何发送设备?设备是一种类型而不是对象, 它向我弹出一个错误,我正在使用 SlimDX ofc,Direct3D11 真的想弄清楚该怎么做,还是创建我自己的设备? 如果还有其他方法可以优化 FPS 和绘图 或者任何人已经创建了一个可以处理这个的控件,我会很感激的, 另外,可以通过邮件联系我:dorbenshimon1{at}gmail{dot}com 非常感谢

您已经回答了您自己的问题 - 您需要传递您创建的 Device 实例,而不是类型。

查看设置视口的示例,了解这是如何完成的。


根据评论,如果您只想快速粘贴图像,DirectX 几乎肯定不是合适的工具。试试类似这样的东西:

using System.Windows.Forms;

public class FastImageRedraw : Panel
{
    private Image image;

    public FastImageRedraw()
    {
        this.SetStyle(ControlStyles.UserPaint, true);
        this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        this.SetStyle(ControlStyles.DoubleBuffer, true);
        this.SetStyle(ControlStyles.ResizeRedraw, true);
        this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        this.UpdateStyles();
    }

    public Image Image
    {
        get { return this.image; }
        set 
        {
            this.image = value;
            this.Invalidate();
        }
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        e.Graphics.DrawImage(this.Image, e.ClipRectangle);
    }
}

这是非常基本的,但是它使用 GDI+ 来处理仅在您更改图像时重绘图像。

使用 var fastImage = new FastImageRedraw();

作为标准创建它的一个实例

然后在图像发生变化时更新图像fastImage.Image = myImage;