34 #ifdef G4VIS_BUILD_OPENGL_DRIVER
51 G4OpenGLImmediateSceneHandler::G4OpenGLImmediateSceneHandler
53 G4OpenGLSceneHandler (system, fSceneIdCount++, name)
56 G4OpenGLImmediateSceneHandler::~G4OpenGLImmediateSceneHandler ()
61 G4bool G4OpenGLImmediateSceneHandler::AddPrimitivePreamble(
const G4VMarker& visible)
63 return AddPrimitivePreambleInternal(visible,
true,
false);
65 G4bool G4OpenGLImmediateSceneHandler::AddPrimitivePreamble(
const G4Polyline& visible)
67 return AddPrimitivePreambleInternal(visible,
false,
true);
69 G4bool G4OpenGLImmediateSceneHandler::AddPrimitivePreamble(
const G4Polyhedron& visible)
71 return AddPrimitivePreambleInternal(visible,
false,
false);
74 G4bool G4OpenGLImmediateSceneHandler::AddPrimitivePreambleInternal(
const G4Visible& visible,
bool isMarker,
bool isPolyline)
77 fpVisAttribs = fpViewer->GetApplicableVisAttributes(visible.
GetVisAttributes());
81 G4bool transparency_enabled =
true;
82 G4bool isMarkerNotHidden =
true;
83 G4OpenGLViewer* pViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
85 transparency_enabled = pViewer->transparency_enabled;
86 isMarkerNotHidden = pViewer->fVP.IsMarkerNotHidden();
89 G4bool isMarkerOrPolyline = isMarker || isPolyline;
90 G4bool treatAsTransparent = transparency_enabled && opacity < 1.;
91 G4bool treatAsNotHidden = isMarkerNotHidden && (isMarker || isPolyline);
93 if (fProcessing2D) glDisable (GL_DEPTH_TEST);
95 if (isMarkerOrPolyline && isMarkerNotHidden)
96 glDisable (GL_DEPTH_TEST);
97 else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);}
100 if (fThreePassCapable) {
105 if (!(fSecondPassForTransparency || fThirdPassForNonHiddenMarkers)) {
107 if (treatAsTransparent) {
108 fSecondPassForTransparencyRequested =
true;
110 if (treatAsNotHidden) {
111 fThirdPassForNonHiddenMarkersRequested =
true;
114 if (treatAsTransparent || treatAsNotHidden) {
120 if (fSecondPassForTransparency) {
121 if (!treatAsTransparent) {
127 if (fThirdPassForNonHiddenMarkers) {
128 if (!treatAsNotHidden) {
135 if (fpViewer->GetViewParameters().IsPicking()) {
136 glLoadName(++fPickName);
138 LoadAtts(visible, holder);
139 fPickMap[fPickName] = holder;
142 if (transparency_enabled) {
151 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polyline& polyline)
153 G4bool furtherprocessing = AddPrimitivePreamble(polyline);
154 if (furtherprocessing) {
155 G4OpenGLSceneHandler::AddPrimitive(polyline);
159 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polymarker& polymarker)
161 G4bool furtherprocessing = AddPrimitivePreamble(polymarker);
162 if (furtherprocessing) {
163 G4OpenGLSceneHandler::AddPrimitive(polymarker);
167 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Text& text)
171 G4bool furtherprocessing = AddPrimitivePreamble(text);
172 if (furtherprocessing) {
173 G4OpenGLSceneHandler::AddPrimitive(text);
177 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Circle& circle)
179 G4bool furtherprocessing = AddPrimitivePreamble(circle);
180 if (furtherprocessing) {
181 G4OpenGLSceneHandler::AddPrimitive(circle);
185 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Square& square)
187 G4bool furtherprocessing = AddPrimitivePreamble(square);
188 if (furtherprocessing) {
189 G4OpenGLSceneHandler::AddPrimitive(square);
193 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Scale&
scale)
195 G4bool furtherprocessing = AddPrimitivePreamble(scale);
196 if (furtherprocessing) {
197 G4OpenGLSceneHandler::AddPrimitive(scale);
201 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polyhedron& polyhedron)
205 G4bool furtherprocessing = AddPrimitivePreamble(polyhedron);
206 if (furtherprocessing) {
207 G4OpenGLSceneHandler::AddPrimitive(polyhedron);
211 void G4OpenGLImmediateSceneHandler::BeginPrimitives
214 G4OpenGLSceneHandler::BeginPrimitives (objectTransformation);
216 G4OpenGLTransform3D oglt (objectTransformation);
230 glMultMatrixd (oglt.GetGLMatrix ());
233 void G4OpenGLImmediateSceneHandler::EndPrimitives ()
240 G4OpenGLSceneHandler::EndPrimitives ();
243 void G4OpenGLImmediateSceneHandler::BeginPrimitives2D
246 G4OpenGLSceneHandler::BeginPrimitives2D(objectTransformation);
250 glMatrixMode (GL_PROJECTION);
253 G4OpenGLViewer* pViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
255 pViewer->g4GlOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
257 glMatrixMode (GL_MODELVIEW);
260 G4OpenGLTransform3D oglt (objectTransformation);
261 glMultMatrixd (oglt.GetGLMatrix ());
262 glDisable(GL_DEPTH_TEST);
263 #ifndef G4OPENGL_VERSION_2
264 glDisable (GL_LIGHTING);
268 void G4OpenGLImmediateSceneHandler::EndPrimitives2D()
271 glMatrixMode (GL_PROJECTION);
273 glMatrixMode (GL_MODELVIEW);
279 G4OpenGLSceneHandler::EndPrimitives2D ();
282 void G4OpenGLImmediateSceneHandler::BeginModeling () {
286 void G4OpenGLImmediateSceneHandler::EndModeling () {
290 void G4OpenGLImmediateSceneHandler::ClearTransientStore ()
294 fpViewer -> SetView ();
295 fpViewer -> ClearView ();
296 fpViewer -> DrawView ();
300 G4int G4OpenGLImmediateSceneHandler::fSceneIdCount = 0;
system("rm -rf microbeam.root")
const G4VisAttributes * GetVisAttributes() const
virtual void BeginModeling()
virtual void EndModeling()
G4double GetAlpha() const
G4double GetGreen() const