質問

I have a WPF application, and part of the screen shows an object that needs to be rendered dynamically in 3D, at perhaps 20 FPS. I understand that typically a WPF application would use DirectX to do the 3D rendering. (I also understand that WFP has a simplified 3D API, but I don't think that would work in my case because I have too many triangles to render.) In my case, I would like to use OpenGL because there is a good chance the whole application will be ported to a non-Windows machine, and I don't want to have to rewrite the 3D code.

I see there have been some attempts to create a WPF control into which OpenGL can render directly, but they all seem a bit too rough/risky to use.

As a safer approach, I thought I could use FBOs with OpenGL to render the frames off-screen, and then take the bitmaps and pass them off, in real time, to WPF as regular 2D images.

My question is about speed. Do you anticipate there being deal-breaking bottlenecks in this scheme? I assume the FBO rendering will be about as fast as direct window rendering on the OpenGL side? And I expect that extracting the bitmaps from the rendered OpenGL images (FBOs) should be fast? I'm less sure about handing those images off to WFP and seeing them update at 20 FPS.

Do you have concrete experience that can help me decide if this is a reasonable way to go?

役に立ちましたか?

解決

I would like to use OpenGL because there is a good chance the whole application will be ported to a non-Windows machine

But then it means you have to rewrite your whole WPF app too as this framework is not cross-platform.So in such a case OpenGL part will be only of minor concern here.I think you should re-consider the whole UI tech.For example I would use Qt SDK as it is truly cross platform and you can connect it with both DirectX and OpenGL at will. But if you plan to stick with WPF on Windows and using OpenGL just use C# OpenGL wrapper. Yes you will get some performance overhead because that is a wrapper.Just like those for Java (JOGL , LWJGL).But still games like MineCraft were originally written and worked fine with these APIs. Another , more challenging approach,is to WPF COM interop and call some C++ app that wraps your OpenGL renderer directly from WPF may be even using unsafe mode to get as low level as possible.Never tried it myself but it may get you a better performance.But that is a lot of work actually. Finally I would suggest you using DirectX for Windows as WPF has the best integration with it naturally.If you design your app well then it won't be a problem to connect it to OpenGL backend later.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top