DirectX and WPF

Started by
-1 comments, last by MattJack2000 12 years, 9 months ago
Dear all,

I am migrating a 3D application from windows forms to WPF. It's a google earth-like application, displaying charts.
To display my 3D scene I use a D3DImage. For 3D Rendering, I'm using managed DirectX 9.0.
I notice a big performance loss, and I would like to know if there are good practices about to use of D3DImage.

First try: In my main WPF control, I subscribe to CompositionTarget.Rendering, and in my OnRendering method I do this stuff :

if (_D3DImage.IsFrontBufferAvailable)
{
_D3DImage.Lock();
// DX rendering here...
_D3DImage.AddDirtyRect(new Int32Rect(0, 0, (int)_D3DImage.Width, (int)_D3DImage.Height));
_D3DImage.Unlock();
}
My business logic is subscribed to MouseMove/MouseDown/MouseUp to implement a "drag"

Result :
When my WPF main form is full screen, I miss plenty of MouseMove. As a consequence for my app, the "dragging" operation is very jerky (the camera is moved every
I have added Console.Writeline to trace when the mousemove occures, and when the DX rendering is done :

RENDER
RENDER
RENDER
... (x10)
RENDER
RENDER
RENDER
RENDER
MOUSE MOVE
MOUSE MOVE

RENDER
RENDER
...
But when my main WPF window is smaller (less than 2/3 of the screen) then this sequence becomes normal. : I get about 2 mouse move per frame, it's cool.

RENDER
MOUSE MOVE
MOUSE MOVE
RENDER
MOUSE MOVE
MOUSE MOVE

Strange isn't it? Any feeling or idea?

Well, more generally, I'm looking for somel "best practice" on "how to integrate a DX rendering in a WPF app. D3DImage looks slow, and my app is much slower in a WPF environment than previously (with Windows forms)

This topic is closed to new replies.

Advertisement