mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 08:56:34 +00:00
ifcviewer (GL minimal): --screenshot for parity diff with wgpu
Closes the other half of task #10. The wgpu minimal already wrote PNGs via wgpuCommandEncoderCopyTextureToBuffer + mapAsync; the GL backend now has the equivalent via glReadPixels on the back buffer just before swapBuffers. - ViewportWindow::captureNextFrameToPng(path, quit_after=true) queues a one-shot capture. render() reads the default framebuffer at full pixel size (width * devicePixelRatio), flips bottom-up → top-down into a QImage::Format_RGBA8888, saves PNG, and optionally QCoreApplication::quit. Synchronous glReadPixels is fine here — pick is interactive and rare; not used per-frame. - ifcviewer-minimal --screenshot PATH wires through MinimalWindow just like --camera / --benchmark. Honoured after all loads complete (applyPendingBenchmark also drains pending_screenshot_). Lets a parity script do: IfcViewerMinimal foo.ifc --camera A,B,C,D,E,F --screenshot gl.png IfcViewerWgpuMinimal foo.ifcview --camera A,B,C,D,E,F --screenshot wgpu.png # then pixel-diff with whatever (ImageMagick, PIL, etc.) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -127,8 +127,13 @@ void MinimalWindow::setPendingBenchmark(int frames) {
|
||||
pending_benchmark_ = frames;
|
||||
}
|
||||
|
||||
void MinimalWindow::setPendingScreenshot(const QString& path) {
|
||||
pending_screenshot_ = path;
|
||||
}
|
||||
|
||||
void MinimalWindow::applyPendingBenchmark() {
|
||||
if (pending_camera_.isEmpty() && pending_benchmark_ <= 0) return;
|
||||
if (pending_camera_.isEmpty() && pending_benchmark_ <= 0
|
||||
&& pending_screenshot_.isEmpty()) return;
|
||||
|
||||
if (!pending_camera_.isEmpty()) {
|
||||
QStringList parts = pending_camera_.split(',');
|
||||
@@ -148,4 +153,9 @@ void MinimalWindow::applyPendingBenchmark() {
|
||||
viewport_->setBenchmarkFrames(pending_benchmark_);
|
||||
pending_benchmark_ = 0;
|
||||
}
|
||||
|
||||
if (!pending_screenshot_.isEmpty()) {
|
||||
viewport_->captureNextFrameToPng(pending_screenshot_, /*quit_after=*/true);
|
||||
pending_screenshot_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@ public:
|
||||
void addFiles(const QStringList& paths);
|
||||
void setPendingCamera(const QString& params);
|
||||
void setPendingBenchmark(int frames);
|
||||
// One-shot framebuffer capture queued for the next render. Forwarded
|
||||
// to ViewportWindow::captureNextFrameToPng; the viewport handles the
|
||||
// glReadPixels + PNG save + optional QCoreApplication::quit.
|
||||
void setPendingScreenshot(const QString& path);
|
||||
|
||||
private slots:
|
||||
void onLoadStarted(uint32_t mid, QString display_name);
|
||||
@@ -55,6 +59,7 @@ private:
|
||||
|
||||
QString pending_camera_;
|
||||
int pending_benchmark_ = 0;
|
||||
QString pending_screenshot_;
|
||||
};
|
||||
|
||||
#endif // MINIMALWINDOW_H
|
||||
|
||||
@@ -44,6 +44,8 @@ int main(int argc, char* argv[]) {
|
||||
"Set camera: tx,ty,tz,dist,yaw,pitch", "params"});
|
||||
parser.addOption({{"b", "benchmark"},
|
||||
"Run N frames then print stats and exit", "frames"});
|
||||
parser.addOption({{"s", "screenshot"},
|
||||
"Render one frame after load, save to PATH as PNG, exit", "path"});
|
||||
parser.process(app);
|
||||
|
||||
MinimalWindow window;
|
||||
@@ -60,6 +62,9 @@ int main(int argc, char* argv[]) {
|
||||
if (parser.isSet("benchmark")) {
|
||||
window.setPendingBenchmark(parser.value("benchmark").toInt());
|
||||
}
|
||||
if (parser.isSet("screenshot")) {
|
||||
window.setPendingScreenshot(parser.value("screenshot"));
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user