Change Background color in Rendered Mode

Hello everyone,I’m using Rhino 6, I want to change the background color in the rendered mode (the default color is white), but I have tried various methods, the following code is closest to the results I want, but I don’t know why the views seems to have no change.
If “DisplaySettings” is changed to “AppearanceSettings”, then in the Wireframe mode, Shaded mode…etc, the background color of all viewports can be changed, but this is not what I want…, there are ways Can this be solved?
Thank you so much.

CRhinoView* view = RhinoApp().ActiveView();
CRhinoDisplaySettings displaySettings = RhinoApp().AppSettings().DisplaySettings();
displaySettings.m_background_color_in_rendered_views = ON_Color::Gray160;
RhinoApp().AppSettings().SetDisplaySettings(displaySettings);
return CRhinoCommand::success;

Hi @t107408022,

This is what you want to change?

– Dale

Hi! @dale,
That’s what I want, but I need to implement this in the Rhino SDK C++.
what should I do?

Hi @t107408022,

See if this helps:

CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
{
  DisplayAttrsMgrListDesc* pAttrsDesc = CRhinoDisplayAttrsMgr::FindDisplayAttrsDesc(ON_StandardDisplayModeId::Rendered);
  if (nullptr != pAttrsDesc)
  {
    CDisplayPipelineAttributes* pAttrs = pAttrsDesc->m_pAttrs;
    if (nullptr != pAttrs)
    {
      pAttrs->m_eFillMode = EFrameBufferFillMode::FBFM_SOLID_COLOR;
      pAttrs->m_SolidColor = ON_Color::Gray160;
      context.m_doc.Regen();
    }
  }

  return CRhinoCommand::success;
}

– Dale

Thank you very much for your help!!