Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
55acd62
Added return value to ExecuteScriptCommand().
najlkin May 12, 2025
b6a7cb0
Added base GLWindow to SdlWindow and added EglWindow basic implementa…
najlkin May 12, 2025
2005b88
Added headless command to scripts with basic implementation.
najlkin May 12, 2025
a3e2c63
Improved compatibility of EglWindow.
najlkin May 12, 2025
8ca321b
Implemented the main event loop in EglWindow.
najlkin May 13, 2025
1f18f20
Fixed script screenshot command.
najlkin May 13, 2025
d2d7ebb
Moved key and mouse handling to GLWindow and implemented in EglWindow.
najlkin May 13, 2025
2ac5430
Improved conformity of GLWindow and removed references to SdlWindow.
najlkin May 13, 2025
1bd3662
Minor fixup in EglWindow.
najlkin May 13, 2025
aa2086c
Unified handling of screenshot between scripts and commands.
najlkin May 13, 2025
f9332e9
Added headless command option working with scripts and saved streams.
najlkin May 13, 2025
b828af1
Added automatic closing after the end of stream for headless runs.
najlkin May 13, 2025
a513701
Added cmd line headless mode.
najlkin May 13, 2025
7dd72ec
Changed HiDPI of EGL to the cmd-line set option.
najlkin May 14, 2025
36497f5
Merge branch 'scripts-refac' into egl-headless
najlkin May 14, 2025
9ce0dc8
Merge branch 'scripts-refac' into egl-headless
najlkin May 14, 2025
f900537
After-merge fixup.
najlkin May 14, 2025
50bcdb0
Implemented proper build options for EGL.
najlkin May 14, 2025
9214127
Moved EGL and SDL files to respective subfolders.
najlkin May 14, 2025
74ff75f
Fixed makefile for Mac.
najlkin May 14, 2025
1d0f9c4
Revert "Used EGL in tests automatically when available."
najlkin May 14, 2025
50872df
Updated Changelog and Install.
najlkin May 14, 2025
a83d773
Added EGL to CI.
najlkin May 14, 2025
1d22e52
Added EGL for Ubuntu only
najlkin May 14, 2025
5e4a288
Fixed name of jobs.
najlkin May 14, 2025
f417f1f
Fixed atrifact name.
najlkin May 14, 2025
bac40b6
Used EGL in tests automatically when available.
najlkin May 14, 2025
00bac4a
Fixed caching of MPI
najlkin May 14, 2025
e10712f
Made EGL option default on Ubuntu and removed it from the matrix.
najlkin May 14, 2025
b8a4be6
Fixed caching of MFEM in release.yml
najlkin May 14, 2025
84d47b5
Fixed typo in builds.yml
najlkin May 14, 2025
eee2bfe
Added EGL to server mode.
najlkin May 19, 2025
d60b05d
Implemented EGL main thread server.
najlkin May 22, 2025
1398c43
Unified usage of the main thread.
najlkin May 22, 2025
700a67c
Separated EGL main thread.
najlkin May 22, 2025
05c6ac2
Added the forgotten egl_main files.
najlkin May 22, 2025
50ed4f2
Fixed the windows counting if the main thread is too fast.
najlkin May 23, 2025
07705ea
Fixed fencing of EGL in aux_vis.cpp.
najlkin May 23, 2025
6c4d47b
Small fix for aux_js.
najlkin May 23, 2025
35e9156
Removed using namespace std pollution.
najlkin May 23, 2025
fe4536a
Minor modification to minimize changeset.
najlkin May 23, 2025
112b08b
Updated Changelog.
najlkin May 23, 2025
7f57081
Added graceful closing of EGL server.
najlkin May 23, 2025
4752012
Non-persistent mode for server.
najlkin May 27, 2025
3cac815
Fixed canvas id in sdl.cpp.
najlkin May 27, 2025
7446595
Fixed definition of GLWindow in aux_js.
najlkin May 27, 2025
31889e6
Fixed dereferencing of window in aux_js.
najlkin May 27, 2025
3293787
Merge pull request #337 from GLVis/egl-headless-nopr
najlkin May 27, 2025
51cdf69
Initial support of CGL.
najlkin May 28, 2025
f451a7b
Fixed compilation on Mac.
najlkin May 28, 2025
58421a7
Removed unused terminating flag.
najlkin May 28, 2025
12808dd
Fixed a typo.
najlkin May 28, 2025
3c930dc
Silenced deprecation warning for CGL.
najlkin May 28, 2025
3e8637b
Added CGL build to CI on Mac.
najlkin May 28, 2025
1c8ddef
Merge branch 'egl-headless' into cgl-headless
najlkin May 28, 2025
152ff7c
Improved pixel format setup.
najlkin May 28, 2025
6142110
Fixed insertion of legacy flag.
najlkin May 28, 2025
5c6c0be
Merge branch 'scripts-refac' into egl-headless
najlkin May 29, 2025
3f18f22
Setup config
camierjs Oct 3, 2025
c1f5a0e
Fix CGL macos
camierjs Oct 5, 2025
1a998bb
Meld back to EGL fused with CGL
camierjs Oct 5, 2025
cf0af34
Remove CGL sub directory
camierjs Oct 5, 2025
938fbab
Cleanup
camierjs Oct 5, 2025
ace4319
Simplify
camierjs Oct 5, 2025
4701ced
Cleanup
camierjs Oct 5, 2025
c34e758
Revert cerr use
camierjs Oct 5, 2025
844e336
Cleanup and remove cmake user settings
camierjs Oct 5, 2025
fef7e06
Add GL_SILENCE_DEPRECATION and update INSTALL
camierjs Oct 5, 2025
7421750
Avoid unused variable 'status'
camierjs Oct 5, 2025
e873d0c
Address reviewers comments
camierjs Oct 6, 2025
e29e622
Merge pull request #345 from GLVis/cgl-headless-dbg
najlkin Oct 7, 2025
4977af2
Added error check to initGLEW().
najlkin Oct 7, 2025
0bf5c63
Fixed error reporting.
najlkin Oct 7, 2025
27263da
if GLEW_KHR_debug, enable GL_DEBUG_OUTPUT
camierjs Oct 7, 2025
8bbc29c
Made the GLEW_KHR_debug condition Mac specific.
najlkin Oct 7, 2025
a497eb0
Made CGL default on Mac.
najlkin Oct 7, 2025
5b54075
Updated INSTALL.
najlkin Oct 7, 2025
4181c70
Merge branch 'master' into egl-headless
najlkin Jan 13, 2026
63d19c9
Merge branch 'egl-headless' into cgl-headless
najlkin Jan 13, 2026
6dd3c8c
Merge pull request #338 from GLVis/cgl-headless
tzanio Jan 14, 2026
deb90e2
Updated changelog for CGL.
najlkin Jan 15, 2026
45ecc6f
Merge branch 'cgl-headless' into egl-headless
najlkin Jan 15, 2026
7370253
Fixed grammer in Changelog.
najlkin Jan 16, 2026
c296c03
Merge branch 'scripts-refac' into egl-headless
najlkin Jan 24, 2026
1615f05
Merge branch 'scripts-refac' into egl-headless
najlkin Jan 26, 2026
dc56aae
Merge branch 'master' into egl-headless
najlkin Jan 30, 2026
c3c5268
Make style
najlkin Jan 30, 2026
053e08a
Fixed memory management.
najlkin Jan 30, 2026
070644a
Fixed nullptr derefencing in display().
najlkin Jan 30, 2026
08896c3
Fix of initial draw in display().
najlkin Jan 31, 2026
5bf67e3
Removed duplicate processing of keys.
najlkin Jan 31, 2026
7dab82b
Replaced sending keys by calling keys in display().
najlkin Jan 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.MFEM_TOP_DIR }}
key: ${{ runner.os }}-build-${{ env.MFEM_TOP_DIR }}-${{ env.MFEM_COMMIT }}-${{ matrix.target }}-${{ matrix.build-system}}-v2.4
key: ${{ runner.os }}-build-${{ env.MFEM_TOP_DIR }}-${{ env.MFEM_COMMIT }}-${{ matrix.build-system }}-${{ matrix.target }}-${{ matrix.mpi }}-v2.4

