G4OpenGLImmediateXViewer.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  7th February 1997
00031 // Class G4OpenGLImmediateXViewer : a class derived from G4OpenGLXViewer and
00032 //                                G4OpenGLImmediateViewer.
00033 
00034 #ifdef G4VIS_BUILD_OPENGLX_DRIVER
00035 
00036 #include "G4OpenGLImmediateXViewer.hh"
00037 #include "G4OpenGLImmediateSceneHandler.hh"
00038 
00039 #include "G4ios.hh"
00040 
00041 G4OpenGLImmediateXViewer::
00042 G4OpenGLImmediateXViewer (G4OpenGLImmediateSceneHandler& sceneHandler,
00043                           const G4String&  name)
00044  : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
00045    G4OpenGLViewer (sceneHandler),
00046    G4OpenGLXViewer (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 << "G4OpenGLImmediateXViewer::G4OpenGLImmediateXViewer -"
00054       " G4OpenGLXViewer couldn't get a visual." << G4endl;  
00055     fViewId = -1;  // This flags an error.
00056     return;
00057   }
00058 }
00059 
00060 G4OpenGLImmediateXViewer::~G4OpenGLImmediateXViewer () {}
00061 
00062 void G4OpenGLImmediateXViewer::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   glDepthFunc (GL_LEQUAL);
00075   glDepthMask (GL_TRUE);
00076 }
00077 
00078 void G4OpenGLImmediateXViewer::DrawView () {
00079 
00080   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
00081 
00082   //Make sure current viewer is attached and clean...
00083   glXMakeCurrent (dpy, win, cx);
00084 
00085   if(style!=G4ViewParameters::hlr &&
00086      haloing_enabled) {
00087 
00088     HaloingFirstPass ();
00089     NeedKernelVisit ();
00090     ProcessView ();
00091     glFlush ();
00092 
00093     HaloingSecondPass ();
00094 
00095   }
00096 
00097   NeedKernelVisit ();  // Always need to visit G4 kernel.
00098   ProcessView ();
00099   FinishView ();
00100 
00101 }
00102 
00103 void G4OpenGLImmediateXViewer::FinishView () {
00104   glXWaitGL (); //Wait for effects of all previous OpenGL commands to
00105                 //be propogated before progressing.
00106   glFlush ();
00107 }
00108 
00109 #endif

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