source: trunk/source/visualization/OpenGL/src/G4OpenGLImmediateXmViewer.cc@ 875

Last change on this file since 875 was 873, checked in by garnier, 17 years ago

Update in code, try to mutualise everything between Stored and immediate Qt Viewers

  • Property svn:mime-type set to text/cpp
File size: 4.5 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: G4OpenGLImmediateXmViewer.cc,v 1.17 2006/07/03 16:38:13 allison Exp $
[850]28// GEANT4 tag $Name: HEAD $
[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"
38
39#include "G4ios.hh"
40
41G4OpenGLImmediateXmViewer::
42G4OpenGLImmediateXmViewer(G4OpenGLImmediateSceneHandler& sceneHandler,
43 const G4String& name)
44 : G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
45 G4OpenGLViewer (sceneHandler),
46 G4OpenGLXmViewer (sceneHandler),
47 G4OpenGLImmediateViewer (sceneHandler)
48{
49 if (fViewId < 0) return; // In case error in base class instantiation.
50
51// ensure a suitable window was found
52 if (!vi_immediate) {
53 G4cerr << "G4OpenGLImmediateXmViewer::G4OpenGLImmediateXmViewer -"
54 " G4OpenGLXmViewer couldn't get a visual." << G4endl;
55 fViewId = -1; // This flags an error.
56 return;
57 }
58}
59
60G4OpenGLImmediateXmViewer::~G4OpenGLImmediateXmViewer () {}
61
62void G4OpenGLImmediateXmViewer::Initialise () {
63
64 CreateGLXContext (vi_immediate);
65 CreateMainWindow ();
66 CreateFontLists ();
67
68 InitializeGLView ();
69
70 // clear the buffers and window.
71 ClearView ();
72 FinishView ();
73
74 glDepthFunc (GL_LEQUAL);
75 glDepthMask (GL_TRUE);
76
77 glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
78 glLineWidth (1.0);
79
80 glEnable (GL_BLEND);
81 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
82
83 // If a double buffer context has been forced upon us, ignore the
84 // back buffer for this OpenGLImmediate view.
85 glDrawBuffer (GL_FRONT);
86}
87
88void G4OpenGLImmediateXmViewer::DrawView () {
89
[873]90#ifdef G4DEBUG
91 printf("G4OpenGLImmediateXmViewer::DrawView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",WinSize_x, WinSize_y);
92#endif
[529]93 G4ViewParameters::DrawingStyle style = GetViewParameters().GetDrawingStyle();
94
95 //Make sure current viewer is attached and clean...
96 glXMakeCurrent (dpy, win, cx);
97 glViewport (0, 0, WinSize_x, WinSize_y);
98
99 if(style!=G4ViewParameters::hlr &&
100 haloing_enabled) {
101
102 HaloingFirstPass ();
103 NeedKernelVisit ();
104 ProcessView ();
105 glFlush ();
[873]106#ifdef G4DEBUG
107 printf("G4OpenGLImmediateXmViewer::DrawView First ProcessView ok\n");
108#endif
[529]109
110 HaloingSecondPass ();
111
112 }
113
[873]114#ifdef G4DEBUG
115 printf("G4OpenGLImmediateXmViewer::DrawView before needKernelVisit %d\n",fNeedKernelVisit);
116#endif
[529]117 NeedKernelVisit (); // Always need to visit G4 kernel.
[873]118#ifdef G4DEBUG
119 printf("G4OpenGLImmediateXmViewer::DrawView before ProcessView\n");
120#endif
[529]121 ProcessView ();
[873]122#ifdef G4DEBUG
123 printf("G4OpenGLImmediateXmViewer::DrawView before FinishView ok\n");
124#endif
[529]125 FinishView ();
126
127}
128
129void G4OpenGLImmediateXmViewer::FinishView () {
130 glXWaitGL (); //Wait for effects of all previous OpenGL commands to
131 //be propogated before progressing.
132 glFlush ();
133}
134
135#endif
Note: See TracBrowser for help on using the repository browser.