[529] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
[975] | 27 | // $Id: G4OpenGLImmediateXmViewer.cc,v 1.21 2009/04/08 16:55:44 lgarnier Exp $ |
---|
[877] | 28 | // GEANT4 tag $Name: $ |
---|
[529] | 29 | // |
---|
| 30 | // |
---|
| 31 | // Andrew Walkden 10th February 1997 |
---|
| 32 | // Class G4OpenGLImmediateXmViewer : a class derived from G4OpenGLXmViewer |
---|
| 33 | // and G4OpenGLImmediateViewer. |
---|
| 34 | |
---|
| 35 | #ifdef G4VIS_BUILD_OPENGLXM_DRIVER |
---|
| 36 | |
---|
| 37 | #include "G4OpenGLImmediateXmViewer.hh" |
---|
[914] | 38 | #include "G4OpenGLImmediateSceneHandler.hh" |
---|
[980] | 39 | #include "G4StateManager.hh" |
---|
[529] | 40 | |
---|
| 41 | #include "G4ios.hh" |
---|
| 42 | |
---|
| 43 | G4OpenGLImmediateXmViewer:: |
---|
| 44 | G4OpenGLImmediateXmViewer(G4OpenGLImmediateSceneHandler& sceneHandler, |
---|
| 45 | const G4String& name) |
---|
| 46 | : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name), |
---|
| 47 | G4OpenGLViewer (sceneHandler), |
---|
| 48 | G4OpenGLXmViewer (sceneHandler), |
---|
| 49 | G4OpenGLImmediateViewer (sceneHandler) |
---|
| 50 | { |
---|
| 51 | if (fViewId < 0) return; // In case error in base class instantiation. |
---|
| 52 | |
---|
| 53 | // ensure a suitable window was found |
---|
| 54 | if (!vi_immediate) { |
---|
| 55 | G4cerr << "G4OpenGLImmediateXmViewer::G4OpenGLImmediateXmViewer -" |
---|
| 56 | " G4OpenGLXmViewer couldn't get a visual." << G4endl; |
---|
| 57 | fViewId = -1; // This flags an error. |
---|
| 58 | return; |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | G4OpenGLImmediateXmViewer::~G4OpenGLImmediateXmViewer () {} |
---|
| 63 | |
---|
| 64 | void G4OpenGLImmediateXmViewer::Initialise () { |
---|
| 65 | |
---|
| 66 | CreateGLXContext (vi_immediate); |
---|
| 67 | CreateMainWindow (); |
---|
| 68 | CreateFontLists (); |
---|
| 69 | |
---|
| 70 | InitializeGLView (); |
---|
| 71 | |
---|
| 72 | // clear the buffers and window. |
---|
| 73 | ClearView (); |
---|
| 74 | FinishView (); |
---|
| 75 | |
---|
| 76 | glDepthFunc (GL_LEQUAL); |
---|
| 77 | glDepthMask (GL_TRUE); |
---|
| 78 | |
---|
| 79 | glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
---|
| 80 | glLineWidth (1.0); |
---|
| 81 | |
---|
| 82 | glEnable (GL_BLEND); |
---|
| 83 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
---|
| 84 | |
---|
| 85 | // If a double buffer context has been forced upon us, ignore the |
---|
| 86 | // back buffer for this OpenGLImmediate view. |
---|
| 87 | glDrawBuffer (GL_FRONT); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | void G4OpenGLImmediateXmViewer::DrawView () { |
---|
| 91 | |
---|
| 92 | G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle(); |
---|
| 93 | |
---|
[948] | 94 | #ifdef G4DEBUG_VIS_OGL |
---|
| 95 | printf("G4OpenGLImmediateXmViewer::DrawView : \n"); |
---|
| 96 | #endif |
---|
| 97 | |
---|
[529] | 98 | //Make sure current viewer is attached and clean... |
---|
[975] | 99 | glXMakeCurrent (dpy, win, cx); |
---|
[529] | 100 | |
---|
| 101 | if(style!=G4ViewParameters::hlr && |
---|
| 102 | haloing_enabled) { |
---|
| 103 | |
---|
| 104 | HaloingFirstPass (); |
---|
| 105 | NeedKernelVisit (); |
---|
[948] | 106 | #ifdef G4DEBUG_VIS_OGL |
---|
| 107 | printf("G4OpenGLImmediateXmViewer::DrawView : change param\n"); |
---|
| 108 | #endif |
---|
[529] | 109 | ProcessView (); |
---|
| 110 | glFlush (); |
---|
| 111 | |
---|
| 112 | HaloingSecondPass (); |
---|
| 113 | |
---|
| 114 | } |
---|
| 115 | |
---|
[948] | 116 | #ifdef G4DEBUG_VIS_OGL |
---|
| 117 | printf("G4OpenGLImmediateXmViewer::DrawView : need Kernel/Process/Finish\n"); |
---|
| 118 | #endif |
---|
[980] | 119 | |
---|
| 120 | |
---|
[529] | 121 | NeedKernelVisit (); // Always need to visit G4 kernel. |
---|
[980] | 122 | |
---|
[529] | 123 | ProcessView (); |
---|
[980] | 124 | |
---|
[529] | 125 | FinishView (); |
---|
| 126 | |
---|
[980] | 127 | |
---|
[529] | 128 | } |
---|
| 129 | |
---|
| 130 | void G4OpenGLImmediateXmViewer::FinishView () { |
---|
[948] | 131 | #ifdef G4DEBUG_VIS_OGL |
---|
| 132 | printf("G4OpenGLImmediateXmViewer::FinishView : \n"); |
---|
| 133 | #endif |
---|
[529] | 134 | glXWaitGL (); //Wait for effects of all previous OpenGL commands to |
---|
| 135 | //be propogated before progressing. |
---|
| 136 | glFlush (); |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | #endif |
---|