OpenGL driver for windows

Dear Geant4 team,
I am used to practicing GEANT4 on Linux but today, I challenged myself trying to make a G4-based application on windows.
First, I have installed Qt5.15.2 with the modules that are shown in the picture below:
image

I successfully compiled Geant4 with CMake using the options -DGEANT4_USE_OPENGL_WIN32=ON -DGEANT4_USE_QT=ON and I linked QT dirs in the CMake. The compilation goes well and I can compile and execute exampleB1. I used MSVC2019-32 bits.

I also setup the environment variables as follows:
image
image

My difficulty is the following:
When I start a Geant4 session on windows, the drivers available for the visualization are:

You have successfully registered the following graphics systems.
Current available graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRep (HepRepXML)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML1FILE (VRML1FILE)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)

Of course, when I execute the viewer with /vis/open OGL, the terminal responds that I do not have an OGL driver. I can execute the other drivers but I would like to see the geometry and track interactively. So, my focus is on the OpenGL driver.
In other topics of this forum, I saw that people have the following additional drivers and I believe I have to get those drivers to be able to use the OpenGL visualization on windows.

OpenGLImmediateQt (OGLIQt, OGLI)
OpenGLStoredQt (OGLSQt, OGL, OGLS)
OpenGLImmediateXm (OGLIXm, OGLIQt_FALLBACK)
OpenGLStoredXm (OGLSXm, OGLSQt_FALLBACK)
OpenGLImmediateX (OGLIX, OGLIQt_FALLBACK, OGLIXm_FALLBACK)
OpenGLStoredX (OGLSX, OGLSQt_FALLBACK, OGLSXm_FALLBACK)
RayTracerX (RayTracerX)

But I do not see those drivers in my geant4 session.
Could you please let me know what I missed in order to be able to use the visualization interactively because for now, the execution of my code looks like the picture below without any viewer?


Thanks a lot in advance for your precious help.

Dear all,
Strange. I also seem having the same issue above. Did anyone manage to successfully link OGL driver to Geant4 on Windows OS?

Thanks for your help.
Nabil

Dear G4 team,
I have some more information to provide now.
I observed that when I compile the example B1 with CMAKE, the openGL drivers are available and I can access the interactive viewer.
However, when the compilation is performed with QtCreator using qmake and a .pro file, they are not available.
The .pro file I did is the following:

CONFIG += c++14
LANGUAGE = C++

win32: GEANTSYS = “C:\G4.11_x86”

win32: INCLUDEPATH += $${GEANTSYS}/include/Geant4
win32: DEPENDPATH += $${GEANTSYS}/include/Geant4
win32: INCLUDEPATH += $${GEANTSYS}/include
win32: DEPENDPATH += $${GEANTSYS}/include
win32: INCLUDEPATH += $${GEANTSYS}/lib
win32: DEPENDPATH += $${GEANTSYS}/lib
win32: INCLUDEPATH += $${GEANTSYS}/bin
win32: DEPENDPATH += $${GEANTSYS}/bin
win32: LIBS += -L$${GEANTSYS}/lib -lG4analysis
win32: LIBS += -L$${GEANTSYS}/lib -lG4clhep
win32: LIBS += -L$${GEANTSYS}/lib -lG4digits_hits
win32: LIBS += -L$${GEANTSYS}/lib -lG4error_propagation
win32: LIBS += -L$${GEANTSYS}/lib -lG4event
win32: LIBS += -L$${GEANTSYS}/lib -lG4expat
win32: LIBS += -L$${GEANTSYS}/lib -lG4FR
win32: LIBS += -L$${GEANTSYS}/lib -lG4geometry
win32: LIBS += -L$${GEANTSYS}/lib -lG4gl2ps
win32: LIBS += -L$${GEANTSYS}/lib -lG4global
win32: LIBS += -L$${GEANTSYS}/lib -lG4GMocren
win32: LIBS += -L$${GEANTSYS}/lib -lG4graphics_reps
win32: LIBS += -L$${GEANTSYS}/lib -lG4intercoms
win32: LIBS += -L$${GEANTSYS}/lib -lG4interfaces
win32: LIBS += -L$${GEANTSYS}/lib -lG4materials
win32: LIBS += -L$${GEANTSYS}/lib -lG4modeling
win32: LIBS += -L$${GEANTSYS}/lib -lG4OpenGL
win32: LIBS += -L$${GEANTSYS}/lib -lG4parmodels
win32: LIBS += -L$${GEANTSYS}/lib -lG4particles
win32: LIBS += -L$${GEANTSYS}/lib -lG4persistency
win32: LIBS += -L$${GEANTSYS}/lib -lG4physicslists
win32: LIBS += -L$${GEANTSYS}/lib -lG4processes
win32: LIBS += -L$${GEANTSYS}/lib -lG4ptl
win32: LIBS += -L$${GEANTSYS}/lib -lG4RayTracer
win32: LIBS += -L$${GEANTSYS}/lib -lG4readout
win32: LIBS += -L$${GEANTSYS}/lib -lG4run
win32: LIBS += -L$${GEANTSYS}/lib -lG4tasking
win32: LIBS += -L$${GEANTSYS}/lib -lG4track
win32: LIBS += -L$${GEANTSYS}/lib -lG4tracking
win32: LIBS += -L$${GEANTSYS}/lib -lG4Tree
win32: LIBS += -L$${GEANTSYS}/lib -lG4vis_management
win32: LIBS += -L$${GEANTSYS}/lib -lG4visHepRep
win32: LIBS += -L$${GEANTSYS}/lib -lG4VRML
win32: LIBS += -L$${GEANTSYS}/lib -lG4zlib
win32: LIBS += -L$${GEANTSYS}/lib -lG4visQt3D
win32: LIBS += -L$${GEANTSYS}/lib -lG4Tools

