diff --git a/CHANGELOG b/CHANGELOG index 34dfe7a3..c4fa3634 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,33 +9,38 @@ http://glvis.org -Version 4.0.1 (development) -=========================== -- Use threads in server mode for window creation and session management - instead of fork(). This resolves some issues with running GLVis in server - mode on macOS. This also allows for closing all open GLVis windows associated - with the server by using Ctrl-C in the terminal. +Version 4.1, released on Aug 31, 2021 +===================================== -- Preliminary support for building natively on Windows via CMake. +- Use threads in server mode for window creation and session management instead + of fork(). This resolves issues with the GLVis server mode on macOS. It also + allows for closing all open GLVis server windows by Ctrl-C in the terminal. -- Refactored glvis.cpp to fix a bug in GLVis script handling. +- Preliminary support for interactive inline GLVis plots in Python Jupyter + Notebooks with https://github.com/glvis/pyglvis and C++ Jupyter Notebooks with + https://github.com/glvis/xeus-glvis. -- Enabled support for WebGL 2, when available. This enables, among other - features, support for controllable multisampling via framebuffers. +- Added support for native builds on Windows with CMake. -- Various bugfixes and improvements related to the JavaScript version. +- Added support for native Mac application bundle with "make app". The resulting + app can be double-clicked, added to the Dock, etc. -- Refactoring of rendering components, including palette and shader handling. +- Added screenshots support to the JavaScript/web version (key 'S'). + +- Enabled support for WebGL 2, when available. This enables, among other + features, support for controllable multisampling via framebuffers. -- Replace pthreads and POSIX-specific code with C++11 standard thread library. +- Refactored rendering components, including palette and shader handling. -- Added build target ("make app") to build a native Mac OS application bundle - that can be double-clicked, added to the Dock, etc. +- Replaced pthreads and POSIX-specific code with C++11 standard thread library. - Added a new regression test suite based on generated screenshots of stream - files. See the README in the tests directory for more details. + files. See the README in the tests/ directory for more details. Note that this + requires a git submodule for the baseline images, which are located in the + separate https://github.com/glvis/data repository. -- Fixed an issue with black screenshots on certain OpenGL implementations. +- Various bugfixes and improvements related to the JavaScript version, vertex + numbering, script handling, screenshots, HiDPI support, and more. Version 4.0, released on Dec 11, 2020 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 772ed44b..f68b4dbb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,7 +87,8 @@ The GLVis source code has the following structure: ├── lib │ └── gl │ └── shaders - └── share + ├── share + └── tests ``` ## GitHub Workflow @@ -203,8 +204,6 @@ Before you can start, you need a GitHub account, here are a few suggestions: directory. This requires [Artistic Style](http://astyle.sourceforge.net) version 2.05.1 and MFEM's style configuration file, typically located in `../mfem/config/mfem.astylerc`. - - Use `glvis::out` and `glvis::err` instead of `std::cout` and `std::cerr` in - internal library code. (You can use `std` in examples and miniapps.) - When manually resolving conflicts during a merge, make sure to mention the conflicted files in the commit message. @@ -263,7 +262,6 @@ Before a PR can be merged, it should satisfy the following: - [ ] Add new patterns (just for the new files above) and re-run the above test. - [ ] New capability: - [ ] All significant new classes, methods and functions have Doxygen-style documentation in source comments. - - [ ] Consider adding new sample runs in existing examples to highlight the new capability. - [ ] Consider saving cool simulation pictures with the new capability in the Confluence gallery (LLNL only) or submitting them, via pull request, to the gallery section of the `glvis/web` repo. - [ ] If this is a major new feature, consider mentioning it in the short summary inside `README` *(rare)*. - [ ] List major new classes in `doc/CodeDocumentation.dox` *(rare)*. diff --git a/INSTALL b/INSTALL index 6c58cf23..f3087932 100644 --- a/INSTALL +++ b/INSTALL @@ -201,28 +201,6 @@ Some building considerations bash glvis-keygen.sh ["Your Name"] ["Your Email"] -- On some versions of Mac OS X, an error may be encountered with GLVis running - in server mode: - - [NSApplication initialize] may have been in progress in another thread - when fork() was called. - - This appears to be the result of some interaction between the Cocoa windowing - system, SDL, and GLVis's fork-based architecture in server mode. There are - two potential fixes: - - 1) Start GLVis with the '-mac' option. This will write out connection streams - to a stream file and start a new process of GLVis to view this stream. - This avoids the problematic 'fork()' call, at the cost of being unable to - view the visualization in real-time. - - 2) Build GLVis with SDL 2.0.12, the last version which appears to avoid the - error. Steps for manually building SDL2 from source are located under the - 'Dependency building instructions' section below. You may need to add a - '--disable-video-x11' switch to the ./configure command. - Note that while this avoids the hard error, and allows for real-time - visualization, occasional hangs have been reported with this method. - - On Mac OS X, GLVis can be built as a native application bundle using the 'make app' target (with both the makefile and CMake build systems). diff --git a/README b/README index 7c6bf875..2267b500 100644 --- a/README +++ b/README @@ -9,7 +9,9 @@ http://glvis.org GLVis is an OpenGL tool for visualization of finite element meshes and -functions. +functions. It is a multiplatform OpenGL application that can be built on +Linux/Unix systems, including Mac OS X, and under Windows. It can also be used +in a Jupyter notebook, or in a web browser, see https://glvis.org/live. For building instructions, see the file INSTALL. Copyright information and licensing restrictions can be found in the file COPYRIGHT. diff --git a/lib/aux_js.cpp b/lib/aux_js.cpp index c1a5a59f..cdc90048 100644 --- a/lib/aux_js.cpp +++ b/lib/aux_js.cpp @@ -311,7 +311,6 @@ void setupResizeEventCallback(const std::string & id) std::cout << "got resize event" << std::endl; return true; }); - // TODO: macro to wrap this if (err != EMSCRIPTEN_RESULT_SUCCESS) { std::cerr << "error (emscripten_set_resize_callback): " << err << std::endl; diff --git a/lib/aux_vis.cpp b/lib/aux_vis.cpp index b2fb24e6..8a55f8ef 100644 --- a/lib/aux_vis.cpp +++ b/lib/aux_vis.cpp @@ -931,7 +931,7 @@ int SaveAsPNG(const char *fname, int w, int h, bool is_hidpi, bool with_alpha) } png_uint_32 ppi = is_hidpi ? 144 : 72; // pixels/inch - png_uint_32 ppm = ppi/0.0254 + 0.5; // pixels/meter + png_uint_32 ppm = ppi/0.0254 + 0.5; // pixels/meter png_set_pHYs(png_ptr, info_ptr, ppm, ppm, PNG_RESOLUTION_METER); png_init_io(png_ptr, fp); @@ -996,14 +996,14 @@ int Screenshot(const char *fname, bool convert) wnd->getGLDrawSize(w, h); if (wnd->isSwapPending()) { -#if GLVIS_DEBUG +#ifdef GLVIS_DEBUG cerr << "Screenshot: reading image data from back buffer..." << endl; #endif glReadBuffer(GL_BACK); } else { -#if GLVIS_DEBUG +#ifdef GLVIS_DEBUG cerr << "Screenshot: reading image data from front buffer..." << endl; #endif MFEM_WARNING("Screenshot: Reading from the front buffer is unreliable. " diff --git a/lib/geom_utils.hpp b/lib/geom_utils.hpp index 74fe9b5c..1ed95c5e 100644 --- a/lib/geom_utils.hpp +++ b/lib/geom_utils.hpp @@ -144,4 +144,5 @@ inline int ProjectVector(double v[], const double n[]) LinearCombination(InnerProd(n, n), v, -InnerProd(v, n), n, v); return Normalize(v); } + #endif // GLVIS_GEOM_UTILS_HPP diff --git a/lib/openglvis.cpp b/lib/openglvis.cpp index 069a94d8..c3b1ab21 100644 --- a/lib/openglvis.cpp +++ b/lib/openglvis.cpp @@ -466,4 +466,3 @@ glm::mat4 VisualizationScene::GetModelViewMtx() modelView.translate(-(x[0]+x[1])/2, -(y[0]+y[1])/2, -(z[0]+z[1])/2); return modelView.mtx; } - diff --git a/lib/palettes.cpp b/lib/palettes.cpp index 313b655a..2e11e7fb 100644 --- a/lib/palettes.cpp +++ b/lib/palettes.cpp @@ -7541,9 +7541,7 @@ int PaletteState::ChoosePalette() } -/* * - * Generates a discrete texture from the given palette. - */ +// Generates a discrete texture from the given palette. void PaletteState::ToTextureDiscrete(double * palette, size_t plt_size, GLuint tex) { @@ -7616,9 +7614,7 @@ void PaletteState::ToTextureDiscrete(double * palette, size_t plt_size, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } -/* * - * Generates a smooth texture from the given palette. - */ +// Generates a smooth texture from the given palette. void PaletteState::ToTextureSmooth(double * palette, size_t plt_size, GLuint tex) { diff --git a/lib/sdl.cpp b/lib/sdl.cpp index 37231852..70b1dfa7 100644 --- a/lib/sdl.cpp +++ b/lib/sdl.cpp @@ -193,6 +193,7 @@ void SdlWindow::windowEvent(SDL_WindowEvent& ew) switch (ew.event) { case SDL_WINDOWEVENT_EXPOSED: + case SDL_WINDOWEVENT_RESIZED: update_before_expose = true; if (onExpose) { @@ -203,7 +204,6 @@ void SdlWindow::windowEvent(SDL_WindowEvent& ew) running = false; break; case SDL_WINDOWEVENT_MOVED: - case SDL_WINDOWEVENT_RESIZED: update_before_expose = true; break; default: diff --git a/lib/sdl_main.cpp b/lib/sdl_main.cpp index 2de28ae2..d6904129 100644 --- a/lib/sdl_main.cpp +++ b/lib/sdl_main.cpp @@ -60,6 +60,20 @@ SdlMainThread::SdlMainThread() PRINT_DEBUG("Using SDL " << (int)sdl_ver.major << "." << (int)sdl_ver.minor << "." << (int)sdl_ver.patch << std::endl); +#ifdef SDL_VIDEO_DRIVER_COCOA + if (SDL_VERSIONNUM(sdl_ver.major, sdl_ver.minor, sdl_ver.patch) + < SDL_VERSIONNUM(2, 0, 14)) + { + std::cerr << "Warning: your current version of SDL (" + << (int)sdl_ver.major << "." << (int)sdl_ver.minor << "." + << (int)sdl_ver.patch + << ") may be unsupported in a future version of GLVis on macOS." + << std::endl; + std::cerr << "If possible, upgrade to SDL version 2.0.14 or newer." + << std::endl; + } +#endif + if (!SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_EVENTS)) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) diff --git a/lib/stream_reader.cpp b/lib/stream_reader.cpp index 4c32e176..9029ec7d 100644 --- a/lib/stream_reader.cpp +++ b/lib/stream_reader.cpp @@ -409,4 +409,3 @@ bool StreamState::SetNewMeshAndSolution(StreamState new_state, return false; } } - diff --git a/lib/stream_reader.hpp b/lib/stream_reader.hpp index 179e4c75..7aa42fb7 100644 --- a/lib/stream_reader.hpp +++ b/lib/stream_reader.hpp @@ -52,5 +52,4 @@ struct StreamState std::unique_ptr ProjectVectorFEGridFunction(std::unique_ptr gf); - #endif // GLVIS_STREAM_READER_HPP diff --git a/lib/vsdata.cpp b/lib/vsdata.cpp index 9b318b4c..d2650d9a 100644 --- a/lib/vsdata.cpp +++ b/lib/vsdata.cpp @@ -33,9 +33,8 @@ void VisualizationSceneScalarData::FixValueRange() if (float(am) < 100*numeric_limits::min()) { am = 1e-3; } if ((maxv-minv) < 1e-5*am) { - // Shading quality may be bad since OpenGL uses single precision. - // We should probably pre-scale the solution before feeding it - // to OpenGL + // Shading quality may be bad since OpenGL uses single precision. We + // should probably pre-scale the solution before feeding it to OpenGL int old_prec = cout.precision(12); cout << "[minv,maxv] = " << "[" << minv << "," << maxv << "] (maxv-minv = " << maxv-minv << ")\n --> "; @@ -755,7 +754,7 @@ void KeyAPressed() void KeyCommaPressed() { locscene->matAlphaCenter -= 0.25; - //vsdata -> EventUpdateColors(); + // vsdata -> EventUpdateColors(); locscene->GenerateAlphaTexture(); SendExposeEvent(); #ifdef GLVIS_DEBUG @@ -766,7 +765,7 @@ void KeyCommaPressed() void KeyLessPressed() { locscene->matAlphaCenter += 0.25; - //vsdata -> EventUpdateColors(); + // vsdata -> EventUpdateColors(); locscene->GenerateAlphaTexture(); SendExposeEvent(); #ifdef GLVIS_DEBUG @@ -1250,7 +1249,7 @@ void VisualizationSceneScalarData::PrepareAxes() gl3::GlBuilder bld = axes_buf.createBuilder(); if (drawaxes == 3) { - //glLineStipple(1, 255); + // glLineStipple(1, 255); bld.glBegin(GL_LINES); bld.glColor3f(1., 0., 0.); bld.glVertex3d(x[0], y[0], z[0]); @@ -1261,8 +1260,8 @@ void VisualizationSceneScalarData::PrepareAxes() bld.glVertex3d(x[0], y[0], z[0]); bld.glEnd(); bld.glColor4fv(blk.data()); - //bld.setUseColor(false); - //bld.glEnable(GL_LINE_STIPPLE); + // bld.setUseColor(false); + // bld.glEnable(GL_LINE_STIPPLE); bld.glBegin(GL_LINE_STRIP); bld.glColor3f(0.75, 0.75, 0.75); bld.glVertex3d(x[1], y[0], z[0]); @@ -1272,7 +1271,7 @@ void VisualizationSceneScalarData::PrepareAxes() } else { - //bld.setUseColor(false); + // bld.setUseColor(false); bld.glBegin(GL_LINE_LOOP); bld.glVertex3d(x[0], y[0], z[0]); bld.glVertex3d(x[1], y[0], z[0]); @@ -1289,15 +1288,15 @@ void VisualizationSceneScalarData::PrepareAxes() if (drawaxes == 3) { - //bld.setUseColor(true); - //bld.glDisable(GL_LINE_STIPPLE); + // bld.setUseColor(true); + // bld.glDisable(GL_LINE_STIPPLE); bld.glBegin(GL_LINES); bld.glVertex3d(x[0], y[0], z[1]); bld.glColor3f(0., 0., 1.); bld.glVertex3d(x[0], y[0], z[0]); bld.glEnd(); - //bld.setUseColor(false); - //bld.glEnable(GL_LINE_STIPPLE); + // bld.setUseColor(false); + // bld.glEnable(GL_LINE_STIPPLE); bld.glColor3f(0.75, 0.75, 0.75); bld.glBegin(GL_LINES); } @@ -1316,7 +1315,7 @@ void VisualizationSceneScalarData::PrepareAxes() bld.glEnd(); if (drawaxes == 3) { - //bld.glDisable(GL_LINE_STIPPLE); + // bld.glDisable(GL_LINE_STIPPLE); } // Write the coordinates of the lower left and upper right corner. diff --git a/lib/vsdata.hpp b/lib/vsdata.hpp index 975de0bb..5df07c94 100644 --- a/lib/vsdata.hpp +++ b/lib/vsdata.hpp @@ -165,7 +165,7 @@ class VisualizationSceneScalarData : public VisualizationScene // Perform autoscaling depending on the value of 'autoscale': // 0 - do nothing - // 1 - call call FindNewBoxAndValueRange + // 1 - call FindNewBoxAndValueRange // 2 - call FindNewValueRange // 3 - call FindMeshBox void DoAutoscale(bool prepare); diff --git a/makefile b/makefile index 7a131eeb..9c7445fe 100644 --- a/makefile +++ b/makefile @@ -93,8 +93,12 @@ GLVIS_LDFLAGS ?= EMCC ?= emcc -std=c++11 FONT_FILE ?= OpenSans.ttf EMCC_OPTS ?= -s USE_SDL=2 -s USE_FREETYPE=1 -s USE_LIBPNG=1 -# TODO: we don't want to have DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -# longterm but until the SDL layer supports non-default canvas ids we need this +# NOTE: we don't want to have DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 +# longterm but until the SDL layer supports non-default canvas ids we need this, +# which will probably be a while. +# NOTE: we don't want to have --minify 0 longterm but we need to patch +# `_JSEvents_requestFullscreen' to be a noop for the live page and that is +# not easy to do in a minified build. EMCC_LIBS ?= -s USE_SDL=2 --bind -s ALLOW_MEMORY_GROWTH=1 -s SINGLE_FILE=1 \ --no-heap-copy -s ENVIRONMENT=web -s MODULARIZE=1 -s EXPORT_NAME=glvis \ -s GL_ASSERTIONS=1 -s GL_DEBUG=1 -s USE_FREETYPE=1 -s MAX_WEBGL_VERSION=2 \ diff --git a/tests/glvis_driver.py b/tests/glvis_driver.py index bab8a844..20fe1285 100644 --- a/tests/glvis_driver.py +++ b/tests/glvis_driver.py @@ -1,3 +1,14 @@ +# Copyright (c) 2010-2021, Lawrence Livermore National Security, LLC. Produced +# at the Lawrence Livermore National Laboratory. All Rights reserved. See files +# LICENSE and NOTICE for details. LLNL-CODE-443271. +# +# This file is part of the GLVis visualization tool and library. For more +# information and source code availability see https://glvis.org. +# +# GLVis is free software; you can redistribute it and/or modify it under the +# terms of the BSD-3 license. We welcome feedback and contributions, see file +# CONTRIBUTING.md for details. + import argparse import sys import os