PlantSimulationLab / Helios

The Helios simulation system is a versatile modeling framework that handles tasks such as managing geometry and associated data structures through a C++ API. Plug-ins build off of the Helios core engine, and access the geometry and data via the Helios context. The sytem comes with a visualization plug-in that can produce stunning renderings of model geometry and data with relatively little effort.
http://baileylab.ucdavis.edu/software/helios
GNU General Public License v2.0
61 stars 27 forks source link

Visualizer error on macOS with SSH X11 forwarding #35

Open pasquierjb opened 1 year ago

pasquierjb commented 1 year ago

When running any code that involves the Visualizer plugin, I get the following error:

Initializing graphics...terminate called after throwing an instance of 'std::runtime_error'
  what():  ERROR(Visualizer): Failed to initialize graphics.
Common causes for this error:
-- OSX
  - Is XQuartz installed (xquartz.org) and configured as the default X11 window handler?  When running the visualizer, XQuartz should automatically open and appear in the dock, indicating it is working.
-- Linux
  - Are you running this program remotely via SSH? Remote X11 graphics along with OpenGL are not natively supported.  Installing and using VirtualGL is a good solution for this (virtualgl.org).

Aborted (core dumped)

Context:

bnbailey-psl commented 1 year ago

The issue is that OpenGL graphics cannot be forwarded over SSH without a 3rd party utility. As mentioned in the error message, one option is to install the VirtualGL utility. You need to follow their install instructions carefully, as it can be tricky in some cases. Another option is to use a VNC server/client like TurboVNC to remotely connect using a virtual desktop rather than over SSH. This is our preferred method because you can run CLion on the remote sever.

pasquierjb commented 1 year ago

Ok thanks, I will try these options.

I am surprised that forwarding glxgears (based on OpenGL) works fine though...

pasquierjb commented 1 year ago

I managed to get the Visualizer working commenting out these two lines in Visualizer.cpp:

 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

Apparently it's an error with GLX_ARB_create_context_profile, it seems to be a common issue with X11 forwarding on Mac.

GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable
GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable

I got the above error when adding some glfw debugging in my script:

 static void glfwError(int id, const char* description)
    {
  std::cout << description << std::endl;
}
int main(){
   glfwSetErrorCallback(&glfwError);
  [...]
  }