Headless Screenshots
Overview
Screenshot collections can now be rendered without a graphical user interface. This works in console (batch) mode (CAESES_crt) on Windows and Linux, including Linux cluster nodes without a display. Before, a screenshot needed an open 3D window, so batch runs produced no images.
What this enables:
- Design engine runs in console mode (e.g. a DoE or an optimization on a cluster) create the configured screenshots for every design. They also list them in the design documentation.
- FSC scripts can execute a screenshot collection explicitly.
- GUI and console mode give the same images: geometry, postprocessing, background, lighting, text annotations, legends and the corner coordinate system.
Screenshots are still set up in the GUI; only rendering works without it. Screenshot collections from a previous release must be recaptured once before they work in console mode (see Screenshot collections from previous releases).
Quick start
These steps cover the typical use cases.
1. Set up the screenshots (GUI)
- Select the design engine (e.g. a Sobol DoE or an optimization) and create a screenshot collection at its Screenshots attribute.
- Set up the first view in a 3D window: geometry, camera and postprocessing/visualization.
- In the screenshot collection editor, choose the 3D window in the empty last row. This captures the current view.
- Adjust Width and Height, and optionally enter a Name and a Caption.
- Repeat steps 2 to 4 for each further view.
- Save the project.
Set up and check the screenshot collection in the GUI before exporting the script file. The batch run uses exactly the views and settings stored in the project. Screenshot collections can be edited via
- Menu (☰) > Export tab > Post-Processing > screenshotCollection1
2. Run it in batch mode
Option A – design engine: run the design engine in console (= batch) mode. Nothing else is needed. Each design gets its screenshots in its design directory and in its design documentation.
myDesignEngine.run()
Option B – script: execute the screenshot collection explicitly in an FSC script:
openProject("/data/projects/hull_study.cdb")
screenshotCollection1.executeAndAddToDesignDocu()
exit(true)
Start the script in batch mode:
| Platform | Command |
|---|---|
| Windows | CAESES_crt.exe myScript.fsc |
| Linux | <installation>/CAESES_crt myScript.fsc |
On Linux, use the start script in the installation directory, not bin/CAESES_crt (see Technical prerequisites).
Technical prerequisites
Screenshots are rendered with OpenGL in an invisible (offscreen) context. The machine must provide OpenGL 3.3 with compatibility profile. Linux needs no graphics card, because software rendering is the default.
| Windows | Linux | |
|---|---|---|
| Start command | CAESES_crt.exe, no extra setup | The start script CAESES_crt in the installation directory |
| Display / X server | Not required | Not required (no X server, no Xvfb, no Wayland) |
| Rendering | Installed graphics driver | Software rendering via Mesa (llvmpipe) |
| Required software | Current graphics driver with OpenGL 3.3 | Mesa OpenGL libraries, e.g. libgl1-mesa-dri + libegl1 (Debian/Ubuntu) or mesa-dri-drivers + mesa-libGL (RHEL/Rocky) |
| Fonts | Bundled with CAESES | Bundled with CAESES |
Notes:
- Windows VMs and remote desktop sessions without a GPU driver offer only an old OpenGL version. Screenshots are then skipped with a message; the run itself continues.
- Linux VMs and cluster nodes work with the default software rendering. The VM's virtual graphics driver is not used.
- Performance: software rendering takes noticeably longer per image than a GPU, especially for large images. Plan for this in design engine runs with many designs.
Setting up screenshots
Each screenshot stores the complete state of the 3D view when it was captured:
- the camera position and orientation;
- the active coordinate system;
- the postprocessing and visualization settings (display options, visualizations such as color maps);
- the scene settings, including background type and color.
When a screenshot is rendered, CAESES first restores this state and then renders the image. A collection can therefore hold several views of the same 3D window with different postprocessing, e.g. pressure and wall shear stress.
Set up the visualization for each screenshot before capturing it. Changes made to the 3D window after capturing are not part of the screenshot.
The screenshot collection editor
| Column | Meaning |
|---|---|
| Window | The 3D window to capture. Choosing a window in the empty last row adds a screenshot. |
| Capture Camera (button) | Captures the current state of the window again: camera, postprocessing and visualization. Also resets Width and Height to the current window size. |
| Width, Height | Image size in pixels |
| Name | Optional; becomes part of the file name |
| Caption | Optional; shown below the image in the design documentation |
| Preview | Shows the screenshot as it will be rendered |
To change an existing screenshot:
- Set up the 3D window as desired.
- Click Capture Camera in the screenshot's row.
- Set Width and Height again if needed.
- Check the result with Preview.
What the image contains
- The 3D geometry with lighting, as in the 3D window.
- Postprocessing and visualizations as captured.
- 3D text annotations.
- 2D overlays such as legends, labels and bar charts.
- The corner coordinate system, at the same size as in the 3D window.
- The scene background. Style colors follow the appearance (dark/light) selected in the GUI preferences, also in console mode.
Images are always PNG with antialiasing.
Where the images are saved (default)
Without further settings, the images go to the directory of the current design. They are named after the screenshot collection:
| File | Name |
|---|---|
| Screenshot | <collection name>_NN.png (NN = position in the collection, starting at 00) |
| Screenshot with a name | <collection name>_NN_<name>.png (spaces become underscores) |
| Geometry snapshot for the Design Viewer | <collection name>_geometry.fwg |
Examples:
- Design engine run: the design's own directory, e.g.
screens_00.pngandscreens_01_pressure.pngfor each design. - Script without a design engine: the directory of the current design; for the baseline design this is
<project folder>/manual_results/baseline/.
Existing files with the same name are overwritten.
Screenshots in design engine runs
A design engine with a screenshot collection creates the screenshots for every design in console mode, just like in the GUI.
For each design, after it has been computed:
- the screenshots are written to the design's directory;
- they are added to the design documentation, each image with its caption;
- they are available in the design results when the project is opened in the GUI.
To create screenshots afterwards for designs that already exist, use Generate Screenshots in the design results table. This action is available only in the GUI and not while a design engine is running.
Executing screenshot collections from FSC scripts
A script can execute a screenshot collection explicitly. This works in console mode and in the GUI. Every call renders all screenshots of the collection again.
| Command | Effect |
|---|---|
executeAndAddToDesignDocu() | Renders the screenshots into the current design's directory and adds them to the design documentation. Recommended. |
execute() | Renders the screenshots into the current design's directory, without changing the design documentation |
-batch opens the project read-only. Changes the script makes to the project are not saved; the images are written anyway.
Screenshot collections from previous releases
In previous releases, a screenshot stored only a reference to its window. Such screenshots still work in the GUI. In console mode they are skipped without a message.
Opening and saving the project is not enough, because only changed objects are saved again. Do one of the following, then save the project:
- Recapture each screenshot: for every row in the screenshot collection editor, set up the 3D window, click Capture Camera, and check Width and Height.
- Set up a new screenshot collection as described in the Quick start, and assign it to the design engine in place of the old one.
Advanced usage
Advanced. The default behavior covers most use cases. Use these options only for special requirements.
Custom file names and output directory
| Setting (attribute / command) | Effect |
|---|---|
Basename / setBaseName(name) | File name prefix instead of the collection name |
Path / setPath(path) | Output directory. Used only outside a design engine run; design engines always write to the design's directory. |
execute(basename, path) | Base name and output directory for this one call |
Example:
openProject("/data/projects/hull_study.cdb")
screens.execute("hull", "/data/results/images")
exit(true)
This writes hull_00.png, hull_01.png, ... to /data/results/images.
Further collection options
| Attribute | Default | Effect |
|---|---|---|
| Export geometry file | On | Also writes the geometry snapshot (.fwg) used by the Design Viewer. Switch it off to save disk space. |
| Execute for valid Designs only | Off | Design engines create no screenshots for invalid designs |
Using a GPU on Linux
The Linux start script selects software rendering via LIBGL_ALWAYS_SOFTWARE=1, but only if that variable is not already set. With an open-source (Mesa) GPU driver, a GPU can be used instead:
export LIBGL_ALWAYS_SOFTWARE=0
<installation>/CAESES_crt -batch render_screens.fsc
Notes:
- Proprietary NVIDIA drivers ignore this variable.
- The setting affects only OpenGL rendering. GPU computations of solvers (CUDA, OpenCL, HIP) are not affected.
- The start script always sets
QT_QPA_PLATFORM=offscreen, so console runs never try to connect to a desktop session.
Troubleshooting
If a screenshot cannot be rendered, CAESES skips it and continues the run. The cause is printed to the console output.
| Symptom or message | Cause | Solution |
|---|---|---|
| No images and no message in console mode, but it works in the GUI | The collection is from a previous release | Recapture the screenshots or set up a new collection (see Screenshot collections from previous releases) |
| Postprocessing or visualization missing in the image | It was set up after capturing the screenshot | Set up the visualization, then click Capture Camera |
| Image size changed unexpectedly | Capture Camera resets width and height to the window size | Set Width and Height again after capturing |
screenshots: context creation failed | No OpenGL available. On Linux usually: started without the start script, or Mesa not installed | Linux: start via <installation>/CAESES_crt and install the Mesa libraries. Windows: install a current graphics driver |
screenshots: OpenGL 3.3 compatibility profile required, got X.Y | The graphics driver offers an older OpenGL version (VM, remote desktop, old Mesa) | Linux: do not set LIBGL_ALWAYS_SOFTWARE=0; update Mesa. Windows: use a machine or session with a GPU driver |
screenshots: no context current | The OpenGL context could not be activated | Contact support with the console output |
| Some designs have no images | Execute for valid Designs only is on and those designs are invalid | Expected; switch the option off if needed |
| Rendering on Linux is slow | Software rendering | Reduce width and height, or use a GPU (see Advanced usage) |
To check which OpenGL a Linux machine provides, run glxinfo -B or eglinfo (package mesa-utils, or glx-utils on RHEL/Rocky).