Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLStoredWin32Viewer.cc
Go to the documentation of this file.
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 // $Id: G4OpenGLStoredWin32Viewer.cc 66373 2012-12-18 09:41:34Z gcosmo $
28 //
29 //
30 // Class G4OpenGLStoredWin32Viewer : a class derived from G4OpenGLWin32Viewer and
31 // G4OpenGLStoredViewer.
32 
33 #ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER
34 
36 
38 
39 #include "G4ios.hh"
40 
41 G4OpenGLStoredWin32Viewer::G4OpenGLStoredWin32Viewer
42 (G4OpenGLStoredSceneHandler& sceneHandler,
43  const G4String& name):
44 G4OpenGLViewer (sceneHandler),
45 G4OpenGLWin32Viewer (sceneHandler),
46 G4OpenGLStoredViewer (sceneHandler),
47 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name) {
48 
49  if (fViewId < 0) return; // In case error in base class instantiation.
50 }
51 
52 void G4OpenGLStoredWin32Viewer::Initialise () {
53 
54  //Check that G4OpenGLWin32Viewer got a double buffered colour visual
55 
56  CreateGLWin32Context ();
57  CreateMainWindow ();
58  CreateFontLists ();
59 
60 // clear the buffers and window.
61  ClearView ();
62  FinishView ();
63 
64  glDepthFunc (GL_LEQUAL);
65  glDepthMask (GL_TRUE);
66 }
67 
68 void G4OpenGLStoredWin32Viewer::DrawView () {
69 
70  //Make sure current viewer is attached and clean...
71  //Win32 version needed
72  // glXMakeCurrent (dpy, win, cx);
73  glViewport (0, 0, getWinWidth(), getWinHeight());
74 
75  G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
76 
77  //See if things have changed from last time and remake if necessary...
78  // The fNeedKernelVisit flag might have been set by the user in
79  // /vis/viewer/rebuild, but if not, make decision and set flag only
80  // if necessary...
81  if (!fNeedKernelVisit) KernelVisitDecision ();
82  G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
83  ProcessView ();
84 
85  if(style!=G4ViewParameters::hlr &&
86  haloing_enabled) {
87 
88  HaloingFirstPass ();
89  DrawDisplayLists ();
90  glFlush ();
91 
92  HaloingSecondPass ();
93 
94  DrawDisplayLists ();
95  FinishView ();
96 
97  } else {
98 
99  // If kernel visit was needed, drawing and FinishView will already
100  // have been done, so...
101  if (!kernelVisitWasNeeded) {
102  DrawDisplayLists ();
103  FinishView ();
104  } else {
105  // However, union cutaways are implemented in DrawDisplayLists, so make
106  // an extra pass...
107  if (fVP.IsCutaway() &&
108  fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
109  ClearView();
110  DrawDisplayLists ();
111  FinishView ();
112  } else { // ADD TO AVOID KernelVisit=1 and nothing to display
113  DrawDisplayLists ();
114  FinishView ();
115  }
116  }
117  }
118 }
119 
120 //////////////////////////////////////////////////////////////////////////////
121 void G4OpenGLStoredWin32Viewer::FinishView (
122 )
123 //////////////////////////////////////////////////////////////////////////////
124 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
125 {
126  if(!fHDC) return;
127 
128  glFlush ();
129  GLint renderMode;
130  glGetIntegerv(GL_RENDER_MODE, &renderMode);
131  if (renderMode == GL_RENDER) ::SwapBuffers(fHDC);
132 
133  // Empty the Windows message queue :
134  MSG event;
135  while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
136  ::TranslateMessage(&event);
137  ::DispatchMessage (&event);
138  }
139 }
140 
141 #endif
const XML_Char * name
bool G4bool
Definition: G4Types.hh:79