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