# We are using the defaults of the MFEM action here, which is to use master
# branch. There is an implicit assumption here that mfem master hasn't
Expand Down Expand Up @@ -199,7 +199,11 @@ jobs:
run: |
glvis_target="opt"
[[ ${{ matrix.target }} == "dbg" ]] && glvis_target="debug";
cd glvis && make ${glvis_target} -j3
use_egl="NO"
[[ ${{ matrix.os }} == "ubuntu-latest" ]] && use_egl="YES"
use_cgl="NO"
[[ ${{ matrix.os }} == "macos-latest" ]] && use_cgl="YES"
cd glvis && make ${glvis_target} -j3 GLVIS_USE_EGL=${use_egl} GLVIS_USE_CGL=${use_cgl}

- name: build GLVis (cmake)
if: matrix.build-system == 'cmake'
Expand All @@ -210,11 +214,17 @@ jobs:
[[ ${{ matrix.target }} == "dbg" ]] && build_type="Debug";
[[ ${{ matrix.os }} == "windows-latest" ]] \
&& toolchain_file="${VCPKG_INSTALLATION_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
use_egl="OFF"
[[ ${{ matrix.os }} == "ubuntu-latest" ]] && use_egl="ON"
use_cgl="NO"
[[ ${{ matrix.os }} == "macos-latest" ]] && use_cgl="YES"
cd glvis && mkdir build && cd build
cmake \
-D CMAKE_TOOLCHAIN_FILE:STRING=${toolchain_file} \
-D CMAKE_BUILD_TYPE:STRING=${build_type} \
-D ENABLE_TESTS:BOOL=TRUE \
-D GLVIS_USE_EGL:BOOL=${use_egl} \
-D GLVIS_USE_CGL:BOOL=${use_cgl} \
-D mfem_DIR:PATH=${GITHUB_WORKSPACE}/${MFEM_TOP_DIR}/build \
-D GLVIS_BASELINE_SYS=${{ matrix.os }} \
..
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.MFEM_TOP_DIR }}
key: ${{ runner.os }}-build-${{ env.MFEM_TOP_DIR }}-${{ env.MFEM_COMMIT }}-${{ matrix.target }}-${{ matrix.build-system}}-v2.2
key: ${{ runner.os }}-build-${{ env.MFEM_TOP_DIR }}-${{ env.MFEM_COMMIT }}-${{ matrix.build-system }}-${{ matrix.target }}-${{ matrix.mpi }}-v2.2

