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