33 #ifdef G4VIS_BUILD_OPENGL_DRIVER
50 G4OpenGLImmediateSceneHandler::G4OpenGLImmediateSceneHandler
52 G4OpenGLSceneHandler (system, fSceneIdCount++, name)
55 G4OpenGLImmediateSceneHandler::~G4OpenGLImmediateSceneHandler ()
62 return AddPrimitivePreambleInternal(visible,
true,
false);
66 return AddPrimitivePreambleInternal(visible,
false,
true);
70 return AddPrimitivePreambleInternal(visible,
false,
false);
73 G4bool G4OpenGLImmediateSceneHandler::AddPrimitivePreambleInternal(
const G4Visible&
visible,
bool isMarker,
bool isPolyline)
76 fpVisAttribs = fpViewer->GetApplicableVisAttributes(visible.
GetVisAttributes());
80 G4bool transparency_enabled =
true;
81 G4bool isMarkerNotHidden =
true;
82 G4OpenGLViewer* pViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
84 transparency_enabled = pViewer->transparency_enabled;
85 isMarkerNotHidden = pViewer->fVP.IsMarkerNotHidden();
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 G4OpenGLViewer* pViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
254 pViewer->g4GlOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG, G4OPENGL_FLT_BIG);
256 glMatrixMode (GL_MODELVIEW);
259 G4OpenGLTransform3D oglt (objectTransformation);
260 glMultMatrixd (oglt.GetGLMatrix ());
261 glDisable(GL_DEPTH_TEST);
262 #ifndef G4OPENGL_VERSION_2
263 glDisable (GL_LIGHTING);
267 void G4OpenGLImmediateSceneHandler::EndPrimitives2D()
270 glMatrixMode (GL_PROJECTION);
272 glMatrixMode (GL_MODELVIEW);
278 G4OpenGLSceneHandler::EndPrimitives2D ();
281 void G4OpenGLImmediateSceneHandler::BeginModeling () {
285 void G4OpenGLImmediateSceneHandler::EndModeling () {
289 void G4OpenGLImmediateSceneHandler::ClearTransientStore ()
293 fpViewer -> SetView ();
294 fpViewer -> ClearView ();
295 fpViewer -> DrawView ();
299 G4int G4OpenGLImmediateSceneHandler::fSceneIdCount = 0;