G4OpenGLStoredWin32Viewer.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 // Class G4OpenGLStoredWin32Viewer : a class derived from G4OpenGLWin32Viewer and
00031 //                             G4OpenGLStoredViewer.
00032 
00033 #ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
00034 
00035 #include "G4OpenGLStoredWin32Viewer.hh"
00036 
00037 #include "G4OpenGLStoredSceneHandler.hh"
00038 
00039 #include "G4ios.hh"
00040 
00041 G4OpenGLStoredWin32Viewer::G4OpenGLStoredWin32Viewer
00042 (G4OpenGLStoredSceneHandler& sceneHandler,
00043  const G4String&  name):
00044 G4OpenGLViewer (sceneHandler),
00045 G4OpenGLWin32Viewer (sceneHandler),
00046 G4OpenGLStoredViewer (sceneHandler),
00047 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name) {
00048 
00049   if (fViewId < 0) return;  // In case error in base class instantiation.
00050 }
00051 
00052 void G4OpenGLStoredWin32Viewer::Initialise () {
00053 
00054   //Check that G4OpenGLWin32Viewer got a double buffered colour visual
00055 
00056   CreateGLWin32Context ();
00057   CreateMainWindow ();
00058   CreateFontLists ();
00059 
00060 // clear the buffers and window.
00061   ClearView ();
00062   FinishView ();
00063 
00064   glDepthFunc (GL_LEQUAL);
00065   glDepthMask (GL_TRUE);
00066 }
00067 
00068 void G4OpenGLStoredWin32Viewer::DrawView () {
00069 
00070   //Make sure current viewer is attached and clean...
00071   //Win32 version needed
00072   //  glXMakeCurrent (dpy, win, cx);
00073   glViewport (0, 0, getWinWidth(), getWinHeight());
00074 
00075   G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
00076 
00077   //See if things have changed from last time and remake if necessary...
00078   // The fNeedKernelVisit flag might have been set by the user in
00079   // /vis/viewer/rebuild, but if not, make decision and set flag only
00080   // if necessary...
00081   if (!fNeedKernelVisit) KernelVisitDecision ();
00082   G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
00083   ProcessView ();
00084 
00085   if(style!=G4ViewParameters::hlr &&
00086      haloing_enabled) {
00087 
00088     HaloingFirstPass ();
00089     DrawDisplayLists ();
00090     glFlush ();
00091 
00092     HaloingSecondPass ();
00093 
00094     DrawDisplayLists ();
00095     FinishView ();
00096 
00097   } else {
00098 
00099     // If kernel visit was needed, drawing and FinishView will already
00100     // have been done, so...
00101     if (!kernelVisitWasNeeded) {
00102       DrawDisplayLists ();
00103       FinishView ();
00104     } else {
00105     // However, union cutaways are implemented in DrawDisplayLists, so make
00106     // an extra pass...
00107       if (fVP.IsCutaway() &&
00108           fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
00109         ClearView();
00110         DrawDisplayLists ();
00111         FinishView ();
00112       } else { // ADD TO AVOID KernelVisit=1 and nothing to display
00113         DrawDisplayLists ();
00114         FinishView ();
00115       }
00116     }
00117   }
00118 }
00119 
00121 void G4OpenGLStoredWin32Viewer::FinishView (
00122 ) 
00123 
00124 
00125 {
00126   if(!fHDC) return;
00127 
00128   glFlush ();
00129   GLint renderMode;
00130   glGetIntegerv(GL_RENDER_MODE, &renderMode);
00131   if (renderMode == GL_RENDER) ::SwapBuffers(fHDC);
00132 
00133   // Empty the Windows message queue :
00134   MSG event;
00135   while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
00136     ::TranslateMessage(&event);
00137     ::DispatchMessage (&event);
00138   }
00139 }
00140 
00141 #endif

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