Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 53 additions & 10 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ jobs:
builds-and-tests:
strategy:
matrix:
os: [ubuntu-20.04, macos-10.15]
target: [debug, optim]
mpi: [sequential]
build-system: [cmake]
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
target: optim
mpi: sequential
build-system: make
- os: ubuntu-18.04
- os: ubuntu-20.04
target: debug
mpi: parallel
build-system: make
Expand All @@ -48,17 +52,13 @@ jobs:
target: debug
mpi: parallel
build-system: make
- os: ubuntu-18.04
target: optim
mpi: sequential
build-system: cmake
name: ${{ matrix.os }}-${{ matrix.target }}-${{ matrix.mpi }}-${{ matrix.build-system }}

runs-on: ${{ matrix.os }}

steps:
- name: get MPI (Linux)
if: matrix.os == 'ubuntu-18.04'
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install mpich libmpich-dev
Expand Down Expand Up @@ -147,10 +147,13 @@ jobs:
build-system: ${{ matrix.build-system }}
mpi: ${{ matrix.mpi }}

# Install GlVis dependencies with package manager
# Install GLVis dependencies with package manager
- name: get deps (Linux)
if: matrix.os == 'ubuntu-18.04'
if: matrix.os == 'ubuntu-20.04'
run: |
# We need to add a PPA for SDL 2.0.14 - fixes some initialization
# errors for X11
sudo add-apt-repository -y ppa:savoury1/multimedia
sudo apt-get update
sudo apt-get install libfontconfig1-dev libfreetype6-dev libsdl2-dev libglew-dev libglm-dev libpng-dev

Expand All @@ -168,6 +171,7 @@ jobs:
uses: actions/checkout@v2
with:
path: glvis
submodules: recursive

- name: build GLVis (make)
if: matrix.build-system == 'make'
Expand All @@ -179,12 +183,51 @@ jobs:
- name: build GLVis (cmake)
if: matrix.build-system == 'cmake'
run: |
build_type="Release"
build_type="RelWithDebInfo"
[[ ${{ matrix.target }} == "debug" ]] && build_type="Debug";
cd glvis && mkdir build && cd build
cmake \
-D CMAKE_BUILD_TYPE:STRING=${build_type} \
-D ENABLE_TESTS:BOOL=TRUE \
-D mfem_DIR:PATH=${GITHUB_WORKSPACE}/${MFEM_TOP_DIR}/build \
-D GLVIS_BASELINE_SYS=${{ matrix.os }} \
..
make -j3

- name: setup Python
if: matrix.build-system == 'cmake'
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: setup Python packages for testing
if: matrix.build-system == 'cmake'
run: |
python -m pip install --upgrade pip
pip install scikit-image

- name: setup Linux testing dependencies
if: matrix.build-system == 'cmake' && matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get install xvfb

- name: test GLVis (cmake/linux)
if: matrix.build-system == 'cmake' && matrix.os == 'ubuntu-20.04'
run: |
cd glvis && cd build
xvfb-run -a ctest --verbose
tar czvf test_screenshots.tar.gz tests/test.*.png

- name: test GLVis (cmake/mac)
if: matrix.build-system == 'cmake' && matrix.os == 'macos-10.15'
run: |
cd glvis && cd build
ctest --verbose
tar czvf test_screenshots.tar.gz tests/test.*.png

- name: upload test screenshots
if: matrix.build-system == 'cmake'
uses: actions/upload-artifact@v2
with:
name: test-screenshots-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.mpi }}
path: glvis/build/test_screenshots.tar.gz
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/data"]
path = tests/data
url = https://github.com/GLVis/data.git
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Version 4.0.1 (development)
- Added build target ("make app") to build a native Mac OS application bundle
that can be double-clicked, added to the Dock, etc.

- Added a new regression test suite based on generated screenshots of stream
files. See the README in the tests directory for more details.

- Fixed an issue with black screenshots on certain OpenGL implementations.


Version 4.0, released on Dec 11, 2020
=====================================
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,8 @@ add_custom_target(app
GLVis.app/Contents/Resources/GLVis.icns
GLVis.app/Contents/Resources/Credits.rtf
VERBATIM)

