SlimDX Direct3D11 设备创建

本文关键字:创建 Direct3D11 SlimDX | 更新日期: 2023-09-27 18:37:24

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

快速视频显示 WPF

为了显示大量的视频流,我以前使用图片框比意识到绘图非常慢,并且FPS变低。

我听了那个人的建议,使用 Direct3D11,但是我在承包商中遇到了问题:

Texture2D tex = new Texture2D(Device, texDesc);

如何发送设备?设备是类型不是对象,它向我弹出一个错误,我正在使用SlimDX ofc,Direct3D11真的想弄清楚如何做到这一点,或者创建我自己的设备?如果还有其他方法可以优化 FPS 和绘图或者任何人创建了一个可以处理这个问题的控件,我会对此表示赞赏,另外,可以通过邮件与我联系:dorbenshimon1{at}gmail{dot}com多谢

SlimDX Direct3D11 设备创建

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

查看设置视口的示例,了解如何完成此操作。


根据评论,如果您只想进行快速图像粘贴,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;