我在屏幕模式下在WPF应用程序中使用CefSharp。
浏览器内部WebGL 3D模型。在模型的某些点必须是"广告牌"但它必须是WPF的2D空间中的WPF对象。
在每个帧渲染时,我计算3D点到2D屏幕坐标的投影,并使用2D坐标向WPF发送回调。
WPF的视觉2D对象比3D模型快1-2帧移动。这很奇怪,因为我抓住了CEF的onRender事件并在浏览器渲染后设置了广告牌坐标。
如何在WPF中同步3D模型和2D广告牌的渲染?
答案 0 :(得分:1)
The culprit may be the fact that a WPF application does not have a predictable refresh rate. It redraws the UI based on under-the-hood heuristics influenced by your hardware and the current state of the OS. WPF cannot be forced to redraw at will unless you work around it with DirectDraw. Read in more detail here: https://rhnatiuk.wordpress.com/2008/12/21/wpf-video-playback-problems/
If you have continuous motion rendering within a WPF application, such as video, animation effects, or a browser with a WebGL-rendered moving object, you cannot reliably frame-sync it for screenshot purposes. I tried to run video in a WPF CefSharp app and the performance (perceived and measured) was abysmal on every (even high-end) computer I could find.
You can try to port your application into WinForms to benefit from constant frame rates. In WinForms, you would have to grab screenshots of the form or of the browser control which is messy but should be doable.