34 #ifdef G4VIS_BUILD_OPENGL_DRIVER
51 G4OpenGLImmediateSceneHandler::G4OpenGLImmediateSceneHandler
53 G4OpenGLSceneHandler (system, fSceneIdCount++, name)
56 G4OpenGLImmediateSceneHandler::~G4OpenGLImmediateSceneHandler ()
61 G4bool G4OpenGLImmediateSceneHandler::AddPrimitivePreamble(
const G4Visible& visible)
66 G4bool transparency_enabled =
true;
67 G4bool isMarkerNotHidden =
true;
68 G4OpenGLViewer* pViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
70 transparency_enabled = pViewer->transparency_enabled;
71 isMarkerNotHidden = pViewer->fVP.IsMarkerNotHidden();
76 (
void) dynamic_cast<const G4VMarker&>(visible);
79 catch (std::bad_cast) {}
83 (
void) dynamic_cast<const G4Polyline&>(visible);
86 catch (std::bad_cast) {}
88 G4bool isMarkerOrPolyline = isMarker || isPolyline;
89 G4bool treatAsTransparent = transparency_enabled && opacity < 1.;
90 G4bool treatAsNotHidden = isMarkerNotHidden && (isMarker || isPolyline);
92 if (fProcessing2D) glDisable (GL_DEPTH_TEST);
94 if (isMarkerOrPolyline && isMarkerNotHidden)
95 glDisable (GL_DEPTH_TEST);
96 else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL);}
99 if (fThreePassCapable) {
104 if (!(fSecondPassForTransparency || fThirdPassForNonHiddenMarkers)) {
106 if (treatAsTransparent) {
107 fSecondPassForTransparencyRequested =
true;
109 if (treatAsNotHidden) {
110 fThirdPassForNonHiddenMarkersRequested =
true;
113 if (treatAsTransparent || treatAsNotHidden) {
119 if (fSecondPassForTransparency) {
120 if (!treatAsTransparent) {
126 if (fThirdPassForNonHiddenMarkers) {
127 if (!treatAsNotHidden) {
134 if (fpViewer->GetViewParameters().IsPicking()) {
135 glLoadName(++fPickName);
137 LoadAtts(visible, holder);
138 fPickMap[fPickName] = holder;
141 if (transparency_enabled) {
150 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polyline& polyline)
152 G4bool furtherprocessing = AddPrimitivePreamble(polyline);
153 if (furtherprocessing) {
154 G4OpenGLSceneHandler::AddPrimitive(polyline);
158 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polymarker& polymarker)
160 G4bool furtherprocessing = AddPrimitivePreamble(polymarker);
161 if (furtherprocessing) {
162 G4OpenGLSceneHandler::AddPrimitive(polymarker);
166 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Text& text)
170 G4bool furtherprocessing = AddPrimitivePreamble(text);
171 if (furtherprocessing) {
172 G4OpenGLSceneHandler::AddPrimitive(text);
176 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Circle& circle)
178 G4bool furtherprocessing = AddPrimitivePreamble(circle);
179 if (furtherprocessing) {
180 G4OpenGLSceneHandler::AddPrimitive(circle);
184 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Square& square)
186 G4bool furtherprocessing = AddPrimitivePreamble(square);
187 if (furtherprocessing) {
188 G4OpenGLSceneHandler::AddPrimitive(square);
192 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Scale&
scale)
194 G4bool furtherprocessing = AddPrimitivePreamble(scale);
195 if (furtherprocessing) {
196 G4OpenGLSceneHandler::AddPrimitive(scale);
200 void G4OpenGLImmediateSceneHandler::AddPrimitive (
const G4Polyhedron& polyhedron)
204 G4bool furtherprocessing = AddPrimitivePreamble(polyhedron);
205 if (furtherprocessing) {
206 G4OpenGLSceneHandler::AddPrimitive(polyhedron);
210 void G4OpenGLImmediateSceneHandler::BeginPrimitives
213 G4OpenGLSceneHandler::BeginPrimitives (objectTransformation);
215 G4OpenGLTransform3D oglt (objectTransformation);
229 glMultMatrixd (oglt.GetGLMatrix ());
232 void G4OpenGLImmediateSceneHandler::EndPrimitives ()
239 G4OpenGLSceneHandler::EndPrimitives ();
242 void G4OpenGLImmediateSceneHandler::BeginPrimitives2D
245 G4OpenGLSceneHandler::BeginPrimitives2D(objectTransformation);
249 glMatrixMode (GL_PROJECTION);
252 glOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
253 glMatrixMode (GL_MODELVIEW);
256 G4OpenGLTransform3D oglt (objectTransformation);
257 glMultMatrixd (oglt.GetGLMatrix ());
258 glDisable(GL_DEPTH_TEST);
259 glDisable (GL_LIGHTING);
262 void G4OpenGLImmediateSceneHandler::EndPrimitives2D()
265 glMatrixMode (GL_PROJECTION);
267 glMatrixMode (GL_MODELVIEW);
273 G4OpenGLSceneHandler::EndPrimitives2D ();
276 void G4OpenGLImmediateSceneHandler::BeginModeling () {
280 void G4OpenGLImmediateSceneHandler::EndModeling () {
284 void G4OpenGLImmediateSceneHandler::ClearTransientStore ()
288 fpViewer -> SetView ();
289 fpViewer -> ClearView ();
290 fpViewer -> DrawView ();
294 G4int G4OpenGLImmediateSceneHandler::fSceneIdCount = 0;
G4double GetAlpha() const
virtual void BeginModeling()
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
G4double GetGreen() const
virtual void EndModeling()
system("rm -rf dna.root")