Viewport resolution change

I am trying to get our plugin to accomodate changes in viewport resolution, but am having no luck so far. When our renderer is originally started up, we receive a RenderWindow, but in the resolution change call OnRenderSizeChanged we get only width and height, which I use to resize our buffer and restart our renderer.

Our logic for restarting the renderer currently relies on the RenderWindow to tell us the resolution, but this is apparently not updated, so on the next StartRender call we inadvertently resize to the old size.

How is this meant to be handled? The plugin sample we got from Andy does not handle this, and the code I have for the Cycles renderer is incomplete, so I cannot see how it is handled there either.

Viewport changes are handled through the ChangeQueue.ApplyViewChanges() function. This includes changes to its resolution:

Hope that helps.

/Nathan

I can see how that could give us the new resolution, but if the RenderWindow still has the old resolution, then when I get the RenderWindow.Channel from it, to copy our buffer to, then there would still be a problem. Is there some other way for us to do things?

At the moment I am doing things very similarly to the MyRealtimeRenderer sample we got from Andy, i.e. looping in a render thread, copying the buffer to the Channel and calling SignalRedraw.

If I override RealtimeDisplayMode::OnRenderSizeChange, I do get size updates. Is this less reliable than ApplyViewChange? The Cycles sample makes it look like you recreate the renderer each time there is a resolution (or any other viewport) update, which isn’t so great for us.

Once the Raytraced mode is enabled (i.e. Cycles engine is created and started) the same renderer is used throughout that viewport mode session.

Through some event path I eventually set the new resolution for the RenderWindow: RenderWindow.SetSize(System.Drawing.Size)

There should be no need to recreate a render.

/Nathan

Ah, I am missing the SetSize. Let me try that, thanks.

Resolution changes work now, thanks for your help!

You’re welcome. I’ll still finish writing about my implementation of a realtime render integration, though. We’re still in flux here, but I’ll try keeping it up-to-date.

/Nathan

Is there documentation for all of this? I have the vague feeling of missing a source for information.

Not yet. I started writing documentation/tutorial, but it isn’t finished yet. I’ll post when the first readable part is done.

/Nathan