INCLUDEPATH += include/
INCLUDEPATH += include/

HEADERS +=
include/B1ActionInitialization.hh
include/B1DetectorConstruction.hh
include/B1EventAction.hh
include/B1PrimaryGeneratorAction.hh
include/B1RunAction.hh
include/B1SteppingAction.hh

SOURCES +=
exampleB1.cc
src/B1ActionInitialization.cc
src/B1DetectorConstruction.cc
src/B1EventAction.cc
src/B1PrimaryGeneratorAction.cc
src/B1RunAction.cc
src/B1SteppingAction.cc

Any idea of why Qt does not link openGL?

In the CMakeLists, there is the following option that I do not know how to activate in the .pro file:

option(WITH_GEANT4_UIVIS “Build example with Geant4 UI and Vis drivers” ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()

I found the following options to activate in the .pro file from GEANT4:

-DG4INTY_USE_QT
-DG4UI_USE_QT
-DG4UI_USE_WIN32
-DG4VIS_USE_OPENGL
-DG4VIS_USE_OPENGLQT
-DG4VIS_USE_OPENGLWT
-DG4VIS_USE_OPENGLWIN32
-DG4VIS_USE_QT3D
-DG4VIS_USE_WIN32
-DG4VERBOSE

Activating them solved the problem. However, could someone kindly let me know what are each of them related to?
Thanks a lot

Hi

I’m not familiar with Windows, but those look like compiler flags (CXXFLAGS). You should not have to set them yourself. They should be set by cmake by setting cmake options

-DGEANT4_USE_OPENGL_WIN32
-DGEANT4_USE_QT

See Installation Guide, Building and Installing from Source — Geant4 Installation Guide 10.7 documentation. Note that, as it says, you may also have to set
-DCMAKE_PREFIX_PATH

If this is not the case for a Windows Installation, then someone with Windows experience needs to look at this.

Cheers
John

Thank you John, the problem was solved by adding in the qt .pro file the following flags for exampleB1 compilation:

-DG4INTY_USE_QT
-DG4UI_USE_QT
-DG4UI_USE_WIN32
-DG4VIS_USE_OPENGL
-DG4VIS_USE_OPENGLQT
-DG4VIS_USE_OPENGLWT
-DG4VIS_USE_OPENGLWIN32
-DG4VIS_USE_QT3D
-DG4VIS_USE_WIN32
-DG4VERBOSE

However, I am not sure what they activate. I understand that the G4VIS_USE_XXX activate the drivers for the vizualization. But it is not clear to me what the G4UI_USE_XXX do especially that if I activate the G4UI_USE_WIN32 the application still loads the G4UI_USE_QT. As well I do not understand what is done by G4INTY_USE_QT and G4VERBOSE.
Thanks

Hi

I don’t they “activate” anything. They are C-pre-processor flags that are used to include (or not) pieces of code depending on your cmake options. The user him/herself should not normally set/use them.

John

Just to note that the issue here is that the -D options are provided to application code automatically when using CMake or the deprecated GNUmake build systems, but not for any others (like QtCreator here). So in this case, adding the -D flags to your .pro file is correct.

The G4INTY/UI_... flags are needed due to these being needed in the UI headers to make these available. It should be possible to remove -DG4VERBOSE as that’s hardcoded in the configuration now.

Thanks, Ben. That clarifies.

John

Thanks both of you for your help.
I have a last question:
How can I avoid the following windows to popup when I start my G4 windows application

I think that’s fixed in the next release. Sorry.