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.7 2003/06/10 17:13:34 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-05-02-patch-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& scene, 40 const G4String& name): 39 const G4String& name): 41 G4OpenGLViewer (sceneHandler), << 40 G4OpenGLViewer (scene), 42 G4OpenGLWin32Viewer (sceneHandler), << 41 G4OpenGLWin32Viewer (scene), 43 G4OpenGLStoredViewer (sceneHandler), << 42 G4OpenGLStoredViewer (scene), 44 G4VViewer (sceneHandler, sceneHandler.Incremen << 43 G4VViewer (scene, scene.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 (); << 56 54 57 // clear the buffers and window. 55 // clear the buffers and window. 58 ClearView (); 56 ClearView (); 59 FinishView (); 57 FinishView (); 60 58 61 glDepthFunc (GL_LEQUAL); 59 glDepthFunc (GL_LEQUAL); 62 glDepthMask (GL_TRUE); 60 glDepthMask (GL_TRUE); 63 } 61 } 64 62 65 void G4OpenGLStoredWin32Viewer::DrawView () { 63 void G4OpenGLStoredWin32Viewer::DrawView () { 66 64 67 glViewport (0, 0, getWinWidth(), getWinHeigh << 65 if (white_background == true) { >> 66 glClearColor (1., 1., 1., 1.); >> 67 } else { >> 68 glClearColor (0., 0., 0., 1.); >> 69 } >> 70 >> 71 //Make sure current viewer is attached and clean... >> 72 //Win32 version needed >> 73 // glXMakeCurrent (dpy, win, cx); >> 74 glViewport (0, 0, WinSize_x, WinSize_y); >> 75 ClearView (); 68 76 69 G4ViewParameters::DrawingStyle style = GetVi 77 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); 70 78 71 //See if things have changed from last time 79 //See if things have changed from last time and remake if necessary... 72 // The fNeedKernelVisit flag might have been << 80 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 (); 81 ProcessView (); 79 82 80 if(style!=G4ViewParameters::hlr && 83 if(style!=G4ViewParameters::hlr && 81 haloing_enabled) { 84 haloing_enabled) { 82 85 83 HaloingFirstPass (); 86 HaloingFirstPass (); 84 DrawDisplayLists (); 87 DrawDisplayLists (); 85 glFlush (); 88 glFlush (); 86 89 87 HaloingSecondPass (); 90 HaloingSecondPass (); 88 91 89 DrawDisplayLists (); << 92 } 90 FinishView (); << 91 93 92 } else { << 94 DrawDisplayLists (); 93 95 94 // If kernel visit was needed, drawing and << 96 FinishView (); 95 // have been done, so... << 97 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 } 98 } 114 99 115 ////////////////////////////////////////////// << 100 #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 101