DBS
DBS

Reputation: 151

SlimDX Direct3D11 Device Creation

I have a problem in my app (WinForms [i hope it is not a problem because the link below refer to WPF]), All my problem describes same as here :

Fast Video Display WPF

to display a lot of video streams, i used to work with picture box than realized that the drawing is very slow, and fps become lower.

I listen to the advised of the guy to work with Direct3D11 but I've got a problem in the constractor :

Texture2D tex = new Texture2D(Device, texDesc);

How can i send a Device ? Device is a type not an object , Its pop up a error to me, Im working with SlimDX ofc, Direct3D11 Really trying to figure out how to do it , or create my own device? If there is any way else to optimze the FPS and drawing Or anyone have created a control who can handle this , I'll appriciate that, Also , can contact me on mail : dorbenshimon1{at}gmail{dot}com thanks a lot

Upvotes: 0

Views: 570

Answers (1)

Octopoid
Octopoid

Reputation: 3698

You've sort of answered your own question - you need to pass the Device instance you've created, not the type.

Look at the examples for setting up a viewport to see how this is done.


As per the comments, DirectX is almost certainly not the right tool if you just want to do fast image pasting. Try something similar to this instead:

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);
    }
}

It's very basic, but that uses GDI+ to handle redrawing the image only when you change it.

Creat an instance of it as standard with var fastImage = new FastImageRedraw();

Then update the image whenever it changes with fastImage.Image = myImage;

Upvotes: 2

Related Questions