OpenGL cannot be opened when trying to open GDML file


ROOT Version: 6.26/10
Platform: Ubuntu 22.04.1 LTS
Compiler: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0


Hello,

I have tried opening a gdml file using a small macro (copied below), however, it seems root is not able to open its GL viewer. The message I receive is Warning in <TCanvas::TPad::CreateViewer3D>: Cannot create 3D viewer of type: ogl. It does open a window where the geometry can be seen, however, it is not as good as the usual GL viewer. When building ROOT, I have checked that OpenGL was found so it should have been compiled against the available ogl module on my system. Any help would be appreciated. Thanks a lot in advance.

The macro file:

void rootreadgeom(const char * infile) {
  gSystem->Load("libGeom");
  gSystem->Load("libGdml");
  gSystem->Load("libGL");

  TGeoManager *geom = TGeoManager::Import(infile);
  TGeoVolume *top = gGeoManager->GetTopVolume();

  top->Draw("ogl");
}

I have also tried adding gStyle->SetCanvasPreferGL(kTRUE); but it did not affect the outcome. I have also checked that gSystem->Load("libGL") returns 0 which I think should imply it was found and loaded.

Maybe @agheata or @bellenot can help here.

Hi, I’m no GL expert, but make sure the GL driver works properly on your box and that ROOT managed to compile GL support (root-config --features should show opengl in the list)

Hi, thanks a lot for your reply. Indeed, it seems opengl is not listed when I run this command. When I built ROOT, it said that it did find the opengl library. Do you perhaps know if there is something else I would need to specify in order to build ROOT with OpenGL?

I noticed some dependencies seemed were missing for OGL but did not receive a warning back then. Now I installed them and rebuilt root specifying the two OGL related flags (-DOPENGL_INCLUDE_DIR and -DOPENGL_gl_LIBRARY) and now it works. Thanks a lot!