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: G4OpenGLImmediateXmViewer.cc,v 1.8 2003/06/10 17:13:33 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-05-02-patch-01 $ 27 // 26 // 28 // 27 // 29 // Andrew Walkden 10th February 1997 28 // Andrew Walkden 10th February 1997 30 // Class G4OpenGLImmediateXmViewer : a class d 29 // Class G4OpenGLImmediateXmViewer : a class derived from G4OpenGLXmViewer 31 // and G4O 30 // and G4OpenGLImmediateViewer. 32 31 >> 32 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER >> 33 33 #include "G4OpenGLImmediateXmViewer.hh" 34 #include "G4OpenGLImmediateXmViewer.hh" 34 #include "G4OpenGLImmediateSceneHandler.hh" << 35 >> 36 #include <GL/gl.h> 35 37 36 #include "G4ios.hh" 38 #include "G4ios.hh" 37 #include "G4Threading.hh" << 38 39 39 G4OpenGLImmediateXmViewer:: 40 G4OpenGLImmediateXmViewer:: 40 G4OpenGLImmediateXmViewer(G4OpenGLImmediateSce << 41 G4OpenGLImmediateXmViewer(G4OpenGLImmediateSceneHandler& scene, 41 const G4String& name 42 const G4String& name) 42 : G4VViewer (sceneHandler, sceneHandler.Incre << 43 : G4VViewer (scene, scene.IncrementViewCount (), name), 43 G4OpenGLViewer (sceneHandler), << 44 G4OpenGLViewer (scene), 44 G4OpenGLXmViewer (sceneHandler), << 45 G4OpenGLXmViewer (scene), 45 G4OpenGLImmediateViewer (sceneHandler) << 46 G4OpenGLImmediateViewer (scene) 46 { 47 { 47 if (fViewId < 0) return; // In case error i 48 if (fViewId < 0) return; // In case error in base class instantiation. 48 49 49 // ensure a suitable window was found 50 // ensure a suitable window was found 50 if (!vi_immediate) { 51 if (!vi_immediate) { 51 G4cerr << "G4OpenGLImmediateXmViewer::G4Op 52 G4cerr << "G4OpenGLImmediateXmViewer::G4OpenGLImmediateXmViewer -" 52 " G4OpenGLXmViewer couldn't get a visual 53 " G4OpenGLXmViewer couldn't get a visual." << G4endl; 53 fViewId = -1; // This flags an error. 54 fViewId = -1; // This flags an error. 54 return; 55 return; 55 } 56 } 56 } 57 } 57 58 58 G4OpenGLImmediateXmViewer::~G4OpenGLImmediateX 59 G4OpenGLImmediateXmViewer::~G4OpenGLImmediateXmViewer () {} 59 60 60 void G4OpenGLImmediateXmViewer::Initialise () 61 void G4OpenGLImmediateXmViewer::Initialise () { 61 62 62 CreateGLXContext (vi_immediate); 63 CreateGLXContext (vi_immediate); >> 64 63 CreateMainWindow (); 65 CreateMainWindow (); 64 CreateFontLists (); << 65 66 66 InitializeGLView (); 67 InitializeGLView (); 67 68 >> 69 // clear the buffers and window. >> 70 ClearView (); >> 71 FinishView (); >> 72 >> 73 glDepthFunc (GL_LEQUAL); >> 74 glDepthMask (GL_TRUE); >> 75 >> 76 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); >> 77 glLineWidth (1.0); >> 78 >> 79 glEnable (GL_BLEND); >> 80 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); >> 81 glShadeModel (GL_FLAT); >> 82 >> 83 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! >> 84 //The following code was in the constructor and found not to work for >> 85 //the reasons below. It was moved to DrawView(), but has now been moved >> 86 //to Initialise(). >> 87 //The following code is useless in its current position, as the >> 88 //G4OpenGLXmViewer constructor gets called *after* it, and hence sets >> 89 //doublebuffer to true or false there, after our little test to correct >> 90 //it in the case of a double buffer being got for an immediate view. >> 91 //Hence, code moved to DrawView. >> 92 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! >> 93 68 // If a double buffer context has been force 94 // If a double buffer context has been forced upon us, ignore the 69 // back buffer for this OpenGLImmediate view 95 // back buffer for this OpenGLImmediate view. 70 glDrawBuffer (GL_FRONT); << 96 if (doublebuffer) { >> 97 doublebuffer = false; >> 98 glDrawBuffer (GL_FRONT); >> 99 } 71 } 100 } 72 101 73 void G4OpenGLImmediateXmViewer::DrawView () { 102 void G4OpenGLImmediateXmViewer::DrawView () { 74 103 >> 104 if (white_background == true) { >> 105 glClearColor (1., 1., 1., 1.); >> 106 } else { >> 107 glClearColor (0., 0., 0., 1.); >> 108 } >> 109 glClearDepth (1.0); >> 110 75 G4ViewParameters::DrawingStyle style = GetVi 111 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); 76 112 77 #ifdef G4DEBUG_VIS_OGL << 113 //Make sure current viewer is attached and clean... 78 printf("G4OpenGLImmediateXmViewer::DrawView << 114 glXMakeCurrent (dpy, win, cx); 79 #endif << 115 glViewport (0, 0, WinSize_x, WinSize_y); >> 116 ClearView (); 80 117 81 if(style!=G4ViewParameters::hlr && 118 if(style!=G4ViewParameters::hlr && 82 haloing_enabled) { 119 haloing_enabled) { 83 120 84 HaloingFirstPass (); 121 HaloingFirstPass (); 85 NeedKernelVisit (); 122 NeedKernelVisit (); 86 #ifdef G4DEBUG_VIS_OGL << 87 printf("G4OpenGLImmediateXmViewer::DrawView << 88 #endif << 89 ProcessView (); 123 ProcessView (); 90 glFlush (); 124 glFlush (); 91 125 92 HaloingSecondPass (); 126 HaloingSecondPass (); 93 127 94 } 128 } 95 129 96 #ifdef G4DEBUG_VIS_OGL << 97 printf("G4OpenGLImmediateXmViewer::DrawView << 98 #endif << 99 NeedKernelVisit (); // Always need to visit 130 NeedKernelVisit (); // Always need to visit G4 kernel. 100 ProcessView (); 131 ProcessView (); 101 FinishView (); 132 FinishView (); 102 133 103 } 134 } 104 135 105 void G4OpenGLImmediateXmViewer::FinishView () << 106 #ifdef G4DEBUG_VIS_OGL << 107 printf("G4OpenGLImmediateXmViewer::FinishVie << 108 #endif 136 #endif 109 // glXWaitGL (); //Wait for effects of all pr << 110 //be propagated before progres << 111 // JA: Commented out July 2021 - slows renderi << 112 // don't see any adverse effects. << 113 glFlush (); << 114 } << 115 137