source: trunk/source/visualization/OpenGL/src/G4OpenGLStoredXmViewer.cc@ 939

Last change on this file since 939 was 938, checked in by garnier, 17 years ago

print PS marche, mais plein de msg de debug a supprimer

  • Property svn:mime-type set to text/cpp
File size: 4.9 KB
Line 
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: G4OpenGLStoredXmViewer.cc,v 1.24 2009/01/19 16:53:42 lgarnier Exp $
28// GEANT4 tag $Name: $
29//
30//
31// Andrew Walkden 10th February 1997
32// Class G4OpenGLStoredXmViewer : a class derived from G4OpenGLXmViewer
33// and G4OpenGLStoredViewer.
34
35#define G4DEBUG_VIS_OGL 1
36#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
37
38#include "G4OpenGLStoredXmViewer.hh"
39
40#include "G4ios.hh"
41
42G4OpenGLStoredXmViewer::
43G4OpenGLStoredXmViewer (G4OpenGLStoredSceneHandler& sceneHandler,
44 const G4String& name)
45 : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
46 G4OpenGLViewer (sceneHandler),
47 G4OpenGLXmViewer (sceneHandler),
48 G4OpenGLStoredViewer (sceneHandler)
49{
50
51 if (fViewId < 0) return; // In case error in base class instantiation.
52
53 if (!vi_stored) {
54 fViewId = -1; // This flags an error.
55 G4cerr << "G4OpenGLStoredXmViewer::G4OpenGLStoredXmViewer -"
56 " G4OpenGLXmViewer couldn't get a visual." << G4endl;
57 return;
58 }
59}
60
61G4OpenGLStoredXmViewer::~G4OpenGLStoredXmViewer () {}
62
63void G4OpenGLStoredXmViewer::Initialise () {
64
65 CreateGLXContext (vi_stored);
66 CreateMainWindow ();
67 CreateFontLists ();
68
69 InitializeGLView ();
70
71// clear the buffers and window.
72 ClearView ();
73 FinishView ();
74
75 glDepthFunc (GL_LEQUAL);
76 glDepthMask (GL_TRUE);
77
78 glEnable (GL_BLEND);
79 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
80
81 glDrawBuffer (GL_BACK);
82}
83
84void G4OpenGLStoredXmViewer::DrawView () {
85#ifdef G4DEBUG_VIS_OGL
86 printf("G4OpenGLStoredXmViewer::DrawView VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n");
87#endif
88
89 //Make sure current viewer is attached and clean...
90 glXMakeCurrent (dpy, win, cx);
91
92 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
93
94 //See if things have changed from last time and remake if necessary...
95 // /vis/viewer/rebuild, but if not, make decision and set flag only
96 // if necessary...
97 if (!fNeedKernelVisit) KernelVisitDecision ();
98 G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
99 ProcessView ();
100
101 if(style!=G4ViewParameters::hlr &&
102 haloing_enabled) {
103
104 HaloingFirstPass ();
105 DrawDisplayLists ();
106 glFlush ();
107
108 HaloingSecondPass ();
109
110 DrawDisplayLists ();
111 FinishView ();
112
113 } else {
114
115 // If kernel visit was needed, drawing and FinishView will already
116 // have been done, so...
117 if (!kernelVisitWasNeeded) {
118#ifdef G4DEBUG_VIS_OGL
119 printf("************************** G4OpenGLStoredXmViewer::ComputeView Don't need kernel Visit \n");
120#endif
121 DrawDisplayLists ();
122 FinishView ();
123 } else {
124#ifdef G4DEBUG_VIS_OGL
125 printf("************************** G4OpenGLStoredXmViewer::ComputeView Need kernel Visit \n");
126#endif
127 // However, union cutaways are implemented in DrawDisplayLists, so make
128 // an extra pass...
129 if (fVP.IsCutaway() &&
130 fVP.GetCutawayMode() == G4ViewParameters::cutawayUnion) {
131 ClearView();
132 DrawDisplayLists ();
133 FinishView ();
134 }
135 }
136 }
137#ifdef G4DEBUG_VIS_OGL
138 printf("G4OpenGLStoredXmViewer::DrawView ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
139#endif
140}
141
142void G4OpenGLStoredXmViewer::FinishView () {
143 glXWaitGL (); //Wait for effects of all previous OpenGL commands to
144 //be propogated before progressing.
145 GLint renderMode;
146 glGetIntegerv(GL_RENDER_MODE, &renderMode);
147 if (renderMode == GL_RENDER) glXSwapBuffers (dpy, win);
148}
149
150#endif
Note: See TracBrowser for help on using the repository browser.