if(ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif(ENABLE_TESTS)
5 changes: 5 additions & 0 deletions glvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ int main (int argc, char *argv[])
double ms_line_width = gl3::LINE_WIDTH_AA;
int geom_ref_type = Quadrature1D::ClosedUniform;
bool legacy_gl_ctx = false;
bool enable_hidpi = true;

OptionsParser args(argc, argv);

Expand Down Expand Up @@ -1206,6 +1207,9 @@ int main (int argc, char *argv[])
args.AddOption(&legacy_gl_ctx, "-oldgl", "--legacy-gl",
"-anygl", "--any-gl",
"Only try to create a legacy OpenGL (< 2.1) context.");
args.AddOption(&enable_hidpi, "-hidpi", "--high-dpi",
"-nohidpi", "--no-high-dpi",
"Enable/disable support for HiDPI at runtime, if supported.");

cout << endl
<< " _/_/_/ _/ _/ _/ _/" << endl
Expand Down Expand Up @@ -1279,6 +1283,7 @@ int main (int argc, char *argv[])
{
SetLegacyGLOnly(legacy_gl_ctx);
}
SetUseHiDPI(enable_hidpi);

GLVisGeometryRefiner.SetType(geom_ref_type);

Expand Down
12 changes: 10 additions & 2 deletions lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ float line_w_aa = gl3::LINE_WIDTH_AA;

thread_local SdlWindow * wnd = nullptr;
bool wndLegacyGl = false;
bool wndUseHiDPI = false;
void SDLMainLoop(bool server_mode)
{
SdlWindow::StartSDL(server_mode);
Expand All @@ -68,6 +69,11 @@ void SetLegacyGLOnly(bool status)
wndLegacyGl = true;
}

void SetUseHiDPI(bool status)
{
wndUseHiDPI = status;
}

void MyExpose(GLsizei w, GLsizei h);
void MyExpose();

Expand Down Expand Up @@ -319,8 +325,7 @@ void SetVisualizationScene(VisualizationScene * scene, int view,

if (keys)
{
// SendKeySequence(keys);
CallKeySequence(keys);
SendKeySequence(keys);
}
wnd->getRenderer().setPalette(&locscene->palette);
}
Expand Down Expand Up @@ -933,6 +938,8 @@ int Screenshot(const char *fname, bool convert)
#if GLVIS_DEBUG
cerr << "Screenshot: reading image data from front buffer..." << endl;
#endif
MFEM_WARNING("Screenshot: Reading from the front buffer is unreliable. "
<< " Resulting screenshots may be incorrect." << endl);
glReadBuffer(GL_FRONT);
}
#if defined(GLVIS_USE_LIBTIFF)
Expand Down Expand Up @@ -1113,6 +1120,7 @@ void KeyS()
wnd->screenshot(fname);
cout << "done" << endl;
}
SendExposeEvent();
}

inline GL2PSvertex CreatePrintVtx(gl3::FeedbackVertex v)
Expand Down
2 changes: 2 additions & 0 deletions lib/aux_vis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,6 @@ GlVisFont * GetFont();
bool SetFont(const vector<std::string>& patterns, int height);
void SetFont(const std::string& fn);

void SetUseHiDPI(bool status);

#endif
24 changes: 19 additions & 5 deletions lib/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,19 @@ bool SdlWindow::createWindow(const char* title, int x, int y, int w, int h,
return false;
}

window_id = SDL_GetWindowID(handle.hwnd);

GLenum err = glewInit();
#ifdef GLEW_ERROR_NO_GLX_DISPLAY
// NOTE: Hacky workaround for Wayland initialization failure
// See https://github.com/nigels-com/glew/issues/172
if (err == GLEW_ERROR_NO_GLX_DISPLAY)
{
cerr << "GLEW: No GLX display found. If you are using Wayland this can "
"be ignored." << endl;
err = GLEW_OK;
}
#endif
if (err != GLEW_OK)
{
cerr << "FATAL: Failed to initialize GLEW: "
Expand Down Expand Up @@ -476,6 +488,11 @@ void SdlWindow::mainLoop()
while (running)
{
mainIter();
if (takeScreenshot)
{
Screenshot(screenshot_file.c_str(), screenshot_convert);
takeScreenshot = false;
}
if (wnd_state == RenderState::SwapPending)
{
#ifdef SDL_VIDEO_DRIVER_COCOA
Expand All @@ -496,11 +513,6 @@ void SdlWindow::mainLoop()
#endif
wnd_state = RenderState::Updated;
}
if (takeScreenshot)
{
Screenshot(screenshot_file.c_str());
takeScreenshot = false;
}
}
#endif
}
Expand Down Expand Up @@ -618,11 +630,13 @@ void SdlWindow::signalKeyDown(SDL_Keycode k, SDL_Keymod m)
if (k >= 32 && k < 128)
{
event.type = SDL_TEXTINPUT;
event.text.windowID = window_id;
event.text.text[0] = k;
}
else
{
event.type = SDL_KEYDOWN;
event.key.windowID = window_id;
event.key.keysym.sym = k;
event.key.keysym.mod = m;
}
Expand Down
8 changes: 7 additions & 1 deletion lib/sdl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class SdlWindow
}
};

int window_id = -1;
Handle handle;
std::unique_ptr<gl3::MeshRenderer> renderer;
static const int high_dpi_threshold = 144;
Expand Down Expand Up @@ -125,6 +126,7 @@ class SdlWindow
//bool requiresExpose;
bool takeScreenshot{false};
std::string screenshot_file;
bool screenshot_convert;

// internal event handlers
void windowEvent(SDL_WindowEvent& ew);
Expand Down Expand Up @@ -236,10 +238,14 @@ class SdlWindow
std::string getSavedKeys() const { return saved_keys; }

/// Queues a screenshot to be taken.
void screenshot(std::string filename)
void screenshot(std::string filename, bool convert = false)
{
takeScreenshot = true;
screenshot_file = filename;
screenshot_convert = convert;
// Queue up an expose, so Screenshot() can pull image from the back
// buffer
signalExpose();
}

void swapBuffer();
Expand Down
Loading