From 487b55046e3bf53d47d988b495cbd565bfe07505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 7 Feb 2020 14:23:20 +0100 Subject: [PATCH] #304 Avoid accessing OpenGL if we are using "-platform offscreen" Add description of how to start ResInsight in headless mode --- .../Application/RiaGuiApplication.cpp | 9 ++++++--- doc/ResInsightHeadlessSnapshots.txt | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 doc/ResInsightHeadlessSnapshots.txt diff --git a/ApplicationCode/Application/RiaGuiApplication.cpp b/ApplicationCode/Application/RiaGuiApplication.cpp index cb89d6ef3b..5eed969520 100644 --- a/ApplicationCode/Application/RiaGuiApplication.cpp +++ b/ApplicationCode/Application/RiaGuiApplication.cpp @@ -394,10 +394,13 @@ bool RiaGuiApplication::useShaders() const { if ( !m_preferences->useShaders() ) return false; - bool isShadersSupported = caf::Viewer::isShadersSupported(); - if ( !isShadersSupported ) return false; + bool isShadersSupported = true; + if ( platformName() != "offscreen" ) // Avoid opengl access if we are in qt offscreen mode + { + isShadersSupported = caf::Viewer::isShadersSupported(); + } - return true; + return isShadersSupported; } //-------------------------------------------------------------------------------------------------- diff --git a/doc/ResInsightHeadlessSnapshots.txt b/doc/ResInsightHeadlessSnapshots.txt new file mode 100644 index 0000000000..0c7608895e --- /dev/null +++ b/doc/ResInsightHeadlessSnapshots.txt @@ -0,0 +1,18 @@ + +Investigations on using ResInsight to render plots in a compleatly Headless state + +- Qt 5.8 or higher needed, it seems. Tested with Qt 5.14.1. Tested with Qt 5.6.1 on CentOS 6 and the plots was rendered without fonts. +- Start ResInsight with the additional options -platform offscreen +- The project can not contain visible 3D views. If it does, ResInsight will crash +- Might add -stylesheet to explicitly control fonts + example contents of stylesheets file: + + * { font: bold italic large "Times New Roman" } + + The "*" might be substituted with specific classes or widgets. + It seems as the Qwt plot axis-titles are not affected by the stylesheet set above + +- Example command line: + + ./ResInsight --project FPPLot.rsp --savesnapshots all --snapshotsize 500 500 -stylesheet stylesheet.txt -platform offscreen +