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.6 2002/10/16 10:44:16 johna Exp $ >> 25 // GEANT4 tag $Name: geant4-05-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 >> 31 #ifdef G4VIS_BUILD_OPENGLWIN32_DRIVER >> 32 32 #include "G4OpenGLStoredWin32Viewer.hh" 33 #include "G4OpenGLStoredWin32Viewer.hh" 33 34 34 #include "G4OpenGLStoredSceneHandler.hh" << 35 #include <GL/gl.h> 35 36 36 #include "G4ios.hh" 37 #include "G4ios.hh" 37 38 38 G4OpenGLStoredWin32Viewer::G4OpenGLStoredWin32 39 G4OpenGLStoredWin32Viewer::G4OpenGLStoredWin32Viewer 39 (G4OpenGLStoredSceneHandler& sceneHandler, << 40 (G4OpenGLStoredSceneHandler& scene, 40 const G4String& name): 41 const G4String& name): 41 G4OpenGLViewer (sceneHandler), << 42 G4OpenGLViewer (scene), 42 G4OpenGLWin32Viewer (sceneHandler), << 43 G4OpenGLWin32Viewer (scene), 43 G4OpenGLStoredViewer (sceneHandler), << 44 G4OpenGLStoredViewer (scene), 44 G4VViewer (sceneHandler, sceneHandler.Incremen << 45 G4VViewer (scene, scene.IncrementViewCount (), name) { 45 46 46 if (fViewId < 0) return; // In case error i 47 if (fViewId < 0) return; // In case error in base class instantiation. 47 } 48 } 48 49 49 void G4OpenGLStoredWin32Viewer::Initialise () 50 void G4OpenGLStoredWin32Viewer::Initialise () { 50 51 51 //Check that G4OpenGLWin32Viewer got a doubl 52 //Check that G4OpenGLWin32Viewer got a double buffered colour visual 52 53 53 CreateGLWin32Context (); 54 CreateGLWin32Context (); 54 CreateMainWindow (); 55 CreateMainWindow (); 55 CreateFontLists (); << 56 56 57 // clear the buffers and window. 57 // clear the buffers and window. 58 ClearView (); 58 ClearView (); 59 FinishView (); 59 FinishView (); 60 60 61 glDepthFunc (GL_LEQUAL); 61 glDepthFunc (GL_LEQUAL); 62 glDepthMask (GL_TRUE); 62 glDepthMask (GL_TRUE); 63 } 63 } 64 64 65 void G4OpenGLStoredWin32Viewer::DrawView () { 65 void G4OpenGLStoredWin32Viewer::DrawView () { 66 66 67 glViewport (0, 0, getWinWidth(), getWinHeigh << 67 if (white_background == true) { >> 68 glClearColor (1., 1., 1., 1.); >> 69 } else { >> 70 glClearColor (0., 0., 0., 1.); >> 71 } >> 72 >> 73 //Make sure current viewer is attached and clean... >> 74 //Win32 version needed >> 75 // glXMakeCurrent (dpy, win, cx); >> 76 glViewport (0, 0, WinSize_x, WinSize_y); >> 77 ClearView (); 68 78 69 G4ViewParameters::DrawingStyle style = GetVi 79 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); 70 80 71 //See if things have changed from last time 81 //See if things have changed from last time and remake if necessary... 72 // The fNeedKernelVisit flag might have been << 82 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 (); 83 ProcessView (); 79 84 80 if(style!=G4ViewParameters::hlr && 85 if(style!=G4ViewParameters::hlr && 81 haloing_enabled) { 86 haloing_enabled) { 82 87 83 HaloingFirstPass (); 88 HaloingFirstPass (); 84 DrawDisplayLists (); 89 DrawDisplayLists (); 85 glFlush (); 90 glFlush (); 86 91 87 HaloingSecondPass (); 92 HaloingSecondPass (); 88 93 89 DrawDisplayLists (); << 94 } 90 FinishView (); << 91 95 92 } else { << 96 DrawDisplayLists (); 93 97 94 // If kernel visit was needed, drawing and << 98 FinishView (); 95 // have been done, so... << 99 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 } 100 } 114 101 115 ////////////////////////////////////////////// << 102 #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 103