Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // << 26 // 7 // >> 8 // $Id: G4OpenGLStoredWin32Viewer.cc,v 1.2 1999/12/15 14:54:08 gunter Exp $ >> 9 // GEANT4 tag $Name: geant4-01-01 $ 27 // 10 // 28 // 11 // 29 // Class G4OpenGLStoredWin32Viewer : a class d 12 // Class G4OpenGLStoredWin32Viewer : a class derived from G4OpenGLWin32Viewer and 30 // G4OpenGLStoredV 13 // G4OpenGLStoredViewer. 31 14 >> 15 #ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER >> 16 32 #include "G4OpenGLStoredWin32Viewer.hh" 17 #include "G4OpenGLStoredWin32Viewer.hh" 33 18 34 #include "G4OpenGLStoredSceneHandler.hh" << 19 #include <GL/gl.h> >> 20 #include <GL/glx.h> >> 21 #include <GL/glu.h> 35 22 36 #include "G4ios.hh" 23 #include "G4ios.hh" >> 24 #include <assert.h> >> 25 #include <unistd.h> 37 26 38 G4OpenGLStoredWin32Viewer::G4OpenGLStoredWin32 << 27 G4OpenGLStoredWin32Viewer::G4OpenGLStoredWin32Viewer (G4OpenGLStoredSceneHandler& scene): 39 (G4OpenGLStoredSceneHandler& sceneHandler, << 28 G4OpenGLViewer (scene), 40 const G4String& name): << 29 G4OpenGLWin32Viewer (scene), 41 G4OpenGLViewer (sceneHandler), << 30 G4OpenGLStoredViewer (scene), 42 G4OpenGLWin32Viewer (sceneHandler), << 31 G4VViewer (scene, scene.IncrementViewCount ()) { 43 G4OpenGLStoredViewer (sceneHandler), << 44 G4VViewer (sceneHandler, sceneHandler.Incremen << 45 32 46 if (fViewId < 0) return; // In case error i 33 if (fViewId < 0) return; // In case error in base class instantiation. 47 } << 48 << 49 void G4OpenGLStoredWin32Viewer::Initialise () << 50 34 51 //Check that G4OpenGLWin32Viewer got a doubl 35 //Check that G4OpenGLWin32Viewer got a double buffered colour visual 52 36 53 CreateGLWin32Context (); 37 CreateGLWin32Context (); 54 CreateMainWindow (); 38 CreateMainWindow (); 55 CreateFontLists (); << 56 39 57 // clear the buffers and window. 40 // clear the buffers and window. 58 ClearView (); 41 ClearView (); 59 FinishView (); 42 FinishView (); 60 43 61 glDepthFunc (GL_LEQUAL); 44 glDepthFunc (GL_LEQUAL); 62 glDepthMask (GL_TRUE); 45 glDepthMask (GL_TRUE); >> 46 63 } 47 } 64 48 65 void G4OpenGLStoredWin32Viewer::DrawView () { 49 void G4OpenGLStoredWin32Viewer::DrawView () { 66 50 67 glViewport (0, 0, getWinWidth(), getWinHeigh << 51 if (white_background == true) { >> 52 glClearColor (1., 1., 1., 1.); >> 53 } else { >> 54 glClearColor (0., 0., 0., 1.); >> 55 } >> 56 >> 57 //Make sure current viewer is attached and clean... >> 58 //Win32 version needed >> 59 // glXMakeCurrent (dpy, win, cx); >> 60 glViewport (0, 0, WinSize_x, WinSize_y); >> 61 ClearView (); 68 62 69 G4ViewParameters::DrawingStyle style = GetVi 63 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); 70 64 71 //See if things have changed from last time 65 //See if things have changed from last time and remake if necessary... 72 // The fNeedKernelVisit flag might have been << 66 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 (); 67 ProcessView (); 79 68 80 if(style!=G4ViewParameters::hlr && 69 if(style!=G4ViewParameters::hlr && 81 haloing_enabled) { 70 haloing_enabled) { 82 71 83 HaloingFirstPass (); 72 HaloingFirstPass (); 84 DrawDisplayLists (); 73 DrawDisplayLists (); 85 glFlush (); 74 glFlush (); 86 75 87 HaloingSecondPass (); 76 HaloingSecondPass (); 88 77 89 DrawDisplayLists (); << 78 } 90 FinishView (); << 91 79 92 } else { << 80 DrawDisplayLists (); 93 81 94 // If kernel visit was needed, drawing and << 82 FinishView (); 95 // have been done, so... << 83 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 } 84 } 114 85 115 ////////////////////////////////////////////// << 86 #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 87