New function that resets screenshot index to 0. Usefull when capturing png sequence for video

This commit is contained in:
Adam Rohdin
2023-03-02 14:36:03 +01:00
parent 83f58b9741
commit 88972fc27b
6 changed files with 30 additions and 2 deletions

View File

@@ -879,6 +879,10 @@ void setSgctDelegateFunctions() {
Engine::instance().takeScreenshot(std::move(windowIds));
return Engine::instance().screenShotNumber();
};
sgctDelegate.resetScreenshotNumber = []() {
ZoneScoped;
Engine::instance().resetScreenshotNumber();
};
sgctDelegate.swapBuffer = []() {
ZoneScoped;

View File

@@ -81,6 +81,8 @@ struct WindowDelegate {
unsigned int (*takeScreenshot)(bool applyWarping, std::vector<int> windowIds) =
[](bool, std::vector<int>) { return 0u; };
void (*resetScreenshotNumber)() = []() {};
void (*swapBuffer)() = []() {};
int (*nWindows)() = []() { return 0; };

View File

@@ -135,6 +135,11 @@ public:
*/
void takeScreenshot();
/**
* Resets the screenshot index to 0
*/
void resetScreenshotNumber();
/**
* Get the filename of the latest screenshot
*/

View File

@@ -1027,6 +1027,14 @@ void RenderEngine::takeScreenshot() {
);
}
/**
* Resets the screenshot index to 0
*/
void RenderEngine::resetScreenshotNumber() {
_latestScreenshotNumber = 0;
global::windowDelegate->resetScreenshotNumber();
}
unsigned int RenderEngine::latestScreenshotNumber() const {
return _latestScreenshotNumber;
}
@@ -1038,7 +1046,8 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
codegen::lua::AddScreenSpaceRenderable,
codegen::lua::RemoveScreenSpaceRenderable,
codegen::lua::TakeScreenshot,
codegen::lua::DpiScaling
codegen::lua::DpiScaling,
codegen::lua::ResetScreenshotNumber
}
};
}

View File

@@ -67,6 +67,14 @@ namespace {
return static_cast<int>(screenshotNumber);
}
/**
* Reset screenshot index to 0.
*/
[[codegen::luawrap]] void resetScreenshotNumber() {
using namespace openspace;
global::renderEngine->resetScreenshotNumber();
}
// Extracts the DPI scaling for either the GUI window or if there is no dedicated GUI
// window, the first window.
[[codegen::luawrap]] float dpiScaling() {