No Text, Repeating Shader Errors with Qt5 / OpenGL

I have been using Geant4 on Mac for a few years (10.02.p02) but needed to upgrade my OS (from 10.11 to 10.15). I have reinstalled Geant4 (10.06.p01) and now whenever I run the visualization (OGL with Qt5 and X11 support), no text is drawn, and I get a constantly repeating error message about creating shaders:

Could not create shader of type 1.
Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile
Could not create shader of type 2.
Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile
QGLShaderProgram: could not create shader program
Errors linking simple shader:
Could not create shader of type 1.
Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile
Could not create shader of type 2.
Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile
QGLShaderProgram: could not create shader program
Errors linking blit shader:
Could not create shader of type 2.
Warning: “” failed to compile!
Could not create shader of type 2.
Warning: “” failed to compile!
Could not create shader of type 2.
Warning: “” failed to compile!
…etc

My question is, is there any way to resolve this error while still using Qt5? I have tried the build Geant4 without X11 support, but it won’t work on my system. I’ve tried building other versions of Geant4 (10.04.p03), and the same problem remains.

I have found that forcing Geant4 to build with Qt4 avoids this issue, but causes a different problem, which is that the visualization only fills 25% of the viewport window (see: this post). If anyone knows how to fix that issue in Qt4, I’d be interested to know as well.

Hi Kris

On Mac, Qt and X11 don’t sit well together. The symptoms are the messages you describe and no text (or grabbed text). I’m afraid we do not have a solution. Apart from that things seem to work correctly.

I usually build with Qt alone, which works fine for me. You say “it won’t work for you”; can you give some details?

Qt4 support is deprecated, and in fact will be removed in the next release.

John

I wrote that other post about the 25% view when using qt4 and was having exactly the same problem as you do with qt5. I tried allisons suggestion by building geant4 with qt alone and everything works fine!

Thank you both very much!

@allison, to answer your question, when I build using this command, turning X11 off:

cmake -DCMAKE_INSTALL_PREFIX=…/geant4.10.06.p01-install -DGEANT4_USE_SYSTEM_EXPAT=OFF -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_INSTALL_DATADIR=…/geant4.10.06.p01-data -DGEANT4_USE_QT=ON -DGEANT4_USE_OPENGL_X11=OFF …/geant4.10.06.p01-source

It finishes the configuration fine, but when I do the make step, I get this error:

In file included from /Users/Kris/Geant4/geant4.10.06.p01-source/source/visualization/OpenGL/include/G4OpenGLXmViewer.hh:38:
/Users/Kris/Geant4/geant4.10.06.p01-source/source/visualization/OpenGL/include/G4OpenGLXViewer.hh:44:10: fatal error:
‘GL/glx.h’ file not found
#include <GL/glx.h>
^~~~~~~~~~
1 error generated.
make[2]: *** [source/visualization/OpenGL/CMakeFiles/G4OpenGL.dir/src/G4OpenGLImmediateXm.cc.o] Error 1

It appears for a number of the G4OpenGL files, and the build fails. Please let me know if you know how to fix. Thanks again!

But X11 is still requested:

Still. You are right. If requested only for Ray Tracer, it should not affect OpenGL. But please try -DGEANT4_USE_RAYTRACER_X11=OFF

If I build with -DGEANT4_USE_RAYTRACER_X11=OFF, the build still fails. This is also true even if I include the path to X11/include (where GL/glx.h appears to be stored) in my environment.

However, if I use -DCMAKE_PREFIX_PATH=/opt/X11/include, then the build succeeds, but I have the same error I was having at the beginning with the text not appearing, etc., which leads me to believe I didn’t really succeed in building with Qt only.

Correction - the build still fails when I use -DCMAKE_PREFIX_PATH and try to path to the location. I had done a bad copy/paste and accidentally turned -DGEANT4_USE_OPENGL_X11 back on.

Finally got it to work! In the end, I think the problem was that I was clearing my build folder using “make clean” instead of deleting it entirely. When I totally deleted it and rebuilt from scratch with -DGEANT4_USE_OPENGL_X11=OFF (RAYTRACER_X11 was off also), then it built successfully, and now the text appears with no more repeating shader errors! Thanks again for the help on this!

You wrote, “In the end, I think the problem was that I was clearing my build folder using “make clean” instead of deleting it entirely.”

Definitely deleting your build directory entirely will “work”, but it’s a pain in the neck :slight_smile: You were making modifications to your CMake configuration, so the make clean action wouldn’t have helped with that. What you can do, if you want to get rid of any previous CMake flags and start over, is to just delete the file CMakeCache.txt in your build directory. That’s where CMake remembers all your previous flag settings.

Makes sense - thanks for the tip!