SampleRealtimeRenderer: How to capture the rendered image via command?

I have built a custom test renderer in order to understand the rhino rendering pipeline. This renderer is based on SampleRealtimeRenderer and SampleChangequeue samples.

When I change the perspective to “myTestRenderer” I can see it working exactly like it works in SampleRealtimeRenderer.

I have two questions on that:

  1. As long as the myTestRenderer is running, I would like to create another custom command in the same plugin which will capture the current rendered image to a file. As I have seen by line-to-line debugging when I change the perspective to “myTestRenderer” the

DisplayMode(const CRhinoDisplayPipeline& pipeline)

is called and then DisplayModeFactory is triggered:

class DisplayModeFactory : public RhRdk::Realtime::DisplayMode::Factory, public CRhRdkObject

which calls the MakeDisplayEngine function:

virtual std::shared_ptr<RhRdk::Realtime::DisplayMode> MakeDisplayEngine(const CRhinoDisplayPipeline&) const override;

Then the DisplayMode is engaged whose main members are:

std::shared_ptr<Update> _update;
std::shared_ptr<Scene> _scene;
std::shared_ptr<ChangeQueue> _changeQueue;, 
std::shared_ptr<myTestRenderer> m_Renderer;

How could I access this m_Renderer from another command of the same plugin in order to capture the rendered image?

  1. A much simpler question is how can I get which perspective is loaded? (Wireframe, SampleRealtimeRenderer, myTestRenderer, etc)


@johnc - is this something you can help with?

@dale Unfortunately not. I think @andy or @nathan are better candidates for helping with this.


I don’t know exactly about the C++ side, but you should be able to get to the instance of your implementation through the view table by iterating over the views.

This is how I do it in C#.

I have a command RhinoCycles_ChangeSamples that fetches a list of RenderedViewport implementations. RenderedViewport is my realtime display mode (RealtimeDisplayMode in RhinoCommon) implementation. I can then access anything I expose myself on that.

The GetRenderedViewports implementation - my own thing, is

In C++ you’d first get a CRhinoView instance (CRhinoView* pView ), get the display pipeline from that (CRhinoDisplayPipeline* dp = pView->DisplayPipeline();). You can then ask std::shared_pointer<RhRdk::Realtime::DisplayMode> rtdm = dp->RealtimeDisplayMode(). To get the pointer to DisplayMode you then of course rtdm.get() .

I believe you can then try cast that to your implementation of the display mode.

Again, I am not 100% about all the C++ parts, but that is essentially what I am doing through C#. In your implementation you just add necessary API to do the things you need to do.