OpenGL logo
Geant4 Visualization Tutorial using the OpenGL Event Display


This tutorial is designed for anyone who wants to learn OpenGL Visualization for Geant4.

This tutorial can be used on its own, but gives the most comprehensive introduction to Geant4 visualization when used as part of the following full set of documents:

While some Geant4 visualization drivers are always included by default in your Geant4 build (because they require no external libraries), OpenGL is not part of the default set. You have to specifically ask to include OpenGL.

If you followed the Geant4 Installation Guides referenced above, you used the Geant4 Configuration script and said "yes" to including OpenGL.

If you are following some other set of build instructions, refer to them for how to include OpenGL. This may involve explicitly setting environment variables.

OpenGL Modes

Geant4 has several different modes in which it can run OpenGL. We will just show you one mode, the easiest to get started, but you may later want to experiment with the other modes. These other modes control whether or not to store information into an intermediate memory area ("Immediate Mode" versus "Display List Mode") and to optionally wrap the OpenGL window in a Qt or Motif user interface.


You cannot run Geant4 with OpenGL if you are also running with the analysis tool JAIDA/JAS.

Running Geant4 with OpenGL

Since OpenGL runs directly from Geant4, you just start Geant4 and then issue a few visualization commands.

The Installation Guides listed above already showed you how to start Geant4 with OpenGL included. They then showed you how to use a few simple commands to do the most minimal visualization of some detector geometry and some event data. This guide will show you some additional commands.

Recap of Geant4 Commands Used in this Tutorial

If you need to quickly get back to where you were in the tutorial, it may be helpful to cut and paste a set of commands from this list:
/vis/open OGL
/vis/viewer/set/viewpointThetaPhi 70 20
/vis/viewer/zoom 2
/vis/viewer/set/viewpointThetaPhi 40 40
/vis/viewer/panTo -5 -1
/vis/viewer/zoom 4.
/run/beamOn 1
/vis/viewer/set/style surface
/run/beamOn 1
/vis/viewer/set/style wireframe
/run/beamOn 1

Further Resources

Documents in this Visualization Tutorial Set:

Other Resources:

Joseph Perl

30 December 2010