Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4OpenGLSceneHandler.hh
Go to the documentation of this file.
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//
28//
29// Andrew Walkden 27th March 1996
30// OpenGL scene handler - base for immediate mode and stored mode classes to
31// inherit from.
32
33#ifndef G4OPENGLSCENEHANDLER_HH
34#define G4OPENGLSCENEHANDLER_HH
35
36#include "globals.hh"
37
38#include "G4VSceneHandler.hh"
39#include "G4OpenGL.hh"
40
41#include <map>
42
43class G4AttHolder;
44
45// Base class for various OpenGLSceneHandler classes.
47
48 friend class G4OpenGLViewer;
49
50public:
51 virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
52 virtual void EndPrimitives ();
53 virtual void BeginPrimitives2D (const G4Transform3D& objectTransformation);
54 virtual void EndPrimitives2D ();
56 void AddPrimitive (const G4Polyline&);
57 void AddPrimitive (const G4Polymarker&);
58 void AddPrimitive (const G4Text&);
59 void AddPrimitive (const G4Circle&);
60 void AddPrimitive (const G4Square&);
61 void AddPrimitivesCircle (const std::vector <G4VMarker>&);
62 void AddPrimitivesSquare (const std::vector <G4VMarker>&);
63 void AddPrimitive (const G4Polyhedron&);
64
65 void PreAddSolid (const G4Transform3D& objectTransformation,
66 const G4VisAttributes&);
67 void AddSolid (const G4Box&);
68 void AddSolid (const G4Cons&);
69 void AddSolid (const G4Tubs&);
70 void AddSolid (const G4Trd&);
71 void AddSolid (const G4Trap&);
72 void AddSolid (const G4Sphere&);
73 void AddSolid (const G4Para&);
74 void AddSolid (const G4Torus&);
75 void AddSolid (const G4Polycone&);
76 void AddSolid (const G4Polyhedra&);
77 void AddSolid (const G4Orb&);
78 void AddSolid (const G4Ellipsoid&);
80 void AddSolid (const G4VSolid&);
81 void AddCompound (const G4VTrajectory&);
82 void AddCompound (const G4VHit&);
83 void AddCompound (const G4VDigi&);
86 void AddCompound (const G4Mesh&);
87
88 // enum for /vis/ogl/flushAt.
95 never
96 };
100 {return fFlushAction;}
101 static void SetEntitiesFlushInterval(G4int interval)
102 {fEntitiesFlushInterval = interval;}
103 static void SetFlushAction(FlushAction action)
104 {fFlushAction = action;}
105
106#ifdef G4OPENGL_VERSION_2
107 private :
108 // vertex vector to be given to the graphic card
109 std::vector<double> fOglVertex;
110 // indices vector to be given to the graphic card
111 std::vector<unsigned short> fOglIndices;
112 // before, drawyType (as GL_QUADS, GL_TRIANGLES...) was
113 // given in glBegin. Now it has to be given in glDrawArray (at the end)
114 GLenum fDrawArrayType;
115 // emulate GL_QUADS behaviour by inverting two last positions
116 bool fEmulate_GL_QUADS;
117 // Try to optimize a bit the pipeline
118 void OptimizeVBOForTrd();
119 void OptimizeVBOForCons(G4int aNoFacet);
120 // emulating glEnd and glBegin
121 void glEndVBO();
122 void glBeginVBO(GLenum type);
123 void drawVBOArray(std::vector<double> vertices);
124
125 // Buffers used to access vertex and indices elements
126 GLuint fVertexBufferObject;
127 GLuint fIndicesBufferObject;
128
129#endif //G4OPENGL_VERSION_2
130
131protected:
132
134 G4int id,
135 const G4String& name = "");
136 virtual ~G4OpenGLSceneHandler ();
137
138 void ProcessScene();
141
142 void ClearAndDestroyAtts(); // Destroys att holders and clears pick map.
143
144#ifdef G4OPENGL_VERSION_2
145 // Special case for VBO, we want to have acces to the VBO drawer everywhere
146 // because instead of OpenGL call which are static, VBO openGL functions :
147 // - Are functions of an WGLWidget object(G4OpenGLImmediateViewer in our case)
148 // - Needs an access to the QGLSHader
149 // - Have to be redefined in a VBO way
150
151 inline void setVboDrawer(G4OpenGLVboDrawer* drawer) {
152 fVboDrawer = drawer;
153 }
154 G4OpenGLVboDrawer* fVboDrawer;
155#endif // G4OPENGL_VERSION_2
156
157 GLuint fPickName;
158 std::map<GLuint, G4AttHolder*> fPickMap; // For picking.
159
160 // Shared code to wait until we make a single glFlush
161 void ScaledFlush () ;
162 // Static so that they apply to all OGL scene handlers...
164 // Number of entities between flushes
166
167 // True if caller of primitives is capable of processing three passes.
169
172
175
176 static const GLubyte fStippleMaskHashed [128];
178};
179
180#include "G4OpenGLSceneHandler.icc"
181
182#endif // G4OPENGLSCENEHANDLER_HH
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Definition: G4Box.hh:56
Definition: G4Cons.hh:78
Definition: G4Mesh.hh:48
G4DisplacedSolid * CreateCutawaySolid()
void AddSolid(const G4Trd &)
void AddSolid(const G4Torus &)
void AddPrimitivesSquare(const std::vector< G4VMarker > &)
void AddSolid(const G4Ellipsoid &)
static void SetFlushAction(FlushAction action)
void AddSolid(const G4Polycone &)
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation)
static G4int GetEntitiesFlushInterval()
static FlushAction fFlushAction
void AddSolid(const G4Orb &)
void AddSolid(const G4TessellatedSolid &)
void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
void AddSolid(const G4VSolid &)
static void SetEntitiesFlushInterval(G4int interval)
void AddSolid(const G4Sphere &)
void AddPrimitive(const G4Polyline &)
void AddCompound(const G4VTrajectory &)
void AddSolid(const G4Para &)
void AddPrimitivesCircle(const std::vector< G4VMarker > &)
void AddSolid(const G4Polyhedra &)
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
void AddSolid(const G4Trap &)
static const GLubyte fStippleMaskHashed[128]
void AddSolid(const G4Tubs &)
void AddSolid(const G4Box &)
G4DisplacedSolid * CreateSectionSolid()
void AddSolid(const G4Cons &)
static FlushAction GetFlushAction()
std::map< GLuint, G4AttHolder * > fPickMap
Definition: G4Orb.hh:56
Definition: G4Para.hh:79
Definition: G4Text.hh:72
Definition: G4Trd.hh:63
Definition: G4Tubs.hh:75
Definition: G4VHit.hh:48
virtual void AddPrimitive(const G4Polyline &)=0