# We are using the defaults of the MFEM action here, which is to use master
# branch. There is an implicit assumption here that mfem master hasn't
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Version 4.4.1 (development)

Unlike previous GLVis releases, this version requires a C++17 compiler.

- Added headless (no GUI) visualization, relying on the EGL (Linux) or CGL
(MacOS) interface. It is available through '-hl' command-line option or
'headless' script command (before the visualization commands). The end of the
loaded stream or script file ends the visualization in this mode. Note GLVis
must be compiled with with EGL/CGL (see INSTALL).

- Added non-persistent mode of the server, when the server terminates after all
visualization windows are closed.

- Implemented DOF numbering in 2D scalar mode, pressing the `n` or `N` key cycles
through: None → Elements → Edges → Vertices → DOFs. Parallel numbering is now by
default 'local' to each rank; 'global' vs. 'local' numbering can be toggled with
Expand Down
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ option(GLVIS_USE_LIBPNG
"Use libpng for taking screenshots internally"
ON)

option(GLVIS_USE_EGL
"Use EGL for headless rendering"
OFF)

option(GLVIS_USE_CGL
"Use CGL for headless rendering"
APPLE)

#
# Handle a few other definitions
#
Expand Down Expand Up @@ -237,6 +245,23 @@ if (NOT EMSCRIPTEN)
message(FATAL_ERROR "Fontconfig not found.")
endif (FONTCONFIG_LIBRARY)

# Find EGL
if (GLVIS_USE_EGL)
find_package(OpenGL OPTIONAL_COMPONENTS EGL)
if (OpenGL_EGL_FOUND)
list(APPEND _glvis_compile_defs "GLVIS_USE_EGL")
list(APPEND _glvis_libraries OpenGL::EGL)
else()
message(WARNING "EGL library not found. EGL disabled.")
set(GLVIS_USE_EGL OFF)
endif (OpenGL_EGL_FOUND)
endif (GLVIS_USE_EGL)

# Find CGL
if (GLVIS_USE_CGL)
list(APPEND _glvis_compile_defs "GLVIS_USE_CGL")
endif (GLVIS_USE_CGL)

# Find threading library
find_package(Threads REQUIRED)
list(APPEND _glvis_libraries "${CMAKE_THREAD_LIBS_INIT}")
Expand Down
9 changes: 9 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Besides a C++ compiler, GLVis depends on the following external packages:
- the XQuartz app (on Mac OS X, if running GLVis remotely through ssh)
https://www.xquartz.org

- the EGL library; used for headless rendering (optional)
https://www.khronos.org/egl

