source: trunk/geant4/visualization/OpenGL/src/G4OpenGLStoredXViewer.cc@ 562

Last change on this file since 562 was 529, checked in by garnier, 18 years ago

r658@mac-90108: laurentgarnier | 2007-06-25 12:02:16 +0200
import de visualisation

  • Property svn:mime-type set to text/cpp
File size: 4.4 KB
RevLine 
[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//
27// $Id: G4OpenGLStoredXViewer.cc,v 1.21 2006/09/04 12:07:59 allison Exp $
28// GEANT4 tag $Name: geant4-08-02-patch-01 $
29//
30//
31// Andrew Walkden 7th February 1997
32// Class G4OpenGLStoredXViewer : a class derived from G4OpenGLXViewer and
33// G4OpenGLStoredViewer.
34
35#ifdef G4VIS_BUILD_OPENGLX_DRIVER
36
37#include "G4OpenGLStoredXViewer.hh"
38
39#include "G4ios.hh"
40
41G4OpenGLStoredXViewer::
42G4OpenGLStoredXViewer (G4OpenGLStoredSceneHandler& sceneHandler,
43 const G4String& name)
44 : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
45 G4OpenGLViewer (sceneHandler),
46 G4OpenGLXViewer (sceneHandler),
47 G4OpenGLStoredViewer (sceneHandler)
48{
49 if (fViewId < 0) return; // In case error in base class instantiation.
50
51 if (!vi_stored) {
52 fViewId = -1; // This flags an error.
53 G4cerr << "G4OpenGLStoredXViewer::G4OpenGLStoredXViewer -"
54 " G4OpenGLXViewer couldn't get a visual." << G4endl;
55 return;
56 }
57}
58
59G4OpenGLStoredXViewer::~G4OpenGLStoredXViewer () {}
60
61void G4OpenGLStoredXViewer::Initialise () {
62
63 CreateGLXContext (vi_stored);
64 CreateMainWindow ();
65 CreateFontLists ();
66
67 InitializeGLView ();
68
69// clear the buffers and window.
70 ClearView ();
71 FinishView ();
72
73 glDepthFunc (GL_LEQUAL);
74 glDepthMask (GL_TRUE);
75}
76
77void G4OpenGLStoredXViewer::DrawView () {
78
79 //Make sure current viewer is attached and clean...
80 glXMakeCurrent (dpy, win, cx);
81 glViewport (0, 0, WinSize_x, WinSize_y);
82
83 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
84
85 //See if things have changed from last time and remake if necessary...
86 // The fNeedKernelVisit flag might have been set by the user in
87 // /vis/viewer/rebuild, but if not, make decision and set flag only
88 // if necessary...
89 if (!fNeedKernelVisit) KernelVisitDecision ();
90 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
91 ProcessView ();
92
93 if(style!=G4ViewParameters::hlr &&
94 haloing_enabled) {
95
96 HaloingFirstPass ();
97 DrawDisplayLists ();
98 glFlush ();
99
100 HaloingSecondPass ();
101
102 DrawDisplayLists ();
103 FinishView ();
104
105 } else {
106
107 // If kernel visit was needed, drawing and FinishView will already
108 // have been done, so...
109 if (!kernelVisitWasNeeded) {
110 DrawDisplayLists ();
111 FinishView ();
112 } else {
113 // However, union cutaways are implemented in DrawDisplayLists, so make
114 // an extra pass...
115 if (fVP.IsCutaway() &&
116 fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
117 ClearView();
118 DrawDisplayLists ();
119 FinishView ();
120 }
121 }
122 }
123}
124
125void G4OpenGLStoredXViewer::FinishView () {
126 glXWaitGL (); //Wait for effects of all previous OpenGL commands to
127 //be propogated before progressing.
128 glXSwapBuffers (dpy, win);
129}
130
131#endif
Note: See TracBrowser for help on using the repository browser.