G4OpenGLImmediateXmViewer.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // Andrew Walkden  10th February 1997
00031 // Class G4OpenGLImmediateXmViewer : a class derived from G4OpenGLXmViewer
00032 //                                     and G4OpenGLImmediateViewer.
00033 
00034 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
00035 
00036 #include "G4OpenGLImmediateXmViewer.hh"
00037 #include "G4OpenGLImmediateSceneHandler.hh"
00038 
00039 #include "G4ios.hh"
00040 
00041 G4OpenGLImmediateXmViewer::
00042 G4OpenGLImmediateXmViewer(G4OpenGLImmediateSceneHandler& sceneHandler,
00043                           const G4String& name)
00044  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
00045    G4OpenGLViewer (sceneHandler),
00046    G4OpenGLXmViewer (sceneHandler),
00047    G4OpenGLImmediateViewer (sceneHandler)
00048 {
00049   if (fViewId < 0) return;  // In case error in base class instantiation.
00050 
00051 // ensure a suitable window was found
00052   if (!vi_immediate) {
00053     G4cerr << "G4OpenGLImmediateXmViewer::G4OpenGLImmediateXmViewer -"
00054       " G4OpenGLXmViewer couldn't get a visual." << G4endl;  
00055     fViewId = -1;  // This flags an error.
00056     return;
00057   }
00058 }
00059 
00060 G4OpenGLImmediateXmViewer::~G4OpenGLImmediateXmViewer () {}
00061 
00062 void G4OpenGLImmediateXmViewer::Initialise () {
00063 
00064   CreateGLXContext (vi_immediate);
00065   CreateMainWindow ();
00066   CreateFontLists ();
00067 
00068   InitializeGLView ();
00069 
00070   // If a double buffer context has been forced upon us, ignore the
00071   // back buffer for this OpenGLImmediate view.
00072   glDrawBuffer (GL_FRONT);
00073 }
00074 
00075 void G4OpenGLImmediateXmViewer::DrawView () {
00076 
00077   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
00078 
00079 #ifdef G4DEBUG_VIS_OGL
00080   printf("G4OpenGLImmediateXmViewer::DrawView : \n");
00081 #endif
00082 
00083   //Make sure current viewer is attached and clean...
00084   glXMakeCurrent (dpy, win, cx);
00085 
00086   if(style!=G4ViewParameters::hlr &&
00087      haloing_enabled) {
00088 
00089     HaloingFirstPass ();
00090     NeedKernelVisit ();
00091 #ifdef G4DEBUG_VIS_OGL
00092   printf("G4OpenGLImmediateXmViewer::DrawView : change param\n");
00093 #endif
00094     ProcessView ();
00095     glFlush ();
00096 
00097     HaloingSecondPass ();
00098 
00099   }
00100 
00101 #ifdef G4DEBUG_VIS_OGL
00102   printf("G4OpenGLImmediateXmViewer::DrawView : need Kernel/Process/Finish\n");
00103 #endif
00104   NeedKernelVisit ();  // Always need to visit G4 kernel.
00105   ProcessView ();
00106   FinishView ();
00107 
00108 }
00109 
00110 void G4OpenGLImmediateXmViewer::FinishView () {
00111 #ifdef G4DEBUG_VIS_OGL
00112   printf("G4OpenGLImmediateXmViewer::FinishView : \n");
00113 #endif
00114   glXWaitGL (); //Wait for effects of all previous OpenGL commands to
00115                 //be propogated before progressing.
00116   glFlush ();
00117 }
00118 
00119 #endif

Generated on Mon May 27 17:49:09 2013 for Geant4 by  doxygen 1.4.7