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