Skip to content

Commit

Permalink
[render] add viewer screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Jan 10, 2025
1 parent c178a3f commit 0c5392a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class AbstractViewerDrawer :

case Key::A: toggleAxisVisibility(); break;

case Key::S:
if (modifiers[KeyModifier::CONTROL])
DRT::DRW::screenshot(derived(), "viewer_screenshot.png");
break;

case Key::T: toggleTrackBallVisibility(); break;

default: break;
Expand Down
25 changes: 25 additions & 0 deletions vclib/render/include/vclib/render/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ class Renderer :
{
return CanvasType::onReadDepth(point, callback);
}

void dScreenshot(const std::string& filename, uint width, uint height)
{
CanvasType::onScreenshot(filename, width, height);
}
};

/*** Inner classes: Attorneys ***/
Expand Down Expand Up @@ -671,6 +676,26 @@ class Renderer<WindowManagerT, CanvasT, Drawers...>::DRW
{
return r->dReadDepth(point, callback);
}

/**
* @brief A Drawer object can request a screenshot of the canvas. This
* function is called by the Drawer object to request a screenshot of the
* canvas.
*
* @param[in] filename: The filename where the screenshot will be saved.
* @param[in] width: The width of the screenshot. If 0, the width of the
* canvas will be used.
* @param[in] height: The height of the screenshot. If 0, the height of the
* canvas will be used.
*/
static void screenshot(
Renderer* r,
const std::string& filename,
uint width = 0,
uint height = 0)
{
r->dScreenshot(filename, width, height);
}
};

} // namespace vcl
Expand Down

0 comments on commit 0c5392a

Please sign in to comment.