There are two build systems, one based on GNU make and one based on CMake, as
described below. Choose the one that matches the build system you used to
build MFEM.
Expand Down Expand Up @@ -87,6 +90,7 @@ cmake \
\
-D GLVIS_USE_LIBTIFF=OFF \
-D GLVIS_USE_LIBPNG=ON \
-D GLVIS_USE_EGL=OFF \
\
-D MFEM_DIR=/path/to/directory/with/MFEMConfig.cmake \
\
Expand All @@ -111,6 +115,11 @@ Some important variables for CMake are:

- GLVIS_USE_LIBTIFF: Use libtiff for creating screenshots. Default is "OFF".

- GLVIS_USE_EGL: Use EGL for headless rendering. Default is "OFF".

- GLVIS_USE_CGL: Use CGL for headless rendering on Mac OS X. Default is "ON" on
this platform, "OFF" otherwise.

- GLVIS_MULTISAMPLE and GLVIS_MS_LINEWIDTH: See building considerations below
for more information on these variables.

Expand Down
44 changes: 29 additions & 15 deletions glvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include "lib/stream_reader.hpp"
#include "lib/file_reader.hpp"
#include "lib/coll_reader.hpp"
#include "lib/sdl/sdl.hpp"
#include "lib/egl/egl.hpp"

using namespace std;
using namespace mfem;
Expand Down Expand Up @@ -77,11 +79,13 @@ class Session
public:
Session(bool fix_elem_orient,
bool save_coloring,
string plot_caption)
string plot_caption,
bool headless)
{
win.data_state.fix_elem_orient = fix_elem_orient;
win.data_state.save_coloring = save_coloring;
win.plot_caption = plot_caption;
win.headless = headless;
}

Session(Window other_win)
Expand Down Expand Up @@ -154,7 +158,7 @@ class Session
};

void GLVisServer(int portnum, bool save_stream, bool fix_elem_orient,
bool save_coloring, string plot_caption)
bool save_coloring, string plot_caption, bool headless = false)
{
std::vector<Session> current_sessions;
string data_type;
Expand Down Expand Up @@ -304,7 +308,7 @@ void GLVisServer(int portnum, bool save_stream, bool fix_elem_orient,
while (1);
}

Session new_session(fix_elem_orient, save_coloring, plot_caption);
Session new_session(fix_elem_orient, save_coloring, plot_caption, headless);

constexpr int tmp_filename_size = 50;
char tmp_file[tmp_filename_size];
Expand Down Expand Up @@ -381,6 +385,7 @@ int main (int argc, char *argv[])
const char *window_title = string_default;
const char *font_name = string_default;
int portnum = 19916;
bool persistent = true;
int multisample = GetMultisample();
double line_width = GetLineWidth();
double ms_line_width = GetLineWidthMS();
Expand Down Expand Up @@ -451,6 +456,9 @@ int main (int argc, char *argv[])
"Save the mesh coloring generated when opening only a mesh.");
args.AddOption(&portnum, "-p", "--listen-port",
"Specify the port number on which to accept connections.");
args.AddOption(&persistent, "-pr", "--persistent",
"-no-pr", "--no-persistent",
"Keep server running after all windows are closed.");
args.AddOption(&secure, "-sec", "--secure-sockets",
"-no-sec", "--standard-sockets",
"Enable or disable GnuTLS secure sockets.");
Expand All @@ -466,6 +474,9 @@ int main (int argc, char *argv[])
"Set the window height.");
args.AddOption(&window_title, "-wt", "--window-title",
"Set the window title.");
args.AddOption(&win.headless, "-hl", "--headless",
"-no-hl", "--no-headless",
"Start headless (no GUI) visualization.");
args.AddOption(&c_plot_caption, "-c", "--plot-caption",
"Set the plot caption (visible when colorbar is visible).");
args.AddOption(&font_name, "-fn", "--font",
Expand Down Expand Up @@ -607,20 +618,21 @@ int main (int argc, char *argv[])
// check for saved stream file
if (stream_file != string_none)
{
// backup the headless flag as the window is moved
const bool headless = win.headless;

// Make sure the singleton object returned by GetMainThread() is
// initialized from the main thread.
GetMainThread();
GetMainThread(headless);

Session stream_session(win.data_state.fix_elem_orient,
win.data_state.save_coloring,
win.plot_caption);
Session stream_session(std::move(win));

if (!stream_session.StartSavedSession(stream_file))
{
return 1;
}

SDLMainLoop();
MainThreadLoop(headless);
return 0;
}

Expand Down Expand Up @@ -676,17 +688,16 @@ int main (int argc, char *argv[])
{
// Make sure the singleton object returned by GetMainThread() is
// initialized from the main thread.
GetMainThread();
GetMainThread(win.headless);

// Run server in new thread
std::thread serverThread{GLVisServer, portnum, save_stream,
win.data_state.fix_elem_orient,
win.data_state.save_coloring,
win.plot_caption};

// Start SDL in main thread
SDLMainLoop(true);
win.plot_caption, win.headless};

// Start message loop in main thread
MainThreadLoop(win.headless, persistent);
serverThread.detach();
}
else // input != 1, non-server mode
Expand Down Expand Up @@ -792,14 +803,17 @@ int main (int argc, char *argv[])
if (ierr) { exit(ierr); }
}

