Sdílet prostřednictvím


Manual Rendering

Folks have really reacted to my mention of manual rendering, so I've made a sample for it.  Good thing, too, because to be frank there are a few warts.  On the upside, however, it is possible to work around all of them and the code required is not too scary.

Get the code!

In this sample, I host a GlobeControl on a form like normal, but instead of using the built-in render thread I render on the UI thread using the manual render API.  If you are content to let WinForms present to the screen for you, you're done at this point.

But it is common in these situations to want to get the rendered surface to make a movie, present in some other context like WPF, etc.  I include an example of the most basic way to do this, which is the only official way to currently do it (WorldEngine.CaptureScreenShot).  If this isn't good enough, and you're a bit more daring, it is possible to get our rendering surface and do more clever things with it.  That's what the good folks at Infostrat did for their WPF code, and for the time being I actually recommend using their wrapper if you want to use WPF.

I've labelled all the warts and their workarounds with the tag "WORKAROUND" in the code so you can look more closely if you like, but you should also just be able to copy and paste the sample and get your code to work as it should.  Also, this is not actually an an official part of the sample pack, but something similar to it will be.

Comments

  • Anonymous
    April 19, 2009
    PingBack from http://asp-net-hosting.simplynetdev.com/manual-rendering/

  • Anonymous
    April 21, 2009
    Since you can now manually initialize the control and the renderer can you still have the globeControl create and manage its own render thread? I sort of want to do this in attempt to clean up some of the infostrat wpf code so the control doesn't need to be hosted in a winform control or wpf window. If this is done and the control isn't part of the UI hierarchy what should I be conscious of when disposing/uninitializing. thanks

  • Anonymous
    May 26, 2010
    There's a slight issue with the sample that if you are animating something in the scene with a plugin that form1 doesn't update frequently enough to show a smooth animation. I fixed this by adding an invalidate after the manual render, i.e. this.globeControl.Host.RenderEngine.ManuallyRenderNextFrame(); this.globeControl.Invalidate();