Can a DirectX surface be plotted to a WPF control?

前端 未结 2 1606
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 05:48

Can DirectX be used to plot a set of points on a WPF control (or something that can be used by WPF).

I need to implement a control in WPF that should plot 16k points

2条回答
  •  遥遥无期
    2020-12-16 06:18

    Yes. You use D3DImage, Texture (SharpDX or SlimDX) and Surface. You need create texture outside your application and update its conent by video driver or by another way. In WPF you create D3DImage:

    Texture = new Texture(Device.DeviceEx, width, height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default, ref handle);
    

    Very important is that you foram must be Format.A8R8G8B8 (it is restriction of WPF):

    using (var surface = texture.GetSurfaceLevel(0))
            {
                var handle = surface.NativePointer;
                Lock();
                    SetBackBuffer(D3DResourceType.IDirect3DSurface9, handle);
                    Unlock();
            }
    

    And after each updating of frame you need only

    Lock();
                    AddDirtyRect(new Int32Rect(0, 0, PixelWidth, PixelHeight));
                    Unlock();
    

    It's better, if you will put your D3DImage in separate Dispatcher

提交回复
热议问题