Skip to content

Commit

Permalink
Merge pull request #186 from GLVis/glvis-4.1-dev
Browse files Browse the repository at this point in the history
Final changes for glvis-4.1
  • Loading branch information
tzanio authored Aug 31, 2021
2 parents ab3656d + 3ac6301 commit 5b65a00
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 75 deletions.
39 changes: 22 additions & 17 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ The GLVis source code has the following structure:
├── lib
│ └── gl
│ └── shaders
└── share
├── share
└── tests
```

## GitHub Workflow
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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)*.
Expand Down
22 changes: 0 additions & 22 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
4 changes: 3 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion lib/aux_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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. "
Expand Down
1 change: 1 addition & 0 deletions lib/geom_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion lib/openglvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

8 changes: 2 additions & 6 deletions lib/palettes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions lib/sdl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion lib/stream_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,3 @@ bool StreamState::SetNewMeshAndSolution(StreamState new_state,
return false;
}
}

1 change: 0 additions & 1 deletion lib/stream_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ struct StreamState
std::unique_ptr<mfem::GridFunction>
ProjectVectorFEGridFunction(std::unique_ptr<mfem::GridFunction> gf);


#endif // GLVIS_STREAM_READER_HPP
27 changes: 13 additions & 14 deletions lib/vsdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ void VisualizationSceneScalarData::FixValueRange()
if (float(am) < 100*numeric_limits<float>::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 --> ";
Expand Down Expand Up @@ -755,7 +754,7 @@ void KeyAPressed()
void KeyCommaPressed()
{
locscene->matAlphaCenter -= 0.25;
//vsdata -> EventUpdateColors();
// vsdata -> EventUpdateColors();
locscene->GenerateAlphaTexture();
SendExposeEvent();
#ifdef GLVIS_DEBUG
Expand All @@ -766,7 +765,7 @@ void KeyCommaPressed()
void KeyLessPressed()
{
locscene->matAlphaCenter += 0.25;
//vsdata -> EventUpdateColors();
// vsdata -> EventUpdateColors();
locscene->GenerateAlphaTexture();
SendExposeEvent();
#ifdef GLVIS_DEBUG
Expand Down Expand Up @@ -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]);
Expand All @@ -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]);
Expand All @@ -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]);
Expand All @@ -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);
}
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/vsdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
11 changes: 11 additions & 0 deletions tests/glvis_driver.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5b65a00

Please sign in to comment.