ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLStoredWin32Viewer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4OpenGLStoredWin32Viewer.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 // Class G4OpenGLStoredWin32Viewer : a class derived from G4OpenGLWin32Viewer and
30 // G4OpenGLStoredViewer.
31 
32 #ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
33 
35 
37 
38 #include "G4ios.hh"
39 
40 G4OpenGLStoredWin32Viewer::G4OpenGLStoredWin32Viewer
41 (G4OpenGLStoredSceneHandler& sceneHandler,
42  const G4String& name):
43 G4OpenGLViewer (sceneHandler),
44 G4OpenGLWin32Viewer (sceneHandler),
45 G4OpenGLStoredViewer (sceneHandler),
46 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name) {
47 
48  if (fViewId < 0) return; // In case error in base class instantiation.
49 }
50 
51 void G4OpenGLStoredWin32Viewer::Initialise () {
52 
53  //Check that G4OpenGLWin32Viewer got a double buffered colour visual
54 
55  CreateGLWin32Context ();
56  CreateMainWindow ();
57  CreateFontLists ();
58 
59 // clear the buffers and window.
60  ClearView ();
61  FinishView ();
62 
63  glDepthFunc (GL_LEQUAL);
64  glDepthMask (GL_TRUE);
65 }
66 
67 void G4OpenGLStoredWin32Viewer::DrawView () {
68 
69  glViewport (0, 0, getWinWidth(), getWinHeight());
70 
71  G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
72 
73  //See if things have changed from last time and remake if necessary...
74  // The fNeedKernelVisit flag might have been set by the user in
75  // /vis/viewer/rebuild, but if not, make decision and set flag only
76  // if necessary...
77  if (!fNeedKernelVisit) KernelVisitDecision ();
78  G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
79  ProcessView ();
80 
81  if(style!=G4ViewParameters::hlr &&
82  haloing_enabled) {
83 
84  HaloingFirstPass ();
85  DrawDisplayLists ();
86  glFlush ();
87 
88  HaloingSecondPass ();
89 
90  DrawDisplayLists ();
91  FinishView ();
92 
93  } else {
94 
95  // If kernel visit was needed, drawing and FinishView will already
96  // have been done, so...
97  if (!kernelVisitWasNeeded) {
98  DrawDisplayLists ();
99  FinishView ();
100  } else {
101  // However, union cutaways are implemented in DrawDisplayLists, so make
102  // an extra pass...
103  if (fVP.IsCutaway() &&
104  fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
105  ClearView();
106  DrawDisplayLists ();
107  FinishView ();
108  } else { // ADD TO AVOID KernelVisit=1 and nothing to display
109  DrawDisplayLists ();
110  FinishView ();
111  }
112  }
113  }
114 }
115 
117 void G4OpenGLStoredWin32Viewer::FinishView (
118 )
119 
120 
121 {
122  if(!fHDC) return;
123 
124  glFlush ();
125  GLint renderMode;
126  glGetIntegerv(GL_RENDER_MODE, &renderMode);
127  if (renderMode == GL_RENDER) ::SwapBuffers(fHDC);
128 
129  // Empty the Windows message queue :
130  MSG event;
131  while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
132  ::TranslateMessage(&event);
133  ::DispatchMessage (&event);
134  }
135 }
136 
137 #endif