Browse Source

Fix screenshot command -t not generating correct PNGs.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
e712c98020
3 changed files with 9 additions and 4 deletions
  1. +3
    -0
      Makefile
  2. +6
    -3
      src/window.cpp
  3. +0
    -1
      standalone/main.cpp

+ 3
- 0
Makefile View File

@@ -112,6 +112,9 @@ ifdef ARCH_LIN
gdb --args ./$< -d
endif

screenshot: $(STANDALONE_TARGET)
./$< -d -t 2

perf: $(STANDALONE_TARGET)
# Requires perf
perf record --call-graph dwarf -o perf.data ./$< -d


+ 6
- 3
src/window.cpp View File

@@ -480,9 +480,11 @@ void Window::screenshotModules(const std::string& screenshotsDir, float zoom) {
system::createDirectory(dir);
for (plugin::Model* model : p->models) {
std::string filename = system::join(dir, model->slug + ".png");

// Skip model if screenshot already exists
if (system::isFile(filename))
continue;

INFO("Screenshotting %s %s to %s", p->slug.c_str(), model->slug.c_str(), filename.c_str());

// Create widgets
@@ -493,16 +495,17 @@ void Window::screenshotModules(const std::string& screenshotsDir, float zoom) {
app::ModuleWidget* mw = model->createModuleWidget(NULL);
fbw->addChild(mw);

// Reset the frame time so FramebufferWidgets are guaranteed to draw
internal->lastFrameTime = 0.0;
// Hack the frame time so FramebufferWidgets are never overdue and therefore guaranteed to draw
internal->lastFrameTime = INFINITY;

// Draw to framebuffer
fbw->step();
nvgluBindFramebuffer(fbw->getFramebuffer());

// Read pixels
nvgluBindFramebuffer(fbw->getFramebuffer());
int width, height;
nvgImageSize(vg, fbw->getImageHandle(), &width, &height);
DEBUG("fb size %d %d", width, height);
uint8_t* pixels = new uint8_t[height * width * 4];
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);



+ 0
- 1
standalone/main.cpp View File

@@ -89,7 +89,6 @@ int main(int argc, char* argv[]) {
} break;
case 't': {
screenshot = true;
// If parsing number failed, use default value
std::sscanf(optarg, "%f", &screenshotZoom);
} break;
case 's': {


Loading…
Cancel
Save