// backup the headless flag as the window is moved
const bool headless = win.headless;

// Make sure the singleton object returned by GetMainThread() is
// initialized from the main thread.
GetMainThread();
GetMainThread(headless);

Session single_session(std::move(win));
single_session.StartSession();

SDLMainLoop();
MainThreadLoop(headless);
}

cout << "Thank you for using GLVis." << endl;
Expand Down
32 changes: 19 additions & 13 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@
# CONTRIBUTING.md for details.

list(APPEND SOURCES
egl/egl.cpp
egl/egl_main.cpp
gl/renderer.cpp
gl/renderer_core.cpp
gl/shader.cpp
gl/types.cpp
sdl/sdl.cpp
sdl/sdl_helper.cpp
sdl/sdl_main.cpp
aux_vis.cpp
coll_reader.cpp
data_state.cpp
file_reader.cpp
font.cpp
gltf.cpp
glwindow.cpp
material.cpp
openglvis.cpp
palettes.cpp
palettes_default.cpp
palettes_base.cpp
script_controller.cpp
sdl.cpp
sdl_helper.cpp
sdl_main.cpp
stream_reader.cpp
vsdata.cpp
vssolution.cpp
Expand All @@ -38,29 +41,32 @@ list(APPEND SOURCES
window.cpp)

list(APPEND HEADERS
egl/egl.hpp
egl/egl_main.hpp
gl/attr_traits.hpp
gl/platform_gl.hpp
gl/renderer.hpp
gl/renderer_core.hpp
gl/shader.hpp
gl/types.hpp
sdl/sdl.hpp
sdl/sdl_helper.hpp
sdl/sdl_main.hpp
sdl/sdl_mac.hpp
aux_vis.hpp
coll_reader.hpp
data_state.hpp
file_reader.hpp
font.hpp
geom_utils.hpp
gltf.hpp
glwindow.hpp
logo.hpp
material.hpp
openglvis.hpp
palettes.hpp
palettes_base.hpp
script_controller.hpp
sdl.hpp
sdl_helper.hpp
sdl_main.hpp
sdl_mac.hpp
stream_reader.hpp
visual.hpp
vsdata.hpp
Expand Down Expand Up @@ -89,15 +95,15 @@ if(EMSCRIPTEN)
target_link_libraries(libglvis PUBLIC "${_glvis_libraries}")
else()
# Desktop build target
list(APPEND SOURCES gl/renderer_ff.cpp threads.cpp gl2ps.c sdl_x11.cpp)
list(APPEND HEADERS gl/renderer_ff.hpp threads.hpp gl2ps.h sdl_x11.hpp)
list(APPEND SOURCES gl/renderer_ff.cpp threads.cpp gl2ps.c sdl/sdl_x11.cpp)
list(APPEND HEADERS gl/renderer_ff.hpp threads.hpp gl2ps.h sdl/sdl_x11.hpp)
if (APPLE)
list(APPEND SOURCES sdl_mac.mm)
list(APPEND HEADERS sdl_mac.hpp)
list(APPEND SOURCES sdl/sdl_mac.mm)
list(APPEND HEADERS sdl/sdl_mac.hpp)
endif()
if (WIN32)
list(APPEND SOURCES sdl_windows.cpp)
list(APPEND HEADERS sdl_windows.hpp)
list(APPEND SOURCES sdl/sdl_windows.cpp)
list(APPEND HEADERS sdl/sdl_windows.hpp)
endif()
add_library(glvis ${SOURCES} ${HEADERS})
target_compile_definitions(glvis PUBLIC "${_glvis_compile_defs}")
Expand Down
Loading
Loading